-
Notifications
You must be signed in to change notification settings - Fork 15
Music syncing
Sigve Sebastian Farstad edited this page Jul 27, 2015
·
2 revisions
See BEATBEAN.js
The bpm and subdivision of beats can be defined in the nin.json file in the root folder of your project.
{
"name": "My awesome demo!",
"music": {
"bpm": 120,
"subdivision": 4
}
}
The global variable BEAT
will be true on each frame that is on a BEAT.
The global variable BEAN
will increase by one each time BEAT is true.
In addition the helper methods BEAN_FOR_FRAME
and FRAME_FOR_BEAN
can be used for doing fancy calculations and finding appropriate BEAN values in your layer.
A common pattern is to use expressions like BEAT && BEAN % 4 == 0
. This will evaluate to true on every 4th BEAT, starting with the first one. In a song with a subdivision of 4, this means the first beat of each bar in the song.