Example #1
0
        private void DirectSound_Start(object sender, EventArgs e)
        {
            soundStream = new SoundStream(File.OpenRead(loadFilePath));
            WaveFormat format = soundStream.Format;

            AudioBuffer buffer = new AudioBuffer
            {
                Stream     = soundStream.ToDataStream(),
                AudioBytes = (int)soundStream.Length,
                Flags      = BufferFlags.EndOfStream
            };

            soundStream.Close();

            sourceVoice = new SourceVoice(xAudio2, format, true);
            sourceVoice.SubmitSourceBuffer(buffer, soundStream.DecodedPacketsInfo);
            sourceVoice.Start();

            if (directSoundEffect == 0)
            {
                SharpDX.XAPO.Fx.Echo effectEcho       = new SharpDX.XAPO.Fx.Echo(xAudio2);
                EffectDescriptor     effectDescriptor = new EffectDescriptor(effectEcho);
                sourceVoice.SetEffectChain(effectDescriptor);
                sourceVoice.EnableEffect(0);
            }
            else if (directSoundEffect == 1)
            {
                SharpDX.XAPO.Fx.Reverb effectReverb     = new SharpDX.XAPO.Fx.Reverb(xAudio2);
                EffectDescriptor       effectDescriptor = new EffectDescriptor(effectReverb);
                sourceVoice.SetEffectChain(effectDescriptor);
                sourceVoice.EnableEffect(0);
            }
        }
Example #2
0
        public override async Task <ISoundPlayerBuilder <IStorageFileEx> > BuildAsync()
        {
            if (Input == null)
            {
                return(this);
            }

            DisposeInternally();

            IRandomAccessStreamEx streamOpenFile = await Input.OpenReadAsync();

            using (Stream nativeStream = streamOpenFile.AsStreamForRead())
            {
                using (var soundStream = new SoundStream(nativeStream))
                {
                    Description = Input.Name;

                    WaveFormat = soundStream.Format;

                    _dataStream = soundStream.ToDataStream();

                    SourceVoice = VoicePool.GetVoice(WaveFormat);

                    SourceVoice.PlayWith(_dataStream);
                }
            }

            return(this);
        }
Example #3
0
        private MyWave LoadSound(string name)
        {
            if (name.IndexOf(".wav", StringComparison.Ordinal) == -1)
            {
                name = Path.Combine(soundsDir, $"{name}.wav");
            }

            var fileInfo = new FileInfo(name);

            if (!fileInfo.Exists)
            {
                return(null);
            }
            var soundStream = new SoundStream(File.OpenRead(name));
            var waveFormat  = soundStream.Format;

            var buffer = new AudioBuffer
            {
                Stream = soundStream.ToDataStream(), AudioBytes = (int)soundStream.Length, Flags = BufferFlags.EndOfStream
            };

            soundStream.Close();
            var wave = new MyWave {
                Buffer = buffer, WaveFormat = waveFormat, DecodedPacketsInfo = soundStream.DecodedPacketsInfo
            };

            Sounds[fileInfo.Name.Split('.').First()] = wave;
            Sounds[fileInfo.Name] = wave;
            return(wave);
        }
Example #4
0
        public void WaveHeaderTest()
        {
            const uint TotalSize = 38;

            riffHeader[4] = (byte)((TotalSize & 0x000000FF) >> 0);
            riffHeader[5] = (byte)((TotalSize & 0x0000FF00) >> 8);
            riffHeader[6] = (byte)((TotalSize & 0x00FF0000) >> 16);
            riffHeader[7] = (byte)((TotalSize & 0xFF000000) >> 24);

            using (var handMadeWaveStream = new MemoryStream())
            {
                handMadeWaveStream.Write(riffHeader, 0, riffHeader.Length);
                handMadeWaveStream.Write(waveFmt, 0, waveFmt.Length);
                handMadeWaveStream.Write(emptyData, 0, emptyData.Length);
                handMadeWaveStream.Seek(0, SeekOrigin.Begin);

                SoundStream waveStreamReader = null;
                Assert.DoesNotThrow(() => waveStreamReader = new SoundStream(handMadeWaveStream), "An error happened while reading of the wave file header.");

                var waveFormat = waveStreamReader.Format;
                Assert.AreEqual(waveFmt[8] + (waveFmt[9] << 8), (int)waveFormat.Encoding, "Audio formats do not match");
                Assert.AreEqual(waveFmt[10] + (waveFmt[11] << 8), waveFormat.Channels, "Channel numbers do not match");
                Assert.AreEqual(waveFmt[12] + (waveFmt[13] << 8) + (waveFmt[14] << 16) + (waveFmt[15] << 24), waveFormat.SampleRate, "Sample rates do not match");
                Assert.AreEqual(waveFmt[16] + (waveFmt[17] << 8) + (waveFmt[18] << 16) + (waveFmt[19] << 24), waveFormat.AverageBytesPerSecond, "Byte rates do not match");
                Assert.AreEqual(waveFmt[20] + (waveFmt[21] << 8), waveFormat.BlockAlign, "Block aligns do not match");
                Assert.AreEqual(waveFmt[22] + (waveFmt[23] << 8), waveFormat.BitsPerSample, "Bits per samples do not match");
            }
        }
Example #5
0
        private static void RunOptionsAndReturnExitCode(Options opts)
        {
            var engine = AudioEngine.CreateDefault();

            if (engine == null)
            {
                Console.WriteLine("Failed to create an audio backend!");
            }

            foreach (var file in opts.InputFiles)
            {
                var soundStream = new SoundStream(File.OpenRead(file), engine);

                soundStream.Volume = opts.Volume / 100.0f;

                soundStream.Play();

                Console.WriteLine("Playing file with duration: " + soundStream.Duration);

                while (soundStream.IsPlaying)
                {
                    Thread.Sleep(100);
                }
            }
        }
Example #6
0
        private void Load()
        {
            m_SoundStream = new SoundStream(Sound.Stream);
            var waveFormat = m_SoundStream.Format;

            m_AudioBuffer = new AudioBuffer
            {
                Stream     = m_SoundStream.ToDataStream(),
                AudioBytes = (int)m_SoundStream.Length,
                Flags      = BufferFlags.EndOfStream
            };
            m_SoundStream.Close();

            m_Audio            = new SourceVoice(m_Device, waveFormat, true);
            m_Audio.BufferEnd += (context) =>
            {
                if (Background)
                {
                    if (IsPlaying)
                    {
                        m_Audio.SubmitSourceBuffer(m_AudioBuffer, m_SoundStream.DecodedPacketsInfo);
                        m_Audio.Start();
                    }
                }
                else
                {
                    m_PlaySync.Signal();
                    IsPlaying = false;
                }
            };
        }
Example #7
0
        public static Task PlaySound(Stream stream)
        {
            var soundstream = new SoundStream(stream);
            var buffer      = new AudioBufferAndMetaData()
            {
                Stream             = soundstream.ToDataStream(),
                AudioBytes         = (int)soundstream.Length,
                Flags              = BufferFlags.EndOfStream,
                WaveFormat         = soundstream.Format,
                DecodedPacketsInfo = soundstream.DecodedPacketsInfo
            };

            var sourceVoice = new SourceVoice(XAudio, buffer.WaveFormat, true);

            sourceVoice.SetVolume(Volume, SharpDX.XAudio2.XAudio2.CommitNow);
            sourceVoice.SubmitSourceBuffer(buffer, buffer.DecodedPacketsInfo);


            //var effect = new SharpDX.XAPO.Fx.Echo(XAudio);
            //EffectDescriptor effectDescriptor = new EffectDescriptor(effect);
            //sourceVoice.SetEffectChain(effectDescriptor);
            //sourceVoice.EnableEffect(0);

            sourceVoice.Start();

            TaskCompletionSource <object> mediaDone = new TaskCompletionSource <object>();

            sourceVoice.StreamEnd += () => {
                mediaDone.SetResult(null);
            };

            return(mediaDone.Task);
        }
Example #8
0
        private void AddSound(Stream stream, string dictName)
        {
            if (sounds.ContainsKey(dictName))
            {
                return;
            }

            using (SoundStream wavFile = new SoundStream(stream))
            {
                byte[] data = new byte[wavFile.Length];
                if (wavFile.Read(data, 0, (int)wavFile.Length) != wavFile.Length)
                {
                    MessageBox.Show(PPDExceptionContentProvider.Provider.GetContent(PPDExceptionType.SoundReadError));
                    return;
                }
                var buffer = CreateSecondarySoundBuffer(wavFile.Format, (int)wavFile.Length);
                buffer.Write(data, 0, SharpDX.DirectSound.LockFlags.EntireBuffer);
                try
                {
                    this.sounds.Add(dictName, new BufferInfo(buffer));
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    return;
                }
            }
        }
Example #9
0
        private void PlayWaveHelper(string soundFile, string soundText)
        {
            var filepath = GetFilePath(soundFile, soundText).Result;

            var nativefilestream = new NativeFileStream(filepath, NativeFileMode.Open, NativeFileAccess.Read);

            using (var soundstream = new SoundStream(nativefilestream))
            {
                var waveFormat = soundstream.Format;
                var buffer     = new AudioBuffer
                {
                    Stream     = soundstream.ToDataStream(),
                    AudioBytes = (int)soundstream.Length,
                    Flags      = BufferFlags.EndOfStream
                };

                if (_sourceVoice != null)
                {
                    _sourceVoice.DestroyVoice();
                    _sourceVoice.Dispose();
                }

                _sourceVoice = new SourceVoice(_xAudio, waveFormat);

                _sourceVoice.SubmitSourceBuffer(buffer, soundstream.DecodedPacketsInfo);
                _sourceVoice.BufferEnd += obj =>
                {
                    _lock.Set();
                };

                _sourceVoice.Start();
            }
        }
Example #10
0
        private void Initialize(string pFileName)
        {
            System.Diagnostics.Debug.Assert(System.IO.File.Exists(pFileName));

            System.IO.FileStream s = System.IO.File.OpenRead(pFileName);

            switch (Game.RenderMethod)
            {
            case Graphics.RenderMethods.DirectX:
                SoundStream soundStream = new SoundStream(s);

                //Create a audio buffer from the file data
                _buffer = new AudioBuffer()
                {
                    Stream     = soundStream,
                    AudioBytes = (int)soundStream.Length,
                    Flags      = BufferFlags.EndOfStream
                };

                DecodedPacketsInfo = soundStream.DecodedPacketsInfo;
                Stream             = soundStream.Format;
                break;

            case Graphics.RenderMethods.OpenGL:
                throw new NotImplementedException();

            default:
                throw new UnknownEnumException(typeof(Graphics.RenderMethods), Game.RenderMethod);
            }
        }
        public SoundEffect(string soundFxPath, bool infiniteLoop)
        {
            _xaudio = new XAudio2();
            var masteringsound = new MasteringVoice(_xaudio);

            var nativefilestream = new NativeFileStream(
                soundFxPath,
                NativeFileMode.Open,
                NativeFileAccess.Read,
                NativeFileShare.Read);

            _soundstream = new SoundStream(nativefilestream);
            _waveFormat  = _soundstream.Format;
            _buffer      = new AudioBuffer
            {
                Stream     = _soundstream.ToDataStream(),
                AudioBytes = (int)_soundstream.Length,
                Flags      = BufferFlags.EndOfStream
            };
            if (infiniteLoop)
            {
                _buffer.LoopCount = AudioBuffer.LoopInfinite;
            }
            isStarted   = false;
            sourceVoice = new SourceVoice(_xaudio, _waveFormat, true);
        }
