Phase 26: add common parameter targets, step automation and MIDI control mapping
This commit is contained in:
parent
7bff7b535d
commit
901a536f10
38 changed files with 740 additions and 67 deletions
|
|
@ -30,6 +30,7 @@ struct xtc_midi_plan {
|
|||
uint64_t monitor_position;
|
||||
xtc_gain_ramp volume[16], pan[16];
|
||||
unsigned int sustain[16];
|
||||
unsigned char control_map[16][3];
|
||||
xtc_mix_snapshot mix;
|
||||
span notes[XTC_PROJECT_MAX_NOTES];
|
||||
size_t count;
|
||||
|
|
@ -39,7 +40,7 @@ struct xtc_midi_plan {
|
|||
};
|
||||
|
||||
/**
|
||||
* @brief Decodes a complete note or all-notes-off MIDI message into a block event.
|
||||
* @brief Decodes a complete note, controller or all-notes-off MIDI message into a block event.
|
||||
*
|
||||
* @param bytes Borrowed MIDI message bytes.
|
||||
* @param size Number of message bytes.
|
||||
|
|
@ -58,8 +59,6 @@ xtc_result xtc_midi_decode(const unsigned char *bytes, size_t size, unsigned int
|
|||
return XTC_ERR_UNSUPPORTED;
|
||||
if (size != 3 || bytes[1] > 127 || bytes[2] > 127)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (command == 176 && bytes[1] != 120 && bytes[1] != 123 && bytes[1] != 7 && bytes[1] != 10 && bytes[1] != 64)
|
||||
return XTC_ERR_UNSUPPORTED;
|
||||
e.offset = offset;
|
||||
e.channel = bytes[0] & 15U;
|
||||
e.pitch = bytes[1];
|
||||
|
|
@ -190,6 +189,7 @@ xtc_result xtc_midi_plan_create(const xtc_project *project, unsigned int rate, x
|
|||
}
|
||||
}
|
||||
free(points);
|
||||
memcpy(p->control_map,project->control_map,sizeof(p->control_map));
|
||||
p->controller_frames = rate / 200U;
|
||||
if (!p->controller_frames) p->controller_frames = 1;
|
||||
xtc_midi_plan_reset(p);
|
||||
|
|
@ -255,10 +255,10 @@ static void event(xtc_midi_plan *p, const xtc_midi_event *e, uint64_t position)
|
|||
return;
|
||||
}
|
||||
if (e->type == XTC_MIDI_CONTROL) {
|
||||
if (e->pitch == 7) (void)xtc_gain_ramp_target(p->volume+e->channel,(float)e->velocity/127.0f,p->controller_frames);
|
||||
else if (e->pitch == 10) (void)xtc_gain_ramp_target(p->pan+e->channel,
|
||||
if (e->pitch == p->control_map[e->channel][0]) (void)xtc_gain_ramp_target(p->volume+e->channel,(float)e->velocity/127.0f,p->controller_frames);
|
||||
else if (e->pitch == p->control_map[e->channel][1]) (void)xtc_gain_ramp_target(p->pan+e->channel,
|
||||
e->velocity >= 64 ? (float)(e->velocity-64)/63.0f : ((float)e->velocity-64)/64.0f,p->controller_frames);
|
||||
else if (e->pitch == 64) {
|
||||
else if (e->pitch == p->control_map[e->channel][2]) {
|
||||
p->sustain[e->channel] = e->velocity >= 64;
|
||||
if (!p->sustain[e->channel]) for (i = 0; i < XTC_MIDI_VOICES; ++i)
|
||||
if (p->voices[i].channel == e->channel && p->voices[i].released) p->voices[i].active = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue