Author Topic: BASS_ChannelSetPosition is failing.  (Read 12821 times)

jakob

  • Posts: 156
BASS_ChannelSetPosition is failing.
« on: 1 Aug '12 - 15:41 »
hi
i'm using BASS_ChannelSetPosition to set the position of my playback stream to the end.
the problem is that it failes with BASS_ERROR_POSITION even though i first calls BASS_ChannelGetLength and set it to that value.
This is what i do:

long length = Bass.BASS_ChannelGetLength(m_Stream,BASSMode.BASS_POS_BYTES);
Bass.BASS_ChannelSetPosition(m_Stream, length, BASSMode.BASS_POS_BYTES);
BASSError error = Bass.BASS_ErrorGetCode();
long pos = Bass.BASS_ChannelGetPosition(m_Stream, BASSMode.BASS_POS_BYTES);

i also try to get the position aftere setting it, and it is not setting it to the length.

there is no problem if i substract one byte from the length, but this, i would rather not do, be cause i'm also using a trackbar to show the position and then this would be incorrect.

can anybody help me with this?

 

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: BASS_ChannelSetPosition is failing.
« Reply #1 on: 1 Aug '12 - 17:35 »
BASS doesn't permit seeking right to the end, so you would need to go just before that, eg. subtract one. To get to the very end, you could then seek again with the BASS_POS_DECODETO flag...

Code: [Select]
BASS_ChannelSetPosition(handle, end-1, BASS_POS_BYTE); // seek to just before then end
BASS_ChannelSetPosition(handle, end, BASS_POS_BYTE|BASS_POS_DECODETO); // decode to the end

jakob

  • Posts: 156
Re: BASS_ChannelSetPosition is failing.
« Reply #2 on: 2 Aug '12 - 07:25 »
hi Ian

thanks for the quick reply.

this line works:
Bass.BASS_ChannelSetPosition(m_Stream, length-1, BASSMode.BASS_POS_BYTES);

unfortunately i get a BASS_ERROR_NOTAVAIL when i run this line, also if i try to set the position in the middle of the stream:
Bass.BASS_ChannelSetPosition(m_Stream, length, BASSMode.BASS_POS_BYTES | BASSMode.BASS_POS_DECODETO);

Do you have some idear as to what im doing wrong?

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: BASS_ChannelSetPosition is failing.
« Reply #3 on: 2 Aug '12 - 16:22 »
Please use BASS_GetVersion to check what BASS.DLL version is being loaded. The BASS_POS_DECODETO flag was introduced in 2.4.7, so it needs to be using at least that (0x02040700). If it is and you still get a BASS_ERROR_NOTAVAIL error, what sort of stream is it that you are playing?

jakob

  • Posts: 156
Re: BASS_ChannelSetPosition is failing.
« Reply #4 on: 3 Aug '12 - 07:27 »
hi Ian

I'm using version 0x02040801

I'm using a Tempo stream, this is the creation of it:

private void InitBassStream()
        {
            if (!string.IsNullOrEmpty(AudioFile))
            {
                m_DecodingStream = Bass.BASS_StreamCreateFile(AudioFile, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN);
                m_ReverseDecodingStream = BassFx.BASS_FX_ReverseCreate(m_DecodingStream, 2, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_STREAM_PRESCAN);
                if (m_ReverseDecodingStream != 0)
                {
                    m_Stream = BassFx.BASS_FX_TempoCreate(m_ReverseDecodingStream, BASSFlag.BASS_FX_FREESOURCE);
                    PositionInSeconds = 0;
                    PlayDirection = AudioPlayDirection.Forward;
                    m_syncProc = new SYNCPROC(PlayBackEndedCallback);
                    m_syncHandle = Bass.BASS_ChannelSetSync(m_Stream, BASSSync.BASS_SYNC_END, 0, m_syncProc, IntPtr.Zero);
                    m_dspProc = new DSPPROC(PlayingCallback);
                    m_dspHandle = Bass.BASS_ChannelSetDSP(m_Stream, m_dspProc, IntPtr.Zero, 0);
                }
            }
        }