Example #12
0
        private void PlatformLoadAudioStream(Stream s)
        {
            SoundStream soundStream = new SoundStream(s);

            _format     = soundStream.Format;
            _dataStream = soundStream.ToDataStream();

            _buffer = new AudioBuffer()
            {
                Stream     = _dataStream,
                AudioBytes = (int)_dataStream.Length,
                Flags      = BufferFlags.EndOfStream,
                PlayBegin  = 0,
                PlayLength = (int)_dataStream.Length / (2 * soundStream.Format.Channels),
                Context    = new IntPtr(42),
            };

            _loopedBuffer = new AudioBuffer()
            {
                Stream     = _dataStream,
                AudioBytes = (int)_dataStream.Length,
                Flags      = BufferFlags.EndOfStream,
                LoopBegin  = 0,
                LoopLength = (int)_dataStream.Length / (2 * soundStream.Format.Channels),
                LoopCount  = AudioBuffer.LoopInfinite,
                Context    = new IntPtr(42),
            };
        }
Example #13
0
        public MyInMemoryWave(MySoundData cue, string path, MyWaveBank owner, bool streamed = false)
        {
            using (var stream = MyFileSystem.OpenRead(path))
            {
                m_owner      = owner;
                m_path       = path;
                m_stream     = new SoundStream(stream);
                m_waveFormat = m_stream.Format;
                m_buffer     = new AudioBuffer
                {
                    Stream     = m_stream.ToDataStream(),
                    AudioBytes = (int)m_stream.Length,
                    Flags      = BufferFlags.None
                };

                if (cue.Loopable)
                {
                    m_buffer.LoopCount = AudioBuffer.LoopInfinite;
                }

                m_stream.Close();

                Streamed = streamed;
            }
        }
Example #14
0
        /// <summary>
        /// Возвращает аудио буфер для файла.
        /// </summary>
        /// <param name="source">Путь к файлу.</param>
        private async Task <AudioBufferAndMetaData> GetBuffer(string source)
        {
            if (cachedBuffers.ContainsKey(source))
            {
                return(cachedBuffers[source]);
            }

            var stream = (await(await StorageFile.GetFileFromApplicationUriAsync(new Uri(source)))
                          .OpenReadAsync()).AsStreamForRead();

            lock (lockObject)
            {
                var soundstream = new SoundStream(stream);
                var buffer      = new AudioBufferAndMetaData
                {
                    Stream             = soundstream.ToDataStream(),
                    AudioBytes         = (int)soundstream.Length,
                    Flags              = BufferFlags.EndOfStream,
                    WaveFormat         = soundstream.Format,
                    DecodedPacketsInfo = soundstream.DecodedPacketsInfo
                };

                cachedBuffers[source] = buffer;
                return(buffer);
            }
        }
Example #15
0
        private void ReloadBuffer(int sampleIndex)
        {
            SoundStream stream = new SoundStream(Instrument.GetDataStream(sampleIndex));

            actualbuffer = new AudioBuffer()
            {
                Stream     = stream,
                AudioBytes = (int)stream.Length,
                Flags      = BufferFlags.EndOfStream,
                PlayBegin  = 0,
                PlayLength = 0,
                LoopCount  = 255
            };
            bufferinfo = stream.DecodedPacketsInfo;
            if (IsPlaying)
            {
                Voice.Stop(XAudio2.CommitNow);
            }
            Voice.FlushSourceBuffers();
            Voice.SubmitSourceBuffer(actualbuffer, bufferinfo);
            if (IsPlaying)
            {
                Voice.Start(XAudio2.CommitNow);
            }
        }
        public void PlaySound(SoundStream stream)
        {
            var soundSource = CreateSoundNode().CreateComponent <SoundSource>();

            soundSource.AutoRemoveMode = AutoRemoveMode.Node;
            soundSource.Play(stream);
        }
Example #17
0
 private void ReloadBuffer(float frequencyRatio, bool reloadNeeded)
 {
     if ((actualbuffer == null) || reloadNeeded)
     {
         SoundStream stream = new SoundStream(Instrument.GetDataStream(frequencyRatio));
         actualbuffer = new AudioBuffer()
         {
             Stream     = stream,
             AudioBytes = (int)stream.Length,
             Flags      = BufferFlags.EndOfStream,
             PlayBegin  = 0,
             PlayLength = 0,
             LoopCount  = (Instrument.IsPlugged) ? 0 : 255
         };
         bufferinfo = stream.DecodedPacketsInfo;
     }
     if (IsPlaying)
     {
         Voice.Stop(XAudio2.CommitNow);
     }
     Voice.FlushSourceBuffers();
     Voice.SubmitSourceBuffer(actualbuffer, bufferinfo);
     if (IsPlaying)
     {
         Voice.Start(XAudio2.CommitNow);
     }
 }
        public void PlaySpatialSound(SoundStream stream, Vector3 position)
        {
            var soundSource = CreateSoundNode(position).CreateComponent <SoundSource3D>();

            soundSource.AutoRemoveMode = AutoRemoveMode.Node;
            soundSource.Play(stream);
        }
Example #19
0
        public EffectSound(string filename)
        {
            lock (loadedSounds)
            {
                EffectSound existingSound;
                if (loadedSounds.TryGetValue(filename, out existingSound))
                {
                    Stream = existingSound.Stream;
                    Buffer = existingSound.Buffer;
                    return;
                }
            }

            using (var fileStream = File.OpenRead(filename))
            {
                Stream = new SoundStream(fileStream);
                Buffer = new AudioBuffer
                {
                    Stream     = Stream.ToDataStream(),
                    AudioBytes = (int)Stream.Length,
                    Flags      = BufferFlags.EndOfStream
                };
                Stream.Close();
            }

            lock (loadedSounds)
            {
                loadedSounds[filename] = this;
            }
        }
Example #20
0
        private static void RunOptionsAndReturnExitCode(Options opts)
        {
            var engine = AudioEngine.CreateDefault();

            if (engine == null)
            {
                Console.WriteLine("Failed to create an audio backend!");
            }

            foreach (var file in opts.InputFiles)
            {
                var soundStream = new SoundStream(File.OpenRead(file), engine);

                soundStream.Volume = opts.Volume / 100.0f;

                soundStream.Play();

                while (soundStream.IsPlaying)
                {
                    var xx = string.Join(", ", soundStream.Metadata.Artists ?? new List <string>());

                    Console.Write($"Playing [{soundStream.Metadata.Title ?? Path.GetFileNameWithoutExtension(file)}] by [{(xx.Length > 0 ? xx : "Unknown")}] {soundStream.Position}/{(soundStream.Duration.TotalSeconds < 0 ? "\u221E" : soundStream.Duration.ToString())}\r");

                    Thread.Sleep(10);
                }

                Console.Write("\n");
            }
        }
Example #21
0
        /// <summary>
        /// Abre o arquivo de carrega para o stream.
        /// </summary>
        /// <param name="filename"></param>
        public EngineSound(string filename)
        {
            Stream fileStream = new NativeFileStream(filename, NativeFileMode.Open, NativeFileAccess.Read, NativeFileShare.Read);

            SoundStream = new SoundStream(fileStream);
            AudioBuffer = new AudioBuffer(SoundStream.ToDataStream());
            fileStream.Dispose();
        }
Example #22
0
        public void PlaySound(string file, double volume)
        {
            if (!FileNameLookup.ContainsKey(file))
            {
                file = FileNameLookup[file] = new System.IO.FileInfo(file).FullName;
            }
            else
            {
                file = FileNameLookup[file];
            }
            if (!CurrentVoices.ContainsKey(file))
            {
                CurrentVoices.Add(file, new Queue <SourceVoice>());
            }
            //if (CurrentVoices[file].Count > 0)
            //{
            //    var voice = CurrentVoices[file].Dequeue();
            //    voice.SetVolume((float)volume);
            //    voice.Start();
            //    return;
            //}
            SoundData data;

            if (!Voices.ContainsKey(file))
            {
                using (var nativeFilestream = new NativeFileStream(file, NativeFileMode.Open, NativeFileAccess.Read))
                    using (var soundstream = new SoundStream(nativeFilestream))
                    {
                        var waveformat = soundstream.Format;
                        var buffer     = new AudioBuffer()
                        {
                            Stream     = soundstream.ToDataStream(),
                            AudioBytes = (int)soundstream.Length,
                            Flags      = BufferFlags.EndOfStream
                        };
                        data = new SoundData()
                        {
                            waveformat         = waveformat,
                            buffer             = buffer,
                            decodedPacketsInfo = soundstream.DecodedPacketsInfo
                        };
                        Voices.Add(file, data);
                    }
            }
            else
            {
                data = Voices[file];
            }
            var sourceVoice = new SourceVoice(xaudio, data.waveformat, true);

            sourceVoice.SubmitSourceBuffer(data.buffer, data.decodedPacketsInfo);
            sourceVoice.StreamEnd += () =>
            {
                CurrentVoices[file].Enqueue(sourceVoice);
            };
            sourceVoice.SetVolume((float)volume);
            sourceVoice.Start();
        }
 public void Add(int index, UnmanagedMemoryStream sourceStream)
 {
     streams[index]            = new SoundStream(sourceStream);
     buffers[index]            = new AudioBuffer();
     buffers[index].Stream     = streams[index].ToDataStream();
     buffers[index].AudioBytes = (int)streams[index].Length;
     buffers[index].Flags      = BufferFlags.EndOfStream;
     voices[index]             = new SourceVoice(audio, streams[index].Format);
 }
