protected void OnPlayUpdated() { if (this.BassHandle.HasValue) { //Check if channel is within a mixer or not int mixerhandle = BassMix.BASS_Mixer_ChannelGetMixer(this.BassHandle.Value); if (mixerhandle != 0) { //In a mixer, updated the proper status if (this.play) { BassMix.BASS_Mixer_ChannelPlay(this.basshandle.Value); } else { BassMix.BASS_Mixer_ChannelPause(this.basshandle.Value); } } else { //Not in a mixer, just updated standard status if (this.play) { Bass.BASS_ChannelPlay(this.basshandle.Value, false); } else { Bass.BASS_ChannelPause(this.basshandle.Value); } } } }
private void UpdateMatrix(int index) { double dhandle; this.FPinHandles[index].GetValue(0, out dhandle); ChannelInfo info = this.manager.GetChannel(Convert.ToInt32(dhandle)); if (info != null) { int mixerhandle = 0; if (info.BassHandle.HasValue) { mixerhandle = BassMix.BASS_Mixer_ChannelGetMixer(info.BassHandle.Value); } if (mixerhandle != 0) { BASS_CHANNELINFO MIXER = Bass.BASS_ChannelGetInfo(mixerhandle); BASS_CHANNELINFO CHANNEL = Bass.BASS_ChannelGetInfo(info.BassHandle.Value); float[,] matrix = new float[MIXER.chans, CHANNEL.chans]; BassMix.BASS_Mixer_ChannelGetMatrix(info.BassHandle.Value, matrix); int idx = 0; for (int i = 0; i < MIXER.chans; i++) { for (int j = 0; j < CHANNEL.chans; j++) { double level; this.FPinLevels[index].GetValue(idx, out level); matrix[i, j] = (float)level; idx++; if (idx == this.FPinLevels[index].SliceCount) { idx = 0; } } } BassMix.BASS_Mixer_ChannelSetMatrix(info.BassHandle.Value, matrix); } } }
public void Evaluate(int SpreadMax) { if (this.FPinInHandle.PinIsChanged || this.FChannel == null) { //Just Update the Handle double dhandle; this.FPinInHandle.GetValue(0, out dhandle); int ihandle = Convert.ToInt32(Math.Round(dhandle)); if (this.FManager.Exists(ihandle)) { this.FChannel = this.FManager.GetChannel(ihandle); if (this.FChannel.BassHandle.HasValue) { if (this.FChannel.IsDecoding) { int mixhandle = BassMix.BASS_Mixer_ChannelGetMixer(this.FChannel.BassHandle.Value); if (mixhandle == 0) { // create a buffer of the source stream //We can't get it from the main stream otherwise it would interfere with the asio buffering bufferStream = new DSP_BufferStream(); bufferStream.ChannelHandle = this.FChannel.BassHandle.Value; // the stream to copy bufferStream.DSPPriority = -4000; bufferStream.Start(); this.FMyBassHandle = bufferStream.BufferStream; this.FMixer = false; } else { //We have a mixer, much better :) this.FMyBassHandle = this.FChannel.BassHandle.Value; this.FMixer = true; } } else { //If it's not decoding, no problem :) this.FMyBassHandle = this.FChannel.BassHandle.Value; this.FMixer = false; } } else { this.FMyBassHandle = 0; this.FChannel = null; } } else { this.FMyBassHandle = 0; this.FChannel = null; } } int len = this.DataLength; this.FPinOutSize.SetValue(0, len); if (len != -1) { BASS_CHANNELINFO info = Bass.BASS_ChannelGetInfo(this.FChannel.BassHandle.Value); //We get float, so length is divided by 4 float[] samples = new float[len]; int val; if (this.FMixer) { val = BassMix.BASS_Mixer_ChannelGetData(this.FMyBassHandle, samples, this.DataType); } else { val = Bass.BASS_ChannelGetData(this.FMyBassHandle, samples, this.DataType); } this.SetData(samples); this.FPinOutMsg.SetString(0, "OK"); } else { this.FPinOutMsg.SetString(0, this.ErrorMsg); } }
public void Evaluate(int SpreadMax) { bool updateplay = false; bool reset = false; reset = this.FPinCfgIsDecoding.PinIsChanged; if (!reset) { double dblreset; this.FPinInReset.GetValue(0, out dblreset); reset = dblreset >= 0.5; } if (this.FPinInLoopStartPos.PinIsChanged || this.FPinInLoopEndPos.PinIsChanged) { this.ProcessStartEnd(); } #region Reset the channel if (reset) { DynamicChannelInfo info = new DynamicChannelInfo(); double dbldec; this.FPinCfgIsDecoding.GetValue(0, out dbldec); info.IsDecoding = dbldec == 1; this.manager.CreateChannel(info); this.FChannelInfo = info; this.ProcessStartEnd(); this.FChannelInfo.Buffer = new float[this.FPinInBuffer.SliceCount]; for (int i = 0; i < this.FPinInBuffer.SliceCount; i++) { double d; this.FPinInBuffer.GetValue(i, out d); this.FChannelInfo.Buffer[i] = (float)d; } this.FOriginalIndices.Clear(); this.FPinOutHandle.SetValue(0, this.FChannelInfo.InternalHandle); updateplay = true; } #endregion #region Write Data double doWrite; this.FPinInDoWrite.GetValue(0, out doWrite); if (doWrite >= 0.5) { int len = this.FPinInData.SliceCount; if (this.FPinInIndices.SliceCount < len) { len = this.FPinInIndices.SliceCount; } for (int i = 0; i < len; i++) { double dblindices, dbldata; this.FPinInIndices.GetValue(i, out dblindices); this.FPinInData.GetValue(i, out dbldata); int idx = Convert.ToInt32(dblindices); if (idx < this.FChannelInfo.Buffer.Length) { if (!this.FOriginalIndices.ContainsKey(idx)) { this.FOriginalIndices.Add(idx, this.FChannelInfo.Buffer[idx]); } this.FChannelInfo.Buffer[idx] = (float)dbldata; } } } #endregion #region Restore double dblrestore; this.FPinInRestore.GetValue(0, out dblrestore); if (dblrestore >= 0.5) { //Restore the buffer with orginal values foreach (int i in this.FOriginalIndices.Keys) { this.FChannelInfo.Buffer[i] = this.FOriginalIndices[i]; } this.FOriginalIndices.Clear(); } #endregion #region Update Play/Pause if (this.FPinInPlay.PinIsChanged || updateplay) { if (this.FChannelInfo.InternalHandle != 0) { double doplay; this.FPinInPlay.GetValue(0, out doplay); if (doplay == 1 && this.FPinOutHandle.IsConnected) { this.manager.GetChannel(this.FChannelInfo.InternalHandle).Play = true; } else { this.manager.GetChannel(this.FChannelInfo.InternalHandle).Play = false; } } } #endregion #region Update Current Position/Length if (this.FChannelInfo.InternalHandle != 0) { if (this.FChannelInfo.BassHandle.HasValue) { int mixerhandle = BassMix.BASS_Mixer_ChannelGetMixer(this.FChannelInfo.BassHandle.Value); long pos; if (mixerhandle != 0) { pos = BassMix.BASS_Mixer_ChannelGetPosition(this.FChannelInfo.BassHandle.Value); } else { pos = Bass.BASS_ChannelGetPosition(this.FChannelInfo.BassHandle.Value); } double seconds = Bass.BASS_ChannelBytes2Seconds(this.FChannelInfo.BassHandle.Value, pos); this.FPinOutCurrentPosition.SetValue(0, seconds); this.FPinOutBufferPosition.SetValue(0, this.FChannelInfo.BufferPosition); } } #endregion #region Tempo and Pitch if (this.FPinInPitch.PinIsChanged || this.FPinInTempo.PinIsChanged) { if (this.FChannelInfo.InternalHandle != 0) { double pitch, tempo; this.FPinInPitch.GetValue(0, out pitch); this.FPinInTempo.GetValue(0, out tempo); this.FChannelInfo.Pitch = pitch; this.FChannelInfo.Tempo = tempo; } } #endregion }