SHARE
TWEET

Untitled

a guest Aug 13th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void Flush(void) {
  2.     //! calculate delta
  3.     u32 delta = (gMidi.gTick - gTick) * 24/gMidi.gDiv;
  4.     //if(!delta) return;
  5.    
  6.     //! update tick position
  7.     gTick += delta * gMidi.gDiv/24;
  8.    
  9.     //! flush chan cmds
  10.     if(gVol&0x80) PushCmd(0x82, 1, (u8[]) {gVol &= 0x7F});
  11.     if(gExp&0x80) PushCmd(0x83, 1, (u8[]) {gExp &= 0x7F});
  12.     if(gPan&0x80) PushCmd(0x84, 1, (u8[]) {gPan &= 0x7F});
  13.     if(gBnd&0x80) PushCmd(0x85, 1, (u8[]) {gBnd &= 0x7F});
  14.    
  15.     //! flush song cmds
  16.     if(gBRn&0x80)  PushCmd(0x88, 1, (u8[]) {gBRn &= 0x7F});
  17.     if(gMidi.gTmp&0x800) {
  18.         PushCmd(0x86, 1, (u8[]) {gMidi.gTmp &= 0xFF});
  19.     }
  20.    
  21.     //! flush note off
  22.     for(u32 i=0;i<gNoteOff.size();i++) {
  23.         PushCmd(0x81, 1, (u8[]) {gNoteOff[i]});
  24.     } gNoteOff.clear();
  25.    
  26.     //! flush note on (and patch set)
  27.     for(u32 i=0;i<gNoteOn.size();i++) {
  28.         u32 dat = gNoteOn[i];
  29.        
  30.         //! patch set or note on?
  31.         if(dat & 0x80) {
  32.             PushCmd(dat, 1, (u8[]) {dat>>8});
  33.         } else PushCmd(0x80, 2, (u8[]) {dat, dat>>8});
  34.     } gNoteOn.clear();
  35.    
  36.     //! push delta
  37.     while(delta >= 96) {
  38.         PushCmd(0x90+96, 0, 0);
  39.         delta -= 96;
  40.     } if(delta) PushCmd(0x90+delta, 0, 0);
  41. }
RAW Paste Data
Top