diff options
author | Jack Humbert <jack.humb@gmail.com> | 2016-04-22 07:04:13 +0200 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2016-04-22 07:04:13 +0200 |
commit | a8086126fecbdce1c192036cf1011329d406949d (patch) | |
tree | b00149e3808780b8a64fdd7240c207cd95028261 /quantum/audio | |
parent | b1900c8dde2a68e87aaabd84280a99bf6658ea9f (diff) | |
parent | 082a0f313d8c842a5de7bae30ec8a3597e35880b (diff) | |
download | qmk_firmware-a8086126fecbdce1c192036cf1011329d406949d.tar.gz qmk_firmware-a8086126fecbdce1c192036cf1011329d406949d.tar.xz |
Merge remote-tracking branch 'origin/master'
# Conflicts:
# quantum/audio/voices.c
Diffstat (limited to 'quantum/audio')
-rw-r--r-- | quantum/audio/audio.h | 6 | ||||
-rw-r--r-- | quantum/audio/voices.c | 41 | ||||
-rw-r--r-- | quantum/audio/voices.h | 4 |
3 files changed, 32 insertions, 19 deletions
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index d1ccfdb82..89769507e 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -50,8 +50,8 @@ void decrease_vibrato_strength(float change); // Polyphony functions void set_polyphony_rate(float rate); -void enable_polyphony(); -void disable_polyphony(); +void enable_polyphony(void); +void disable_polyphony(void); void increase_polyphony_rate(float change); void decrease_polyphony_rate(float change); @@ -61,7 +61,7 @@ void set_tempo(float tempo); void increase_tempo(uint8_t tempo_change); void decrease_tempo(uint8_t tempo_change); -void audio_init(); +void audio_init(void); #ifdef PWM_AUDIO void play_sample(uint8_t * s, uint16_t l, bool r); diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c index 8b3978f3d..886101187 100644 --- a/quantum/audio/voices.c +++ b/quantum/audio/voices.c @@ -1,4 +1,5 @@ #include "voices.h" +#include "stdlib.h" // these are imported from audio.c extern uint16_t envelope_index; @@ -27,26 +28,31 @@ float voice_envelope(float frequency) { case default_voice: note_timbre = TIMBRE_50; polyphony_rate = 0; - break; + break; + case butts_fader: polyphony_rate = 0; switch (compensated_index) { case 0 ... 9: frequency = frequency / 4; note_timbre = TIMBRE_12; - break; + break; + case 10 ... 19: frequency = frequency / 2; note_timbre = TIMBRE_12; - break; + break; + case 20 ... 200: note_timbre = .125 - pow(((float)compensated_index - 20) / (200 - 20), 2)*.125; - break; + break; + default: note_timbre = 0; - break; + break; } - break; + break; + case octave_crunch: polyphony_rate = 0; switch (compensated_index) { @@ -56,17 +62,20 @@ float voice_envelope(float frequency) { frequency = frequency / 2; note_timbre = TIMBRE_12; break; + case 10 ... 19: case 25 ... 29: case 33 ... 35: frequency = frequency * 2; note_timbre = TIMBRE_12; - break; + break; + default: note_timbre = TIMBRE_12; - break; + break; } - break; + break; + case duty_osc: // This slows the loop down a substantial amount, so higher notes may freeze polyphony_rate = 0; @@ -78,9 +87,10 @@ float voice_envelope(float frequency) { // note_timbre = (sin((float)compensated_index/10000*OCS_SPEED) * OCS_AMP / 2) + .5; // triangle wave is a bit faster note_timbre = (float)abs((compensated_index*OCS_SPEED % 3000) - 1500) * ( OCS_AMP / 1500 ) + (1 - OCS_AMP) / 2; - break; + break; } - break; + break; + case duty_octave_down: polyphony_rate = 0; note_timbre = (envelope_index % 2) * .125 + .375 * 2; @@ -88,18 +98,21 @@ float voice_envelope(float frequency) { note_timbre = 0.5; if ((envelope_index % 8) == 0) note_timbre = 0; - break; + break; case duty_fifth_down: note_timbre = 0.5; if ((envelope_index % 5) == 0) note_timbre = 0.75; - break; + break; case duty_fourth_down: if ((envelope_index % 12) == 0) note_timbre = 0.25; else note_timbre = 0.5; - break; + break; + + default: + break; } return frequency; diff --git a/quantum/audio/voices.h b/quantum/audio/voices.h index 718671f77..cdd14798b 100644 --- a/quantum/audio/voices.h +++ b/quantum/audio/voices.h @@ -22,7 +22,7 @@ typedef enum { } voice_type; void set_voice(voice_type v); -void voice_iterate(); -void voice_deiterate(); +void voice_iterate(void); +void voice_deiterate(void); #endif
\ No newline at end of file |