@@ -190,6 +190,7 @@ unsigned int lfo_vca_wave_new = 0;
190190unsigned long lfo_vca_period_msec = 1000 ;
191191unsigned long lfo_vca_period_msec_new = 1000 ;
192192unsigned long lfo_vca_value = 0 ;
193+ unsigned long lfo_vca_value_prev = 0 ;
193194float lfo_vca_amt = 0.0 ;
194195bool lfo_vca_retrig = false ;
195196
@@ -338,7 +339,7 @@ void readInputs()
338339
339340 // todo: scale the correct values
340341 lfo_delay = analogRead (LFO_DELAY_PIN);
341- slide_time_msec = analogRead (PORTAMENTO_TIME_PIN);
342+ slide_time_msec = pot_max - analogRead (PORTAMENTO_TIME_PIN);
342343
343344
344345 attack_pot = analogRead (ATTACK_PIN);
@@ -392,25 +393,25 @@ void readInputs()
392393 lfo_wave_pot = analogRead (LFO_WAVEFORM);
393394 if (lfo_amt_pot != lfo_amt_pot_prev){
394395 if (lfo_sel){
395- lfo_vca_amt = (float )(pot_max - lfo_amt_pot)/(float )pot_max ;
396- } else {
397396 lfo_filt_amt = (float )(pot_max - lfo_amt_pot)/(float )pot_max ;
397+ } else {
398+ lfo_vca_amt = (float )(pot_max - lfo_amt_pot)/(float )pot_max ;
398399 }
399400 lfo_amt_pot_prev = lfo_amt_pot;
400401 }
401402 if (lfo_period_pot != lfo_period_pot_prev){
402403 if (lfo_sel){
403- lfo_vca_period_msec_new = ((pot_max - lfo_period_pot))*4 ;
404- } else {
405404 lfo_filt_period_msec_new = ((pot_max - lfo_period_pot))*4 ;
405+ } else {
406+ lfo_vca_period_msec_new = ((pot_max - lfo_period_pot))*4 ;
406407 }
407408 lfo_period_pot_prev = lfo_period_pot;
408409 }
409410 if (lfo_wave_pot != lfo_wave_pot_prev){
410411 if (lfo_sel){
411- lfo_vca_wave_new = (pot_max - lfo_wave_pot) / 170 ;
412- } else {
413412 lfo_filt_wave_new = (pot_max - lfo_wave_pot) / 170 ;
413+ } else {
414+ lfo_vca_wave_new = (pot_max - lfo_wave_pot) / 170 ;
414415 }
415416 lfo_wave_pot_prev = lfo_wave_pot;
416417 }
@@ -1029,6 +1030,12 @@ unsigned int pitch_cv(
10291030 return result_pitch;
10301031}
10311032
1033+
1034+
1035+
1036+
1037+
1038+
10321039void loop () {
10331040
10341041 unsigned int note_stack_peek = 0 ;
@@ -1048,7 +1055,6 @@ void loop() {
10481055 gate_prev_state = HIGH;
10491056 note_on=1 ;
10501057 env_trig_time_msec = now_msec ;
1051-
10521058 if (lfo_filt_retrig) {
10531059 lfo_filt_trig_time_msec = now_msec;
10541060 }
@@ -1065,6 +1071,7 @@ void loop() {
10651071 vca_env_at_note_off = vca_env_value;
10661072 }
10671073
1074+ // FILTER
10681075 if (lfo_filt_period_msec == 0 ) {
10691076 lfo_filt_value = dac_max / 2 ;
10701077 }
@@ -1082,38 +1089,44 @@ void loop() {
10821089 if ((lfo_filt_period_msec != lfo_filt_period_msec_new)
10831090 || (lfo_filt_wave != lfo_filt_wave_new)){
10841091 // wait zero crossing
1085- if ((lfo_filt_value_prev <= (dac_max/2 ) and lfo_filt_value >= (dac_max/2 ))){;
1092+ if ((lfo_filt_value_prev <= (dac_max/2 ) and lfo_filt_value >= (dac_max/2 ))){
10861093 // restart wave at zero crossing
10871094 lfo_filt_trig_time_msec = now_msec;
10881095 lfo_filt_period_msec = lfo_filt_period_msec_new;
10891096 lfo_filt_wave = lfo_filt_wave_new;
10901097 }
10911098 }
10921099
1093- // Serial.println(lfo_filt_value);
1094- // Serial.println(lfo_filt_retrig);
1095- /*
1096- unsigned int lfo_vca_value_prev = lfo_vca_value;
1097- lfo_vca_value = lfo_wavetable(lfo_vca_period_msec,
1100+
1101+
1102+
1103+ // VCA
1104+ if (lfo_vca_period_msec == 0 ) {
1105+ lfo_vca_value = dac_max / 2 ;
1106+ }
1107+ else {
1108+ lfo_vca_value_prev = lfo_vca_value;
1109+ lfo_vca_value = lfo_wavetable (lfo_vca_period_msec,
10981110 now_msec,
10991111 wave_table,
11001112 lfo_vca_wave,
1101- lfo_trig_time_msec,
1102- lfo_vca_retrig);
1103- if (lfo_vca_period_msec != lfo_vca_period_msec_new){
1104- if (lfo_vca_value >= 2048 && lfo_vca_value_prev <= 2048){
1105- lfo_vca_period_msec = lfo_vca_period_msec_new;
1106- lfo_trig_time_msec = now_msec;
1107- lfo_vca_value = lfo_wavetable(lfo_vca_period_msec,
1108- now_msec,
1109- wave_table,
1110- lfo_vca_wave,
1111- lfo_trig_time_msec,
1112- lfo_vca_retrig);
1113- }
1113+ lfo_vca_trig_time_msec,
1114+ lfo_vca_retrig);
1115+ }
1116+
1117+ // knob has changed
1118+ if ((lfo_vca_period_msec != lfo_vca_period_msec_new)
1119+ || (lfo_vca_wave != lfo_vca_wave_new)){
1120+ // wait zero crossing
1121+ if ((lfo_vca_value_prev <= (dac_max/2 ) and lfo_vca_value >= (dac_max/2 ))){
1122+ // restart wave at zero crossing
1123+ lfo_vca_trig_time_msec = now_msec;
1124+ lfo_vca_period_msec = lfo_vca_period_msec_new;
1125+ lfo_vca_wave = lfo_vca_wave_new;
1126+ }
11141127 }
11151128
1116- */
1129+
11171130
11181131 note_stack_is_empty = note_stack.isEmpty ();
11191132 if (!note_stack_is_empty) {
@@ -1160,33 +1173,37 @@ void loop() {
11601173
11611174 float lfo_filt_value_scaled = 0 ;
11621175 lfo_filt_value_scaled = ((((float )dac_max/2 )-(float )lfo_filt_value) /2 )*lfo_filt_amt;
1163-
11641176 float filter_float=0 ;
1165-
11661177 filter_float = (float )(((filter_env_value * filter_env_amt) / dac_max + vcf))+lfo_filt_value_scaled ;
11671178 if (filter_float < 0 ){
11681179 curr_filter=0 ;
11691180 } else {
11701181 curr_filter = filter_float;
11711182 }
1172- // curr_vca = (vca_env_value * vca_env_amt) / dac_max +
1173- // ((lfo_vca_value * lfo_vca_amt) / lfo_amt_max) ; // ADD VELOCITY SENSITIVITY HERE!!!
1174- curr_vca = (vca_env_value * vca_env_amt) / dac_max ; // ADD VELOCITY SENSITIVITY HERE!!!
11751183
1176-
1184+
1185+ // ADD VELOCITY SENSITIVITY HERE!!!
1186+ float lfo_vca_value_scaled = 0 ;
1187+ lfo_vca_value_scaled = ((((float )dac_max/2 )-(float )lfo_vca_value) /2 )*lfo_vca_amt;
1188+ float vca_float=0 ;
1189+ vca_float = (float )(((vca_env_value * vca_env_amt) / dac_max))+lfo_vca_value_scaled ;
1190+ if (vca_float < 0 ){
1191+ curr_vca=0 ;
1192+ } else {
1193+ curr_vca = vca_float;
1194+ }
1195+
11771196 if (curr_filter > dac_max) { // clear up too big numbers
11781197 curr_filter = dac_max;
11791198 }
1180-
1181-
1182- if (curr_vca > dac_max) { // clear up too big numbers
1199+ if (curr_vca > dac_max) {
11831200 curr_vca = dac_max;
11841201 }
11851202 // scale based on velocity
11861203 // curr_filter = curr_filter * velocity;
11871204 // Serial.println(curr_filter);
11881205 // curr_filter = 300;
1189- Serial.println (curr_filter );
1206+ // Serial.println(curr_vca );
11901207
11911208 setOutput (curr_pitch);
11921209 setOutput_filter ((unsigned int )curr_filter);
0 commit comments