I’m playing streams…iis there any callback which executes at the time parameter.
eg. song lengthms is 300000.
callback must write “hello world” when song come to 270000 ms.
Should be useable with mp3 and ogg files.
Yes I know that I can do that via timer…..
- zeljko asked 15 years ago
I’m not aware of a callback that can be set on a timer, but one way to do it
without using a manually programmed timer would be to call FSOUND_Stream_AddSynchPoint
– you would have to work out how many samples 270000 ms equates to
(using sample rate & bit depth)
Then you can set a sync callback by calling FSOUND_Stream_SetSynchCallback
which will be called at the sync point you set
The way to think about it is like this:
Each “sample” contains a number of bits that represent the sample at the
current timeslice – this is bit depth
e.g. CD bitdepth is 16 – uses 16 bits to represent one sample
Frequency is then how many samples per second
e.g. CD frequency is 44100 – that’s 44100 samples per second
so to calculate how many samples in 5 seconds you go
16 * 44100 * 5 = 3 528 000
You can find the sample rate of the sound with FSOUND_Sample_GetDefaults
you pass in pointers to int’s one of which is the default frequency (you can
just pass in NULL for the ones you don’t need)
Not sure how to get bit depth of a sample though – and if you’re using
vbr mp3’s it becomes trickyer
maybe someone else can help here??
Not sure what happens for stereo samples – maybe need to times by two again? – maybe not?
Please login first to submit.