Beispiel #1
0
        private void SoundReader()
        {
            MemoryMappedViewStream viewStream = MemoryMappedFile.CreateOrOpen("Ficedula/UltrasoundData", 32768L, MemoryMappedFileAccess.ReadWrite).CreateViewStream();

            byte[] buffer = new byte[768];
            foreach (int replacedId in this._ultrasound.ReplacedIDs())
            {
                buffer[replacedId] = (byte)1;
            }
            viewStream.Position = 32000L;
            viewStream.Write(buffer, 0, 768);
            AutoResetEvent autoResetEvent = new AutoResetEvent(false);

            autoResetEvent.SafeWaitHandle = new SafeWaitHandle(fVoices.CreateEvent(IntPtr.Zero, false, false, "Ficedula/UltrasoundEvent"), true);
            int num1 = Util.ReadIntFrom((Stream)viewStream, 0);
            int num2 = 0;
            int num3 = 0;

            while (true)
            {
                autoResetEvent.WaitOne();
                int FID = (int)Util.ReadUShortFrom((Stream)viewStream, 4);
                int PPV = (int)Util.ReadUShortFrom((Stream)viewStream, 6);
                if (FID != num2 || PPV != num3)
                {
                    this.UpdateAmbient(FID, PPV);
                }
                num2 = FID;
                num3 = PPV;
                int num4;
                do
                {
                    num4 = Util.ReadIntFrom((Stream)viewStream, 0);
                    if (num4 != -1 && num4 != num1)
                    {
                        num1 = num1 + 1 & 16383;
                        fVoices.SoundEvent se = new fVoices.SoundEvent();
                        se.FieldID = Util.ReadUShortFrom((Stream)viewStream, 16 + 16 * num1);
                        se.PPV     = Util.ReadUShortFrom((Stream)viewStream, 16 + 16 * num1 + 2);
                        se.Sound   = Util.ReadUShortFrom((Stream)viewStream, 16 + 16 * num1 + 4);
                        se.Channel = Util.ReadUShortFrom((Stream)viewStream, 16 + 16 * num1 + 6);
                        se.Pan     = Util.ReadUShortFrom((Stream)viewStream, 16 + 16 * num1 + 8);
                        se.Param   = (int)Util.ReadUShortFrom((Stream)viewStream, 16 + 16 * num1 + 12);
                        this.IncomingSEvent(se);
                        this.Invoke(new Action(() => this.LogSEvent(se.ToString())));
                    }
                    else
                    {
                        break;
                    }
                }while (num4 != num1);
            }
        }
Beispiel #2
0
        private void IncomingSEvent(fVoices.SoundEvent se)
        {
            Sound s = this._ultrasound.Select((int)se.Sound, (int)se.FieldID, (int)se.PPV);
            if (s == null || !this._data.Exists(this._config.strightApplyAudioPath(s.File)))
                return;

            this.Invoke(new Action(() => this.LogSEvent("  --> playing " +  s.File + " with length of " + GetSoundLength(s.File).ToString() + " Frames")));
            this._output.Play(new ALOutput.SoundPlay()
            {
                File = this._config.strightApplyAudioPath(s.File),
                Pan = Math.Max(Math.Min(1f, (float)se.Pan / 128f), 0.0f),
                Volume = 1f,
                OnComplete = new Action(() => {
                    Console.WriteLine("Line 344");
                    UltrasoundLib.Hooker.GetInstance().onSoundComplete(0, s.File);
                })
            });
        }
Beispiel #3
0
        private void IncomingSEvent(fVoices.SoundEvent se)
        {
            Sound s = this._ultrasound.Select((int)se.Sound, (int)se.FieldID, (int)se.PPV);

            try
            {
                if (s == null || !this._data.Exists(s.File))
                {
                    return;
                }
                this.Invoke(new Action(() => this.LogSEvent("  --> playing " + s.File + " with length of " + GetSoundLength(s.File))));
                this._output.Play(new ALOutput.SoundPlay()
                {
                    File   = s.File,
                    Pan    = Math.Max(Math.Min(1f, (float)se.Pan / 128f), 0.0f),
                    Volume = 10f
                });
            }catch (FileNotFoundException ex)
            {
                this.LogSEvent("  --> ERROR::: " + s.File + " could not be found");
            }
        }