Browse Source

unison key stack fix

vampirefrog 3 years ago
parent
commit
9ac8d4ca42
3 changed files with 11 additions and 3 deletions
  1. 0
    1
      envelope.c
  2. 1
    1
      patches/bass.patch
  3. 10
    1
      synth.c

+ 0
- 1
envelope.c View File

@@ -11,7 +11,6 @@ void envelope_init(struct Envelope *env) {
11 11
 	envelope_set_sustain_level(env, 1.0);
12 12
 	envelope_set_target_ratio_a(env, 0.3);
13 13
 	envelope_set_target_ratio_dr(env, 0.0001);
14
-	printf("envelope_init()\n");
15 14
 }
16 15
 
17 16
 void envelope_reset(struct Envelope *env) {

+ 1
- 1
patches/bass.patch View File

@@ -4,7 +4,7 @@ osc_env.decay 0
4 4
 osc_env.sustain .4
5 5
 osc_env.release 0
6 6
 filter_env.attack 100
7
-filter_env.decay 40000
7
+filter_env.decay 50000
8 8
 filter_env.sustain 0
9 9
 filter_env.release 100
10 10
 filter_eg_intensity 1

+ 10
- 1
synth.c View File

@@ -134,7 +134,16 @@ static void synth_note_off_monophonic(struct Synth *synth) {
134 134
 void synth_note_off(struct Synth *synth, uint8_t note, uint8_t velocity) {
135 135
 	if(synth->monophonic) {
136 136
 		if(synth->key_stack_size > 1) {
137
-			synth_note_on_monophonic(synth, synth->key_stack[synth->key_stack_size - 2].note, synth->key_stack[synth->key_stack_size - 2].velocity);
137
+			if(synth->key_stack[synth->key_stack_size - 1].note == note) {
138
+				synth_note_on_monophonic(synth, synth->key_stack[synth->key_stack_size - 2].note, synth->key_stack[synth->key_stack_size - 2].velocity);
139
+			} else {
140
+				for(int i = 0; i < synth->key_stack_size - 1; i++) {
141
+					if(synth->key_stack[i].note == note) {
142
+						memmove(synth->key_stack + i, synth->key_stack + i + 1, sizeof(synth->key_stack[0]) * (synth->key_stack_size - i - 1));
143
+						break;
144
+					}
145
+				}
146
+			}
138 147
 		} else {
139 148
 			synth_note_off_monophonic(synth);
140 149
 		}

Loading…
Cancel
Save