Some questions on sound

BlitzMax Forums/BlitzMax Programming/Some questions on sound

ziggy(Posted 2007) [#1]
Hi, I wonder if anybody can lend a hand on this particual issue.

I need a quick way to start a sound playing from an speccific offset of millisecs() (I mean, not at the start of the sample, but in a given offset). I supose there will be a sort of playing stream in the BlitzMax internal audio engine. I would need a function to make this stream 'jump' to a speciffic location, expressed on millisecs. I don't want to install any third party library such as OpenAL, as this is something I need for a module I'm writting.

I also need a function to get the lenght of a speciffic sound in millisecs (independent from the file size, as BlitzMax can support several sound formats).

Any help on this issue will be much appreciated.

:D


ziggy(Posted 2007) [#2]
No one can lend a hand?


GfK(Posted 2007) [#3]
To be honest, without 3rd party libraries I think you're stuck.


ziggy(Posted 2007) [#4]
mmm, is it possible to statically link the OpenAL library?


Vertex(Posted 2007) [#5]
I think its possible to link OpenAL static but you have to puplish your application under the terms of LGPL:
http://en.wikipedia.org/wiki/OpenAL
http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License

You can set the offset on OpenAL sources(^= channels) by using alSourcef with the parameter AL_SEC_OFFSET(in seconds) or AL_SAMPLE_OFFSET(in samples)

cu olli


Yan(Posted 2007) [#6]
I haven't really touched the sound system too much yet, but I think you could probably do this with some pointer shenanigans?

I'll have a play later and post any results.


ziggy(Posted 2007) [#7]
Yes, I think this also, but I don't think I can have access to this pointer...


Yan(Posted 2007) [#8]
This seems to work...

...You may want to check for leaks as the sound system seems to be a law unto itself when it comes to memory management. ;o)


ziggy(Posted 2007) [#9]
Thanks Yan. I can't test right now, but I will give it a try as soon as possible.

Are the sound samples free when no longer referenced and no longer being played?


Yan(Posted 2007) [#10]
They should be.

I know that channels can misbehave at times, so I was just being cautious. :o)


xMicky(Posted 2007) [#11]
Couldn't you start the sound with volume =0, let it play offset-many seconds, pause it - and resume it with volume >0, if the moment has come to use it in the scene ?


degac(Posted 2007) [#12]
Thanks! Very useful!

@xMicky: your solutions should work, but you are wasting cpu time doing something not useful like playing a sample at 0 volume


ziggy(Posted 2007) [#13]
@xMicky: No I can't do that. I'm working in a flash-like movie generator module that syncs timeline based bitmap animations with sound, and I can't pause the movie for some seconds just to get audio and images syncronized. All the drawings and interpolation are being done in in a delta-time based style, very precise, so I think I would only need to make 'jumps' on the audio when there's a jump on the timeline.


Winni(Posted 2007) [#14]
Use multiple audio chunks that start at certain keyframes instead of one long audio sample. Just a thought.


ziggy(Posted 2007) [#15]
Well, it is a good idea, but this module will come with a editor, where people will create their own movies and the movies will be loadable from inside games or apps. I really would like the module to not modify the media used by the module users. So, to say, if the game has background music. I would like the same TAudio object, to be usable in the animation. To avoid having a big file, and then the same big file splitted down in pieces. Not to mention all the possible sound glitches when 'pasting' parts at runtime. The engine has an adaptative FPS system that mantains animation speed, but entering sound at a speciffic point can have +/- 1 frame of time latency.