Hello all!
given a note(row?) and BPM of a song on famitracker how would I go to calculate in which frame that note will play(NTSC or PAL would do)?
scenario: I'm trying to do a rhythm game.
thanks!
Correlating note with game frames on famitracker
Moderator: Moderators
Re: Correlating note with game frames on famitracker
Probably you wouldn't want to directly calculate the frame, but rather have an event handler that gets triggered by the music engine.
Re: Correlating note with game frames on famitracker
If you're using the Pently sound driver, try pently_get_beat_fraction in its "BPM math" module. It returns a beat fraction from 0/96 to 95/96 calculated from the tempo and the declared time signature. Your code can use this to determine how far to move the arrows. Pently also supports callbacks that run on each row (pently_row_callback) or when the music loops (pently_dalsegno_callback).
Re: Correlating note with game frames on famitracker
I have used famitone, havent looked deeply into it though.
Interesting, I always used famitone for my pet projects, will take a look at Pently!tepples wrote: ↑Fri Sep 04, 2020 8:55 am If you're using the Pently sound driver, try pently_get_beat_fraction in its "BPM math" module. It returns a beat fraction from 0/96 to 95/96 calculated from the tempo and the declared time signature. Your code can use this to determine how far to move the arrows. Pently also supports callbacks that run on each row (pently_row_callback) or when the music loops (pently_dalsegno_callback).
- rainwarrior
- Posts: 8732
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Correlating note with game frames on famitracker
If the "tempo" is 150 BPM, the "speed" is how many frames per row of the pattern. The default speed of 6 results in 4 rows per beat:
6 frames/row × 4 rows/beat = 24 frames/beat
60 frames/second × 60 seconds/minute ÷ 24 frames/beat = 150 beats/minute
(For PAL we'd use 50 frames/second instead of 60.)
With the tempo set to 150 and otherwise only adjusting the speed, it's easy to make sure there is a whole number of frames per row. If the tempo is not 150 BMP then it has to approximate, sometimes having 1 extra or 1 less frame in a row to adjust the speed to match. Because of this approximation the precise rhythm of playback gets a bit uneven when the tempo is not 150, so you will probably want to keep your tempo locked to 150 for the purpose of a rhythm game, and only adjust the speed. (For PAL, you would use a tempo of 125 instead of 150 to ensure this.)
Your rows per beat could be anything you want, and the frames per row (speed) can be anything you want, but the simplest way to ensure a precise frame-locked rhythm is to use tempo 150 only (125 for PAL).
Re: Correlating note with game frames on famitracker
thanks! i am still confused though...rainwarrior wrote: ↑Fri Sep 04, 2020 2:18 pmIf the "tempo" is 150 BPM, the "speed" is how many frames per row of the pattern. The default speed of 6 results in 4 rows per beat:
6 frames/row × 4 rows/beat = 24 frames/beat
60 frames/second × 60 seconds/minute ÷ 24 frames/beat = 150 beats/minute
(For PAL we'd use 50 frames/second instead of 60.)
With the tempo set to 150 and otherwise only adjusting the speed, it's easy to make sure there is a whole number of frames per row. If the tempo is not 150 BMP then it has to approximate, sometimes having 1 extra or 1 less frame in a row to adjust the speed to match. Because of this approximation the precise rhythm of playback gets a bit uneven when the tempo is not 150, so you will probably want to keep your tempo locked to 150 for the purpose of a rhythm game, and only adjust the speed. (For PAL, you would use a tempo of 125 instead of 150 to ensure this.)
Your rows per beat could be anything you want, and the frames per row (speed) can be anything you want, but the simplest way to ensure a precise frame-locked rhythm is to use tempo 150 only (125 for PAL).
i just checked and the music I have to sync speed is "11", the BPM is 150 which i think is a good start from what you said
the part that gets me:
*The default speed of 6 results in 4 rows per beat*
that scalated quickly =p maybe im confused about notation. How would that relate to a speed of 11 for example?
edit:
would that be 11x4 = 44frames per beat?
ye just tested thats it, thanks again
Last edited by vnsbr on Sun Sep 06, 2020 2:34 pm, edited 1 time in total.
Re: Correlating note with game frames on famitracker
As rainwarrior said, the standard convention in tracker formats is:
64 rows represents four measures of 4/4 where each quarter note is four rows.
However, as the speed gets further away from 6, the less likely this is true. At a speed of 11, that could mean that each pattern is four measures of ♩=82, or eight measures of ♩=164. Because this is a matter of interpretation, there isn't is a singular correct answer, and it comes down to how you choose to describe what's going on.
64 rows represents four measures of 4/4 where each quarter note is four rows.
However, as the speed gets further away from 6, the less likely this is true. At a speed of 11, that could mean that each pattern is four measures of ♩=82, or eight measures of ♩=164. Because this is a matter of interpretation, there isn't is a singular correct answer, and it comes down to how you choose to describe what's going on.
- rainwarrior
- Posts: 8732
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Correlating note with game frames on famitracker
Sorry, I should have said that differently.
The default tempo of 150 BPM and speed 6 gives you 4 rows per beat. That's just the built-in meaning of these in Famitracker. If you leave speed at 6, any tempo you give is the BPM of 4 rows at a time.
If you change speed, tempo BPM no longer matches 4 rows. E.g. speed 4 is 3/2x faster (6/4), or 6 rows per beat. Speed 12 would be 1/2x (6/12) as fast, or 2 rows per beat. Speed 3 is 2x faster (6/3), or 8 rows per beat. etc.
There is a visual highlight on every 4th row by default to mark the beat, but you can change this with a setting in the corner. This is a visual indicator only, though, and can be set any way you want.