Example #1
0
        protected void Dispose(bool bManagedDispose)
        {
            this.e出力デバイス = ESoundDeviceType.Unknown;                    // まず出力停止する(Dispose中にクラス内にアクセスされることを防ぐ)
            if (hMixer_DeviceOut != 0)
            {
                BassMix.BASS_Mixer_ChannelPause(this.hMixer_DeviceOut);
                Bass.BASS_StreamFree(this.hMixer_DeviceOut);
                this.hMixer_DeviceOut = 0;
            }
            if (hMixer != 0)
            {
                BassMix.BASS_Mixer_ChannelPause(this.hMixer);
                Bass.BASS_StreamFree(this.hMixer);
                this.hMixer = 0;
            }
            if (!this.bIsBASSFree)
            {
                BassAsio.BASS_ASIO_Free();                  // システムタイマより先に呼び出すこと。(tAsio処理() の中でシステムタイマを参照してるため)
                Bass.BASS_Free();
            }

            if (bManagedDispose)
            {
                CCommon.tDispose(this.tmシステムタイマ);
                this.tmシステムタイマ = null;
            }
        }
        /// <summary>
        ///     Removes and audio stream from a mixer.
        /// </summary>
        /// <param name="audioStream">The audio stream.</param>
        /// <param name="mixerChannel">The mixer channel.</param>
        public static void RemoveFromMixer(AudioStream audioStream, MixerChannel mixerChannel)
        {
            if (audioStream == null || !audioStream.IsAudioLoaded())
            {
                return;
            }

            //throw new Exception("Audio file null or not audio not loaded");

            if (mixerChannel.ChannelId == int.MinValue)
            {
                throw new Exception("Mixer channel not initialized");
            }

            //lock (Lock)
            {
                // DebugHelper.WriteLine($"RemoveFromMixer {audioStream.Description} {audioStream.Channel}...");
                BassMix.BASS_Mixer_ChannelPause(audioStream.ChannelId);
                Bass.BASS_ChannelLock(mixerChannel.ChannelId, true);

                foreach (var channel in audioStream.ChannelIds)
                {
                    BassMix.BASS_Mixer_ChannelRemove(channel);
                }

                Bass.BASS_ChannelLock(mixerChannel.ChannelId, false);
                // DebugHelper.WriteLine("done");


                if (audioStream.MixerChannelId == mixerChannel.ChannelId)
                {
                    audioStream.MixerChannelId = int.MinValue;
                }
            }
        }
Example #3
0
        private void EndSync(int handle, int channel, int data, IntPtr user)
        {
            if (this.IsLooping == true)
            {
                if (this.IsSingleHardLoop == true)
                {
                    //do nothing let it loop
                }
                else // needs to change sample and/or pause
                {
                    BassMix.BASS_Mixer_ChannelPause(CurrentSample.Channel);
                    GetNextSoundFile(IsPlayList);
                    Int32 loopGap = RandomLoopGap();

                    if (loopGap > 0) //needs a gapTimer
                    {
                        gapTimer.Interval = loopGap;
                        gapTimer.Start();
                    }
                    else //no timer needed play next
                    {
                        PlayCurrentSample(true);
                    }
                }
            }
            else
            {
                OnEnded(EventArgs.Empty);
            }
        }
Example #4
0
        protected void OnPlayUpdated()
        {
            if (this.BassHandle.HasValue)
            {
                //Check if channel is within a mixer or not
                int mixerhandle = BassMix.BASS_Mixer_ChannelGetMixer(this.BassHandle.Value);

                if (mixerhandle != 0)
                {
                    //In a mixer, updated the proper status
                    if (this.play)
                    {
                        BassMix.BASS_Mixer_ChannelPlay(this.basshandle.Value);
                    }
                    else
                    {
                        BassMix.BASS_Mixer_ChannelPause(this.basshandle.Value);
                    }
                }
                else
                {
                    //Not in a mixer, just updated standard status
                    if (this.play)
                    {
                        Bass.BASS_ChannelPlay(this.basshandle.Value, false);
                    }
                    else
                    {
                        Bass.BASS_ChannelPause(this.basshandle.Value);
                    }
                }
            }
        }
Example #5
0
        public void PlaySample(Sample sample)
        {
            BassMix.BASS_Mixer_ChannelPause(sample.Channel);

            Bass.BASS_ChannelSetPosition(sample.Channel, 1);

            BassMix.BASS_Mixer_ChannelPlay(sample.Channel);
        }
