Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: Clyde on September 02, 2008
-
Hi all,
I've read from a few posts that syncing with UFmod is easy; I have used Bass in the past to sync effects with, and really would like to utilize UFmod; mostly as it's smaller. I have seen the few replies in the other UFmod topic.
How ever I am very stuck with this; and I'd love some help on achieving syncing with UFmod. And I have a small list of questions.
A/ Is it possible to sync to certain instruments / samples?
B/ Is getting Volume changes the only way of syncing?
C/ Can you get hold of the individual samples volumes for vu type effects, or is limited to just 2 over all volumes ( Left And Right ? )
Cheers and many thanks in advance,
Clyde.
-
I haven't got any clue about FreeBasic nor uFMOD, but i exactly needed what you're asking for do sync this (http://dbfinteractive.com/forum/index.php?topic=3387.0).
If you want to have a look at miniFMOD (http://www.fmod.org/files/minifmod170.zip), it's pretty easy to look up all this information (note, sample-number, volume, effect+parameter of every channel) for the currently playing order/row (see FMUSIC_MODULE::pattern in music.h).
-
@Clyde:
Yeah. I also used fmod as sound engine for syncing. See my entry
for the scroll competition here:
http://dbfinteractive.com/forum/index.php?topic=1377.0 (http://dbfinteractive.com/forum/index.php?topic=1377.0)
If you need the source - I will try to find it. Guess its on my old PC -
but I could search for it. I think I sync'd it to a certain sample.
-
Thanks dudes - Will take a look. :)
btw- Benny, is it UFMod? reason being I dont want to have any external files / dlls.
I wonder if the answers to my first topic starter are mostly no you cant do that. If it would be possible to implement them into UFMod?
Cheers,
Clyde.
-
@Clyde:
Sorry dude. I used that normal external dll in that production.
Don't know about UFMod and syncing. But I remember that I
looked at several sound engines and had the same problem like
you - that most of them which supports syncing came as
external DLLs.
But that was some years ago ...
Hmm .. but maybe its worth having a look at miniFmod which
Hellfire suggested. This lib sounds like it can be statically linked.
-
I had a quick look at uFMOD and it basically looks like miniFMOD just that everything is written in assembly (and thus turns out a kilobyte smaller).
When I'm back home from work I will have a look at how to read the currently playing pattern-data. Should be pretty much the same though.
Is getting Volume changes the only way of syncing?
Another method is to put an unused effect+parameter into the tune which define certain "actions".
-
Cheers Hellfire dude.
-
uFMOD handles all its' memory internally, so you are not able to access the pattern-data without making changes to the library.
If you can afford to have a few additional kilobytes of code-size, it's far easier to use miniFMOD instead.
The following example is C-code but I guess it should be easy to convert; I also assume you know a bit about how .mod-files work:
FMUSIC_LoadSong loads a song and returns a structure that contains everything you might be interessted in:
FMUSIC_MODULE *mod= FMUSIC_LoadSong();(look at Music.h for a detailed description of FMUSIC_MODULE)
Get the currently playing row:
int row= FMUSIC_GetRow(mod);
Now get the currently playing order (an index into a list that defines the order of the patterns).
int order= FMUSIC_GetOrder(mod);
You can now fetch the playing pattern-number from the order-list (stored in FMUSIC_MODULE):
int patnum= mod->orderlist[order];
Now get the actual pattern from the pattern-list (also in FMUSIC_MODULE):
FMUSIC_PATTERN *pattern= &mod->pattern[patnum];FMUSIC_PATTERN basically stores channels*rows notes (which also include volume, instrument-number & effects).
You get the number of channels:
int chan= mod->numchannels;
And look into the notes of the currently playing row:
// get a pointer to the note of the first channel of the currently playing row:
FMUSIC_NOTE *notes= &pattern->data[row*chan];
for (int c=0;c<chan;c++)
{
// now you can access the "note" for each channel "c":
notes[c].note
notes[c].number
notes[c].volume
notes[c].effect
notes[c].eparam
}
-
It looks very good and cheers for the reply dude.
-
I just tryed what Hellfire explained and got stuck:
You can now fetch the playing pattern-number from the order-list (stored in FMUSIC_MODULE):
int patnum= mod->orderlist[order];
As soon as i try to access the orderlist the compiler complains that on the left side of "orderlist" should be a pointer to a generic class/struct/union. It seems that VS2012 doesnt know the structure of the FMUSIC_MODULE type. I thought it could be solved by including:
#include "minifmod/music.h"
but after that the compiler complains that FSOUND_BufferSize was redefined in sound.h (179) and tells to look at sound.h(168). The funny thing is that there is no redefinition. Line 179 defines FSOUND_BufferSize while line 169 defines FSOUND_BufferSizeMS. Any clue what might be wrong?
Thanks in advance.
-
If I remember correctly I had to change "Fsound.c" and "sound.h" files to make it compile.
Check out the attached source, it might help you.