diff options
author | inmarket <andrewh@inmarket.com.au> | 2014-03-11 17:13:31 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2014-03-11 17:13:31 +1000 |
commit | ea5a1b849df6e5085a92957ad387f9e653674415 (patch) | |
tree | 72ede5ed78263a6fdba25039398b5c2a55bd1d3a /src/gaudin | |
parent | 944c33cbff5f2cfb1c80f48193aa2161574864fd (diff) | |
download | uGFX-ea5a1b849df6e5085a92957ad387f9e653674415.tar.gz uGFX-ea5a1b849df6e5085a92957ad387f9e653674415.tar.bz2 uGFX-ea5a1b849df6e5085a92957ad387f9e653674415.zip |
Combine GAUDIN and GAUDOUT into a single GAUDIO module.
Simplify GAUDIN (now GAUDIO RECORD) api.
Update audio demo's to match.
Port Win32 driver to new audio api.
Diffstat (limited to 'src/gaudin')
-rw-r--r-- | src/gaudin/driver.h | 102 | ||||
-rw-r--r-- | src/gaudin/gaudin.c | 158 | ||||
-rw-r--r-- | src/gaudin/sys_defs.h | 174 | ||||
-rw-r--r-- | src/gaudin/sys_make.mk | 1 | ||||
-rw-r--r-- | src/gaudin/sys_options.h | 32 | ||||
-rw-r--r-- | src/gaudin/sys_rules.h | 30 |
6 files changed, 0 insertions, 497 deletions
diff --git a/src/gaudin/driver.h b/src/gaudin/driver.h deleted file mode 100644 index b534e2a5..00000000 --- a/src/gaudin/driver.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file is subject to the terms of the GFX License. If a copy of - * the license was not distributed with this file, you can obtain one at: - * - * http://ugfx.org/license.html - */ - -/** - * @file src/gaudin/driver.h - * @brief GAUDIN - Audio Input driver header file. - * - * @defgroup Driver Driver - * @ingroup GAUDIN - * @{ - */ - -#ifndef _GAUDIN_LLD_H -#define _GAUDIN_LLD_H - -#include "gfx.h" - -#if GFX_USE_GAUDIN || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Type definitions */ -/*===========================================================================*/ - -/** - * @brief The structure passed to start a audio conversion - * @note We use the structure instead of parameters purely to save - * interrupt stack space which is very limited in some platforms. - * @{ - */ -typedef struct gaudin_params_t { - uint16_t channel; - uint32_t frequency; - audin_sample_t *buffer; - size_t bufcount; - size_t samplesPerEvent; - } gaudin_params; -/** @} */ - -/** - * @brief These routines are the callbacks that the driver uses. - * @details Defined in the high level GAUDIN code. - * - * @iclass - * @notapi - * - * @{ - */ - -/** - * @param[in] buffer The buffer - * @param[in] n The amount of samples - * */ -extern void GAUDIN_ISR_CompleteI(audin_sample_t *buffer, size_t n); - -extern void GAUDIN_ISR_ErrorI(void); -/** - * @} - */ - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Initialise the driver - * - * @param[in] paud Initialisation parameters - * - * @api - */ -void gaudin_lld_init(const gaudin_params *paud); - -/** - * @brief Start the audio input sampling - * - * @api - */ -void gaudin_lld_start(void); - -/** - * @brief Stop the audio input sampling - * - * @api - */ -void gaudin_lld_stop(void); - -#ifdef __cplusplus -} -#endif - -#endif /* GFX_USE_GADC */ - -#endif /* _GADC_LLD_H */ -/** @} */ diff --git a/src/gaudin/gaudin.c b/src/gaudin/gaudin.c deleted file mode 100644 index 2e3507ef..00000000 --- a/src/gaudin/gaudin.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * This file is subject to the terms of the GFX License. If a copy of - * the license was not distributed with this file, you can obtain one at: - * - * http://ugfx.org/license.html - */ - -/** - * @file src/gaudin/gaudin.c - * @brief GAUDIN sub-system code. - * - * @addtogroup GAUDIN - * @{ - */ -#include "gfx.h" - -#if GFX_USE_GAUDIN - -/* Include the driver defines */ -#include "src/gaudin/driver.h" - -static gaudin_params aud; -static gfxSem *paudSem; -static GEventAudioIn *paudEvent; -static audin_sample_t *lastbuffer; -static size_t lastcount; -static uint16_t audFlags; - #define AUDFLG_RUNNING 0x0001 - #define AUDFLG_USE_EVENTS 0x0002 - -#if GFX_USE_GEVENT - static GTimer AudGTimer; - - static void AudGTimerCallback(void *param) { - (void) param; - GSourceListener *psl; - GEventADC *pe; - - psl = 0; - while ((psl = geventGetSourceListener((GSourceHandle)(&aud), psl))) { - if (!(pe = (GEventAudioIn *)geventGetEventBuffer(psl))) { - // This listener is missing - save this. - psl->srcflags |= GAUDIN_LOSTEVENT; - continue; - } - - pe->type = GEVENT_AUDIO_IN; - pe->channel = aud.channel; - pe->count = lastcount; - pe->buffer = lastbuffer; - pe->flags = psl->srcflags; - psl->srcflags = 0; - geventSendEvent(psl); - } - } -#endif - -void GAUDIN_ISR_CompleteI(audin_sample_t *buffer, size_t n) { - /* Save the details */ - lastcount = n; - lastbuffer = buffer; - - /* Signal the user with the data */ - if (paudEvent) { - #if GFX_USE_GEVENT - paudEvent->type = GEVENT_AUDIO_IN; - #endif - paudEvent->channel = aud.channel; - paudEvent->count = lastcount; - paudEvent->buffer = lastbuffer; - paudEvent->flags = 0; - } - - /* Our two signalling mechanisms */ - if (paudSem) - gfxSemSignalI(paudSem); - - #if GFX_USE_GEVENT - if (audFlags & AUDFLG_USE_EVENTS) - gtimerJabI(&AudGTimer); - #endif -} - -void GAUDIN_ISR_ErrorI(void) { - /* Ignore any errors for now */ -} - -void _gaudinInit(void) -{ - #if GFX_USE_GEVENT - gtimerInit(&AudGTimer); - #endif -} - -void _gaudinDeinit(void) -{ - // Commented stuff still ToDo - #if GFX_USE_GEVENT - gtimerDeinit(&AudGTimer); - #endif -} - -bool_t gaudinInit(uint16_t channel, uint32_t frequency, audin_sample_t *buffer, size_t bufcount, size_t samplesPerEvent) { - /* Check the channel is valid */ - if (channel >= GAUDIN_NUM_CHANNELS || frequency > GAUDIN_MAX_SAMPLE_FREQUENCY) - return FALSE; - - /* Stop any existing transfers */ - if ((audFlags & AUDFLG_RUNNING)) - gaudin_lld_stop(); - audFlags = 0; - - /* Initialise everything */ - aud.channel = channel; - aud.frequency = frequency; - aud.buffer = buffer; - aud.bufcount = bufcount; - aud.samplesPerEvent = samplesPerEvent; - paudSem = 0; - paudEvent = 0; - - /* Set up the low level driver */ - gaudin_lld_init(&aud); - return TRUE; -} - -#if GFX_USE_GEVENT - GSourceHandle gaudinGetSource(void) { - if (!gtimerIsActive(&AudGTimer)) - gtimerStart(&AudGTimer, AudGTimerCallback, 0, TRUE, TIME_INFINITE); - audFlags |= AUDFLG_USE_EVENTS; - return (GSourceHandle)&aud; - } -#endif - -void gaudinSetBSem(gfxSem *pbsem, GEventAudioIn *pEvent) { - gfxSystemLock(); - paudSem = pbsem; - paudEvent = pEvent; - gfxSystemUnlock(); -} - -void gaudinStart(void) { - if (!(audFlags & AUDFLG_RUNNING)) { - audFlags |= AUDFLG_RUNNING; - gaudin_lld_start(); - } -} - -void gaudinStop(void) { - if ((audFlags & AUDFLG_RUNNING)) { - gaudin_lld_stop(); - audFlags &= ~AUDFLG_RUNNING; - } -} - -#endif /* GFX_USE_GAUDIN */ -/** @} */ diff --git a/src/gaudin/sys_defs.h b/src/gaudin/sys_defs.h deleted file mode 100644 index c65a69c1..00000000 --- a/src/gaudin/sys_defs.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * This file is subject to the terms of the GFX License. If a copy of - * the license was not distributed with this file, you can obtain one at: - * - * http://ugfx.org/license.html - */ - -/** - * @file src/gaudin/sys_defs.h - * - * @addtogroup GAUDIN - * - * @brief Module to read audio inputs - * - * @{ - */ - -#ifndef _GAUDIN_H -#define _GAUDIN_H - -#include "gfx.h" - -#if GFX_USE_GAUDIN || defined(__DOXYGEN__) - -/* Include the driver defines */ -#include "gaudin_lld_config.h" - -/*===========================================================================*/ -/* Type definitions */ -/*===========================================================================*/ - -// Event types for GAUDIN -#define GEVENT_AUDIO_IN (GEVENT_GAUDIN_FIRST+0) - -/** - * @brief The Audio Input event structure. - * @{ - */ -typedef struct GEventAudioIn_t { - #if GFX_USE_GEVENT || defined(__DOXYGEN__) - /** - * @brief The type of this event (GEVENT_AUDIO_IN) - */ - GEventType type; - #endif - /** - * @brief The current channel - */ - uint16_t channel; - /** - * @brief The event flags - */ - uint16_t flags; - /** - * @brief The event flag values. - * @{ - */ - #define GAUDIN_LOSTEVENT 0x0001 /**< @brief The last GEVENT_AUDIO_IN event was lost */ - /** @} */ - /** - * @brief The number of audio samples in the buffer - */ - size_t count; - /** - * @brief The buffer containing the audio samples - */ - audin_sample_t *buffer; -} GEventAudioIn; -/** @} */ - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Initialise (but not start) the Audio Input Subsystem. - * @details Returns FALSE for an invalid channel or other invalid parameter. - * - * @param[in] channel The channel to convert. Can be set from 0 to GAUDIN_NUM_CHANNELS - 1. - * @param[in] frequency The sample frequency - * @param[in] buffer The static buffer to put the samples into. - * @param[in] bufcount The total number of conversions that will fit in the buffer. - * @param[in] samplesPerEvent The number of conversions to do before returning an event. - * - * @note Only one channel is active at a time. If an audio input is running it will be stopped. - * The Event subsystem is disconnected from the audio subsystem and any binary semaphore - * event is forgotten. - * @note Some channels may be stereo channels which return twice as much sample data with - * the left and right channel data interleaved. Other channels may be mono channels. - * Where stereo channels exist it would be common for the low level driver to also - * offer the left and right channels separately. - * @note Due to a bug in Chibi-OS countPerEvent must be even if using the GADC low level audio driver. - * If bufcount is not evenly divisable by countPerEvent, the remainder must also be even. - * This requirement may not apply to other GAUDIN drivers. - * @note The number of samples for stereo devices will be double the number of conversions. - * Make sure you allocate your buffers large enough. Each channel is then interleaved - * into the provided buffer. Note 'bufcount' and 'countPerEvent' parameters describe the - * number of conversions not the number of samples. - * @note The buffer is circular. When the end of the buffer is reached it will start - * putting data into the beginning of the buffer again. - * @note The event listener must process the event (and the data in it) before the - * next event occurs. If not, the following event will be lost. - * @note If bufcount is evenly divisable by countPerEvent, then every event will return - * countPerEvent conversions. If bufcount is not evenly divisable, it will return - * a block of samples containing less than countPerEvent samples when it reaches the - * end of the buffer. - * - * @return FALSE if invalid channel or parameter - * - * @api - */ -bool_t gaudinInit(uint16_t channel, uint32_t frequency, audin_sample_t *buffer, size_t bufcount, size_t samplesPerEvent); - -#if GFX_USE_GEVENT || defined(__DOXYGEN__) - /** - * @brief Turn on sending results to the GEVENT sub-system. - * @details Returns a GSourceHandle to listen for GEVENT_AUDIO_IN events. - * - * @note The audio input will not use the GEVENT system unless this is - * called first. This saves processing time if the application does - * not want to use the GEVENT sub-system for audio input. - * Once turned on it can only be turned off by calling @p gaudinInit() again. - * @note The audio input is capable of signalling via this method and a binary semaphore - * at the same time. - * - * @return The GSourceHandle - * - * @api - */ - GSourceHandle gaudinGetSource(void); -#endif - -/** - * @brief Allow retrieving of results from the audio input using a Binary Semaphore and a static event buffer. - * - * @param[in] pbsem The semaphore is signaled when data is available. - * @param[in] pEvent The static event buffer to place the result information. - * - * @note Passing a NULL for pbsem or pEvent will turn off signalling via this method. - * @note The audio input is capable of signalling via this method and the GEVENT - * sub-system at the same time. - * - * @api - */ -void gaudinSetBSem(gfxSem *pbsem, GEventAudioIn *pEvent); - -/** - * @brief Start the audio input conversions. - * @pre It must have been initialised first with @p gaudinInit() - * - * @api - */ -void gaudinStart(void); - -/** - * @brief Stop the audio input conversions. - * - * @api - */ -void gaudinStop(void); - -#ifdef __cplusplus -} -#endif - -#endif /* GFX_USE_GAUDIN */ - -#endif /* _GAUDIN_H */ -/** @} */ - diff --git a/src/gaudin/sys_make.mk b/src/gaudin/sys_make.mk deleted file mode 100644 index 16bb33b7..00000000 --- a/src/gaudin/sys_make.mk +++ /dev/null @@ -1 +0,0 @@ -GFXSRC += $(GFXLIB)/src/gaudin/gaudin.c diff --git a/src/gaudin/sys_options.h b/src/gaudin/sys_options.h deleted file mode 100644 index 305a6f8d..00000000 --- a/src/gaudin/sys_options.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is subject to the terms of the GFX License. If a copy of - * the license was not distributed with this file, you can obtain one at: - * - * http://ugfx.org/license.html - */ - -/** - * @file src/gaudin/sys_options.h - * @brief GAUDIN - Audio Input subsystem options header file. - * - * @addtogroup GAUDIN - * @{ - */ - -#ifndef _GAUDIN_OPTIONS_H -#define _GAUDIN_OPTIONS_H - -/** - * @name GAUDIN Functionality to be included - * @{ - */ -/** - * @} - * - * @name GAUDIN Optional Sizing Parameters - * @{ - */ -/** @} */ - -#endif /* _GAUDIN_OPTIONS_H */ -/** @} */ diff --git a/src/gaudin/sys_rules.h b/src/gaudin/sys_rules.h deleted file mode 100644 index 21d2552f..00000000 --- a/src/gaudin/sys_rules.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is subject to the terms of the GFX License. If a copy of - * the license was not distributed with this file, you can obtain one at: - * - * http://ugfx.org/license.html - */ - -/** - * @file src/gaudin/sys_rules.h - * @brief GAUDIN safety rules header file. - * - * @addtogroup GAUDIN - * @{ - */ - -#ifndef _GAUDIN_RULES_H -#define _GAUDIN_RULES_H - -#if GFX_USE_GAUDIN - #if GFX_USE_GEVENT && !GFX_USE_GTIMER - #if GFX_DISPLAY_RULE_WARNINGS - #warning "GAUDIN: GFX_USE_GTIMER is required if GFX_USE_GAUDIN and GFX_USE_GEVENT are TRUE. It has been turned on for you." - #endif - #undef GFX_USE_GTIMER - #define GFX_USE_GTIMER TRUE - #endif -#endif - -#endif /* _GAUDIN_RULES_H */ -/** @} */ |