private void DefaultASIOAudioOutput_Load(object sender, EventArgs e) { try { int n; int selecteddeviceprev = (int)KeppySynthConfiguratorMain.SynthSettings.GetValue("defaultAdev", 0); BASS_ASIO_DEVICEINFO info = new BASS_ASIO_DEVICEINFO(); BassAsio.BASS_ASIO_GetDeviceInfo(selecteddeviceprev, info); DefOut.Text = String.Format("Def. ASIO output: {0}", info.ToString()); for (n = 0; BassAsio.BASS_ASIO_GetDeviceInfo(n, info); n++) { DevicesList.Items.Add(info.ToString()); } if (n < 1) { Functions.ShowErrorDialog(1, System.Media.SystemSounds.Asterisk, "Error", "No ASIO devices installed!\n\nClick OK to close this window.", false, null); Close(); return; } DevicesList.SelectedIndex = selecteddeviceprev; MaxThreads.Text = String.Format("ASIO is allowed to use a maximum of {0} threads.", Environment.ProcessorCount); BassAsio.BASS_ASIO_Init(DevicesList.SelectedIndex, 0); DeviceTrigger(); DevicesList.SelectedIndexChanged += new System.EventHandler(this.DevicesList_SelectedIndexChanged); } catch (Exception ex) { MessageBox.Show("Unable to load the dialog.\nBASS is probably unable to start, or it's missing.\n\nError:\n" + ex.Message.ToString(), "Oh no! Keppy's Synthesizer encountered an error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); Dispose(); } }
public DefaultASIOAudioOutput() { InitializeComponent(); try { if (GetASIODevicesCount() < 1) { Functions.ShowErrorDialog(ErrorType.Error, System.Media.SystemSounds.Asterisk, "Error", "No ASIO devices installed!\n\nClick OK to close this window.", false, null); Close(); Dispose(); } BASS_ASIO_DEVICEINFO info = new BASS_ASIO_DEVICEINFO(); // Populate devices list for (int n = 0; BassAsio.BASS_ASIO_GetDeviceInfo(n, info); n++) { DevicesList.Items.Add(info.ToString()); } // Load previous device from registry String PreviousDevice = (String)OmniMIDIConfiguratorMain.SynthSettings.GetValue("ASIOOutput", "None"); DefOut.Text = String.Format("Def. ASIO output: {0}", PreviousDevice); DevicesList.SelectedIndex = 0; for (int n = 0; n < DevicesList.Items.Count; n++) { if (DevicesList.Items[n].Equals(PreviousDevice)) { DevicesList.SelectedIndex = n; break; } } MaxThreads.Text = String.Format("ASIO is allowed to use a maximum of {0} threads.", Environment.ProcessorCount); BassAsio.BASS_ASIO_Init(DevicesList.SelectedIndex, BASSASIOInit.BASS_ASIO_THREAD | BASSASIOInit.BASS_ASIO_JOINORDER); GetASIODeviceInfo(); DeviceTrigger(true); DevicesList.SelectedIndexChanged += new EventHandler(DevicesList_SelectedIndexChanged); /* * Unavailable at the moment * * if (Convert.ToInt32(OmniMIDIConfiguratorMain.SynthSettings.GetValue("ASIOSeparateThread", 0)) == 1) * ASIOSeparateThread.Checked = true; * */ } catch (Exception ex) { MessageBox.Show("Unable to load the dialog.\nBASS is probably unable to start, or it's missing.\n\nError:\n" + ex.Message.ToString(), "Oh no! OmniMIDI encountered an error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); Dispose(); } }
public static int GetASIODevicesCount() { int numbdev; BASS_ASIO_DEVICEINFO info = new BASS_ASIO_DEVICEINFO(); for (numbdev = 0; BassAsio.BASS_ASIO_GetDeviceInfo(numbdev, info); numbdev++) { ; } return(numbdev); }
private void GetASIODeviceInfo() { try { BASS_ASIO_INFO dInfo = BassAsio.BASS_ASIO_GetInfo(); BASS_ASIO_DEVICEINFO fInfo = new BASS_ASIO_DEVICEINFO(); BassAsio.BASS_ASIO_GetDeviceInfo(DevicesList.SelectedIndex, fInfo); DeviceName.Text = String.Format("{0} (Driver library: {1})", dInfo.name, Path.GetFileName(fInfo.driver).ToUpperInvariant()); Inputs.Text = String.Format("{0} input channels available.", dInfo.inputs); Outputs.Text = String.Format("{0} output channels available.", dInfo.outputs); BufferInfo.Text = String.Format("Min/Max size {0}/{1} samples, set to {2} samples (Granularity value: {3})", dInfo.bufmin, dInfo.bufmax, dInfo.bufpref, GetASIOGranularity(dInfo.bufgran)); } catch { SetDummyASIOInfo(); } }
private void DefaultASIOAudioOutput_Load(object sender, EventArgs e) { try { int selecteddeviceprev = (int)KeppySynthConfiguratorMain.SynthSettings.GetValue("defaultAdev", 0); BASS_ASIO_DEVICEINFO info = new BASS_ASIO_DEVICEINFO(); BassAsio.BASS_ASIO_GetDeviceInfo(selecteddeviceprev, info); DefOut.Text = String.Format("Def. ASIO output: {0}", info.ToString()); for (int n = 0; BassAsio.BASS_ASIO_GetDeviceInfo(n, info); n++) { DevicesList.Items.Add(info.ToString()); } DevicesList.SelectedIndex = selecteddeviceprev; MaxThreads.Text = String.Format("ASIO is allowed to use a maximum of {0} threads.", Environment.ProcessorCount); BassAsio.BASS_ASIO_Init(DevicesList.SelectedIndex, 0); } catch (Exception ex) { MessageBox.Show("Unable to load the dialog.\nBASS is probably unable to start, or it's missing.\n\nError:\n" + ex.Message.ToString(), "Oh no! Keppy's Synthesizer encountered an error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); Dispose(); } }
/// <summary>Initialize the base ASIO streams, and actually start ASIO running.</summary> /// <remarks>[MainThread]</remarks> internal void StartASIO() { // not playing anything via BASS, so don't need an update thread CheckError(Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 0)); // setup BASS - "no sound" device but SampleFrequencyHz (default for ASIO) CheckError(Bass.BASS_Init(0, Clock.TimepointRateHz, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)); CheckError(BassAsio.BASS_ASIO_Init(AsioDeviceId, BASSASIOInit.BASS_ASIO_THREAD)); CheckError(BassFx.LoadMe()); if (UseVst) { CheckError(BassVst.LoadMe()); // testing scaffolding; retain for reference TempFrobBassVst(); } // register all effects once VST is set up EffectRegistrar.RegisterAll(); ////////////////////// DEVICE SETUP CheckError(BassAsio.BASS_ASIO_SetDevice(AsioDeviceId)); BASS_ASIO_DEVICEINFO info = new BASS_ASIO_DEVICEINFO(); System.Text.StringBuilder b = new System.Text.StringBuilder(); for (int n = 0; BassAsio.BASS_ASIO_GetDeviceInfo(n, info); n++) { b.AppendLine("device #" + n + ": " + info.ToString()); } b.AppendLine("done"); string all = b.ToString(); b.Clear(); for (int chan = 0; chan < 16; chan++) { BASS_ASIO_CHANNELINFO cinfo = BassAsio.BASS_ASIO_ChannelGetInfo(true, chan); if (cinfo != null) { b.AppendLine(cinfo.ToString()); } cinfo = BassAsio.BASS_ASIO_ChannelGetInfo(false, chan); if (cinfo != null) { b.AppendLine(cinfo.ToString()); } } all = b.ToString(); CheckError(BassAsio.BASS_ASIO_SetRate(Clock.TimepointRateHz)); BASS_ASIO_INFO asioInfo = BassAsio.BASS_ASIO_GetInfo(); int inputLatency = BassAsio.BASS_ASIO_GetLatency(IsInputChannel); int outputLatency = BassAsio.BASS_ASIO_GetLatency(IsOutputChannel); m_asioBufferPreferredSize = 128; // B4CKIN: asioInfo.bufpref; ////////////////////// OUTPUT SETUP // converted away from BassAsioHandler, to enable better viewing of intermediate data // (and full control over API use, allocation, etc.) m_mixerHStream = (StreamHandle)BassMix.BASS_Mixer_StreamCreate( Clock.TimepointRateHz, StereoChannels, BASSFlag.BASS_MIXER_RESUME | BASSFlag.BASS_MIXER_NONSTOP | BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT); BASS_CHANNELINFO mixerInfo = new BASS_CHANNELINFO(); CheckError(Bass.BASS_ChannelGetInfo((int)m_mixerHStream, mixerInfo)); // connect to ASIO output channel CheckError(BassAsio.BASS_ASIO_ChannelEnable(IsOutputChannel, AsioOutputChannelId, m_mixerToOutputAsioProc, new IntPtr((int)m_mixerHStream))); // Join second mixer channel (right stereo channel). CheckError(BassAsio.BASS_ASIO_ChannelJoin(IsOutputChannel, 1, AsioOutputChannelId)); CheckError(BassAsio.BASS_ASIO_ChannelSetFormat(IsOutputChannel, AsioOutputChannelId, BASSASIOFormat.BASS_ASIO_FORMAT_FLOAT)); CheckError(BassAsio.BASS_ASIO_ChannelSetRate(IsOutputChannel, AsioOutputChannelId, Clock.TimepointRateHz)); ////////////////////// INPUT SETUP CheckError(BassAsio.BASS_ASIO_SetDevice(HolofunkBassAsio.AsioDeviceId)); m_input0 = new HolofunkBassAsioInput(this, 0, m_bass.AudioAllocator); m_input1 = new HolofunkBassAsioInput(this, 1, m_bass.AudioAllocator); ////////////////////// ASIO LAUNCH CheckError(BassAsio.BASS_ASIO_Start(m_asioBufferPreferredSize)); // get the info again, see if latency has changed asioInfo = BassAsio.BASS_ASIO_GetInfo(); inputLatency = BassAsio.BASS_ASIO_GetLatency(IsInputChannel); outputLatency = BassAsio.BASS_ASIO_GetLatency(IsOutputChannel); }
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); }