コード例 #1
0
 public void Stop()
 {
     _threadDispatcher.Invoke(new Action(() =>
     {
         BassFx.BASS_FX_BPM_BeatCallbackReset(_recordChan);
         if (HasWasapi)
         {
             _wasapi.Stop();
             _wasapi.Dispose();
             _wasapi = null;
             BassWasapi.BASS_WASAPI_Free();
         }
         else
         {
             Bass.BASS_ChannelStop(_recordChan);
         }
         Bass.BASS_Free();
     }));
 }
コード例 #2
0
        private void InitWasapi(int deviceId)
        {
            if (deviceId == -1)
            {
                deviceId = AutodetectWasapiDevice();
            }
            else
            {
                if (BassWasapi.BASS_WASAPI_GetDeviceInfo(deviceId) == null)
                {
                    deviceId = AutodetectWasapiDevice();
                }
            }

            if (deviceId > -1)
            {
                var info = BassWasapi.BASS_WASAPI_GetDeviceInfo(deviceId);
                _wasapi = new BassWasapiHandler(deviceId, false, info.mixfreq, info.mixchans, 0, info.minperiod);
                _wasapi.Init();
                _wasapi.Start();
                _recordChan = _wasapi.InputChannel;
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: eariassoto/ColourSharp
        private bool StopBass()
        {
            FFTThink.Enabled = false;
            _wasapi.RemoveFullDuplex();
            _wasapi.Stop();
            _wasapiOutput.Stop();

            Bass.BASS_SetDevice(Device);

            _wasapi = null;
            _wasapiOutput = null;

            if (!Bass.BASS_Free() || !BassWasapi.FreeMe()) return false;
            return true;
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: eariassoto/ColourSharp
        private bool StartBass()
        {
            try
            {
                //Start Bass and BassWASAPI
                Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
                BassWasapi.BASS_WASAPI_Init(0, 44100, 2, BASSWASAPIInit.BASS_WASAPI_AUTOFORMAT, 0f, 0f, null,
                    IntPtr.Zero);
            }
            catch (Exception exc)
            {
                MessageBox.Show("BASS Failed to Init. \n " + exc);
            }

            // assign WASAPI input and outpt in shared-mode
            if (Device > 0)
            {
                try
                {
                    _wasapi = new BassWasapiHandler(Device, false, 44100, 2, 0f, 0f); //Device
                    _wasapiOutput = new BassWasapiHandler(Device, false, 48000, 2, 0f, 0f);

                    // init and start WASAPI
                    _wasapi.Init();
                    if (_wasapi.DeviceMute)
                        _wasapi.DeviceMute = false;
                    _wasapi.Start();

                    // setup a full-duplex stream
                    _wasapi.SetFullDuplex(0, BASSFlag.BASS_STREAM_DECODE, false);

                    stream = _wasapi.OutputChannel;
                    // and assign it to an output
                    _wasapiOutput.AddOutputSource(stream, BASSFlag.BASS_DEFAULT);

                    //Start the output stream
                    _wasapiOutput.Init();
                    _wasapiOutput.Start();

                    FFTThink.Enabled = true;
                    return true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("ERROR STARTING WASAPI I/O: " + ex +
                                    "\n \nThis is usually due to an incorrect device being used, settings have been reset.");
                    ini.IniWriteValue("recent_device", "DeviceNumber", "-1");

                    Device = -1;
                    MessageBox.Show("OMG: Starting up abnormally.");

                    return false;
                }
            }
            MessageBox.Show("Please choose an output device in device settings before starting.");
            return false;
        }