Exemplo n.º 1
0
        internal OpenTKAudioCue(Stream data, AudioContext ac)
        {
            this.ac = ac;

            buffer = AL.GenBuffer();
            ac.CheckErrors();

            source = AL.GenSource();
            ac.CheckErrors();

            AL.Source(source, ALSourcef.Gain, (float)this.Volume);
            ac.CheckErrors();

#warning OpenTK Audio is not implemented.
            //using (AudioReader ar = new AudioReader(data))
            //{
            //    SoundData d = ar.ReadToEnd();
            //    AL.BufferData(source, d);
            //    ac.CheckErrors();
            //}

            AL.Source(source, ALSourcei.Buffer, buffer);
            ac.CheckErrors();

            this.VolumeChanged  += new VolumeChangedEventHandler(OpenTKAudioCue_VolumeChanged);
            this.BalanceChanged += new BalanceChangedEventHandler(OpenTKAudioCue_BalanceChanged);
            this.FadeChanged    += new FadeChangedEventHandler(OpenTKAudioCue_FadeChanged);
        }
Exemplo n.º 2
0
        public static void Init()
        {
            ac = new AudioContext();
            ac.CheckErrors();
            ac.MakeCurrent();
            eax_sup = ac.SupportsExtension("EAX3.0");
            if (eax_sup)
            {
                xram = new XRamExtension();
            }

            mp3_sup = ac.SupportsExtension("AL_EXT_mp3");
            devices = Alc.GetString(IntPtr.Zero, AlcGetStringList.AllDevicesSpecifier);
        }
Exemplo n.º 3
0
        protected bool init()
        {
            if (myIsInitialized == true)
            {
                return(true);
            }


            Info.print("------------------AUDIO MANAGER----------------");

            try
            {
                //try to get the DirectSound default (openAL-soft's target)
                string defaultDevice = AudioContext.DefaultDevice;
                myContext = new AudioContext(defaultDevice);
            }
            catch (AudioException ex)
            {
                Error.print("Exception trying to initialize OpenAL Context.  Verify OpenAL drivers are installed");
                Error.print("Exception: {0}", ex.Message);
                if (ex.InnerException != null)
                {
                    Error.print("Inner Exception: {0}", ex.InnerException.Message);
                }

                return(false);
            }

            //make the context current
            myContext.MakeCurrent();
            myContext.CheckErrors();
            myDevice = Alc.GetContextsDevice(Alc.GetCurrentContext());

            //print out the attributs
            int attributeSize = 0;

            Alc.GetInteger(myDevice, AlcGetInteger.AttributesSize, 1, out attributeSize);
            int[] attBuffer = new int[attributeSize * 2 + 1];
            Alc.GetInteger(myDevice, AlcGetInteger.AllAttributes, attributeSize * 2 + 1, attBuffer);
            int idx = 0;

            while (attBuffer[idx] != 0)
            {
                Info.print(String.Format("Context attribute: {0}:{1}", Audio.enumToString(attBuffer[idx]), attBuffer[idx + 1]));
                idx += 2;
            }

            //print some debug information about the system
            string alExtensions  = AL.Get(ALGetString.Extensions);
            string alcExtensions = Alc.GetString(myDevice, AlcGetString.Extensions);

            Info.print("Opened Audio device {0}", myContext.ToString());
            Info.print("OpenAL Vendor: {0}", AL.Get(ALGetString.Vendor));
            Info.print("OpenAL Version: {0}", AL.Get(ALGetString.Version));
            Info.print("OpenAL Renderer: {0}", AL.Get(ALGetString.Renderer));
            Info.print("OpenAL Extensions: {0}", AL.Get(ALGetString.Extensions));
            Info.print("OpenAL Context Extensions: {0} ", Alc.GetString(myDevice, AlcGetString.Extensions));



            string[] extensions = alcExtensions.Split(' ');
            for (int i = 0; i < extensions.Length; i++)
            {
                if (extensions[i] == "ALC_EXT_EFX")
                {
                    myEnvironmentalProcessingAvailable = true;
                }
            }

            Info.print("Environmental Processing: " + (myEnvironmentalProcessingAvailable ? "available" : "unavailable"));

            createVoices(myMaxVoices);

            Info.print("------------------AUDIO MANAGER----------------");

            return(true);
        }
Exemplo n.º 4
0
 public OpenTKAudioEngine()
 {
     ac = new AudioContext();
     ac.CheckErrors();
 }