private void UpdateChannels() { if (this.FDeviceIndex != -1 || this.FPinInVolumeOutput.SliceCount > 0) { BASS_ASIO_INFO deviceinfo = BassAsio.BASS_ASIO_GetInfo(); int current = 0; for (int i = 0; i < deviceinfo.outputs; i++) { double active; this.FPinInActive.GetValue(current, out active); if (active == 1) { BassAsio.BASS_ASIO_ChannelReset(false, i, BASSASIOReset.BASS_ASIO_RESET_PAUSE); } else { BassAsio.BASS_ASIO_ChannelPause(false, i); } //Bin for the channels current++; if (current == this.FPinInActive.SliceCount) { current = 0; } } } }
private void buttonPause_Click(object sender, System.EventArgs e) { if (BassAsio.BASS_ASIO_ChannelIsActive(false, 0) == BASSASIOActive.BASS_ASIO_ACTIVE_PAUSED) { // channel is paused...so unpause BassAsio.BASS_ASIO_ChannelReset(false, 0, BASSASIOReset.BASS_ASIO_RESET_PAUSE); this.labelStatus.Text = "playing"; } else { // channel is playing...so pause BassAsio.BASS_ASIO_ChannelPause(false, 0); this.labelStatus.Text = "paused"; this.progressBarVULeft.Value = 0; this.progressBarVURight.Value = 0; } }
// the main ASIO callback - filling the ASIO buffer with sample data to play... private int AsioCallback(bool input, int channel, IntPtr buffer, int length, IntPtr user) { // Note: 'user' contains the underlying stream channel (_streamFX) // get the status of the playing channel...(Note: you can do this also with a SYNCPORC)! _status = Bass.BASS_ChannelIsActive(user.ToInt32()); // now we evaluate the status... if (_status == BASSActive.BASS_ACTIVE_STOPPED) { // if the playing channel is at the end, we pause ASIO // Note: you need to call BASS_ASIO_ChannelReset to resume the ASIO channel! BassAsio.BASS_ASIO_ChannelPause(false, channel); this.BeginInvoke(new UpdateMessageDelegate(UpdateMessageDisplay), new object[] { "stopped" }); return(0); } else if (_status == BASSActive.BASS_ACTIVE_PAUSED || _status == BASSActive.BASS_ACTIVE_STALLED) { this.BeginInvoke(new UpdateMessageDelegate(UpdateMessageDisplay), new object[] { "paused" }); return(0); } else { // if playing, we just get the data from our decoding channel // Note: a decoding channel will be 'advanced' automatically, // so the next call to the decoding channel will get the next data... _decLength = Bass.BASS_ChannelGetData(user.ToInt32(), buffer, length); // however, it might be the case, that BASS_ChannelGetData returned less data than requested if (_decLength < 0) { _decLength = 0; } } // from here on we deal with our buffer...calculating the peak VU int l4 = _decLength / 4; _maxL = 0; _maxR = 0; unsafe { float *data = (float *)buffer; for (a = 0; a < l4; a++) { // decide on L/R channel if (a % 2 == 0) { // L channel if (data[a] > _maxL) { _maxL = data[a]; } } else { // R channel if (data[a] > _maxR) { _maxR = data[a]; } } } } // limit the maximum peak levels to 0bB = 32768 // and a float value of 1.0 also represents 0db. _peakL = (int)Math.Round(32768f * _maxL); if (_peakL > 32768) { _peakL = 32768; } _peakR = (int)Math.Round(32768f * _maxR); if (_peakR > 32768) { _peakR = 32768; } return(_decLength); }
public override void Pause() { BassAsio.BASS_ASIO_ChannelPause(false, 0); }