In my earlier post, I asked how would one know when a sound is being played at X(milliseconds) for a MOD file. After some digging I realize that I simply can’t use the FMOD APIs for this and I would have to go down another software level.
In order to determine this, I would have to do something similar to what this function does:
signed char FMUSIC_LoadMOD(FMUSIC_MODULE *mod, FSOUND_FILE_HANDLE *fp)
I would have to create a vector of objects that store the sounds and ms for each of the 4 tracks thus giving me a list of when things are ‘played’. I am not sure if the file format contains this information though, but FMOD has to figure it out I assume. I think FMOD creates a sample buffer within the FMUSIC_LoadMod function for the entire file and doesn’t store the raw data in the file which is what I am trying to extract.
I have some other FMOD questions though.
I am not sure whether I can do this with the API or if I would have to modify FMOD a little bit, but I am trying to make it so that when the user presses the UP ARROW, that my application plays a ‘sound’ where the sound is any of the sounds extracted from the MOD file (as described above).
I know how to play a sound file quite easily, but I am not sure how to get FMOD to play a ‘single sound’ that is within a MOD file on a given track.
I am able to get an entire track using the APIs but that doesn’t do me much good I think.
Any suggestions are greatly welcomed and I thank you in advance.
- Mousey asked 14 years ago
There are many factors that will affect the duration of a note.
– The note value. A high note has a shorter duration than a low note (simple frequency change when playing the sample).
– Looping sample. Potentially infinite, or at the least indeterminate, duration.
– A new note played on the same channel before the current note has finished. This will result in a shorter note duration.
You really want a lot more than FMOD will ever provide in music playback. FMOD exists in the present, not in the future.
You will not be able to determine which channel the instrument is playing on via the instrument callback. You will just know that the instrument has been played on a channel.
Brett, I checked out GetSample and that was a very useful function
Is there a way to specify what note to play that sample at?
I noticed that FSOUND_PlaySound only takes a pointer to the sample, but returns a channel handle.
I assume you do take that returned channel and pass the note to the channel??
FMOD does indeed store the patterns, order and samples when it loads a MOD. This is how it knows what value to return when you ask for the current pattern, order or row. FMOD does not give you access to the information for each channel in each row though.
You can get the samples in a MOD file. Take a look at FMUSIC_GetSample(). This returns a handle to the sample. Pass that handle to FSOUND_PlaySound() to play that sound when you want.
Interesting, that is definately a good start!!
If I understand this: The order of FMUSIC_GetSample() gives a good indication of which order the samples will be played in but not necessarily when they will be played and for how long which was my final hopes 😀 If two instruments use the same sample, would the same pointer be returned by GetSample?
I am looking into fmod now to see if the row information is stored at all so that I can return row information with getsample in hopes that I could get this info. I am assume there isn’t a cheap work around, because as you have said, no row information is returned with GetSample(). 😉 Is there a way to scan the patterns?
When you say channel, do you refer to the tracks? There are 4 tracks in a mod file and each one can be played on different channels. Where each track can have any number of samples.
I’ve never heard of them called tracks before. They have always been channels to me, eg. a 4-channel MOD or a 16-channel XM, even back in the old Soundtracker days on the Amiga.
Take a look in the help file at the FMUSIC functions. That is all the information you have access to. There is no function to get any row information other than the row number.
If two instruments use the same sample, then yes, you will most likely get the same pointer.
As an alternative, take a look at MiniFMOD. That is a cut-down music player that comes with source code. You could try using that.
I figured as much, but there has to be ways to know when a note will be played and for how long on all 4 channels in the mod file…. I really want to avoid parsing the mod file itself but looks like there may not be any other way.
Another possibility was that I could play the mod file on a seperate channel with no volume 10 seconds before playing the same mod file on another channel but with volume. I could get the callback to whenever an Instrument plays and figure out the length that way, but I am not sure if I could determine which channel it is playing on.
Please login first to submit.