示例#1
0
 private void AsioRecording_Load(object sender, System.EventArgs e)
 {
     // we don't play via Bass, but only via BassAsio
     // not playing anything via BASS, so don't need an update thread
     Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 0);
     // setup BASS - "no sound" device and Init first Asio device
     if (Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, this.Handle) &&
         BassAsio.BASS_ASIO_Init(0, BASSASIOInit.BASS_ASIO_DEFAULT))
     {
         // just here as a demo ;-)
         BASS_ASIO_CHANNELINFO info = new BASS_ASIO_CHANNELINFO();
         int chan = 0;
         while (true)
         {
             if (!BassAsio.BASS_ASIO_ChannelGetInfo(false, chan, info))
             {
                 break;
             }
             Console.WriteLine(info.ToString());
             chan++;
         }
     }
     else
     {
         MessageBox.Show(this, "Bass_Init error!");
     }
 }
示例#2
0
        private void comboBoxInputDevice_SelectedIndexChanged(object sender, EventArgs e)
        {
            /*   if (inputDev)
             * {
             *     //Get the device index from the selected device
             *     DeviceInfo info = (DeviceInfo)comboBoxInputDevice.Items[comboBoxInputDevice.SelectedIndex];
             *     if (info == null) return;
             *
             *     WasapiDevice.Stop();
             *
             *     WasapiDevice.SetDevice(info.WasapiDeviceNum, WasapiDevice.GetOutputDefaultDevice(), this);
             *     WasapiDevice.Start();
             *
             * }*/
            try
            {
                if (m_inputDev)
                {
                    if (Player.IsAsioInitialized)
                    {
                        BassAsioDevice.inputDevice = comboBoxInputDevice.SelectedIndex;
                        //groupMicrophoneEffects.Visible = false;
                        BASS_ASIO_CHANNELINFO chanInfo = BassAsio.BASS_ASIO_ChannelGetInfo(true, comboBoxInputDevice.SelectedIndex * 2);
                        BassAsioDevice.Stop();
                        BassAsioDevice.SetDevice(comboBoxInputDevice.SelectedIndex * 2, comboBoxOutputDevice.SelectedIndex * 2);
                        BassAsioDevice.Start();
                        Effects.GetorSetFx = Effects.Load.CHANNETSTRIP;
                        RefreshEffects();
                        // groupMicrophoneEffects.Visible = true;
                        m_inputDev  = false;
                        m_outputDev = false;
                    }

                    if (Player.IsWasapiInitialized)
                    {
                        //Get the device index from the selected device
                        DeviceInfo info = (DeviceInfo)comboBoxInputDevice.Items[comboBoxInputDevice.SelectedIndex];
                        if (info == null)
                        {
                            return;
                        }

                        WasapiDevice.Stop();
                        WasapiDevice.SetDevice(info.WasapiDeviceNum, WasapiDevice.GetOutputDefaultDevice());
                        WasapiDevice.Start();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogFile(ex.Message, "", "comboBoxInputDevice_SelectedIndexChanged", ex.LineNumber(), this.Name);
            }
        }
示例#3
0
        private void comboBoxAsioInputDevice_SelectedIndexChanged(object sender, EventArgs e)
        {
            // get the available Asio channels
            this.comboBoxAsioInputChannel.Items.Clear();
            this.comboBoxAsioInputChannel.Text = "";
            int n = this.comboBoxAsioInputDevice.SelectedIndex;

            if (BassAsio.BASS_ASIO_GetDevice() == n || BassAsio.BASS_ASIO_SetDevice(n))
            {
                BASS_ASIO_INFO info = BassAsio.BASS_ASIO_GetInfo();
                if (info != null)
                {
                    // assuming stereo input
                    for (int i = 0; i < info.inputs; i += 2)
                    {
                        BASS_ASIO_CHANNELINFO chanInfo = BassAsio.BASS_ASIO_ChannelGetInfo(true, i);
                        if (chanInfo != null)
                        {
                            this.comboBoxAsioInputChannel.Items.Add(chanInfo);
                        }
                    }
                    if (this.comboBoxAsioInputChannel.Items.Count > 0)
                    {
                        this.comboBoxAsioInputChannel.SelectedIndex = 0;
                    }
                }
                else
                {
                    MessageBox.Show(String.Format("AsioError = {0}", BassAsio.BASS_ASIO_ErrorGetCode()));
                }
            }
            else
            {
                MessageBox.Show(String.Format("AsioError = {0}", BassAsio.BASS_ASIO_ErrorGetCode()));
            }
        }
示例#4
0
        public static void SetDevice(int inputChannel, int outputChannel)
        {
            //  Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 0);
            //   Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_FLOATDSP, true);
            // BassAsio.BASS_ASIO_Init(0, BASSASIOInit.BASS_ASIO_DEFAULT);
            //   Bass.BASS_Init(0, (int)samplerate, 0, IntPtr.Zero);

            //   m_asioInputHandlers = new BassAsioHandler();
            //   m_asioOutputHandlers = new BassAsioHandler();
            devinfo              = new BASS_ASIO_DEVICEINFO();
            m_asioInputChannels  = new List <object>();
            m_asioOutputChannels = new List <object>();
            thisControl          = PlayerControl.MainFormControl;
            m_inputChannel       = inputChannel;
            m_outputChannel      = outputChannel;

            /*   for (int n = 0; BassAsio.BASS_ASIO_GetDeviceInfo(n, devinfo); n++)
             * {
             *     if (devinfo.name.Contains("ASIO4ALL"))
             *     {
             *         if (!BassAsio.BASS_ASIO_IsStarted())
             *             BassAsio.BASS_ASIO_Init(n, BASSASIOInit.BASS_ASIO_DEFAULT);
             *
             *         samplerate = BassAsio.BASS_ASIO_GetRate();
             *         m_asiodevice = n;
             *
             *         BASS_ASIO_INFO asioinfo = BassAsio.BASS_ASIO_GetInfo();
             *         if (asioinfo != null)
             *         {
             *             // assuming stereo input
             *             for (int i = 0; i < asioinfo.inputs; i += 2)
             *             {
             *                 BASS_ASIO_CHANNELINFO chanInfo = BassAsio.BASS_ASIO_ChannelGetInfo(true, i);
             *                 if (chanInfo != null)
             *                     GetAsioInputChannels.Add(chanInfo);
             *
             *                 if (chanInfo.name.Contains("VB-Audio Point 1"))
             *                     GetVlcAsioInputChannel = i;
             *             }
             *
             *             for (int o = 0; o < asioinfo.outputs; o += 2)
             *             {
             *                 BASS_ASIO_CHANNELINFO chanInfo = BassAsio.BASS_ASIO_ChannelGetInfo(false, o);
             *                 if (chanInfo != null)
             *                     GetAsioOutputChannels.Add(chanInfo);
             *             }
             *         }
             *     }
             *
             * }
             *
             * CreateInputs(m_inputChannel);
             * CreateOutput(m_outputChannel);
             * Connect();
             * int ggg = 0;*/


            for (int n = 0; BassAsio.BASS_ASIO_GetDeviceInfo(n, devinfo); n++)
            {
                if (devinfo.name.Contains("ASIO4ALL"))
                {
                    if (!BassAsio.BASS_ASIO_IsStarted())
                    {
                        BassAsio.BASS_ASIO_Init(n, BASSASIOInit.BASS_ASIO_THREAD);
                    }

                    samplerate   = BassAsio.BASS_ASIO_GetRate();
                    m_asiodevice = n;

                    BASS_ASIO_INFO asioinfo = BassAsio.BASS_ASIO_GetInfo();
                    if (asioinfo != null)
                    {
                        // assuming stereo input
                        for (int i = 0; i < asioinfo.inputs; i += 2)
                        {
                            BASS_ASIO_CHANNELINFO chanInfo = BassAsio.BASS_ASIO_ChannelGetInfo(true, i);
                            if (chanInfo != null)
                            {
                                GetAsioInputChannels.Add(chanInfo);
                            }

                            if (chanInfo.name.Contains("VB-Audio Point 1"))
                            {
                                VlcAsioInputChannel = i;
                            }
                        }

                        for (int o = 0; o < asioinfo.outputs; o += 2)
                        {
                            BASS_ASIO_CHANNELINFO chanInfo = BassAsio.BASS_ASIO_ChannelGetInfo(false, o);
                            if (chanInfo != null)
                            {
                                AsioOutputChannels.Add(chanInfo);
                            }
                        }
                    }

                    BassAsio.BASS_ASIO_ChannelSetVolume(true, m_inputChannel, PlayerControl.MicVolumeScroll.Value * 0.01f);
                    BassAsio.BASS_ASIO_ChannelSetVolume(true, m_inputChannel + 1, PlayerControl.MicVolumeScroll.Value * 0.01f);

                    _asioProc = new ASIOPROC(AsioCallback);
                }
            }

            if (!m_bassinit)
            {
                Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 0);
                Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_FLOATDSP, true);
                Bass.BASS_Init(0, 48000, 0, IntPtr.Zero);

                Player.Mixer = MixerStreamCreate((int)samplerate);

                if (Player.Mixer == 0)
                {
                    var error = Bass.BASS_ErrorGetCode();
                    MessageBox.Show(error.ToString(), "Could not create mixer!");
                    Bass.BASS_Free();
                    return;
                }

                m_mixerChannel = Player.Mixer;

                m_streamInputMic = Bass.BASS_StreamCreatePush((int)samplerate, 2, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT, IntPtr.Zero);
                StreamInputVlc   = Bass.BASS_StreamCreatePush((int)samplerate, 2, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT, IntPtr.Zero);

                //m_streamInputMic = Bass.BASS_StreamCreateFile(f, 0L, 0L, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_SAMPLE_LOOP);
                //m_stream[0] = BassMix.BASS_Split_StreamCreate(m_streamInputMic, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE, null);//_instream;
                //m_stream[1] = BassMix.BASS_Split_StreamCreate(m_streamInputMic, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE, null);// _instream;
                //m_stream[2] = BassMix.BASS_Split_StreamCreate(m_streamInputMic, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE, null);//_instream;
                //m_stream[3] = BassMix.BASS_Split_StreamCreate(m_streamInputMic, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE, null);//_instream;


                //Group 1 VST Effects ============================================================
                Channel1Fx.SetEffects(m_streamInputMic);


                //Group 2 VST Effects ============================================================
                // Channel2Fx.SetEffects(m_stream[1]);


                //Group 3 VST Effects ============================================================
                // Channel3Fx.SetEffects(m_stream[2]);


                //Group 4 VST Effects ============================================================
                // Channel4Fx.SetEffects(m_stream[3]);

                BassMix.BASS_Mixer_StreamAddChannel(m_mixerChannel, StreamInputVlc, BASSFlag.BASS_MIXER_DOWNMIX | BASSFlag.BASS_STREAM_AUTOFREE);
                BassMix.BASS_Mixer_StreamAddChannel(m_mixerChannel, m_streamInputMic, BASSFlag.BASS_MIXER_DOWNMIX | BASSFlag.BASS_STREAM_AUTOFREE);
                // BassMix.BASS_Mixer_StreamAddChannel(m_mixerChannel, m_stream[1], BASSFlag.BASS_MIXER_DOWNMIX | BASSFlag.BASS_STREAM_AUTOFREE);
                //BassMix.BASS_Mixer_StreamAddChannel(m_mixerChannel, m_stream[2], BASSFlag.BASS_MIXER_DOWNMIX | BASSFlag.BASS_STREAM_AUTOFREE);
                //BassMix.BASS_Mixer_StreamAddChannel(m_mixerChannel, m_stream[3], BASSFlag.BASS_MIXER_DOWNMIX | BASSFlag.BASS_STREAM_AUTOFREE);
                BASS_CHANNELINFO info = Bass.BASS_ChannelGetInfo(m_mixerChannel);

                m_bassinit = true;
            }

            //BassAsio.BASS_ASIO_ControlPanel();
            BassAsio.BASS_ASIO_ChannelEnable(true, VlcAsioInputChannel, _asioProc, new IntPtr(StreamInputVlc));
            BassAsio.BASS_ASIO_ChannelJoin(true, VlcAsioInputChannel + 1, VlcAsioInputChannel);
            BassAsio.BASS_ASIO_ChannelSetFormat(true, VlcAsioInputChannel, BASSASIOFormat.BASS_ASIO_FORMAT_FLOAT);
            BassAsio.BASS_ASIO_ChannelSetRate(true, VlcAsioInputChannel, samplerate);
            BassAsio.BASS_ASIO_SetRate(samplerate);

            BassAsio.BASS_ASIO_ChannelEnable(true, m_inputChannel, _asioProc, new IntPtr(m_streamInputMic));
            BassAsio.BASS_ASIO_ChannelJoin(true, m_inputChannel + 1, m_inputChannel);
            BassAsio.BASS_ASIO_ChannelSetFormat(true, m_inputChannel, BASSASIOFormat.BASS_ASIO_FORMAT_FLOAT);
            BassAsio.BASS_ASIO_ChannelSetRate(true, m_inputChannel, samplerate);
            BassAsio.BASS_ASIO_SetRate(samplerate);

            BassAsio.BASS_ASIO_ChannelEnable(false, m_outputChannel, _asioProc, new IntPtr(m_mixerChannel));
            BassAsio.BASS_ASIO_ChannelJoin(false, m_outputChannel + 1, m_outputChannel);
            BassAsio.BASS_ASIO_ChannelSetFormat(false, m_outputChannel, BASSASIOFormat.BASS_ASIO_FORMAT_FLOAT);
            BassAsio.BASS_ASIO_ChannelSetRate(false, m_outputChannel, samplerate);
            BassAsio.BASS_ASIO_SetRate(samplerate);
        }