mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-01 18:42:40 +00:00
prepare for MIDI velocity mapping
This commit is contained in:
parent
bdef72666b
commit
69998e2c7e
4 changed files with 21 additions and 2 deletions
|
@ -48,7 +48,9 @@ enum DivDispatchCmds {
|
||||||
DIV_CMD_ENV_RELEASE,
|
DIV_CMD_ENV_RELEASE,
|
||||||
DIV_CMD_INSTRUMENT, // (ins, force)
|
DIV_CMD_INSTRUMENT, // (ins, force)
|
||||||
DIV_CMD_VOLUME, // (vol)
|
DIV_CMD_VOLUME, // (vol)
|
||||||
|
// TODO: think of possibly moving this
|
||||||
DIV_CMD_GET_VOLUME, // () -> vol
|
DIV_CMD_GET_VOLUME, // () -> vol
|
||||||
|
// TODO: move. shouldn't be a command.
|
||||||
DIV_CMD_GET_VOLMAX, // () -> volMax
|
DIV_CMD_GET_VOLMAX, // () -> volMax
|
||||||
DIV_CMD_NOTE_PORTA, // (target, speed) -> 2 if target reached
|
DIV_CMD_NOTE_PORTA, // (target, speed) -> 2 if target reached
|
||||||
DIV_CMD_PITCH, // (pitch)
|
DIV_CMD_PITCH, // (pitch)
|
||||||
|
@ -589,6 +591,14 @@ class DivDispatch {
|
||||||
*/
|
*/
|
||||||
virtual bool isVolGlobal();
|
virtual bool isVolGlobal();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* map MIDI velocity (from 0 to 127) to chip volume.
|
||||||
|
* @param ch the chip channel. -1 means N/A.
|
||||||
|
* @param vel input velocity.
|
||||||
|
* @return output volume.
|
||||||
|
*/
|
||||||
|
virtual int mapVelocity(int ch, unsigned char vel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the lowest note in a portamento.
|
* get the lowest note in a portamento.
|
||||||
* @param ch the channel in question.
|
* @param ch the channel in question.
|
||||||
|
|
|
@ -190,7 +190,7 @@ struct DivNoteEvent {
|
||||||
channel(-1),
|
channel(-1),
|
||||||
ins(0),
|
ins(0),
|
||||||
note(0),
|
note(0),
|
||||||
volume(0),
|
volume(-1),
|
||||||
on(false),
|
on(false),
|
||||||
nop(true),
|
nop(true),
|
||||||
pad1(false),
|
pad1(false),
|
||||||
|
|
|
@ -102,6 +102,11 @@ bool DivDispatch::isVolGlobal() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DivDispatch::mapVelocity(int ch, unsigned char vel) {
|
||||||
|
const int volMax=MAX(1,dispatch(DivCommand(DIV_CMD_GET_VOLMAX,MAX(ch,0))));
|
||||||
|
return (vel*volMax)/127;
|
||||||
|
}
|
||||||
|
|
||||||
int DivDispatch::getPortaFloor(int ch) {
|
int DivDispatch::getPortaFloor(int ch) {
|
||||||
return 0x00;
|
return 0x00;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1372,7 +1372,11 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
|
||||||
}
|
}
|
||||||
if (note.on) {
|
if (note.on) {
|
||||||
dispatchCmd(DivCommand(DIV_CMD_INSTRUMENT,note.channel,note.ins,1));
|
dispatchCmd(DivCommand(DIV_CMD_INSTRUMENT,note.channel,note.ins,1));
|
||||||
dispatchCmd(DivCommand(DIV_CMD_VOLUME,note.channel,(note.volume*(chan[note.channel].volMax>>8))/127));
|
if (note.volume>=0) {
|
||||||
|
int mappedVol=disCont[dispatchOfChan[note.channel]].dispatch->mapVelocity(note.channel,note.volume);
|
||||||
|
logV("dispatching volume (%d -> %d)",note.volume,mappedVol);
|
||||||
|
dispatchCmd(DivCommand(DIV_CMD_VOLUME,note.channel,mappedVol));
|
||||||
|
}
|
||||||
dispatchCmd(DivCommand(DIV_CMD_NOTE_ON,note.channel,note.note));
|
dispatchCmd(DivCommand(DIV_CMD_NOTE_ON,note.channel,note.note));
|
||||||
keyHit[note.channel]=true;
|
keyHit[note.channel]=true;
|
||||||
chan[note.channel].releasing=false;
|
chan[note.channel].releasing=false;
|
||||||
|
|
Loading…
Reference in a new issue