void pressureChange(u8 value) { u8 newvalue = value; // Clamp if(newvalue > 127) newvalue = 127; dsmi_write(0xB0+channel, 0, newvalue); }
void pitchChange(s16 value) { s16 newvalue = value; // Clamp to [-64, 64] if(newvalue < -64) newvalue = -64; if(newvalue > 63) newvalue = 63; // Make positive newvalue += 64; // Scale to interval [0,2^14] u16 uvalue = newvalue * 128; // Split into lower and higher 7 bit u8 ls7b = uvalue & 0x7F; uvalue >>= 7; u8 ms7b = uvalue & 0x7F; dsmi_write(0xE0+channel, ls7b, ms7b); }
void stop(u8 note) { dsmi_write(0x80 | channel, note+12*baseOctave, 0); }
void play(u8 note) { dsmi_write(0x90 | channel, note+12*baseOctave, 127); }
void MidiModule::send_note_off(int channel, int note) { channel--; dsmi_write(0x80 | channel, note, 0); }
void MidiModule::send_note_on(int channel, int note, int velocity) { channel--; dsmi_write(0x90 | channel, note, velocity); }
void MidiModule::send(u8 message, u8 data1, u8 data2) { dsmi_write(message,data1,data2); }