示例#1
0
        private void buttonSetEnvelope_Click(object sender, EventArgs e)
        {
            if (_currentTrack.Channel != 0)
            {
                BASS_MIXER_NODE[] nodes =
                {
                    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 10d), 1f),
                    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 13d), 0f),
                    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 17d), 0f),
                    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 20d), 1f)
                };
                BassMix.BASS_Mixer_ChannelSetEnvelope(_currentTrack.Channel, BASSMIXEnvelope.BASS_MIXER_ENV_VOL, nodes);
                // already align the envelope position to the current playback position
                // pause mixer
                Bass.BASS_ChannelLock(_mixer, true);
                long pos = BassMix.BASS_Mixer_ChannelGetPosition(_currentTrack.Channel);
                // convert source pos to mixer pos
                long envPos = Bass.BASS_ChannelSeconds2Bytes(_mixer, Bass.BASS_ChannelBytes2Seconds(_currentTrack.Channel, pos));
                BassMix.BASS_Mixer_ChannelSetEnvelopePos(_currentTrack.Channel, BASSMIXEnvelope.BASS_MIXER_ENV_VOL, envPos);
                // resume mixer
                Bass.BASS_ChannelLock(_mixer, false);

                // and show it in our waveform
                _WF.DrawVolume = WaveForm.VOLUMEDRAWTYPE.Solid;
                foreach (BASS_MIXER_NODE node in nodes)
                {
                    _WF.AddVolumePoint(node.pos, node.val);
                }
                DrawWave();
            }
        }
示例#2
0
        private void ToggleZoom()
        {
            if (_WF == null)
            {
                return;
            }

            // WF is not null, so the stream must be playing...
            if (_zoomed)
            {
                // unzoom...(display the whole wave form)
                _zoomStart      = -1;
                _zoomStartBytes = -1;
                _zoomEnd        = -1;
            }
            else
            {
                // zoom...(display only a partial wave form)
                long pos = BassMix.BASS_Mixer_ChannelGetPosition(_currentTrack.Channel);
                // calculate the window to display
                _zoomStart      = _WF.Position2Frames(pos);
                _zoomStartBytes = _WF.Frame2Bytes(_zoomStart);
                _zoomEnd        = _zoomStart + _WF.Position2Frames(_zoomDistance) - 1;
                if (_zoomEnd >= _WF.Wave.data.Length)
                {
                    // beyond the end, so we zoom from end - _zoomDistance.
                    _zoomEnd        = _WF.Wave.data.Length - 1;
                    _zoomStart      = _zoomEnd - _WF.Position2Frames(_zoomDistance) + 1;
                    _zoomStartBytes = _WF.Frame2Bytes(_zoomStart);
                }
            }
            _zoomed = !_zoomed;
            // and display this new wave form
            DrawWave();
        }
示例#3
0
        /// <summary>
        /// Текущая позиция в секундах
        /// </summary>
        /// <param name="stream"></param>
        /// <returns></returns>
        public double GetPosOfStream(int stream)
        {
            long pos;

            if (point_L.IsAllocated)
            {
                pos = BassMix.BASS_Mixer_ChannelGetPosition(stream, BASSMode.BASS_POS_BYTES);
            }
            else
            {
                pos = Bass.BASS_ChannelGetPosition(stream);
            }
            return(Bass.BASS_ChannelBytes2Seconds(stream, pos));
        }
示例#4
0
        private void timerUpdate_Tick(object sender, EventArgs e)
        {
            int level = Bass.BASS_ChannelGetLevel(_mixer);

            progressBarLeft.Value  = Utils.LowWord32(level);
            progressBarRight.Value = Utils.HighWord32(level);

            if (_currentTrack != null)
            {
                long pos = BassMix.BASS_Mixer_ChannelGetPosition(_currentTrack.Channel);
                labelTime.Text   = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(_currentTrack.Channel, pos), "HHMMSS");
                labelRemain.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(_currentTrack.Channel, _currentTrack.TrackLength - pos), "HHMMSS");

                DrawWavePosition(pos, _currentTrack.TrackLength);
            }
        }
示例#5
0
        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
        }