Chris

  • Posts: 2217
Re: BASS_ChannelSetPosition is failing.
« Reply #5 on: 3 Aug '12 - 09:55 »
BASS doesn't permit seeking right to the end, so you would need to go just before that, eg. subtract one. To get to the very end, you could then seek again with the BASS_POS_DECODETO flag...

Code: [Select]
BASS_ChannelSetPosition(handle, end-1, BASS_POS_BYTE); // seek to just before then end
BASS_ChannelSetPosition(handle, end, BASS_POS_BYTE|BASS_POS_DECODETO); // decode to the end



Code: [Select]
BASS_ChannelSetPosition(handle, end-1, BASS_POS_BYTE); // will working fine
Code: [Select]
BASS_ChannelSetPosition(handle, end, BASS_POS_BYTE|BASS_POS_DECODETO); // // will working fine

// and Bass will me notice that the File has end and thats correct!!
Chris

« Last Edit: 3 Aug '12 - 12:13 by Chris »

Chris

  • Posts: 2217
Re: BASS_ChannelSetPosition is failing.
« Reply #6 on: 3 Aug '12 - 12:34 »
@ jakob after I have seen your source its a litttle bit more logic why your code will not work.
Code: [Select]
procedure TForm4.Button1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
  begin
    Bass_StreamFree(Chan);
    Chan := Bass_StreamCreateFile(false, PChar(OpenDialog1.FileName), 0, 0,BASS_SAMPLE_FLOAT or BASS_STREAM_PRESCAN or BASS_STREAM_DECODE or BASS_UNICODE);
    Chan := BASS_FX_ReverseCreate(Chan, 2, BASS_STREAM_DECODE or BASS_FX_FREESOURCE);
    Chan := BASS_FX_TempoCreate(Chan, BASS_FX_FREESOURCE);
    BASS_ChannelSetAttribute(BASS_FX_TempoGetSource(Chan), BASS_ATTRIB_REVERSE_DIR, BASS_FX_RVS_FORWARD);
    Bass_ChannelPlay(Chan, false);
  end;
end;


Code: [Select]
procedure TForm4.Button2Click(Sender: TObject);
var
  len: int64;
begin
  len := BASS_ChannelGetLength(Chan, BASS_POS_BYTE);
  BASS_ChannelSetPosition(Chan, len - 1, BASS_POS_BYTE);
  // seek to just before then end
  BASS_ChannelSetPosition(Chan, len, BASS_POS_BYTE or BASS_POS_DECODETO);
  // decode to the end
  ShowMessage(inttostr(Bass_ErrorGetCode()));
end;

will working here fine

If you don`t setting this
 
Code: [Select]
BASS_ChannelSetAttribute(BASS_FX_TempoGetSource(Chan), BASS_ATTRIB_REVERSE_DIR, BASS_FX_RVS_FORWARD);so then of Cource you position call must be
Code: [Select]
BASS_ChannelSetPosition(Chan, 1, BASS_POS_BYTE);  // seek to just before then end
  
Code: [Select]
BASS_ChannelSetPosition(Chan, 0, BASS_POS_BYTE or BASS_POS_DECODETO);
Chris
« Last Edit: 3 Aug '12 - 12:39 by Chris »

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: BASS_ChannelSetPosition is failing.
« Reply #7 on: 3 Aug '12 - 15:14 »
I'm using a Tempo stream

OK. I don't think tempo (or reverse) streams currently support the DECODETO flag, so that would explain it. I'll check with Arthur and see if we can do something about that.

jphilippe

  • Posts: 7
Re: BASS_ChannelSetPosition is failing.
« Reply #8 on: 21 May '13 - 01:46 »
Hi Ian,

Has this problem been sovled? i.e. DECODETO flags on tempo streams?

jakob

  • Posts: 156
Re: BASS_ChannelSetPosition is failing.
« Reply #9 on: 21 May '13 - 08:19 »
hi all
yes this has been solved, thank you for all the help