Example #6
0
 public void Pause()
 {
     if (this.PlayState == PlayState.Playing)
     {
         this.PlayState = PlayState.Paused;
         BassMix.BASS_Mixer_ChannelPause(this.Channel);
     }
 }
        protected void Dispose(bool bManagedDispose)
        {
            if (encoder != null)
            {
                encoder.Stop();                  // finish
                encoder.Dispose();
                encoder = null;
            }
            this.e出力デバイス = ESoundDeviceType.Unknown;                    // まず出力停止する(Dispose中にクラス内にアクセスされることを防ぐ)

            if (this.hMixer_DeviceOut != 0)
            {
                BassMix.BASS_Mixer_ChannelPause(this.hMixer_DeviceOut);
                Bass.BASS_StreamFree(this.hMixer_DeviceOut);
                this.hMixer_DeviceOut = 0;
            }
            if (this.hMixer_Record != 0)
            {
                BassMix.BASS_Mixer_ChannelPause(this.hMixer_Record);
                Bass.BASS_StreamFree(this.hMixer_Record);
                this.hMixer_Record = 0;
            }

            if (hMixer != 0)
            {
                BassMix.BASS_Mixer_ChannelPause(this.hMixer_Record);
                Bass.BASS_StreamFree(this.hMixer);
            }
            if (this.hMixer_Chips != null)
            {
                for (int i = 0; i <= (int)CSound.EInstType.Unknown; i++)
                {
                    if (this.hMixer_Chips[i] != 0)
                    {
                        // Mixerにinputされるchannelsがfreeされると、Mixerへのinputも自動でremoveされる。
                        // 従い、ここでは、mixer本体をfreeするだけでよい
                        BassMix.BASS_Mixer_ChannelPause(this.hMixer_Chips[i]);
                        Bass.BASS_StreamFree(this.hMixer_Chips[i]);
                        this.hMixer_Chips[i] = 0;
                    }
                }
            }
#if TEST_MultiThreadedMixer
            //BASSThreadedMixerLibraryWrapper.FreeBASSThreadedMixerLibrary();
#endif

            if (!this.bIsBASSFree)
            {
                BassWasapi.BASS_WASAPI_Free();                  // システムタイマより先に呼び出すこと。(tWasapi処理() の中でシステムタイマを参照してるため)
                Bass.BASS_Free();
            }
            if (bManagedDispose)
            {
                CCommon.tDispose(this.tmシステムタイマ);
                this.tmシステムタイマ = null;
            }
        }
Example #8
0
 public void Stop()
 {
     if (CurrentSample != null)
     {
         BassMix.BASS_Mixer_ChannelPause(CurrentSample.Channel);
     }
     gapTimer.Stop();
     OnStopping(EventArgs.Empty);
     CurrentSample = null;
 }
Example #9
0
        /// <summary>
        ///     Loads a WinAmp DSP plug-in and applies it to the mixer
        /// </summary>
        /// <param name="location">The file location of the WinAmp DSP DLL</param>
        public WaPlugin LoadWaPlugin(string location)
        {
            if (location == "")
            {
                return(null);
            }

            if (WaPlugin != null && WaPlugin.Location == location)
            {
                return(WaPlugin);
            }

            if (!File.Exists(location))
            {
                return(null);
            }

            BassMix.BASS_Mixer_ChannelPause(ChannelId);

            if (!_waDspLoaded)
            {
                StartWaDspEngine();
            }

            // DebugHelper.WriteLine("Load WAPlugin " + location);
            var id = BassWaDsp.BASS_WADSP_Load(location, 10, 10, 300, 300, null);

            Thread.Sleep(20);

            var plugin = new WaPlugin
            {
                Id     = id,
                Module = 0
            };

            plugin.Name = BassWaDsp.BASS_WADSP_GetName(plugin.Id);
            Thread.Sleep(20);
            plugin.Location = location;

            BassWaDsp.BASS_WADSP_Start(plugin.Id, plugin.Module, ChannelId);
            Thread.Sleep(20);

            BassWaDsp.BASS_WADSP_ChannelSetDSP(plugin.Id, ChannelId, 1);
            Thread.Sleep(20);

            WaPlugin = plugin;

            BassMix.BASS_Mixer_ChannelPlay(ChannelId);
            Thread.Sleep(20);

            return(plugin);
        }
 /// <summary>
 ///     Pause an audio stream
 /// </summary>
 /// <param name="audioStream">The audio stream.</param>
 public static void Pause(AudioStream audioStream)
 {
     if (audioStream == null || !audioStream.IsAudioLoaded())
     {
         return;
     }
     //lock (Lock)
     {
         // DebugHelper.WriteLine("Pause Audio Stream (" + audioStream.Description + ")");
         BassMix.BASS_Mixer_ChannelPause(audioStream.ChannelId);
         Thread.Sleep(1);
     }
 }
Example #11
0
 public bool loadDeckB(string songName)
 {
     if (running())
     {
         if (!songName.Equals(string.Empty))
         {
             _songB    = songName;
             _deckB    = Bass.BASS_StreamCreateFile(songName, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
             _bRunning = false;                       // definitely not playing
             bool b = BassMix.BASS_Mixer_StreamAddChannel(_mixer, _deckB, BASSFlag.BASS_DEFAULT);
             BassMix.BASS_Mixer_ChannelPause(_deckB); // pause as soon as it loads
             return(b);
         }
     }
     return(false);
 }
Example #12
0
 public void playDeckB()
 {
     Console.WriteLine(_deckB);
     if (running())
     {
         if (_deckB != 0)
         {
             if (_bRunning)
             {
                 _bRunning = false;
                 BassMix.BASS_Mixer_ChannelPause(_deckB);
             }
             else
             {
                 _bRunning = true;
                 BassMix.BASS_Mixer_ChannelPlay(_deckB);
             }
         }
     }
 }
Example #13
0
 public void Pause()
 {
     BassMix.BASS_Mixer_ChannelPause(this.Channel);
 }
Example #14
0
 public void StopSample(Sample sample)
 {
     BassMix.BASS_Mixer_ChannelPause(sample.Channel);
 }