Example #24
0
 public SoundManager(int sounds)
 {
     _audio          = new XAudio2();
     _masteringVoice = new MasteringVoice(_audio);
     _masteringVoice.SetVolume(0.5f);
     _soundStreams = new SoundStream[sounds];
     _audioBuffers = new AudioBuffer[sounds];
     _sourceVoices = new SourceVoice[sounds];
 }
Example #25
0
        private void PlatformLoadAudioStream(Stream s)
        {
            var soundStream = new SoundStream(s);
            var dataStream  = soundStream.ToDataStream();

            CreateBuffers(soundStream.Format,
                          dataStream,
                          0);
        }
Example #26
0
 //Adds the sound we want to play
 public void Add(int index, UnmanagedMemoryStream stream)
 {
     _soundStreams[index]            = new SoundStream(stream);
     _audioBuffers[index]            = new AudioBuffer();
     _audioBuffers[index].Stream     = _soundStreams[index].ToDataStream();
     _audioBuffers[index].AudioBytes = (int)_soundStreams[index].Length;
     _audioBuffers[index].Flags      = BufferFlags.EndOfStream;
     _sourceVoices[index]            = new SourceVoice(_audio, _soundStreams[index].Format);
 }
Example #27
0
        private void TryLoadData(Stream fileData)
        {
            var soundStream = new SoundStream(fileData);

            format      = soundStream.Format;
            length      = CalculateLengthInSeconds(format, (int)soundStream.Length);
            buffer      = CreateAudioBuffer(soundStream.ToDataStream());
            decodedInfo = soundStream.DecodedPacketsInfo;
        }
Example #28
0
        public void Load()
        {
            NativeFileStream nativeFileStream = new NativeFileStream(fileName, NativeFileMode.Open, NativeFileAccess.Read);
            SoundStream      soundStream      = new SoundStream(nativeFileStream);

            stream     = soundStream.ToDataStream();
            waveFormat = soundStream.Format;
            LoadNextVoice(defaultRepeat);
            isLoaded = true;
        }
