Example #1
0
 public ALOutput(DataSource data)
 {
     this._source = data;
     this._dev    = Alc.OpenDevice((string)null);
     if (this._dev.Equals((object)IntPtr.Zero))
     {
         throw new AudioException("Failed to init OpenAL");
     }
     Alc.MakeContextCurrent(Alc.CreateContext(this._dev, new int[2]
     {
         4103,
         44100
     }));
     float[] values = new float[6]
     {
         0.0f,
         0.0f,
         1f,
         0.0f,
         1f,
         0.0f
     };
     AL.Listener(ALListener3f.Position, 0.0f, 0.0f, 0.0f);
     AL.Listener(ALListener3f.Velocity, 0.0f, 0.0f, 0.0f);
     AL.Listener(ALListenerfv.Orientation, ref values);
     AL.DistanceModel(ALDistanceModel.None);
     this._sChannels = new ALOutput.Channel[16];
     for (int index = 0; index < this._sChannels.Length; ++index)
     {
         this._sChannels[index].Handle = AL.GenSource();
     }
     ALOutput.Check();
     new Thread(new ThreadStart(this.ThreadProc)).Start();
 }
Example #2
0
        private void fVoices_Load(object sender, EventArgs e)
        {
            this._ff7  = ConfigurationManager.AppSettings["FF7"];
            this._hook = ConfigurationManager.AppSettings["HookDll"];
            this._hook = this._hook.Replace("{APPPATH}", Application.CommonAppDataPath);
            using (Stream input = this._data.Open("index.xml"))
                this._index = Util.Deserialise <VoiceIndex>(input);
            this._index.Freeze();
            string file = this._index.Lookup(0);

            if (file != null)
            {
                this._global = this.LoadVL(file);
            }
            using (Stream input = this._data.Open("ultrasound.xml"))
                this._ultrasound = Util.Deserialise <Voices.Ultrasound>(input);
            this._ultrasound.Freeze();
            this._output = new ALOutput(this._data)
            {
                Log = new Action <string>(this.DoLog)
            };
            new Thread(new ThreadStart(this.ThreadReader))
            {
                Name         = "BackgroundVoiceReader",
                IsBackground = true
            }.Start();
            new Thread(new ThreadStart(this.SoundReader))
            {
                Name         = "BackgroundUltrasoundReader",
                IsBackground = true,
                Priority     = ThreadPriority.AboveNormal
            }.Start();
            Button bTest = this.bTest;
            Button bDump = this.bDump;

            string[]            commandLineArgs = Environment.GetCommandLineArgs();
            Func <string, bool> predicate       = (Func <string, bool>)(s => s.Equals("/DUMP", StringComparison.InvariantCultureIgnoreCase));
            int  num1;
            bool flag = (num1 = ((IEnumerable <string>)commandLineArgs).Any <string>(predicate) ? 1 : 0) != 0;

            bDump.Visible = num1 != 0;
            int num2 = flag ? 1 : 0;

            bTest.Visible = num2 != 0;
            ComboBox cbLogging      = this.cbLogging;
            int?     nullable       = (int?)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Ficedula\\Ultrasound", "Logging", (object)0);
            int      valueOrDefault = (nullable.HasValue ? new int?(nullable.GetValueOrDefault()) : new int?(0)).GetValueOrDefault();

            cbLogging.SelectedIndex = valueOrDefault;
        }
Example #3
0
        private void ThreadProc()
        {
            try
            {
label_28:
                bool flag = true;
                this._event.WaitOne(100);
                while (true)
                {
                    flag = true;
                    this.Update();
                    ALOutput.Check();
                    ALOutput.CommandInst commandInst;
                    lock (this._commands)
                    {
                        if (this._commands.Any <ALOutput.CommandInst>())
                        {
                            commandInst = this._commands.Dequeue();
                        }
                        else
                        {
                            goto label_28;
                        }
                    }
                    switch (commandInst.Command)
                    {
                    case ALOutput.Command.Play:
                        for (int index = 0; index < this._sChannels.Length; ++index)
                        {
                            if (this._sChannels[index].Buffer == null)
                            {
                                this._sChannels[index].Buffer     = this.GetBuffer(commandInst.Sound.File);
                                this._sChannels[index].OnComplete = commandInst.Sound.OnComplete;
                                AL.Source(this._sChannels[index].Handle, ALSourcei.Buffer, this._sChannels[index].Buffer.Buffer);
                                AL.Source(this._sChannels[index].Handle, ALSourcef.Gain, commandInst.Sound.Volume);
                                Vector3 values = new Vector3((float)((double)commandInst.Sound.Pan * 2.0 - 1.0), 0.0f, 0.0f);
                                AL.Source(this._sChannels[index].Handle, ALSource3f.Position, ref values);
                                if (commandInst.Sound.Loop)
                                {
                                    AL.Source(this._sChannels[index].Handle, ALSourceb.Looping, true);
                                }
                                AL.SourcePlay(this._sChannels[index].Handle);
                                ALOutput.Check();
                                break;
                            }
                        }
                        break;

                    case ALOutput.Command.Stop:
                        for (int index = 0; index < this._sChannels.Length; ++index)
                        {
                            if (this._sChannels[index].Buffer != null && this._sChannels[index].Buffer.File.Equals(commandInst.Sound.File, StringComparison.InvariantCultureIgnoreCase))
                            {
                                AL.SourceStop(this._sChannels[index].Handle);
                                this.ReleaseBuffer(this._sChannels[index].Buffer);
                                this._sChannels[index].Buffer = (ALOutput.BufferCache)null;
                                ALOutput.Check();
                                break;
                            }
                        }
                        break;

                    case ALOutput.Command.Reset:
                        for (int index = 0; index < this._sChannels.Length; ++index)
                        {
                            if (this._sChannels[index].Buffer != null)
                            {
                                AL.SourceStop(this._sChannels[index].Handle);
                                this.ReleaseBuffer(this._sChannels[index].Buffer);
                                this._sChannels[index].Buffer = (ALOutput.BufferCache)null;
                            }
                        }
                        break;

                    case ALOutput.Command.Terminate:
                        goto label_18;
                    }
                }
                label_18 :;
            }
            catch (Exception ex)
            {
                this.Log(ex.ToString());
            }
        }