private void buttonStopRecording_Click(object sender, EventArgs e) { if (_asioIn != null) { if (_plmRec != null) { _plmRec.Stop(); _plmRec = null; } // stop the device, since we don't need it anymore _asioIn.Stop(); // and dispose (unjoin and disable any channel) _asioIn.Dispose(); _asioIn = null; this.comboBoxAsioInputDevice.Enabled = true; this.comboBoxAsioInputChannel.Enabled = true; this.buttonStartRecording.Enabled = true; this.buttonStopRecording.Enabled = false; this.radioButtonNoFullDuplex.Checked = true; this.radioButtonAsioFullDuplex.Checked = false; this.radioButtonBassFullDuplex.Checked = false; this.radioButtonNoFullDuplex.Enabled = false; this.radioButtonAsioFullDuplex.Enabled = false; this.radioButtonBassFullDuplex.Enabled = false; this.comboBoxBassDevice.Enabled = false; this.checkBoxSaveToWave.Enabled = false; this.progressBarRecL.Value = 0; this.progressBarRecR.Value = 0; } }
private void buttonStop_Click(object sender, System.EventArgs e) { if (plm != null) { plm.Notification -= new EventHandler(plm_Notification); plm.Stop(); plm = null; } this.progressBarLeft.Value = 0; this.progressBarRight.Value = 0; if (enc != null) { enc.Stop(); // finish encoding enc.Dispose(); enc = null; } if (asio != null) { asio.RemoveMirror(); } asio.Stop(); this.buttonStart.Enabled = true; }
private void buttonStartRecording_Click(object sender, EventArgs e) { // now setup the ASIO handler (recording 48kHz, stereo) _asioIn = new BassAsioHandler(true, comboBoxAsioInputDevice.SelectedIndex, comboBoxAsioInputChannel.SelectedIndex * 2, 2, BASSASIOFormat.BASS_ASIO_FORMAT_FLOAT, 48000d); if (_asioIn.Start((int)this.numericUpDownAsioBuffer.Value, 1)) { // use a DSP to measure the Level of the input _plmRec = new DSP_PeakLevelMeter(_asioIn.InputChannel, 0); _plmRec.Notification += new EventHandler(_plm_Rec_Notification); this.comboBoxAsioInputDevice.Enabled = false; this.comboBoxAsioInputChannel.Enabled = false; this.buttonStopRecording.Enabled = true; this.buttonStartRecording.Enabled = false; this.radioButtonNoFullDuplex.Enabled = true; this.radioButtonAsioFullDuplex.Enabled = true; this.radioButtonBassFullDuplex.Enabled = true; this.comboBoxBassDevice.Enabled = true; this.checkBoxSaveToWave.Enabled = true; } else { _asioIn.Dispose(); _asioIn = null; MessageBox.Show("Asio Device could not be started!"); } }
private void AddDSP() { if (this.FCHannel != null) { // create a buffer of the source stream //We can't get it from the main stream otherwise it would interfere with the asio buffering this.FLevelMeter = new DSP_PeakLevelMeter(this.FCHannel.BassHandle.Value, 1); this.FLevelMeter.UpdateTime = 0.05f; this.FLevelMeter.CalcRMS = true; this.FLevelMeter.Start(); } }
private void radioButtonNoFullDuplex_CheckedChanged(object sender, EventArgs e) { if (radioButtonNoFullDuplex.Checked && _asioIn != null) { // remove the full-duplex output DSP if (_plmPlay != null) { _plmPlay.Stop(); _plmPlay = null; this.progressBarPlayL.Value = 0; this.progressBarPlayR.Value = 0; } // remove the full-duplex option and disable/unjoin any output channels _asioIn.RemoveFullDuplex(true); } }
private void radioButtonBassFullDuplex_CheckedChanged(object sender, EventArgs e) { if (radioButtonBassFullDuplex.Checked && _asioIn != null) { // remove the previous one? if (_asioIn.IsInputFullDuplex) { _asioIn.RemoveFullDuplex(true); } // set a new one if (_asioIn.SetFullDuplex(comboBoxBassDevice.SelectedIndex, BASSFlag.BASS_SAMPLE_SOFTWARE, true)) { // set up a DSP on the full-duplex bass output _plmPlay = new DSP_PeakLevelMeter(_asioIn.OutputChannel, 0); _plmPlay.Notification += new EventHandler(_plm_Play_Notification); } } }
private void radioButtonAsioFullDuplex_CheckedChanged(object sender, EventArgs e) { if (radioButtonAsioFullDuplex.Checked && _asioIn != null) { // remove the previous one? if (_asioIn.IsInputFullDuplex) { _asioIn.RemoveFullDuplex(true); } // set a new one _asioIn.SetFullDuplex(comboBoxAsioOutputDevice.SelectedIndex, comboBoxAsioOutputChannel.SelectedIndex * 2); if (_asioIn.StartFullDuplex(0)) { // set up a DSP on the full-duplex asio output _plmPlay = new DSP_PeakLevelMeter(_asioIn.OutputChannel, 0); _plmPlay.Notification += new EventHandler(_plm_Play_Notification); } } }
private void buttonOpenFile_Click(object sender, System.EventArgs e) { this.openFileDialog.FileName = _fileName; if (DialogResult.OK == this.openFileDialog.ShowDialog(this)) { if (File.Exists(this.openFileDialog.FileName)) { _fileName = this.openFileDialog.FileName; // create the decoding stream _stream = Bass.BASS_StreamCreateFile(_fileName, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT); if (_stream != 0) { // now setup the ASIO handler _asioOut = new BassAsioHandler(comboBoxAsioOutputDevice.SelectedIndex, comboBoxAsioOutputChannel.SelectedIndex * 2, _stream); if (_asioOut.Start((int)this.numericUpDownAsioBuffer.Value, 1)) { // use a DSP to measure the Level _plmPlay = new DSP_PeakLevelMeter(_asioOut.OutputChannel, 0); _plmPlay.Notification += new EventHandler(_plm_Play_Notification); this.comboBoxAsioOutputDevice.Enabled = false; this.comboBoxAsioOutputChannel.Enabled = false; this.buttonOpenFile.Enabled = false; this.buttonStop.Enabled = true; } else { _asioOut.Dispose(); _asioOut = null; MessageBox.Show("Asio Device could not be started!"); } } else { MessageBox.Show(String.Format("Error = {0}", Bass.BASS_ErrorGetCode())); } } else { _fileName = String.Empty; } } }
private Timer trackTimer = new Timer(30000); // 30 second timer for track logging #endregion Fields #region Constructors /// <summary> /// Starts up BASS, ready for audio to be logged /// </summary> public Logger() { // Registration code for Bass.Net // Provided value should be used only for ShockLog, not derived products BassNet.Registration("*****@*****.**", "2X24373423243720"); // Set dll locations if (IntPtr.Size == 8) // If running in 64 bit { Bass.LoadMe("x64"); BassEnc.LoadMe("x64"); } else // Else if running in 32 bit { Bass.LoadMe("x86"); BassEnc.LoadMe("x86"); } // Initialise BASS if (!Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, System.IntPtr.Zero)) // If unable to initialise { // Throw exception successfulInit = false; throw new ApplicationException(); } successfulInit = true; // Initialise audio input if (!Bass.BASS_RecordInit(-1)) // If unable to initialise default input device { // Throw exception throw new ApplicationException(); } // Start recording recordingHandle = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_SAMPLE_FLOAT, recordProc, IntPtr.Zero); // Add Peak Level Meter DSP and Event Handler peakLevelMeter = new DSP_PeakLevelMeter(recordingHandle, 1); peakLevelMeter.Notification += new EventHandler(PeakLevelMeterNotification); // Add timer event handler timer.Elapsed += new ElapsedEventHandler(TimerElapsed); trackTimer.Elapsed += new ElapsedEventHandler(TrackTimerElapsed); }
private void buttonStop_Click(object sender, System.EventArgs e) { if (_asioOut != null) { // stop the DSP _plmPlay.Stop(); _plmPlay = null; // stop the device, since we don't need it anymore _asioOut.Stop(); // and dispose (unjoin and disable any channel) _asioOut.Dispose(); _asioOut = null; // and free the source channel Bass.BASS_StreamFree(_stream); _stream = 0; this.comboBoxAsioOutputDevice.Enabled = true; this.comboBoxAsioOutputChannel.Enabled = true; this.buttonOpenFile.Enabled = true; this.buttonStop.Enabled = false; this.progressBarPlayL.Value = 0; this.progressBarPlayR.Value = 0; } }
public void RefreshAll() { try { _plm = new DSP_PeakLevelMeter(BassEngine.Instance.ActiveStreamHandle, 1); _plm.CalcRMS = true; _plm.Notification += UpdatePeakMeterDisplay; UpdateChorus(); UpdateReverb(); UpdateEcho(); UpdateI3Dl2Reverb(); UpdateGargle(); UpdateFlanger(); UpdateCompressor(); UpdateDistortion(); UpdateAutoWah(); UpdateApf(); UpdatePhaser(); } catch { } ; }
private void buttonStart_Click(object sender, System.EventArgs e) { asio = new BassAsioHandler(true, 0, 0, 2, BASSASIOFormat.BASS_ASIO_FORMAT_16BIT, 44100); // set a mirror on output channel 0 (for monitoring) asio.SetMirror(0); this.checkBoxMonitor.Checked = true; // start ASIO (actually starts recording/playing) BASS_ASIO_INFO info = BassAsio.BASS_ASIO_GetInfo(); bool ok = asio.Start(info.bufmax); if (!ok) { MessageBox.Show("Could not start ASIO : " + BassAsio.BASS_ASIO_ErrorGetCode().ToString()); } // now setup the encoder on the provided asio bass channel (which will be created by the above SetFullDuplex call) if (radioButtonLAME.Checked) { lame = new EncoderLAME(asio.InputChannel); lame.InputFile = null; //STDIN lame.OutputFile = "test.mp3"; lame.LAME_Bitrate = (int)EncoderLAME.BITRATE.kbps_128; lame.LAME_Mode = EncoderLAME.LAMEMode.Default; lame.LAME_Quality = EncoderLAME.LAMEQuality.Quality; lame.Start(null, IntPtr.Zero, false); enc = lame; } else if (radioButtonOGG.Checked) { ogg = new EncoderOGG(asio.InputChannel); ogg.InputFile = null; //STDIN ogg.OutputFile = "test.ogg"; ogg.OGG_UseQualityMode = true; ogg.OGG_Quality = 4.0f; ogg.Start(null, IntPtr.Zero, false); enc = ogg; } else if (radioButtonAAC.Checked) { aac = new EncoderNeroAAC(asio.InputChannel); aac.InputFile = null; //STDIN aac.OutputFile = "test.mp4"; aac.NERO_Bitrate = 64; aac.Start(null, IntPtr.Zero, false); enc = aac; } else if (radioButtonWAVE.Checked) { // writing 16-bit wave file here (even if we use a float asio channel) wav = new EncoderWAV(asio.InputChannel); wav.InputFile = null; // STDIN wav.OutputFile = "test.wav"; wav.Start(null, IntPtr.Zero, false); enc = wav; } this.buttonStart.Enabled = false; // display the level plm = new DSP_PeakLevelMeter(asio.InputChannel, 0); plm.UpdateTime = 0.1f; // 100ms plm.Notification += new EventHandler(plm_Notification); }
public void SetDSP(int streamFX , int stream) { StreamFX = streamFX; StreamReverse = BassFx.BASS_FX_ReverseCreate(stream, 2f, BASSFlag.BASS_FX_FREESOURCE); if (_beforePLM != null) _beforePLM.Notification -= new EventHandler(BeforePLMNotification); _beforePLM = new DSP_PeakLevelMeter(StreamFX, 2000); _beforePLM.CalcRMS = true; _beforePLM.Notification += new EventHandler(BeforePLMNotification); if (_afterPLM != null) _afterPLM.Notification -= new EventHandler(AfterPLMNotification); _afterPLM = new DSP_PeakLevelMeter(StreamFX, -2000); _afterPLM.CalcRMS = true; _afterPLM.Notification += new EventHandler(AfterPLMNotification); _gain = new DSP_Gain(StreamFX, 0); _mono = new DSP_Mono(); _mono.ChannelHandle = StreamFX; _mono.DSPPriority = 0; _mono.Invert = MonoInvert; if (MonoChecked) _mono.Start(); else _mono.Stop(); _stereoEnhancer = new DSP_StereoEnhancer(StreamFX, 0); _stereoEnhancer.SetBypass(!StereoEnhancerEnabled); _delay = new DSP_IIRDelay(StreamFX, 0, 2f); _delay.SetBypass(!DelayEnabled); foreach (Band band in TempoBands) { switch (band.Label) { case "Tempo": Bass.BASS_ChannelSetAttribute(StreamFX, BASSAttribute.BASS_ATTRIB_TEMPO, band.Value); break; case "TempoPitch": Bass.BASS_ChannelSetAttribute(StreamFX, BASSAttribute.BASS_ATTRIB_TEMPO_PITCH, band.Value); break; case "TempoFreq": Bass.BASS_ChannelSetAttribute(StreamFX, BASSAttribute.BASS_ATTRIB_TEMPO_FREQ, band.Value); break; } } foreach (Band band in DSPDelayBands) { switch (band.Label) { case "Samples": _delay.Delay = (int)band.Value; break; case "WetDry": _delay.WetDry = band.Value; break; case "Feedback": _delay.Feedback = band.Value; break; } } foreach (Band band in DSPStereoEnhancerBands) { switch (band.Label) { case "WetDry": _stereoEnhancer.WetDry = band.Value; break; case "WideCoef": _stereoEnhancer.WideCoeff = band.Value; break; } } TempoEnableFunc(TempoEnabled); }
/// <summary> /// Initialises the audio inputs and outputs /// </summary> /// <param name="mainWindowHandle">Handle of the main user interface window</param> public Router(IntPtr mainWindowHandle) { // Registration code for Bass.Net // Provided value should be used only for ShockRouter, not derived products BassNet.Registration("*****@*****.**", "2X24373423243720"); // Load BASS libraries Bass.LoadMe(); BassMix.LoadMe(); BassWaDsp.LoadMe(); // Initialise BASS if (!Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, System.IntPtr.Zero)) // If unable to initialise audio output { // Throw exception throw new ApplicationException(Bass.BASS_ErrorGetCode().ToString()); } // Create Mixer mixerHandle = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_MIXER_NONSTOP); if (mixerHandle == 0) // If unable to initialise mixer { // Throw exception throw new ApplicationException(Bass.BASS_ErrorGetCode().ToString()); } Bass.BASS_ChannelPlay(mixerHandle, false); // Initalise Winamp DSP support BassWaDsp.BASS_WADSP_Init(mainWindowHandle); // Find Winamp DSPs if (Directory.Exists(Path.GetPathRoot(Environment.CurrentDirectory) + "Program Files (x86)")) // If on 64 bit Windows { if (Directory.Exists(Path.GetPathRoot(Environment.CurrentDirectory) + "Program Files (x86)\\Winamp\\Plugins")) { WINAMP_DSP.FindPlugins(Path.GetPathRoot(Environment.CurrentDirectory) + "Program Files (x86)\\Winamp\\Plugins"); } } else // If on 32 bit Windows { if (Directory.Exists(Path.GetPathRoot(Environment.CurrentDirectory) + "Program Files\\Winamp\\Plugins")) { WINAMP_DSP.FindPlugins(Path.GetPathRoot(Environment.CurrentDirectory) + "Program Files\\Winamp\\Plugins"); } } // Create list of Winamp DSPs if (WINAMP_DSP.PlugIns.Count > 0) // If there is plugins available { availableDSPs = new string[WINAMP_DSP.PlugIns.Count]; // Set size of array // Get information for each DSP and add to list for (int i = 0; i < WINAMP_DSP.PlugIns.Count; i++) { availableDSPs[i] = WINAMP_DSP.PlugIns[i].File; } } // Initalise Line In InitaliseLineIn(); // Add source peak level meter DSP and event handler sourceLevelMeter = new DSP_PeakLevelMeter(mixerHandle, 3); sourceLevelMeter.Notification += new EventHandler(SourceLevelMeterNotification); // Add output peak level meter DSP and event handler outputLevelMeter = new DSP_PeakLevelMeter(mixerHandle, 1); outputLevelMeter.Notification += new EventHandler(OutputLevelMeterNotification); // Setup remote response remote.RemoteSourceChange += new EventHandler(RemoteSourceChange); }
internal HolofunkBassAsioInput(HolofunkBassAsio bassAsio, int asioChannel, BufferAllocator<float> audioAllocator) { m_bassAsio = bassAsio; m_asioChannel = asioChannel; // buffer one second's worth of audio; that will always be more than we need to look at m_recentPastStream = new DenseSampleFloatStream( default(Time<Sample>), audioAllocator, 1, // input channels are mono maxBufferedDuration: Clock.TimepointRateHz); m_inputToInputPushStreamAsioProc = new ASIOPROC(InputToInputPushStreamAsioProc); // create input push stream; this receives data pushed from ASIO's input, and feeds the mixer m_inputPushStream = (StreamHandle)Bass.BASS_StreamCreatePush( Clock.TimepointRateHz, HolofunkBassAsio.InputChannelCount, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT, new IntPtr(m_asioChannel)); // connect to ASIO input channel CheckError(BassAsio.BASS_ASIO_ChannelEnable( HolofunkBassAsio.IsInputChannel, m_asioChannel, m_inputToInputPushStreamAsioProc, new IntPtr(m_asioChannel))); // join right channel if we have more than one input channel // (this is not generalized for >stereo) if (HolofunkBassAsio.InputChannelCount == 2) { CheckError(BassAsio.BASS_ASIO_ChannelJoin(HolofunkBassAsio.IsInputChannel, 1, m_asioChannel)); } // set format and rate of input channel CheckError(BassAsio.BASS_ASIO_ChannelSetFormat(HolofunkBassAsio.IsInputChannel, m_asioChannel, BASSASIOFormat.BASS_ASIO_FORMAT_FLOAT)); CheckError(BassAsio.BASS_ASIO_ChannelSetRate(HolofunkBassAsio.IsInputChannel, m_asioChannel, Clock.TimepointRateHz)); // add input push stream to mixer CheckError(BassMix.BASS_Mixer_StreamAddChannel( (int)m_bassAsio.MixerHStream, (int)m_inputPushStream, BASSFlag.BASS_MIXER_DOWNMIX | BASSFlag.BASS_MIXER_NORAMPIN)); // set up the input effects (aka microphone effects) m_inputPushEffects = AllEffects.CreateLoopEffectSet(m_inputPushStream, m_bassAsio.BaseForm); // connect peak level meter to input push stream m_plmRec = new DSP_PeakLevelMeter((int)m_inputPushStream, 0); m_plmRec.Notification += new EventHandler(Plm_Rec_Notification); // Register DSPPROC handler for input channel. Make sure to hold the DSPPROC itself. // See documentation for BassAsioHandler.InputChannel m_inputDspProc = new DSPPROC(InputDspProc); // set up our recording DSP -- priority 10 hopefully means "run first first first!" CheckError(Bass.BASS_ChannelSetDSP((int)m_inputPushStream, m_inputDspProc, new IntPtr(0), 10) != 0); }