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 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 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); }