diff options
author | Maximilien Cuony <maximilien@theglu.org> | 2016-06-04 00:24:30 +0200 |
---|---|---|
committer | Maximilien Cuony <maximilien@theglu.org> | 2016-06-04 00:24:30 +0200 |
commit | f4a93ecce5813c9ddf9e5dc4a416777681dc04f9 (patch) | |
tree | 20f9a258417da24fcabb62819f76bf81e60f0834 /src/common/includes/Audio | |
parent | 53c2afbf719d91f660e815c160e73066ef1ec9e0 (diff) | |
download | glutte-o-matic-f4a93ecce5813c9ddf9e5dc4a416777681dc04f9.tar.gz glutte-o-matic-f4a93ecce5813c9ddf9e5dc4a416777681dc04f9.tar.bz2 glutte-o-matic-f4a93ecce5813c9ddf9e5dc4a416777681dc04f9.zip |
Simulator: GPS, Audio, CW
Diffstat (limited to 'src/common/includes/Audio')
-rw-r--r-- | src/common/includes/Audio/audio.h | 50 | ||||
-rw-r--r-- | src/common/includes/Audio/cw.h | 49 |
2 files changed, 99 insertions, 0 deletions
diff --git a/src/common/includes/Audio/audio.h b/src/common/includes/Audio/audio.h new file mode 100644 index 0000000..006f82e --- /dev/null +++ b/src/common/includes/Audio/audio.h @@ -0,0 +1,50 @@ +#ifndef __AUDIO_H__ +#define __AUDIO_H__ + +#include <stdint.h> +#include <stdbool.h> + +typedef void AudioCallbackFunction(void *context,int buffer); + +#define Audio8000HzSettings 256,5,12,1,8000 +#define Audio16000HzSettings 213,2,13,0,16000 +#define Audio32000HzSettings 213,2,6,1,32000 +#define Audio48000HzSettings 258,3,3,1,48000 +#define Audio96000HzSettings 344,2,3,1,96000 +#define Audio22050HzSettings 429,4,9,1,22050 +#define Audio44100HzSettings 271,2,6,0,44100 +#define AudioVGAHSyncSettings 419,2,13,0,31475 // 31475.3606. Actual VGA timer is 31472.4616. + +#define AUDIO_BUF_LEN 4096 + + +// Initialize and power up audio hardware. Use the above defines for the parameters. +// Can probably only be called once. +void audio_initialize(int plln,int pllr,int i2sdiv,int i2sodd, int rate); + +// Power up and down the audio hardware. +void audio_on(); +void audio_off(); + +// Set audio volume in steps of 0.5 dB. 0xff is +12 dB. +void audio_set_volume(int volume); + +// Output one audio sample directly to the hardware without using DMA. +void audio_output_sample(int16_t sample); +void audio_output_sample_without_blocking(int16_t sample); + +// Start and stop audio playback using DMA. +// Callback is optional, and called whenever a new buffer is needed. +void audio_play_with_callback(AudioCallbackFunction *callback,void *context); +void audio_stop(); + +// Provide a new buffer to the audio DMA. Output is double buffered, so +// at least two buffers must be maintained by the program. It is not allowed +// to overwrite the previously provided buffer until after the next callback +// invocation. +// Buffers must reside in DMA1-accessible memory, that is, the 128k RAM bank, +// or flash. +void audio_provide_buffer(void *samples,int numsamples); +bool audio_provide_buffer_without_blocking(void *samples,int numsamples); + +#endif diff --git a/src/common/includes/Audio/cw.h b/src/common/includes/Audio/cw.h new file mode 100644 index 0000000..384918d --- /dev/null +++ b/src/common/includes/Audio/cw.h @@ -0,0 +1,49 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 Matthias P. Braendli + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. +*/ + +#ifndef __CW_H_ +#define __CW_H_ + +#include <stdint.h> +#include <stddef.h> + +// Setup the CW generator to create audio samples at the given +// samplerate. +void cw_psk31_init(unsigned int samplerate); + +// Append new CW or PSK31 text to transmit +// CW/PSK31 audio centre frequency in Hz +// if dit_duration == 0, message is sent in PSK31 +// otherwise it is sent in CW, with dit_duration in ms +// returns 0 on failure, 1 on success +int cw_psk31_push_message(const char* text, int frequency, int dit_duration); + +// Write the waveform into the buffer (stereo), both for cw and psk31 +size_t cw_psk31_fill_buffer(int16_t *buf, size_t bufsize); + +// Return 1 if the CW or PSK31 generator is running +int cw_psk31_busy(void); + +#endif // __CW_H_ + |