Author Topic: Tempo issue when replaying song  (Read 109 times)

kafffee

  • Posts: 296
Tempo issue when replaying song
« on: 24 Jan '25 - 05:49 »
Hey everybody :-)

I have an issue with BASS_ATTRIB_TEMPO when I start playback of the same song repeatedly. I get ErrorCode 0 on the call, but the music will only be playing with normal speed, as if I set BASS_ATTRIB_TEMPO to 0. The value seems to be valid. So when I play the song, then set the tempo, and then call PlayBeat_Execute again, the song plays as if Tempo was 0.

When I change the value while the song is playing, it works all fine...

Here is my code:

Code: [Select]
Private _Tempo As Single
Public Property Tempo As Single
    Get
        Return _Tempo
    End Get
    Set(value As Single)
        _Tempo = CSng(Math.Round(value, 0))   'round to 0 decimal places
        Bass.BASS_ChannelSetAttribute(streamfx, BASSAttribute.BASS_ATTRIB_TEMPO, _Tempo)
        RaisePropertyChanged()
    End Set
End Property

  Private Sub PlayBeat_Execute(obj As Object)

      Bass.BASS_ChannelStop(streamfx)
      Bass.BASS_StreamFree(streamfx)
      Bass.BASS_StreamFree(stream)

      WF = New WaveForm(SelektierterBeat.DateiName, New Un4seen.Bass.Misc.WAVEFORMPROC(AddressOf MeineWaveFormCallback), Nothing)

      InitialisiereWF()  'initialize waveform
      WF.RenderStart(True, Nothing)

      stream = Bass.BASS_StreamCreateFile(SelectedBeat.FileName, 0, 0, BASSFlag.BASS_SAMPLE_LOOP Or BASSFlag.BASS_STREAM_DECODE)
      streamfx = BassFx.BASS_FX_TempoCreate(stream, Nothing)

      Bass.BASS_ChannelSetAttribute(streamfx, BASSAttribute.BASS_ATTRIB_TEMPO, Tempo)
      MessageBox.Show("Tempo: " & Tempo.ToString & " " & Bass.BASS_ErrorGetCode.ToString)
      Bass.BASS_ChannelSetAttribute(streamfx, BASSAttribute.BASS_ATTRIB_VOL, Volume)
      Bass.BASS_ChannelPlay(streamfx, True)

End Sub

Issue #2:

The song does not automatically replay when I call Bass.BASS_ChannelPlay(streamfx, True). Will I just have to use the SYNCTRACKEND callback to do so?

Ian @ un4seen

  • Administrator
  • Posts: 26264
Re: Tempo issue when replaying song
« Reply #1 on: 24 Jan '25 - 14:57 »
I have an issue with BASS_ATTRIB_TEMPO when I start playback of the same song repeatedly. I get ErrorCode 0 on the call, but the music will only be playing with normal speed, as if I set BASS_ATTRIB_TEMPO to 0. The value seems to be valid. So when I play the song, then set the tempo, and then call PlayBeat_Execute again, the song plays as if Tempo was 0.

When I change the value while the song is playing, it works all fine...

To narrow down where the problem is, please check/log the BASS_ATTRIB_TEMPO value (with BASS_ChannelGetAttribute), immediately after setting it (with BASS_ChannelSetAttribute) and when it sounds wrong during playback. Also log the "streamfx" value with it to see if/when that's changing.

The song does not automatically replay when I call Bass.BASS_ChannelPlay(streamfx, True). Will I just have to use the SYNCTRACKEND callback to do so?

Do you mean it doesn't go back to the start of the stream when you call BASS_ChannelPlay with restart=true? It should do, so long as the stream is seekable. What is the return value and error code from the BASS_ChannelPlay call?

Please also confirm what BASS_FX version you're using, ie. what BASS_FX_GetVersion returns. If you haven't already, you could try this latest build:

   www.un4seen.com/stuff/bass_fx.zip

kafffee

  • Posts: 296
Re: Tempo issue when replaying song
« Reply #2 on: 25 Jan '25 - 06:26 »
Quote
To narrow down where the problem is, please check/log the BASS_ATTRIB_TEMPO value (with BASS_ChannelGetAttribute), immediately after setting it (with BASS_ChannelSetAttribute) and when it sounds wrong during playback. Also log the "streamfx" value with it to see if/when that's changing.

Ah I found the mistake in my XAML code. I had the minimum value for the slider that controls the tempo set to -100. Of course then I get an error, because it's out of range... sry for that :-)

Edit: Please never mind the following. As I need to resume playback at another position in my code, I cannot use ChannelPlay with restart = true anyways. I am tying to handle that with the SYNCTRACKEND callback function and get back to you if there are any other issues...

________________________________________________________________________________________________________

Quote
Do you mean it doesn't go back to the start of the stream when you call BASS_ChannelPlay with restart=true?

Yes exactly...


Quote
It should do, so long as the stream is seekable. What is the return value and error code from the BASS_ChannelPlay call?
It returns error code BASS_OK. What do you mean by "seekable"? It's an mp3 file that I am playing...


Quote
Please also confirm what BASS_FX version you're using, ie. what BASS_FX_GetVersion returns.

I am using version 33819654 / 2.4.12.6. Is the one in the BASS/add-ons tab of your website not the most recent, i.e. the link you posted is an even newer version?
« Last Edit: 25 Jan '25 - 09:29 by kafffee »

Ian @ un4seen

  • Administrator
  • Posts: 26264
Re: Tempo issue when replaying song
« Reply #3 on: 27 Jan '25 - 15:41 »
Quote
It should do, so long as the stream is seekable. What is the return value and error code from the BASS_ChannelPlay call?
It returns error code BASS_OK. What do you mean by "seekable"? It's an mp3 file that I am playing...

By "seekable", I mean it's possible to jump to different positions using BASS_ChannelSetPosition. A stream created with BASS_StreamCreateFile will usually be seekable, while a stream created with BASS_StreamCreate won't be.

I am using version 33819654 / 2.4.12.6. Is the one in the BASS/add-ons tab of your website not the most recent, i.e. the link you posted is an even newer version?

Yes, the BASS_FX version linked above is newer than the one on the BASS webpage. The files in the "stuff" path are the latest available builds, newer than the release versions. They can be considered beta versions.

kafffee

  • Posts: 296
Re: Tempo issue when replaying song
« Reply #4 on: 4 Feb '25 - 09:07 »
Quote
Yes, the BASS_FX version linked above is newer than the one on the BASS webpage. The files in the "stuff" path are the latest available builds, newer than the release versions. They can be considered beta versions.

Ah okay, that's good to know...