1
0
Fork 0

Converted audio play functions to *_user (#349)

* Updated personal layouts

* tweaked personal

* Nightly - Audio Cleanup

Refactored the LUTs. Abstracted some of the registers out of audio to
use more functional names. Split audio into audio and audio_pwm. WIP

* nightly - collapsed code

* Added check for note playing to LEDs

* Usability tweaks

* TWEAE

* nightly

added extra kcs to keymap common

* turned on Plank audio

* Added backlight breathing to atomic

* reverted accidental merge

* Added music and audio toggles to Quantum.c

* Redid the audio callbacks

* Adjusted default planck layout to use the user tone naming

* tabs to spaces

* Rewrote the ALL recipe to allow for faster parallel make

* tabs to spaces

* Renamed custom event functions to be 'startup_user' and 'shutdown_user'. Also moved the prototypes around.

* Tweaked pvc atomic layout to work with the pvc planck.

* updates midi scale calling
This commit is contained in:
Jack Humbert 2016-05-24 11:56:53 -04:00
parent 1ae6011cef
commit 287eb7ad14
11 changed files with 214 additions and 281 deletions

View file

@ -475,20 +475,3 @@ void increase_tempo(uint8_t tempo_change) {
note_tempo -= tempo_change;
}
}
//------------------------------------------------------------------------------
// Override these functions in your keymap file to play different tunes on
// startup and bootloader jump
__attribute__ ((weak))
void play_startup_tone() {}
__attribute__ ((weak))
void play_goodbye_tone() {}
__attribute__ ((weak))
void audio_on_user() {}
__attribute__ ((weak))
void play_music_scale() {}
//------------------------------------------------------------------------------

View file

@ -5,6 +5,7 @@
#include "musical_notes.h"
#include "song_list.h"
#include "voices.h"
#include "quantum.h"
#ifndef AUDIO_H
#define AUDIO_H
@ -87,9 +88,4 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest)
bool is_playing_notes(void);
void play_goodbye_tone(void);
void play_startup_tone(void);
void audio_on_user(void);
void play_music_scale(void);
#endif

View file

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "backlight.h"
#include "bootloader.h"
#include "eeconfig.h"
#include "quantum.h"
#ifdef MIDI_ENABLE
#include "keymap_midi.h"
@ -190,7 +191,7 @@ static action_t keycode_to_action(uint16_t keycode)
clear_keyboard();
#ifdef AUDIO_ENABLE
stop_all_notes();
play_goodbye_tone();
shutdown_user();
#endif
_delay_ms(250);
#ifdef ATREUS_ASTAR

View file

@ -23,17 +23,16 @@ int offset = 7;
#ifdef AUDIO_ENABLE
bool music_activated = false;
float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
// music sequencer
static bool music_sequence_recording = false;
static bool music_sequence_playing = false;
static float music_sequence[16] = {0};
static uint8_t music_sequence_count = 0;
static uint8_t music_sequence_position = 0;
// music sequencer
static bool music_sequence_recording = false;
static bool music_sequence_playing = false;
static float music_sequence[16] = {0};
static uint8_t music_sequence_count = 0;
static uint8_t music_sequence_position = 0;
static uint16_t music_sequence_timer = 0;
static uint16_t music_sequence_interval = 100;
static uint16_t music_sequence_timer = 0;
static uint16_t music_sequence_interval = 100;
#endif
@ -133,7 +132,7 @@ bool process_record_quantum(keyrecord_t *record) {
#ifdef MIDI_ENABLE
if (keycode == MI_ON && record->event.pressed) {
midi_activated = true;
play_music_scale();
music_scale_user();
return false;
}
@ -230,37 +229,37 @@ bool process_record_quantum(keyrecord_t *record) {
}
if (keycode == MU_ON && record->event.pressed) {
music_on();
return false;
music_on();
return false;
}
if (keycode == MU_OFF && record->event.pressed) {
music_off();
return false;
music_off();
return false;
}
if (keycode == MU_TOG && record->event.pressed) {
if (music_activated)
{
music_off();
music_off();
}
else
{
music_on();
music_on();
}
return false;
}
if (keycode == MUV_IN && record->event.pressed) {
voice_iterate();
play_music_scale();
return false;
voice_iterate();
music_scale_user();
return false;
}
if (keycode == MUV_DE && record->event.pressed) {
voice_deiterate();
play_music_scale();
return false;
voice_deiterate();
music_scale_user();
return false;
}
if (music_activated) {
@ -272,12 +271,14 @@ bool process_record_quantum(keyrecord_t *record) {
music_sequence_count = 0;
return false;
}
if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing
stop_all_notes();
music_sequence_recording = false;
music_sequence_playing = false;
return false;
}
if (keycode == KC_LGUI && record->event.pressed) { // Start playing
stop_all_notes();
music_sequence_recording = false;
@ -289,12 +290,13 @@ bool process_record_quantum(keyrecord_t *record) {
if (keycode == KC_UP) {
if (record->event.pressed)
music_sequence_interval-=10;
music_sequence_interval-=10;
return false;
}
if (keycode == KC_DOWN) {
if (record->event.pressed)
music_sequence_interval+=10;
music_sequence_interval+=10;
return false;
}
@ -459,5 +461,24 @@ void matrix_scan_quantum() {
}
#endif
//------------------------------------------------------------------------------
// Override these functions in your keymap file to play different tunes on
// different events such as startup and bootloader jump
__attribute__ ((weak))
void startup_user() {}
__attribute__ ((weak))
void shutdown_user() {}
__attribute__ ((weak))
void music_on_user() {}
__attribute__ ((weak))
void audio_on_user() {}
__attribute__ ((weak))
void music_scale_user() {}
//------------------------------------------------------------------------------

View file

@ -67,6 +67,10 @@ void music_toggle(void);
void music_on(void);
void music_off(void);
void startup_user(void);
void shutdown_user(void);
void audio_on_user(void);
void music_on_user(void);
void music_scale_user(void);
#endif