22 May '13 - 22:06 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: problem gettign position first and last time during playback  (Read 556 times)
jakob
Posts: 69


« on: 2 Aug '12 - 10:42 »
Reply with quoteQuote

Hi

i have a callback setup:
m_dspProc = new DSPPROC(PlayingCallback);
m_dspHandle = Bass.BASS_ChannelSetDSP(m_Stream, m_dspProc, IntPtr.Zero, 0);

i'm calling BASS_ChannelGetPosition from the callback proc during playback to update a progressbar:
long tempopos = Bass.BASS_ChannelGetPosition(m_Stream, BASSMode.BASS_POS_BYTES);

The problem that im seeing is that the first time the calback i invoked the position read is wrong. The second time it is invoked it is right
The problem also exist in the end of the playback, it jumps.

Is there any suggestions on what might be the problem?

below is a playback sample of a the hole sound file showing positions read:

SET tempoPOS: 0(setting the position to beginning before starting playback)
GET decodePOS: 0 reversedecodePOS: 0 tempoPOS: 0(reading it before starting playback)
GET decodePOS: 0 reversedecodePOS: 0 tempoPOS: 0(reading it before starting playback)
GET decodePOS: 0 reversedecodePOS: 0 tempoPOS: 0(reading it before starting playback)
GET decodePOS: 32768 reversedecodePOS: 32768 tempoPOS: 25724 First call after starting playback (first callback invoke)
GET decodePOS: 65536 reversedecodePOS: 65536 tempoPOS: 0
GET decodePOS: 65536 reversedecodePOS: 65536 tempoPOS: 1308
GET decodePOS: 65536 reversedecodePOS: 65536 tempoPOS: 1448
GET decodePOS: 81920 reversedecodePOS: 81920 tempoPOS: 14252
GET decodePOS: 98304 reversedecodePOS: 98304 tempoPOS: 27052
GET decodePOS: 114688 reversedecodePOS: 114688 tempoPOS: 39844
GET decodePOS: 131072 reversedecodePOS: 131072 tempoPOS: 52636
GET decodePOS: 131072 reversedecodePOS: 131072 tempoPOS: 65412
GET decodePOS: 131072 reversedecodePOS: 131072 tempoPOS: 65508
GET decodePOS: 147456 reversedecodePOS: 147456 tempoPOS: 78240
GET decodePOS: 163840 reversedecodePOS: 163840 tempoPOS: 91044
GET decodePOS: 180224 reversedecodePOS: 180224 tempoPOS: 103844
GET decodePOS: 196608 reversedecodePOS: 196608 tempoPOS: 116644
GET decodePOS: 196608 reversedecodePOS: 196608 tempoPOS: 129428
GET decodePOS: 196608 reversedecodePOS: 196608 tempoPOS: 129596
GET decodePOS: 212992 reversedecodePOS: 212992 tempoPOS: 142244
GET decodePOS: 229376 reversedecodePOS: 229376 tempoPOS: 155052
GET decodePOS: 245760 reversedecodePOS: 245760 tempoPOS: 167848
GET decodePOS: 245760 reversedecodePOS: 245760 tempoPOS: 180620
GET decodePOS: 262144 reversedecodePOS: 262144 tempoPOS: 193568
GET decodePOS: 262144 reversedecodePOS: 262144 tempoPOS: 193676
GET decodePOS: 268800 reversedecodePOS: 268800 tempoPOS: 206240
GET decodePOS: 268800 reversedecodePOS: 268800 tempoPOS: 268800
Logged
Ian @ un4seen
Administrator
Posts: 15269


« Reply #1 on: 2 Aug '12 - 16:24 »
Reply with quoteQuote

That looks like you have decoder/tempo/reverse streams? If so, please post the code that you are using the set them up and the code to get their positions, to confirm how you are doing that stuff.
Logged
jakob
Posts: 69


« Reply #2 on: 3 Aug '12 - 07:22 »
Reply with quoteQuote

hi Ian

this i this is how i setup the streams:

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);
                }
            }
        }

this is how i read the position:

public long PositionInBytes
        {
            get
            {
                if (m_Stream != 0)
                {
                    long decodepos = Bass.BASS_ChannelGetPosition(m_DecodingStream, BASSMode.BASS_POS_BYTES);
                    long reversedecodepos = Bass.BASS_ChannelGetPosition(m_ReverseDecodingStream, BASSMode.BASS_POS_BYTES);
                    long tempopos = Bass.BASS_ChannelGetPosition(m_Stream, BASSMode.BASS_POS_BYTES);
                    System.Diagnostics.Debug.WriteLine("GET decodePOS: " + decodepos + " reversedecodePOS: " + reversedecodepos + " tempoPOS: " + tempopos);
                    return tempopos;
                }
                return 0;
            }
       }

hope it helps.
Logged
Ian @ un4seen
Administrator
Posts: 15269


« Reply #3 on: 3 Aug '12 - 17:02 »
Reply with quoteQuote

Please confirm when that "PositionInBytes" code is called. I guess it's in the "PlayingCallback" DSP function, so I tried logging the positions in a DSP function myself but it seemed to be fine, ie. the position never jumped forward and back again. If that is what you're doing, please confirm what (if any) CONFIG settings you're making, and whether changing them makes a difference. Also, when are you setting the reverse stream's direction (BASS_ATTRIB_REVERSE_DIR) to forward?

Also confirm that you are using the latest BASS.DLL and BASS_FX.DLL versions (via BASS_GetVersion and BASS_FX_GetVersion).
Logged
jakob
Posts: 69


« Reply #4 on: 6 Aug '12 - 08:42 »
Reply with quoteQuote

hi Ian

you are right, PositionInBytes is called from a DSP callback function.

the versions i'm using are:
BassFx.BASS_FX_GetVersion();
0x02040701
Bass.BASS_GetVersion();
0x02040801

I'm not sure what you mean by config settings. is it the flags that i create the streams with?

This is how i setup the streams, and also set the playback direction:

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);
                }
            }
        }

Logged
jakob
Posts: 69


« Reply #5 on: 6 Aug '12 - 09:37 »
Reply with quoteQuote

hi Ian

as an extra note to my latest reply just above, i may not have mensioned that it actually stops playback when it jumps
i can also say that when i play the file in windows media player, it also also stops playback before it hits the end, same as what i see in my player.
Logged
Ian @ un4seen
Administrator
Posts: 15269


« Reply #6 on: 6 Aug '12 - 12:54 »
Reply with quoteQuote

I'm not sure what you mean by config settings.

I meant any settings applied via BASS_SetConfig, eg. BASS_CONFIG_BUFFER to set the buffer length.

as an extra note to my latest reply just above, i may not have mensioned that it actually stops playback when it jumps
i can also say that when i play the file in windows media player, it also also stops playback before it hits the end, same as what i see in my player.

Is the problem only happening with a particular file then, not all files? If so, please upload that file to have a look at here...

   ftp.un4seen.com/incoming/
Logged
jakob
Posts: 69


« Reply #7 on: 6 Aug '12 - 14:06 »
Reply with quoteQuote

hi Ian

i don't use Config.

it happens to all recordings, when i play them. i've uploaded an example file "example1.wav".
Logged
jakob
Posts: 69


« Reply #8 on: 9 Aug '12 - 08:41 »
Reply with quoteQuote

hi Ian

i tried setting the BASS_CONFIG_BUFFER=100 and BASS_CONFIG_UPDATEPERIOD=10. This solved the problem.

thanks for the help
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines