Author Topic: How to correctly reset my Pitch funtion  (Read 229 times)

Cafony

  • Posts: 26
How to correctly reset my Pitch funtion
« on: 20 Jun '24 - 10:28 »
Hello I got this trackbar controling my pitch value;
Code: [Select]
        private void trackBarTransp2_Scroll(object sender, EventArgs e)
        {
            _trackBarPitch = trackBarTranspose.Value; // define pitch value
            if (_trackBarPitch == 0)
            {
                Bass.BASS_FXReset(_streamPitch);    // This reset Is not working !!
                labelTranspose.Text = "Transpose: " + trackBarTranspose.Value.ToString();
                labelTranspose.ForeColor = Color.Black;
            }
            else
            {
                labelTranspose.Text = "Transpose: " + trackBarTranspose.Value.ToString();
                labelTranspose.ForeColor = Color.Red;
                pitchShift(_trackBarPitch);
            }           
        }

My pitch funtion:
Code: [Select]
            _stream = Bass.BASS_StreamCreateFile(_musicFile, 0L, 0L, BASSFlag.BASS_STREAM_DECODE);
            _streamPitch = Bass.BASS_ChannelSetFX(_stream, BASSFXType.BASS_FX_BFX_PITCHSHIFT, 0);

            BASS_BFX_PITCHSHIFT parametros = new BASS_BFX_PITCHSHIFT();
            Bass.BASS_FXGetParameters(_streamPitch, parametros);


            parametros.fPitchShift = _pitchArrayValue;             //this is ZERO
            parametros.fSemitones = _pitch;           //(0 won't change the pitch). Default = 0.)
            Bass.BASS_FXSetParameters(_streamPitch, parametros);

The problem is:
Everytime I make trackbar on ZERO value the funtion wont reset, It makes strange pitch values.
It seams like i got crazy on pitch values.
Please a little help to reset pitch.
Thanks

Ian @ un4seen

  • Administrator
  • Posts: 26015
Re: How to correctly reset my Pitch funtion
« Reply #1 on: 20 Jun '24 - 11:48 »
BASS_FXReset will reset the FX state (eg. clear internal buffers) but not its parameters. If you want to reset the parameters then you should call BASS_FXSetParameters again to do that. Basically remove the "if (_trackBarPitch == 0)" block, it looks like.

Cafony

  • Posts: 26
Re: How to correctly reset my Pitch funtion
« Reply #2 on: 26 Jun '24 - 17:14 »
Thanks alot, I remove the if condition, and works fine.
thanks