コード例 #1
0
        //=============================================

        public static bool OpenAudio(AudioLibrary AL, int sampleRate, int channels)
        {
            if (UsedLibrary != AudioLibrary.Null || (playbackDevice != null && playbackDevice.PlaybackState == PlaybackState.Playing))
            {
                return(false);
            }

            UsedLibrary = AL;

            if (UsedLibrary == AudioLibrary.NAudio)
            {
                //NAUDIO
                Mixer32          = new RecordableMixerStream32(sampleRate, channels);
                Mixer32.AutoStop = false;

                // try asio
                playbackDevice = new AsioOut(0);

                // if failed, try normal wave out
                if (playbackDevice == null)
                {
                    playbackDevice = new WaveOut();
                }
                if (playbackDevice == null)
                {
                    return(false);
                }
                playbackDevice.Init(Mixer32);

                //=============================================
            }
            return(true);
        }
コード例 #2
0
        public static void Dispose()
        {
            if (mp3Channel != null)
            {
                mp3Channel.Dispose();
            }
            DisposeVST();

            if (UsedLibrary == AudioLibrary.NAudio)
            {
                //NAUDIO
                Samples.Clear();
                if (playbackDevice != null)
                {
                    playbackDevice.Stop();
                    playbackDevice.Dispose();
                    playbackDevice = null;
                }

                if (Mixer32 != null)
                {
                    Mixer32.Dispose(); Mixer32 = null;
                }
            }
            UsedLibrary = AudioLibrary.Null;
        }
コード例 #3
0
        //=============================================

        public static bool OpenAudio(AudioLibrary audioLibrary, string asioDevice)
        {
            if (_usedLibrary != AudioLibrary.Null || (_playbackDevice != null && _playbackDevice.PlaybackState == PlaybackState.Playing))
            {
                return(false);
            }

            _usedLibrary = audioLibrary;

            if (_usedLibrary == AudioLibrary.NAudio)
            {
                // NAUDIO
                _mixer32 = new RecordableMixerStream32 {
                    AutoStop = false
                };

                // remove this comments if you wanna hear the sounds, but then only realtime recording is possible
                //
                //if (asioDevice != null) {
                //	playbackDevice = new AsioOut(asioDevice);
                //}

                //// if failed, try normal wave out
                //if (playbackDevice == null) playbackDevice = new WaveOut();
                //if (playbackDevice == null) return false;
                //playbackDevice.Init(Mixer32);

                //=============================================
            }
            return(true);
        }
コード例 #4
0
        //=============================================

        public static bool OpenAudio(AudioLibrary audioLibrary, string asioDevice)
        {
            if (UsedLibrary != AudioLibrary.Null || (playbackDevice != null && playbackDevice.PlaybackState == PlaybackState.Playing))
            {
                return(false);
            }

            UsedLibrary = audioLibrary;

            if (UsedLibrary == AudioLibrary.NAudio)
            {
                // NAUDIO
                Mixer32          = new RecordableMixerStream32();
                Mixer32.AutoStop = false;

                // try asio
                if (asioDevice != null)
                {
                    playbackDevice = new AsioOut(asioDevice);
                }

                // if failed, try normal wave out
                if (playbackDevice == null)
                {
                    playbackDevice = new WaveOut();
                }
                if (playbackDevice == null)
                {
                    return(false);
                }
                playbackDevice.Init(Mixer32);

                //=============================================
            }
            return(true);
        }
コード例 #5
0
        public static void Dispose()
        {
            _mp3Channel?.Dispose();

            DisposeVst();

            if (_usedLibrary == AudioLibrary.NAudio)
            {
                // NAUDIO
                _samples.Clear();
                if (_playbackDevice != null)
                {
                    _playbackDevice.Stop();
                    _playbackDevice.Dispose();
                    _playbackDevice = null;
                }

                if (_mixer32 != null)
                {
                    _mixer32.Dispose(); _mixer32 = null;
                }
            }
            _usedLibrary = AudioLibrary.Null;
        }