I'm working on an iOS music app (written in C++) and my model looks more or less like this:
--Song
----Track
----Track
------Pattern
------Pattern
--------Note
--------Note
--------Note
So basically a Song
has multiple Tracks
, a Track
can have multiple Patterns
and a Pattern
has multiple Notes.
Each one of those things is represented by a class and except for the Song object, they're all stored inside vectors.
Each Note
has a "frame"
parameter so that I can calculate when a note should be played. For example, if I have 44100 samples / second and the frame for a particular note is 132300 I know that I need that Note at the start of the third second.
My question is how I should represent those notes for best performance? Right now I'm thinking of storing the notes in a vector datamember of each pattern and than loop all the Tracks
of the Song
, than look the Patterns
and than loop the Notes
to see which one has a frame datamember that is greater than 132300 and smaller than 176400 (start of 4th second).
As you can tell, that's a lot of loops and a song could be as long as 10 minutes. So I'm wondering if this will be fast enough to calculate all the frames and send them to the buffer on time.
[.] "I'm reinventing MOD files"
or[.] "I'm reinventing MIDI files"
. Note that MOD players already exist for smart phones – sehe Apr 9 '12 at 22:19