Example #29
0
        /// <summary>
        ///   Worker thread.
        /// </summary>
        ///
        private void WorkerThread()
        {
            SoundStream waveStream = null;

            try
            {
                waveStream = (stream != null)
                    ? new SoundStream(stream)
                    : new SoundStream(File.OpenRead(fileName));

                // Open the Wave stream
                decoder.Open(waveStream);

                while (stopEvent.WaitOne(0, false))
                {
                    // get next frame
                    Signal s = decoder.Decode(frameSize);
                    framesReceived += s.Length;
                    bytesReceived  += decoder.Bytes;

                    if (NewFrame != null)
                    {
                        NewFrame(this, new NewFrameEventArgs(s));
                    }

                    // check current position
                    if (waveStream.Position >= waveStream.Length)
                    {
                        break;
                    }

                    // sleeping ...
                    Thread.Sleep(100);
                }
            }
            catch (Exception exception)
            {
                // provide information to clients
                if (AudioSourceError != null)
                {
                    AudioSourceError(this, new AudioSourceErrorEventArgs(exception.Message));
                }
                else
                {
                    throw;
                }
            }

            if (waveStream != null)
            {
                waveStream.Close();
                waveStream.Dispose();
                waveStream = null;
            }
        }
        private void frmRomanSplashScreen_Load(object sender, EventArgs e)
        {
            this.Show();

            XAudio2  xaudio;
            Assembly assembly;

            AudioBuffer logo_buffer;
            SoundStream logo_soundstream;
            SourceVoice logo_voice;
            WaveFormat  logo_waveFormat;

            assembly = Assembly.GetExecutingAssembly();
            xaudio   = new XAudio2();
            var masteringsound = new MasteringVoice(xaudio);

            logo_soundstream = new SoundStream(assembly.GetManifestResourceStream("Arriba_Ultimate_Study_Guide.Audio.logosong.wav"));

            logo_waveFormat = logo_soundstream.Format;

            logo_buffer = new AudioBuffer
            {
                Stream     = logo_soundstream.ToDataStream(),
                AudioBytes = (int)logo_soundstream.Length,
                Flags      = BufferFlags.EndOfStream
            };

            logo_voice = new SourceVoice(xaudio, logo_waveFormat, true);
            logo_voice.SubmitSourceBuffer(logo_buffer, logo_soundstream.DecodedPacketsInfo);
            logo_voice.Start();

            //if (installOnce == false)
            //{
            //    try
            //    {
            //        RegisterFont("Arriba_Ultimate_Study_Guide.Fonts.OpenSans-Bold.ttf");
            //        //RegisterFont("Arriba_Ultimate_Study_Guide.Fonts.OpenSans-BoldItalic.ttf");
            //        //RegisterFont("Arriba_Ultimate_Study_Guide.Fonts.OpenSans-ExtraBold.ttf");
            //        //RegisterFont("Arriba_Ultimate_Study_Guide.Fonts.OpenSans-ExtraBoldItalic.ttf");
            //        //RegisterFont("Arriba_Ultimate_Study_Guide.Fonts.OpenSans-Italic.ttf");
            //        //RegisterFont("Arriba_Ultimate_Study_Guide.Fonts.OpenSans-Light.ttf");
            //        //RegisterFont("Arriba_Ultimate_Study_Guide.Fonts.OpenSans-LightItalic.ttf");
            //        //RegisterFont("Arriba_Ultimate_Study_Guide.Fonts.OpenSans-Regular.ttf");
            //        //RegisterFont("Arriba_Ultimate_Study_Guide.Fonts.OpenSans-Semibold.ttf");
            //        //RegisterFont("Arriba_Ultimate_Study_Guide.Fonts.OpenSans-SemiboldItalic.ttf");
            //    }
            //    catch (IOException error)
            //    {
            //        if (error.Source != null)
            //            MessageBox.Show("Cannot install OpenSans fonts from resource. IOException source: {0}, " + error.Source, "Arriba Ultimate Study Guide", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //        throw;
            //    }
            //    installOnce = true;
            //}
        }
Example #31
0
        /// <summary>
        /// Creates a new instance of the <see cref="SoundEffect"/> class from the spefified data stream.
        /// </summary>
        /// <param name="audioManager">The audio manager associated to the created instance.</param>
        /// <param name="stream">The stream containing the data from which to create the effect.</param>
        /// <param name="name">The name of the effect (optional).</param>
        /// <returns>The created effect.</returns>
        public static SoundEffect FromStream(AudioManager audioManager, Stream stream, string name = null)
        {
            if (audioManager == null)
                throw new ArgumentNullException("audioManager");

            if (stream == null)
                throw new ArgumentNullException("stream");

            var sound = new SoundStream(stream);
            var format = sound.Format;
            var decodedPacketsInfo = sound.DecodedPacketsInfo;
            var buffer = sound.ToDataStream();

            sound.Dispose();

            return audioManager.ToDisposeAudioAsset(new SoundEffect(audioManager, name, format, buffer, decodedPacketsInfo));
        }