API for the Noise Nugget development board, which offers digital audio processing and synthesis.
More...
#include <stdint.h>
#include <stdbool.h>
Go to the source code of this file.
|
typedef void(* | audio_cb_t) (uint32_t **buffer, uint32_t *stereo_point_count) |
| Defines a callback type for audio processing.
|
|
|
bool | audio_init (int sample_rate, audio_cb_t output_callback, audio_cb_t input_callback) |
| Initializes the audio system of the Noise Nugget board.
|
|
bool | enable_line_out (bool left, bool right) |
| Enable line level output.
|
|
bool | enable_speakers (bool left, bool right, uint8_t gain) |
| Enable speaker amp.
|
|
bool | set_line_out_volume (float L2L, float L2R, float R2L, float R2R) |
| Set volume for line output (and speakers)
|
|
bool | set_adc_volume (float left, float right) |
| Set ADC (Analog to Digital Converter) volume.
|
|
bool | set_hp_volume (float left, float right) |
| Set Headphone output volume.
|
|
bool | set_line_in_boost (uint8_t line, uint8_t L2L, uint8_t L2R, uint8_t R2L, uint8_t R2R) |
| Set line input boost.
|
|
bool | enable_mic_bias (void) |
| Enable microphone bias.
|
|
API for the Noise Nugget development board, which offers digital audio processing and synthesis.
This file provides the initialization functions and callback mechanisms needed to interface with the Noise Nugget's audio processing capabilities.
◆ audio_cb_t
Defines a callback type for audio processing.
This callback function is used by the Noise Nugget development board to handle audio data processing. The function will be called when audio data needs to be output or input through the board. The callback must return as fast as possible to not interrupt the flow of sample being played/recorded. Therefore any audio synthesis or processing must be done separately, for instance using flip buffers, the callbacks are just here to provide pointers to the next fresh buffers.
- Parameters
-
buffer | Double pointer to the audio data buffer. Set *buffer with the address of the next stereo audio samples (uint32_t) to be played/recorded, or set *buffer to NULL if there is no buffer available. |
stereo_point_count | Pointer to the number of stereo points (left-right pairs) available in the buffer. Set *stereo_point_count to specified the size of the buffer to be played/recorded. |
◆ audio_init()
Initializes the audio system of the Noise Nugget board.
This function initializes the audio system with a specified sample rate and sets up the necessary callback functions for audio data input and output.
- Parameters
-
sample_rate | The audio sample rate to be configured. Typical values might include 44100 or 21500 Hz. |
output_callback | The callback function to be invoked when an audio output buffer is required. |
input_callback | The callback function to be invoked when an audio input buffer is required. |
- Returns
- Returns true if the audio system was successfully initialized, false otherwise.
◆ enable_line_out()
bool enable_line_out |
( |
bool |
left, |
|
|
bool |
right |
|
) |
| |
Enable line level output.
- Parameters
-
left | enable left channel |
right | enable right channel |
- Returns
- Returns true on success, false otherwise.
◆ enable_mic_bias()
bool enable_mic_bias |
( |
void |
| ) |
|
Enable microphone bias.
Mircophone bias is a small voltage providing power to a microphone (typically and electret condenser microphone).
- Returns
- Returns true on success, false otherwise.
◆ enable_speakers()
bool enable_speakers |
( |
bool |
left, |
|
|
bool |
right, |
|
|
uint8_t |
gain |
|
) |
| |
Enable speaker amp.
- Parameters
-
left | enable left channel |
right | enable right channel |
gain | Amplification gain between 0 and 3 |
- Returns
- Returns true on success, false otherwise.
◆ set_adc_volume()
bool set_adc_volume |
( |
float |
left, |
|
|
float |
right |
|
) |
| |
Set ADC (Analog to Digital Converter) volume.
- Parameters
-
left | left channel volume |
right | right channel volume |
- Returns
- Returns true on success, false otherwise.
◆ set_hp_volume()
bool set_hp_volume |
( |
float |
left, |
|
|
float |
right |
|
) |
| |
Set Headphone output volume.
- Parameters
-
left | left channel volume |
right | right channel volume |
- Returns
- Returns true on success, false otherwise.
◆ set_line_in_boost()
bool set_line_in_boost |
( |
uint8_t |
line, |
|
|
uint8_t |
L2L, |
|
|
uint8_t |
L2R, |
|
|
uint8_t |
R2L, |
|
|
uint8_t |
R2R |
|
) |
| |
Set line input boost.
Both left and right channels of each lines 1 and 3 can be routed to left and/or right line ADC channels. This can used to produce stereo sound from a single microphone.
- Parameters
-
line | Line identifier between 1 and 3 |
L2L | left input into left channel between 0 (mute) and 10 |
L2R | left input into right channel between 0 (mute) and 10 |
R2L | right input into left channel between 0 (mute) and 10 |
R2R | right input into right channel between 0 (mute) and 10 |
- Returns
- Returns true on success, false otherwise.
◆ set_line_out_volume()
bool set_line_out_volume |
( |
float |
L2L, |
|
|
float |
L2R, |
|
|
float |
R2L, |
|
|
float |
R2R |
|
) |
| |
Set volume for line output (and speakers)
Both left and right DAC channels can be routed to left and/or right line outputs. This can used to mix left and right channels into a single speaker for instance.
- Parameters
-
L2L | left channel into left output |
L2R | left channel into right output |
R2L | right channel into left output |
R2R | right channel into right output |
- Returns
- Returns true on success, false otherwise.