Can someone help me?
I need to know what do they mean when it says :
Pointer to the song to set channel/volume optimization settings.
How do you program a pointer to a song????
Is it in TYPE
Do you do something like this :
aaaa = ^song;
Please Help me!!!!!!!!!!!!!
- Anonymous asked 14 years ago
Your doing the same thing with the repeat statement, assigning playing to true until the songs is finished then making it false.
I use a timer, and I look for the Position to equal the count of either frames or time depending on the type of song being played, stream or music module.
Either way, you’ll need some kind of routine to check and see if the end has been reached.
Do you know how to use FSound_SetEndCallback;
I managed to do my plylist with the timer, but i would like to know if it is possible to do it with FSound_SetEndCallback;
In fact, i’m not sure that i really understand what is this function or how you use it;
If Someone could help me….
I have never used this callback, although I have used callbacks. The only thing I can recommend is that you play around with any sample code you can get.
If you want to see my code for a callback to get waveform data to create an oscilloscope, you can download it here :
This is a CPU intensive example since it graphs 512 values every 25ms but you will be able to see what I have done. I do believe I commented everything that was relevant.
So there it is, you should be able to get an idea of how to use callbacks. One note though, my callback gets called with every update of the buffer, SetEndCallback will only be called once, at the end of a song.
Hope this helps.
The types are already declared in fmod.pas. Declare a variable of the required type, use it to store the value returned by the various Open functions, and pass it in to the various functions that require a pointer to the song. Take a look at the samples for an example of how it is done.
Use a StringList. I use one for my player, and you could easily read from a text file that has the paths to the songs or samples or whatever you want to play. I would recommend using a Quoted String though. If you try to load a file with an apostrophe in it you could get into trouble.
Take an MP3 located and named as such :
C:MP3Some Silly Lil’ Song.mp3
As a Quoted Str (QuotedStr(String) is the function) would be :
‘C:MP3Some Silly Lil”’ Song.mp3′
And when you load it, use AnsiDeQuotedStr(String,Char); or:
AnsiDeQuotedStr(‘C:MP3Some Silly Lil”’ Song.mp3′,#39);
39 is the ASCII for the Apostrophe. Using this eliminates most file not found and related errors.
Hmm… Kinda went on a tangent there… Use a StringList though, very easy just remember to Create and Free it where needed.
Also, you shouldn’t need to use Callbacks to find the end of a song, use FSOUND_IsPlaying or FMusic_IsPlaying. They return boolean TRUE if a song is playing.
Hope this helps.
Thank you but here is what i used for my playlist, it is working when i run it alone , but while running a game at the same time, it occurs an error because of this call:
PlayList[i+2].play := true;
until FSound-IsPlaying(i)= false);
procedure SoundMusicPlay(i: integer); // always put i to 0
PlayList[i+2].jouer := true;
until (FSound_IsPlaying(i)= false);
if (Fsound_IsPlaying(i) = false) and (PlayList[i+2].jouer = true) then
function SoundMusicQueue(filename: PChar): boolean;
i := 1;
while (Playlist[i].titre <> ”) or (PlayList[i].jouer = true) do
i := i + 1;
if (PlayList[i].titre = ”) then
PlayList[i].titre := filename;
result := true;
function SoundLoadSound(filename: PCHAR): boolean;
stream := FSOUND_Stream_OpenFile(filename,FSOUND_NORMAL, 0);
if stream = nil then
And the problem is that when i’m running the game with SoundMusicPlay(0), It stops because of the repeat-until so i have to find another way to program this and to make my playlist.
Please give me some new advices
Think of a computer stream like an actual water stream, or river. Information flows from one point to another, but not all at once.
A computer stream flows from one location to another. When ever you download a file your are using a type of stream. If you listen to any kind of online music that is a stream.
As far as FMOD goes (And I hope I’m not wrong on this) when you open a file (MP3 say) you are setting the start and end points, but not reading all the data yet. Once you start to play the song, a stream of data relating to that songs passes through FMOD and then into the soundcard.
I none stream would be like a document, where you load the entire file into memory.
Hope this helps.
here are the others procedures and functions:
MAX = 15;
TSon = record
PSmallInt = ^SmallInt;
PlayList: array [1..Max] of Tson;
function SoundPlaySound(filename: PChar;chann: integer): boolean;
FSOUND_SetPaused(chann , False);
channel := FSOUND_Stream_Play(chann,FSOUND_Stream_OpenFile(filename,FSOUND_NORMAL, 0));
if channel < 0 then
To answer the oher part of your question :
You would stream a song or any file when you only need a samll amount of the data immediatley. There is no sense in loading a HUGE file into memory when at any one time you are only using a small amount of the entire thing. So we stream it.
Keep in mind that the term “Stream” changes in context each time it is used to describe something. In FMOD it is a true stream, in Delphi me have FileStreams, MemoryStreams, BlobStreams, etc. Each of which is a stream but in a different context.
when i run it , ido something like this
Sound_Init; // i already have the procedure.
this works alone but not in a game because of the repeat-until in SoundMusicPlay
Tahnk you so much.
I have a lot of questions like this, like what is a buffer, how do you use it, what is a callback and how you use it.
Could someone give me a real procedure or function in Delphi that loads a song, sterams it and plays it????
That would be so nice. Thank you in advance
Here you go:
Buffer – A buffer is a segment of active memory used to hold information (data), in the case of FMOD, the buffer is sort of variable that can be accessed by your program. The buffer for FMOD holds the actual data that makes up a song or sound. I believe it is an array of floating point numbers from -32767 to +32768, making it 16 Bit (65535 numbers). From this buffer, you can create a callback to analyse or “sample” the buffer. The buffer is a stream and is ever changing.
Callback – A callback is a routine you add into your program to “sample” or grab the buffer. From here you can do some manipulation on the buffer and then send it ons its way back toward the soundcard. You HAVE to return the buffer to the chain for everything to work. I recently (month or two ago) did up my first callback with FMOD in the form of an oscilloscope of the waveforem data. Check the other messages to find it. Its for Delphi. In it’s truest sense, I liken a callback to a small program that the FMOD dll runs along with its own functions. However you write the program for FMOD to run. Very cool stuff!
As for your last question, when you downloaded the FMOD zip you also received some sample source code, the TestBed is an excellent example of using FMOD. I based my first work on the TestBed and it taught me alot. Also, absorb every particle of information you can find through the API documentation, I have it open whenever I’m coding with FMOD.
So there you go.
For myself, I try to stay away from Repeat statements. I try my best to avoid a possible unterminating loop.
I would recommend using a timer and for the event set somethis like this :
If FSound_IsPlaying(i)= True then
PlayList[i+2].play := true
PlayList[i+2].play := False;
// Do code here needed to account for the end of a sound
PlayList[i+2].play := true;
there. By using the timer, you are letting other functions work as well since it should be on its own thread.
I’m guessing this is what is going on, that the game won’t work because it is not given then chance to do its own code. Let me stress that fact “I’m Guessing!” since I can’t see exactly what you are doing.
I can’t see trying to set a boolean to true in a repeat statement causing an error, but I suppose it is possible.
Hope this helps.
Please login first to submit.