Skip to content

Commit

Permalink
Fixed: Use only the activated CC values ​​of the tracks for the LFO II
Browse files Browse the repository at this point in the history
- find real previous value of par in track instead of storing
  • Loading branch information
rio-rattenrudel committed May 9, 2022
1 parent d58b5ae commit 9bfde02
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 42 deletions.
90 changes: 54 additions & 36 deletions apps/sequencers/midibox_seq_v4/!!!!!INFO!!!!.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ modified size (with IIC Hack):
-------------------------------------------------------------------------
arm-none-eabi-size project_build/project.elf
text data bss dec hex filename
423444 960 62944 487348 76fb4 project_build/project.elf
423572 960 62912 487444 77014 project_build/project.elf
10000000 B __ram_start
10007ee0 B __ram_end
10007ec0 B __ram_end
2007c000 D __ram_start_ahb
20083ac0 B __ram_end_ahb

Expand Down Expand Up @@ -5360,36 +5360,6 @@ s32 SEQ_MIDI_ROUTER_SendMIDIClockEvent(u8 evnt0, u32 bpm_tick)

seq_lfo.c -->

//###########################################################################
//# RIO: Added Spezial Behaviour LFO (rstcount for increment spirals, delay)
//###########################################################################

typedef struct {
u16 step_ctr;
u16 pos;
u16 rstcount; // RIO: added rstcount
u8 delay; // RIO: added delay
u8 fadeoffset; // RIO: added fadeoffset
u8 lasttrkccval; // RIO: added lasttrkccval
} seq_lfo_t;

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


s32 SEQ_LFO_ResetTrk(u8 track)
{
seq_lfo_t *lfo = &seq_lfo[track];

lfo->step_ctr = 0;
lfo->pos = 0;
lfo->rstcount = 0; // RIO: added rstcount
lfo->delay = 0; // RIO: added delay
lfo->fadeoffset = 0; // RIO: added fadeoffset
lfo->lasttrkccval = 0; // RIO: added lasttrkccval


s32 SEQ_LFO_Event(u8 track, seq_layer_evnt_t *e)
{
..
Expand All @@ -5399,10 +5369,58 @@ s32 SEQ_LFO_Event(u8 track, seq_layer_evnt_t *e)
//##################################################################
//# RIO: Use only the activated CC values ​​of the tracks for the LFO
//##################################################################
u8 mvalue = e->midi_package.value;
if (mvalue < 128) lfo->lasttrkccval = mvalue;
else mvalue = lfo->lasttrkccval;
s16 value = mvalue + lfo_value;

// init lfo value
s16 value = lfo_value;

// get cc + value of event
u8 cc_number = e->midi_package.cc_number;
u8 cc_value = e->midi_package.value;

// get step of track
seq_core_trk_t *t = &seq_core_trk[track];
u8 step = t->step;

// append event's value or loop previous
if (cc_value < 0x80) value += cc_value;
else {

// loop all CC layer for previous step match
u8 num_p_layers = SEQ_PAR_NumLayersGet(track);
u8 *layer_type_ptr = (u8 *)&tcc->lay_const[0*16];

int par_layer;
for(par_layer=0; par_layer<num_p_layers; ++par_layer, ++layer_type_ptr) {
if( *layer_type_ptr == SEQ_PAR_Type_CC) {

// find cc
u8 pcc = SEQ_CC_Get(track, SEQ_CC_LAY_CONST_B1 + par_layer);
if (pcc == cc_number) {

// loop previous steps
while (step > 0) {

// find real val
u8 pval = SEQ_PAR_Get(track, --step, par_layer, 0);
if (pval < 0x80) {

// append val
value += pval;

// found val
break;
}
}

// found cc
break;
}
}
}
}

//DEBUG_MSG("cc: %d ccval: %d value: %d", cc_number, cc_value, value);

//##################################################################
//# RIO: END MODIFICATION
//##################################################################
Expand Down
59 changes: 53 additions & 6 deletions apps/sequencers/midibox_seq_v4/core/seq_lfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "seq_lfo.h"
#include "seq_core.h"
#include "seq_cc.h"
#include "seq_par.h"


/////////////////////////////////////////////////////////////////////////////
Expand All @@ -36,7 +37,6 @@ typedef struct {
u16 rstcount; // RIO: added rstcount
u8 delay; // RIO: added delay
u8 fadeoffset; // RIO: added fadeoffset
u8 lasttrkccval; // RIO: added lasttrkccval
} seq_lfo_t;

// globals
Expand Down Expand Up @@ -88,7 +88,6 @@ s32 SEQ_LFO_ResetTrk(u8 track)
lfo->rstcount = 0; // RIO: added rstcount
lfo->delay = 0; // RIO: added delay
lfo->fadeoffset = 0; // RIO: added fadeoffset
lfo->lasttrkccval = 0; // RIO: added lasttrkccval

seq_cc_trk_t *tcc = &seq_cc_trk[track];
if (tcc->lfo_phase > 100 && tcc->lfo_phase <= 200) lfo->delay = tcc->lfo_phase-100;
Expand Down Expand Up @@ -205,10 +204,58 @@ s32 SEQ_LFO_Event(u8 track, seq_layer_evnt_t *e)
//##################################################################
//# RIO: Use only the activated CC values ​​of the tracks for the LFO
//##################################################################
u8 mvalue = e->midi_package.value;
if (mvalue < 128) lfo->lasttrkccval = mvalue;
else mvalue = lfo->lasttrkccval;
s16 value = mvalue + lfo_value;

// init lfo value
s16 value = lfo_value;

// get cc + value of event
u8 cc_number = e->midi_package.cc_number;
u8 cc_value = e->midi_package.value;

// get step of track
seq_core_trk_t *t = &seq_core_trk[track];
u8 step = t->step;

// append event's value or loop previous
if (cc_value < 0x80) value += cc_value;
else {

// loop all CC layer for previous step match
u8 num_p_layers = SEQ_PAR_NumLayersGet(track);
u8 *layer_type_ptr = (u8 *)&tcc->lay_const[0*16];

int par_layer;
for(par_layer=0; par_layer<num_p_layers; ++par_layer, ++layer_type_ptr) {
if( *layer_type_ptr == SEQ_PAR_Type_CC) {

// find cc
u8 pcc = SEQ_CC_Get(track, SEQ_CC_LAY_CONST_B1 + par_layer);
if (pcc == cc_number) {

// loop previous steps
while (step > 0) {

// find real val
u8 pval = SEQ_PAR_Get(track, --step, par_layer, 0);
if (pval < 0x80) {

// append val
value += pval;

// found val
break;
}
}

// found cc
break;
}
}
}
}

//DEBUG_MSG("cc: %d ccval: %d value: %d", cc_number, cc_value, value);

//##################################################################
//# RIO: END MODIFICATION
//##################################################################
Expand Down

0 comments on commit 9bfde02

Please sign in to comment.