PDA

View Full Version : VERY stupid Question: SoundEngine



Mrwb
10-11-2003, 07:50 PM
Very stupid question (like always.. sorry for beeing a complete newb ;))

How on earth do you use the callback thingy on the TGLXSoundEngine??
I never did understand that stuff... :/ :oops: It would really make my day if someone could give me an example.

Thanks. :)

Andreaz
11-11-2003, 10:57 AM
No problems, questions is always welcome :D , none is stupid.

First, from the FMOD Documentation, applies to TGLXStreamItem aswell:


All you have to do is drop 'markers' into a wav editing program like SoundForge, and FMOD will automatically generate callbacks as the stream plays when the play cursor runs over the markers!.
The strings that you label markers with are even passed into the callback.
Note that only WAV files and MP3 with RIFF wrappers will work here. The markers are saved in a RIFF chunk.

Remember FMOD is a real-time system and the amount of time spent in a callback has to be low, or you could cause buffer underrun or stuttering.


Then just assign the OnCallback event, load and play the file and it should do the trick.

It's also possible to add sync points manually, hoverver GLX hasn't that implemented so you'll have to add them your self.


If you don't have this luxury or want to use a format that doesn't support this feature, then the next best way to synchronize a stream is by using custom synch points. This way you can add and remove your own points that wav markers would normally generate. See FSOUND_Stream_AddSynchPoint.
Add your markers manually with this and set your synch point callback with FSOUND_Stream_SetSynchCallback
Your callback could then look something like this but you can put what you like in the callback function.


If you want's more info on fmod, you can download the documentation etc at www.fmod.org

Mrwb
11-11-2003, 07:34 PM
Thanks Andreaz :) I've played around with FMod earlier to create some synch stuff, and I made a program that read the markers etc. but I don't know how to write the callback, were to put my code etc. I have some code I would like to have executet everytime a synch point is reached, but I really don't know how. :S

So.. yet another question... how do you assign code to the callback event? :oops:

Andreaz
11-11-2003, 07:59 PM
The onCallback in TGLXSound item is just an normal event, here is how it works.

Procedure TForm1.StreamCallback(Stream: TGLXStreamItem; Name: String);
begin
// Do something here
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
GLXSoundEngine1.Streams[0].OnCallback:=StreamCallback;
end;

Mrwb
12-11-2003, 12:06 AM
Brilliant! :D Thanks again! :) I actually tried somthing like that a while ago, but couldn't get it to work.. Hmm.. I think it's about time I advance my delphi skills a bit... ;)

Andreaz
12-11-2003, 09:14 AM
No probs, hope you'll get it working :wink:

Mrwb
12-11-2003, 03:20 PM
Just wanted to say that it works just fine now :) thanks again! :D