Skip to content

Commit

Permalink
Feature: Poly Pressure (Poly Aftertouch)
Browse files Browse the repository at this point in the history
- as mode for LFO FX (13. button)
- as TRK PAR (PP)
- seq_pp_labels contains"Access Virus"  PolyPressure parameter labels
- Note: PolyPressure can't recorded!
  • Loading branch information
rio-rattenrudel committed Nov 14, 2019
1 parent 51b5e48 commit 4a8d6e5
Show file tree
Hide file tree
Showing 14 changed files with 468 additions and 53 deletions.
3 changes: 2 additions & 1 deletion apps/sequencers/midibox_seq_v4/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LCD = $(MIOS32_LCD)
################################################################################

####################################
# RIO: Added PROTEUS files
# RIO: Added NEW files
####################################

THUMB_SOURCE = core/app.c \
Expand Down Expand Up @@ -85,6 +85,7 @@ THUMB_SOURCE = core/app.c \
core/seq_blm.c \
core/seq_cc.c \
core/seq_cc_labels.c \
core/seq_pp_labels.c \
core/seq_core.c \
core/seq_scale.c \
core/seq_groove.c \
Expand Down
15 changes: 14 additions & 1 deletion apps/sequencers/midibox_seq_v4/core/seq_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2318,7 +2318,11 @@ s32 SEQ_CORE_NotifyIncomingMIDIEvent(u8 track, mios32_midi_package_t p)
}
} break;

//case PolyPressure:
//####################################
//# RIO: POLYPHONIC PRESSURE
//####################################

case PolyPressure:
case CC:
case ProgramChange:
//case Aftertouch:
Expand All @@ -2336,6 +2340,15 @@ s32 SEQ_CORE_NotifyIncomingMIDIEvent(u8 track, mios32_midi_package_t p)
apply_mask = 1;
}
} break;
case SEQ_PAR_Type_PolyPressure: {
if( p.event == PolyPressure && p.cc_number == tcc->lay_const[1*16 + par_layer] ) {
apply_mask = 1;
}
} break;

//####################################
//# RIO: END MODIFICATION
//####################################

case SEQ_PAR_Type_PitchBend: {
if( p.event == PitchBend ) {
Expand Down
82 changes: 75 additions & 7 deletions apps/sequencers/midibox_seq_v4/core/seq_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,35 @@ s32 SEQ_LAYER_GetEvents(u8 track, u16 step, seq_layer_evnt_t layer_events[16], u
for(par_layer=0; par_layer<num_p_layers; ++par_layer, ++layer_type_ptr) {

switch( *layer_type_ptr ) {

//####################################
//# RIO: POLYPHONIC PRESSURE
//####################################

case SEQ_PAR_Type_PolyPressure:
case SEQ_PAR_Type_CC: {
u8 cc_number = seq_layer_drum_cc[drum][par_layer];
u8 value = SEQ_PAR_Get(track, step, par_layer, drum);

if( !insert_empty_notes ) {

if (*layer_type_ptr == SEQ_PAR_Type_PolyPressure) {

// new: don't send CC if assigned to invalid CC number
// new: don't send if CC is assigned to LFO extra CC function in POLYPRESSURE mode
if( cc_number >= 0x80 ||
(tcc->lfo_waveform && tcc->lfo_cc == cc_number && tcc->lfo_enable_flags.POLYPRESSURE) )
break;

// don't send CC if value hasn't changed (== invalid value)
// but only if LFO not assigned to CC layer in POLYPRESSURE mode
if( !tcc->lfo_enable_flags.CC && !tcc->lfo_enable_flags.POLYPRESSURE &&
( value >= 0x80 || value == cc_last_value[track][drum][par_layer]) ) {
break;
}

} else {

// new: don't send CC if assigned to invalid CC number
// new: don't send if CC is assigned to LFO extra CC function
if( cc_number >= 0x80 ||
Expand All @@ -441,23 +465,29 @@ s32 SEQ_LAYER_GetEvents(u8 track, u16 step, seq_layer_evnt_t layer_events[16], u
( value >= 0x80 || value == cc_last_value[track][drum][par_layer]) ) {
break;
}
}

cc_last_value[track][drum][par_layer] = value;
}

if( insert_empty_notes || !(layer_muted & (1 << drum)) ) {
seq_layer_evnt_t *e = &layer_events[num_events];
mios32_midi_package_t *p = &e->midi_package;

p->type = CC;
p->type = *layer_type_ptr == SEQ_PAR_Type_PolyPressure ? PolyPressure : CC;
p->cable = track;
p->event = CC;
p->event = *layer_type_ptr == SEQ_PAR_Type_PolyPressure ? PolyPressure : CC;
p->chn = tcc->midi_chn;
p->cc_number = cc_number;
p->value = value;
e->len = -1;
e->layer_tag = drum;
++num_events;

//####################################
//# RIO: END MODIFICATION
//####################################

// morph it
if( !insert_empty_notes && tcc->morph_mode )
SEQ_MORPH_EventCC(track, step, e, drum, par_layer);
Expand Down Expand Up @@ -757,13 +787,36 @@ s32 SEQ_LAYER_GetEvents(u8 track, u16 step, seq_layer_evnt_t layer_events[16], u

} break;

//####################################
//# RIO: POLYPHONIC PRESSURE
//####################################

case SEQ_PAR_Type_PolyPressure:
case SEQ_PAR_Type_CC: {
seq_layer_evnt_t *e = &layer_events[num_events];
mios32_midi_package_t *p = &e->midi_package;
u8 cc_number = tcc->lay_const[1*16 + par_layer];
u8 value = SEQ_PAR_Get(track, step, par_layer, instrument);

if( !insert_empty_notes ) {

if (*layer_type_ptr == SEQ_PAR_Type_PolyPressure) {

// new: don't send CC if assigned to invalid CC number
// new: don't send if CC is assigned to LFO extra CC function in POLYPRESSURE mode
if( cc_number >= 0x80 ||
(tcc->lfo_waveform && tcc->lfo_cc == cc_number && tcc->lfo_enable_flags.POLYPRESSURE) )
break;

// don't send CC if value hasn't changed (== invalid value)
// but only if LFO not assigned to CC layer in POLYPRESSURE mode
if( !tcc->lfo_enable_flags.CC && !tcc->lfo_enable_flags.POLYPRESSURE &&
( value >= 0x80 || value == cc_last_value[track][0][par_layer]) ) {
break;
}

} else {

// new: don't send CC if assigned to invalid CC number
// new: don't send if CC is assigned to LFO extra CC function
if( cc_number >= 0x80 ||
Expand All @@ -776,24 +829,30 @@ s32 SEQ_LAYER_GetEvents(u8 track, u16 step, seq_layer_evnt_t layer_events[16], u
( value >= 0x80 || value == cc_last_value[track][0][par_layer]) ) {
break;
}
cc_last_value[track][0][par_layer] = value;
}

cc_last_value[track][0][par_layer] = value;
}

if(
#ifndef MBSEQV4L
(tcc->event_mode != SEQ_EVENT_MODE_CC || gate) &&
#endif
(insert_empty_notes || !(layer_muted & (1 << par_layer))) ) {
p->type = CC;
p->type = *layer_type_ptr == SEQ_PAR_Type_PolyPressure ? PolyPressure : CC;
p->cable = track;
p->event = CC;
p->event = *layer_type_ptr == SEQ_PAR_Type_PolyPressure ? PolyPressure : CC;
p->chn = tcc->midi_chn;
p->cc_number = cc_number;
p->value = value;
e->len = -1;
e->layer_tag = par_layer;
++num_events;

//####################################
//# RIO: END MODIFICATION
//####################################

// morph it
if( !insert_empty_notes && tcc->morph_mode )
SEQ_MORPH_EventCC(track, step, e, instrument, par_layer);
Expand Down Expand Up @@ -1231,20 +1290,29 @@ s32 SEQ_LAYER_DirectSendEvent(u8 track, u8 par_layer)
p.cable = track;
p.chn = tcc->midi_chn;

//####################################
//# RIO: POLYPHONIC PRESSURE
//####################################

switch( layer_type ) {
case SEQ_PAR_Type_PolyPressure:
case SEQ_PAR_Type_CC: {
u8 cc_number = tcc->lay_const[1*16 + par_layer];
u8 value = (cc_last_value[track][0][par_layer] < 0x80) ? cc_last_value[track][0][par_layer] : 0x40;

if( cc_number >= 0x80 )
return -1; // CC disabled

p.type = CC;
p.event = CC;
p.type = layer_type == SEQ_PAR_Type_PolyPressure ? PolyPressure : CC;
p.event = layer_type == SEQ_PAR_Type_PolyPressure ? PolyPressure : CC;
p.cc_number = tcc->lay_const[1*16 + par_layer];
p.value = value;
} break;

//####################################
//# RIO: END MODIFICATION
//####################################

case SEQ_PAR_Type_PitchBend: {
u8 value = (pb_last_value[track] < 0x80) ? pb_last_value[track] : 0x40;

Expand Down
14 changes: 14 additions & 0 deletions apps/sequencers/midibox_seq_v4/core/seq_lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,13 @@ s32 SEQ_LCD_PrintLayerValue(u8 track, u8 par_layer, u8 par_value)
SEQ_LCD_PrintGatelength(par_value);
break;

//####################################
//# RIO: POLYPHONIC PRESSURE
//####################################
case SEQ_PAR_Type_PolyPressure:
//####################################
//# RIO: END MODIFICATION
//####################################
case SEQ_PAR_Type_CC:
case SEQ_PAR_Type_ProgramChange:
case SEQ_PAR_Type_PitchBend:
Expand Down Expand Up @@ -1007,6 +1014,13 @@ s32 SEQ_LCD_PrintLayerEvent(u8 track, u8 step, u8 par_layer, u8 instrument, u8 s
SEQ_LCD_PrintGatelength(layer_event.len);
break;

//####################################
//# RIO: POLYPHONIC PRESSURE
//####################################
case SEQ_PAR_Type_PolyPressure:
//####################################
//# RIO: END MODIFICATION
//####################################
case SEQ_PAR_Type_CC:
case SEQ_PAR_Type_ProgramChange:
case SEQ_PAR_Type_PitchBend:
Expand Down
10 changes: 8 additions & 2 deletions apps/sequencers/midibox_seq_v4/core/seq_lfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,18 @@ s32 SEQ_LFO_FastCC_Event(u8 track, u32 bpm_tick, mios32_midi_package_t *p, u8 ig
else if( lfo_value > 127 )
lfo_value = 127;

p->type = CC;
//####################################
//# RIO: POLYPHONIC PRESSURE
//####################################
p->type = (tcc->lfo_enable_flags.POLYPRESSURE) ? PolyPressure : CC;
p->cable = track;
p->event = CC;
p->event = (tcc->lfo_enable_flags.POLYPRESSURE) ? PolyPressure : CC;
p->chn = tcc->midi_chn;
p->cc_number = tcc->lfo_cc;
p->value = lfo_value;
//####################################
//# RIO: END MODIFICATION
//####################################

return 1; // returned 1 event
}
Expand Down
5 changes: 3 additions & 2 deletions apps/sequencers/midibox_seq_v4/core/seq_lfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ typedef union {
u8 VELOCITY:1;
u8 LENGTH:1;
u8 CC:1;
u8 REVERSE:1; // RIO: added Reverse
u8 FADEUP:1; // RIO: added Fade OUT
u8 REVERSE:1; // RIO: added Reverse
u8 FADEUP:1; // RIO: added Fade OUT
u8 POLYPRESSURE:1; // RIO: added PolyPressure
};
} seq_lfo_enable_flags_t;

Expand Down
40 changes: 25 additions & 15 deletions apps/sequencers/midibox_seq_v4/core/seq_par.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ static const char seq_par_type_names[SEQ_PAR_NUM_TYPES][6] = {
"Root ", // 16
"Scale", // 17
"Chrd3", // 18
//####################################
//# RIO: MUTES LAYER
//####################################
//########################################
//# RIO: MUTES LAYER / POLYPHONIC PRESSURE
//########################################
"Mute1", // 19
"Mute2", // 20
"Mute3", // 21
Expand All @@ -82,9 +82,10 @@ static const char seq_par_type_names[SEQ_PAR_NUM_TYPES][6] = {
"Mut14", // 32
"Mut15", // 33
"Mut16", // 34
//####################################
" PP ", // 35
//########################################
//# RIO: END MODIFICATION
//####################################
//########################################
};

static const u8 seq_par_map[SEQ_PAR_NUM_TYPES] = { // allows to change the order for the UI selection
Expand All @@ -96,6 +97,13 @@ static const u8 seq_par_map[SEQ_PAR_NUM_TYPES] = { // allows to change the order
SEQ_PAR_Type_Velocity,
SEQ_PAR_Type_Length,
SEQ_PAR_Type_CC,
//####################################
//# RIO: POLYPHONIC PRESSURE
//####################################
SEQ_PAR_Type_PolyPressure,
//####################################
//# RIO: END MODIFICATION
//####################################
SEQ_PAR_Type_PitchBend,
SEQ_PAR_Type_Aftertouch,
SEQ_PAR_Type_ProgramChange,
Expand Down Expand Up @@ -151,9 +159,9 @@ static const u8 seq_par_default_value[SEQ_PAR_NUM_TYPES] = {
0, // Root: C
0, // Scale: 0
0x01, // Chord3: 1
//####################################
//# RIO: MUTES LAYER
//####################################
//########################################
//# RIO: MUTES LAYER / POLYPHONIC PRESSURE
//########################################
0, // Mute1: 0
0, // Mute2: 0
0, // Mute3: 0
Expand All @@ -170,9 +178,10 @@ static const u8 seq_par_default_value[SEQ_PAR_NUM_TYPES] = {
0, // Mute14: 0
0, // Mute15: 0
0, // Mute16: 0
//####################################
0x80, // PolyPressure
//########################################
//# RIO: END MODIFICATION
//####################################
//########################################
};

static const u8 seq_par_max_value[SEQ_PAR_NUM_TYPES] = {
Expand All @@ -195,9 +204,9 @@ static const u8 seq_par_max_value[SEQ_PAR_NUM_TYPES] = {
0x7f, // Root
0x7f, // Scale
0x7f, // Chord3
//####################################
//# RIO: MUTES LAYER
//####################################
//########################################
//# RIO: MUTES LAYER / POLYPHONIC PRESSURE
//########################################
2, // Mute1
2, // Mute2
2, // Mute3
Expand All @@ -214,9 +223,10 @@ static const u8 seq_par_max_value[SEQ_PAR_NUM_TYPES] = {
2, // Mute14
2, // Mute15
2, // Mute16
//####################################
0x80, // PolyPressure
//########################################
//# RIO: END MODIFICATION
//####################################
//########################################
};


Expand Down
13 changes: 7 additions & 6 deletions apps/sequencers/midibox_seq_v4/core/seq_par.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ typedef enum {
SEQ_PAR_Type_Root=16,
SEQ_PAR_Type_Scale=17,
SEQ_PAR_Type_Chord3=18,
//####################################
//# RIO: MUTES LAYER
//####################################
//########################################
//# RIO: MUTES LAYER / POLYPHONIC PRESSURE
//########################################
SEQ_PAR_Type_Mute1=19,
SEQ_PAR_Type_Mute2=20,
SEQ_PAR_Type_Mute3=21,
Expand All @@ -72,12 +72,13 @@ typedef enum {
SEQ_PAR_Type_Mute14=32,
SEQ_PAR_Type_Mute15=33,
SEQ_PAR_Type_Mute16=34,
SEQ_PAR_Type_PolyPressure=35,
} seq_par_layer_type_t;

#define SEQ_PAR_NUM_TYPES 35
//####################################
#define SEQ_PAR_NUM_TYPES 36
//########################################
//# RIO: END MODIFICATION
//####################################
//########################################

// NOTE: numbers have to be aligned with the strings in SEQ_LCD_PrintNthMode!
#define SEQ_PAR_TYPE_NTH_OFF 0
Expand Down
Loading

0 comments on commit 4a8d6e5

Please sign in to comment.