Skip to content

use loop in write midi file #81

Answered by jazz-soft
m-feyz asked this question in Q&A
Discussion options

You must be logged in to vote

If you have an array Ticks[] of ticks and array Notes[][] (grouped by ticks), you can try something like this:

trk.smfSeqName('Music').ch(0).program(0);
for (var t = 0; t < Ticks.length; t++) {
  trk = trk.tick(Ticks[t]); // now trk is a time-shifted version of itself...
  for (var n = 0; n < Notes[t].length; n++) trk.noteOn(Notes[t][n]);
}

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@m-feyz
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by m-feyz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants