midi sequencer. timed events

Status
Not open for further replies.

snowsh

Well-known member
t4.1

I am developing a midi sequencer. At present its timer is based on a couple of counters. the first counter measures the steps in each pattern, and the second increments on each round of the pattern sequence.

It has 16 channels, some of these channels could be a drum sequencer which offers 16 instruments... there is allot going on.

I am now addming an "Arranger" so you can setup pattern changes at a given time in the song.

how would you suggest defining these events? I am working on a struct and up to 100 entries to define these event changes, but I dont want to have to hunt all the entries at every round to find an event based on the current song position. This struc below seems to lead towards that issue of having to hunt for the startTime constantly....

Maybe I am approaching the whole thing wrong?

Code:
#define NUMBER_OF_ARRANGER_BLOCKS 100

struct arrangerBlockStruct {
  uint8_t blockId;
  int start;
  uint8_t patternId;
  uint8_t transpose;                                                          // value to transpose everything
  uint8_t theory;                                                             // value to set a new theory
} currentArrangerBlock[NUMBER_OF_CHANNELS];                                   // keep in SRAM the current block for eaach channel;

EXTMEM struct arrangerBlockStruct arrangerBlockLibrary[NUMBER_OF_CHANNELS][NUMBER_OF_ARRANGER_BLOCKS]; // keep in PSRAM the library
 
Last edited:
I may not be interpreting your intent 100% correctly, but just in case I am, how about if each entry in your array includes a value for its length (# of beats, # of measures, etc.). You keep an index value that tells you which entry in the array is the current one, & you keep a counter corresponding the the length value, incrementing as appropriate (each beat, each measure, or whatever the "length" represents). When the length of the current entry is reached, you increment your index value, you reset your counter to 0, & you start using the next entry in your array. After you increment the index value, you would perform the MOD function with the maximum number of entries (sequences) that you have defined in your array. That way, when you reach the end of the defined entries, you automatically start back over at the first entry.

For example, using the following assumptions:
1) your sequences are 4 beats per measure
2) your length counter in an entry is defined such that it represents # of measures to play for a particular entry in your array
3) for this example, let's assume your overall sequence includes three patterns (max=3)
4) the first entry in your array (index=0) includes a length value indicating that it should play for 8 measures
5) the second entry in your array (index=1) includes a length value indicating that it should play for 4 measures
6) the third entry in your array (index=2) includes a length value indicating that it should play for 12 measures

Using these defined sequences, your device would start playing the sequence for the first entry. The index would start at 0 & the counter would start at 0. With each 4 beats, the counter would be incremented (i.e. each measure). When the counter exceeds the length for the current entry in your array (in this case, for index=0, length=8), the index would increment by 1, then mod by max (now, index=1) & the counter would reset to 0. Your device would then start playing the sequence for the second entry. When the counter exceeds the length for the current entry in your array (in this case, for index=1, length=4), the index would increment by 1, then mod by max (now, index = 2) & the counter would reset to 0. Your device would then start playing the sequence for the third entry. When the counter exceeds the length for the current entry in your array (in this case, for index=2, length=12), the index would increment by 1, then mod by max (now, index = 0) & the counter would reset to 0. Your device would then start playing the sequence for the first entry once again. And the whole cycle repeats . . .

Hope I properly understood your intent & maybe that this helps . . .

Mark J Culross
KD5RXT
 
Status
Not open for further replies.
Back
Top