/* Copyright 2016-2020 Jack Humbert
* Copyright 2020 JohSchneider
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
typedef union audio_config_t;
// AVR/LUFA has a MIN, arm/chibios does not
/*
* a 'musical note' is represented by pitch and duration; a 'musical tone' adds intensity and timbre
* https://en.wikipedia.org/wiki/Musical_tone
* "A musical tone is characterized by its duration, pitch, intensity (or loudness), and timbre (or quality)"
*/
typedef struct musical_tone_t;
// public interface
/**
* @brief one-time initialization called by quantum/quantum.c
* @details usually done lazy, when some tones are to be played
*
* @post audio system (and hardware) initialized and ready to play tones
*/
void ;
void ;
/**
* @brief en-/disable audio output, save this choice to the eeprom
*/
void ;
/**
* @brief enable audio output, save this choice to the eeprom
*/
void ;
/**
* @brief disable audio output, save this choice to the eeprom
*/
void ;
/**
* @brief query the if audio output is enabled
*/
bool ;
/**
* @brief start playback of a tone with the given frequency and duration
*
* @details starts the playback of a given note, which is automatically stopped
* at the the end of its duration = fire&forget
*
* @param[in] pitch frequency of the tone be played
* @param[in] duration in milliseconds, use 'audio_duration_to_ms' to convert
* from the musical_notes.h unit to ms
*/
void ;
// TODO: audio_play_note(float pitch, uint16_t duration, float intensity, float timbre);
// audio_play_note_with_instrument ifdef AUDIO_ENABLE_VOICES
/**
* @brief start playback of a tone with the given frequency
*
* @details the 'frequency' is put on-top the internal stack of active tones,
* as a new tone with indefinite duration. this tone is played by
* the hardware until a call to 'audio_stop_tone'.
* should a tone with that frequency already be active, its entry
* is put on the top of said internal stack - so no duplicate
* entries are kept.
* 'hardware_start' is called upon the first note.
*
* @param[in] pitch frequency of the tone be played
*/
void ;
/**
* @brief stop a given tone/frequency
*
* @details removes a tone matching the given frequency from the internal
* playback stack
* the hardware is stopped in case this was the last/only frequency
* being played.
*
* @param[in] pitch tone/frequency to be stopped
*/
void ;
/**
* @brief play a melody
*
* @details starts playback of a melody passed in from a SONG definition - an
* array of {pitch, duration} float-tuples
*
* @param[in] np note-pointer to the SONG array
* @param[in] n_count number of MUSICAL_NOTES of the SONG
* @param[in] n_repeat false for onetime, true for looped playback
*/
void ;
/**
* @brief play a short tone of a specific frequency to emulate a 'click'
*
* @details constructs a two-note melody (one pause plus a note) and plays it through
* audio_play_melody. very short durations might not quite work due to
* hardware limitations (DAC: added pulses from zero-crossing feature;...)
*
* @param[in] delay in milliseconds, length for the pause before the pulses, can be zero
* @param[in] pitch
* @param[in] duration in milliseconds, length of the 'click'
*/
void ;
/**
* @brief stops all playback
*
* @details stops playback of both a melody as well as single tones, resetting
* the internal state
*/
void ;
/**
* @brief query if one/multiple tones are playing
*/
bool ;
/**
* @brief query if a melody/SONG is playing
*/
bool ;
// These macros are used to allow audio_play_melody to play an array of indeterminate
// length. This works around the limitation of C's sizeof operation on pointers.
// The global float array for the song must be used here.
/**
* @brief convenience macro, to play a melody/SONG once
*/
// TODO: a 'song' is a melody plus singing/vocals -> PLAY_MELODY
/**
* @brief convenience macro, to play a melody/SONG in a loop, until stopped by 'audio_stop_all'
*/
// Tone-Multiplexing functions
// this feature only makes sense for hardware setups which can't do proper
// audio-wave synthesis = have no DAC and need to use PWM for tone generation
// 0=off, good starting value is 4; the lower the value the higher the cpu-load
void ;
void ;
void ;
void ;
void ;
// Tempo functions
void ;
void ;
void ;
// conversion macros, from 64parts-to-a-beat to milliseconds and back
uint16_t ;
uint16_t ;
void ;
// hardware interface
// implementation in the driver_avr/arm_* respective parts
void ;
void ;
void ;
/**
* @brief get the number of currently active tones
* @return number, 0=none active
*/
uint8_t ;
/**
* @brief access to the raw/unprocessed frequency for a specific tone
* @details each active tone has a frequency associated with it, which
* the internal state keeps track of, and is usually influenced
* by various effects
* @param[in] tone_index, ranging from 0 to number_of_active_tones-1, with the
* first being the most recent and each increment yielding the next
* older one
* @return a positive frequency, in Hz; or zero if the tone is a pause
*/
float ;
/**
* @brief calculate and return the frequency for the requested tone
* @details effects like glissando, vibrato, ... are post-processed onto the
* each active tones 'base'-frequency; this function returns the
* post-processed result.
* @param[in] tone_index, ranging from 0 to number_of_active_tones-1, with the
* first being the most recent and each increment yielding the next
* older one
* @return a positive frequency, in Hz; or zero if the tone is a pause
*/
float ;
/**
* @brief update audio internal state: currently playing and active tones,...
* @details This function is intended to be called by the audio-hardware
* specific implementation on a somewhat regular basis while a SONG
* or notes (pitch+duration) are playing to 'advance' the internal
* state (current playing notes, position in the melody, ...)
*
* @return true if something changed in the currently active tones, which the
* hardware might need to react to
*/
bool ;
// legacy and back-warts compatibility stuff
// vibrato functions are not used in any keyboards