21 May '13 - 04:43 *
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: make a stream loop  (Read 440 times)
tom
Posts: 3


« on: 8 Sep '12 - 11:54 »
Reply with quoteQuote

Hello,

I'm new to BASS and I want to make a 4 channel stream with custom samples (sine waves) in an automatic loop.
I've tried using BASS_ChannelFlags(stream, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP) but this doesn't set the BASS_SAMPLE_LOOP flag.

Code (VB6.0):

BASS_Init(-1, 24000, 0, FrmMain.Hwnd, 0)
stream = BASS_StreamCreate(24000, 4, 0, STREAMPROC_PUSH, 0)

'code to generate all samples stored in WaveData() array goes here

BASS_ChannelFlags(stream, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP)  'DOES NOT WORK (returns 0x20) BASS_SAMPLE_LOOP is not set ???
BASS_StreamPutData(stream, WaveData(0), DataLength)
BASS_StreamPutData(stream, Null, BASS_STREAMPROC_END)

sync_end = BASS_ChannelSetSync(stream, BASS_SYNC_END, 0, AddressOf SyncEndTest, 0) 'works
sync = BASS_ChannelSetSync(stream, BASS_SYNC_POS, 24000 * 4 * 2, AddressOf SyncTest, 0) 'DOES NOT WORK SyncTest is not called after 1 sec. (does not return 0 in the sync variable  ???).
BASS_ChannelPlay(stream, BASSFALSE) 'plays the sound only once

Does anyone know how to make it play in a loop?
Also like to receive updates of the current sample that is played (every +/-100ms) using the BASS_ChannelSetSync().
Logged
Ian @ un4seen
Administrator
Posts: 15253


« Reply #1 on: 10 Sep '12 - 15:09 »
Reply with quoteQuote

BASS doesn't retain a copy of a custom stream's sample data, so it can't be looped automatically via the BASS_SAMPLE_LOOP flag. If you want to loop the data, you need to feed it to the stream again. Another option is to place a WAVE header in front of the sample data and then pass it to BASS_StreamCreateFile (with mem=TRUE). You would then be able to use the BASS_SAMPLE_LOOP flag to loop it. Examples of generating WAVE headers can be found in the RECTEST and WRITEWAV examples in the BASS package.
Logged
tom
Posts: 3


« Reply #2 on: 10 Sep '12 - 18:48 »
Reply with quoteQuote

OK Thanks al lot I will try this tomorrow.

Another question:
-When I feed the data back into the stream in an "endless loop". Then (if I'm correct) the BASS_ChannelGetPosition(handle, BASS_POS_BYTE) will keep increasing. What will happen after a few hours will it just overflow to -2147483648 and go back to -1 and then start from 0 again? (function returns a Long in vb6.0).

-In case of using the BASS_StreamCreateFile and wave header: Will it accept wave files with 4 channels using the WAVEFORMATEXTENSIBLE header? (Maybe someone has an example on this  Grin)?
Logged
tom
Posts: 3


« Reply #3 on: 11 Sep '12 - 17:37 »
Reply with quoteQuote

I've used the BASS_StreamCreateFile() and the WAVEFORMATEXTENSIBLE everything is working now as it should be  Cool

Thanks for the help
Logged
Ian @ un4seen
Administrator
Posts: 15253


« Reply #4 on: 11 Sep '12 - 18:10 »
Reply with quoteQuote

Jolly good. Just to confirm, what you said above regarding the reported position in VB6 is correct. BASS_ChannelGetPosition returns a 64-bit value, but unfortunately VB6 doesn't support 64-bit integers, so you will only see the low 32 bits of it, and I don't think VB6 supports unsigned integers either, so the value will indeed go from 0 to 2147483647 and then -2147483648 to -1.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines