diff --git a/keyboards/planck/config.h b/keyboards/planck/config.h
index 4dd1d22a..5cf96bb8 100644
--- a/keyboards/planck/config.h
+++ b/keyboards/planck/config.h
@@ -36,6 +36,8 @@ along with this program. If not, see .
#define MATRIX_COL_PINS { F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 }
#define UNUSED_PINS
+#define AUDIO_VOICES
+
#define BACKLIGHT_PIN B7
/* COL2ROW or ROW2COL */
diff --git a/keyboards/preonic/config.h b/keyboards/preonic/config.h
index f88acf21..239c29eb 100644
--- a/keyboards/preonic/config.h
+++ b/keyboards/preonic/config.h
@@ -37,6 +37,8 @@ along with this program. If not, see .
#define MATRIX_COL_PINS { F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 }
#define UNUSED_PINS
+#define AUDIO_VOICES
+
#define BACKLIGHT_PIN B7
/* COL2ROW or ROW2COL */
diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c
index 06ff275b..4e302897 100644
--- a/quantum/audio/voices.c
+++ b/quantum/audio/voices.c
@@ -33,6 +33,8 @@ float voice_envelope(float frequency) {
polyphony_rate = 0;
break;
+ #ifdef AUDIO_VOICES
+
case something:
glissando = false;
polyphony_rate = 0;
@@ -58,36 +60,87 @@ float voice_envelope(float frequency) {
case drums:
glissando = false;
polyphony_rate = 0;
- note_timbre = 0;
+ // switch (compensated_index) {
+ // case 0 ... 10:
+ // note_timbre = 0.5;
+ // break;
+ // case 11 ... 20:
+ // note_timbre = 0.5 * (21 - compensated_index) / 10;
+ // break;
+ // default:
+ // note_timbre = 0;
+ // break;
+ // }
+ // frequency = (rand() % (int)(frequency * 1.2 - frequency)) + (frequency * 0.8);
+
+ if (frequency < 80.0) {
+
+ } else if (frequency < 160.0) {
+
+ // Bass drum: 60 - 100 Hz
+ frequency = (rand() % (int)(40)) + 60;
+ switch (envelope_index) {
+ case 0 ... 10:
+ note_timbre = 0.5;
+ break;
+ case 11 ... 20:
+ note_timbre = 0.5 * (21 - envelope_index) / 10;
+ break;
+ default:
+ note_timbre = 0;
+ break;
+ }
+
+ } else if (frequency < 320.0) {
+
+
+ // Snare drum: 1 - 2 KHz
+ frequency = (rand() % (int)(1000)) + 1000;
+ switch (envelope_index) {
+ case 0 ... 5:
+ note_timbre = 0.5;
+ break;
+ case 6 ... 20:
+ note_timbre = 0.5 * (21 - envelope_index) / 15;
+ break;
+ default:
+ note_timbre = 0;
+ break;
+ }
+
+ } else if (frequency < 640.0) {
+
+ // Closed Hi-hat: 3 - 5 KHz
+ frequency = (rand() % (int)(2000)) + 3000;
switch (envelope_index) {
- case 0 ... 20:
+ case 0 ... 15:
note_timbre = 0.5;
+ break;
+ case 16 ... 20:
+ note_timbre = 0.5 * (21 - envelope_index) / 5;
+ break;
default:
- frequency = (rand() % (int)(frequency * 1.2 - frequency)) + (frequency * 0.8);
+ note_timbre = 0;
break;
}
- // if (frequency < 80.0) {
- // switch (envelope_index % 4) {
- // case 0:
- // frequency = 348.0;
- // case 1:
- // frequency = 53.0;
- // case 2:
- // frequency = 128.0;
- // case 3:
- // frequency = 934.0;
- // default:
- // break;
- // }
- // } else if (frequency < 160.0) {
-
- // } else if (frequency < 320.0) {
-
- // } else if (frequency < 640.0) {
-
- // } else if (frequency < 1280.0) {
-
- // }
+
+ } else if (frequency < 1280.0) {
+
+ // Open Hi-hat: 3 - 5 KHz
+ frequency = (rand() % (int)(2000)) + 3000;
+ switch (envelope_index) {
+ case 0 ... 35:
+ note_timbre = 0.5;
+ break;
+ case 36 ... 50:
+ note_timbre = 0.5 * (51 - envelope_index) / 15;
+ break;
+ default:
+ note_timbre = 0;
+ break;
+ }
+
+ }
break;
case butts_fader:
glissando = true;
@@ -217,6 +270,8 @@ float voice_envelope(float frequency) {
// note_timbre = 0.25;
// break;
+ #endif
+
default:
break;
}
diff --git a/quantum/audio/voices.h b/quantum/audio/voices.h
index 72f139e9..52f7e006 100644
--- a/quantum/audio/voices.h
+++ b/quantum/audio/voices.h
@@ -11,6 +11,7 @@ float voice_envelope(float frequency);
typedef enum {
default_voice,
+ #ifdef AUDIO_VOICES
something,
drums,
butts_fader,
@@ -23,6 +24,7 @@ typedef enum {
// duty_fourth_down,
// duty_third_down,
// duty_fifth_third_down,
+ #endif
number_of_voices // important that this is last
} voice_type;