• Welcome to Dark Bit Factory & Gravity.
 

[C/C++] Using FreeBasic-version of MiniFmod library

Started by Clyde, November 26, 2009

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Jim

Hellfire shows how to work out which note at which octave is playing.  You already know how to work out which sample is playing.
What else do you need?  Alternatively, what do you mean you're having a problem incorporating it?

Jim
Challenge Trophies Won:

hellfire

#21
So you want to compare a numeric xm-note with an textual representation as shown in a tracker ?

Try something like this:

int stringToXmNote(char *note)
{
   char map[7]={
      9, // A- A#
     11, // B-
      0, // C- C#
      2, // D- D#
      4, // E-
      5, // F- F#
      7  // G- G#
   };

   // map first character from [C,D,E,F,G,A,B] to [0,2,4,5,7,9,11]
   int n= map[note[0]-'A'];
   // half note: second character is '#'
   if (note[1]=='#') n++;
   // extract octave
   int o= note[2] - '0';
   // convert to note-number
   return (o*12)+n+1;
}


Use like this:

int xmnote= MiniFmod_GetSynch(channel) & 0xff;
if (xmnote == stringToXmNote("D#4"))
{
  ...
}


Challenge Trophies Won:

Clyde

Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

Clyde

I've got back to this, it looks brilliant the snippet above Dude, but it's not working with the stringToXMNote.


int xmnote= MiniFmod_GetSynch(5) & 0xff;
if (xmnote == stringToXmNote("D-6"))
{
draw_box();
}


Huge thanks,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

hellfire

Quoteit looks brilliant the snippet above Dude, but it's not working
Yes, Dude, that's quite possible!
That's either because my code is crap or you're using it wrong, Dude.
Can you be more specific, Dude, or even post an example?
;D
Challenge Trophies Won:

Clyde

Dude, it's just using your code above, and the bit I posted above dude.

you could try it out with the riseup module, if you wanted Hellfire dude.

Cheers Dude!
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

hellfire

Quote from: Clyde on September 30, 2010you could try it out with the riseup module
That's a 4-channel module, but you're reading the note from channel 5:
Quoteint xmnote= MiniFmod_GetSynch(5) & 0xff;

Try

int xmnote= MiniFmod_GetSynch(3) & 0xff;
if (xmnote == stringToXmNote("A-4")) ...

Challenge Trophies Won:

Clyde

Ok thanks mate, I need to remember it's -1 for the channel / track.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won: