Noise Nugget SDK
Loading...
Searching...
No Matches
noise_nugget.h File Reference

API for the Noise Nugget development board, which offers digital audio processing and synthesis. More...

#include <stdint.h>
#include <stdbool.h>
Include dependency graph for noise_nugget.h:

Go to the source code of this file.

Typedefs

typedef void(* audio_cb_t) (uint32_t **buffer, uint32_t *stereo_point_count)
 Defines a callback type for audio processing.
 

Functions

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.
 

Detailed Description

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.

Typedef Documentation

◆ audio_cb_t

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
bufferDouble 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_countPointer 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.

Function Documentation

◆ audio_init()

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.

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_rateThe audio sample rate to be configured. Typical values might include 44100 or 21500 Hz.
output_callbackThe callback function to be invoked when an audio output buffer is required.
input_callbackThe 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
leftenable left channel
rightenable 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
leftenable left channel
rightenable right channel
gainAmplification 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
leftleft channel volume
rightright 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
leftleft channel volume
rightright 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
lineLine identifier between 1 and 3
L2Lleft input into left channel between 0 (mute) and 10
L2Rleft input into right channel between 0 (mute) and 10
R2Lright input into left channel between 0 (mute) and 10
R2Rright 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
L2Lleft channel into left output
L2Rleft channel into right output
R2Lright channel into left output
R2Rright channel into right output
Returns
Returns true on success, false otherwise.