Atmel Software Framework

audio_mixer.c File Reference
#include <stddef.h>
#include "conf_audio_mixer.h"
#include "conf_audio_player.h"
#include "compiler.h"
#include "audio.h"
#include "audio_mixer.h"
#include "board.h"

Macros

#define AUDIO_MIXER_CODEC_COUNT   (sizeof(AUDIO_MIXER_DACS) / sizeof(AUDIO_MIXER_DACS[0]))
 Number of DACs. More...
 

Functions

static void audio_mixer_callback (uint32_t arg)
 Callback function the DACs drivers should invoke when out of samples. More...
 
void audio_mixer_close_direct (void)
 Close the audio_mixer. More...
 
bool audio_mixer_create_buffers_direct (uint8_t nb_buffers, size_t buffer_size)
 Creates DAC buffers. More...
 
void audio_mixer_dacs_decrease_volume_direct (void)
 Decreases the output volume of the DACs. More...
 
void audio_mixer_dacs_flush_direct (bool force)
 Flushes the sample buffer being output to the DACs. More...
 
uint8_t audio_mixer_dacs_get_volume_direct (void)
 Get the average volume of the DACs.
The value returned is in the range 0; 255 where 255 corresponds to the highest volume. More...
 
void audio_mixer_dacs_increase_volume_direct (void)
 Increases the output volume of the DACs. More...
 
bool audio_mixer_dacs_input_direct (void *sample_buffer, size_t sample_length)
 Inputs a sample buffer from the ADCs. More...
 
bool audio_mixer_dacs_is_volume_muted_direct (void)
 Checks if the volume is muted or un-muted.
. More...
 
bool audio_mixer_dacs_output_direct (void *sample_buffer, size_t sample_length)
 Outputs a sample buffer to the DACs. More...
 
void audio_mixer_dacs_set_volume_direct (uint8_t volume)
 set the average volume of the DACs.
More...
 
void audio_mixer_dacs_setup_direct (uint32_t sample_rate_hz, uint8_t num_channels, uint8_t bits_per_sample, bool swap_channels)
 Sets the DACs up with new settings. More...
 
void audio_mixer_dacs_start_direct (uint32_t sample_rate_hz, uint8_t num_channels, uint8_t bits_per_sample, bool swap_channels)
 Starts the DACs. More...
 
void audio_mixer_dacs_stop_direct (void)
 Stops the DACs. More...
 
void audio_mixer_disable_dacs_direct (uint32_t dacs_mask)
 Disables the handling of the specified DACs by the audio mixer. More...
 
void audio_mixer_enable_dacs_direct (uint32_t dacs_mask)
 Enables the handling of the specified DACs by the audio mixer. More...
 
void * audio_mixer_get_buffer_direct (size_t size)
 This functions returns a NULL pointer when no buffer are free, else returns a free temporary buffer. More...
 
void audio_mixer_mute_audio_direct (bool mute)
 Mute Audio if True. More...
 

Variables

struct {
   void(*   decrease_volume )(void)
 
   void(*   flush )(void)
 
   uint8_t(*   get_volume )(void)
 
   void(*   increase_volume )(void)
 
   bool(*   input )(void *sample_buffer, size_t
      sample_length)
 
   bool(*   is_volume_boosted )(void)
 
   bool(*   is_volume_muted )(void)
 
   void(*   mute_audio )(bool mute)
 
   bool(*   output )(void *sample_buffer, size_t
      sample_length)
 
   void(*   set_volume )(uint8_t volume)
 
   void(*   setup )(uint32_t sample_rate_hz,
      uint8_t num_channels, uint8_t
      bits_per_sample, bool
      swap_channels, void(*callback)(uint32_t
      arg), uint32_t callback_opt,
      uint32_t pba_hz)
 
   void(*   start )(uint32_t sample_rate_hz,
      uint8_t num_channels, uint8_t
      bits_per_sample, bool
      swap_channels, void(*callback)(uint32_t
      arg), uint32_t callback_opt,
      uint32_t pba_hz)
 
   void(*   stop )(void)
 
AUDIO_MIXER_DACS [] = AUDIO_MIXER_DACS_INTERFACES
 DACs interfaces. More...
 
struct {
   uint8_t   bits_per_sample
 
   void **   buffers
 
   uint8_t   current_buffer
 
   uint8_t   nb_buffers
 
   uint8_t   num_channels
 
   uint32_t   sample_rate_hz
 
   bool   swap_channels
 
audio_mixer_dacs_settings
 DACs settings. More...
 
static uint32_t audio_mixer_enabled_dacs_mask = 0x00000000
 Enabled DACs mask. More...
 

static void audio_mixer_callback ( uint32_t  arg)
static
void audio_mixer_close_direct ( void  )

Close the audio_mixer.

References audio_mixer_dacs_settings, i, and NULL.

bool audio_mixer_create_buffers_direct ( uint8_t  nb_buffers,
size_t  buffer_size 
)

Creates DAC buffers.

References audio_mixer_dacs_settings, buffers, i, j, and nb_buffers.

void audio_mixer_dacs_decrease_volume_direct ( void  )

Decreases the output volume of the DACs.

Note
The DACs must have been started beforehand.

References AUDIO_MIXER_CODEC_COUNT, AUDIO_MIXER_DACS, audio_mixer_enabled_dacs_mask, and i.

void audio_mixer_dacs_flush_direct ( bool  force)

Flushes the sample buffer being output to the DACs.

Parameters
forceForce flushing means do not wait until all samples have been played before flushing the DAC.

References AUDIO_MIXER_CODEC_COUNT, AUDIO_MIXER_DACS, audio_mixer_enabled_dacs_mask, and i.

Referenced by audio_speaker_set_sample_freq(), buff_player_dacs_flush(), player_shutdown(), and usb_stream_new_sample_rate().

uint8_t audio_mixer_dacs_get_volume_direct ( void  )

Get the average volume of the DACs.
The value returned is in the range 0; 255 where 255 corresponds to the highest volume.

Note
The DACs must have been started beforehand.

References AUDIO_MIXER_CODEC_COUNT, AUDIO_MIXER_DACS, audio_mixer_enabled_dacs_mask, count, i, and volume.

void audio_mixer_dacs_increase_volume_direct ( void  )

Increases the output volume of the DACs.

Note
The DACs must have been started beforehand.

References AUDIO_MIXER_CODEC_COUNT, AUDIO_MIXER_DACS, audio_mixer_enabled_dacs_mask, and i.

bool audio_mixer_dacs_input_direct ( void *  sample_buffer,
size_t  sample_length 
)

Inputs a sample buffer from the ADCs.

Note
The ADCs must have been started beforehand.

References AUDIO_MIXER_CODEC_COUNT, AUDIO_MIXER_DACS, audio_mixer_enabled_dacs_mask, i, and input.

bool audio_mixer_dacs_is_volume_muted_direct ( void  )

Checks if the volume is muted or un-muted.
.

Note
The DACs must have been started beforehand.

References AUDIO_MIXER_CODEC_COUNT, AUDIO_MIXER_DACS, audio_mixer_enabled_dacs_mask, count, and i.

bool audio_mixer_dacs_output_direct ( void *  sample_buffer,
size_t  sample_length 
)
void audio_mixer_dacs_set_volume_direct ( uint8_t  volume)

set the average volume of the DACs.

Note
The DACs must have been started beforehand.

References AUDIO_MIXER_CODEC_COUNT, AUDIO_MIXER_DACS, audio_mixer_enabled_dacs_mask, count, and i.

Referenced by audio_speaker_set_mute(), and audio_speaker_set_volume().

void audio_mixer_dacs_setup_direct ( uint32_t  sample_rate_hz,
uint8_t  num_channels,
uint8_t  bits_per_sample,
bool  swap_channels 
)
void audio_mixer_dacs_stop_direct ( void  )
void audio_mixer_disable_dacs_direct ( uint32_t  dacs_mask)

Disables the handling of the specified DACs by the audio mixer.

References AUDIO_MIXER_CODEC_COUNT, AUDIO_MIXER_DACS, audio_mixer_dacs_settings, audio_mixer_enabled_dacs_mask, and i.

void audio_mixer_enable_dacs_direct ( uint32_t  dacs_mask)

Enables the handling of the specified DACs by the audio mixer.

References audio_mixer_dacs_settings, audio_mixer_dacs_start_direct(), and audio_mixer_enabled_dacs_mask.

void* audio_mixer_get_buffer_direct ( size_t  size)

This functions returns a NULL pointer when no buffer are free, else returns a free temporary buffer.

References audio_mixer_dacs_output, audio_mixer_dacs_settings, buffer, and NULL.

void audio_mixer_mute_audio_direct ( bool  mute)

Mute Audio if True.

Parameters
muteSet to true to mute the audio stream.
Set to false otherwise.

References AUDIO_MIXER_CODEC_COUNT, AUDIO_MIXER_DACS, audio_mixer_enabled_dacs_mask, and i.

Referenced by buff_player_mute_audio().

struct { ... } audio_mixer_dacs_settings
Initial value:
=
{
.sample_rate_hz = 0,
.num_channels = 0,
.bits_per_sample = 0,
.swap_channels = false,
.nb_buffers = 0,
.current_buffer = 0,
.buffers = NULL
}
#define NULL
Definition: lwip-1.4.0/src/include/lwip/def.h:47

DACs settings.

Referenced by audio_mixer_close_direct(), audio_mixer_create_buffers_direct(), audio_mixer_dacs_setup_direct(), audio_mixer_dacs_start_direct(), audio_mixer_dacs_stop_direct(), audio_mixer_disable_dacs_direct(), audio_mixer_enable_dacs_direct(), and audio_mixer_get_buffer_direct().

void** buffers
void(* decrease_volume)(void)
void(* flush)(void)
uint8_t(* get_volume)(void)
void(* increase_volume)(void)
bool(* is_volume_boosted)(void)
bool(* is_volume_muted)(void)
void(* mute_audio)(bool mute)
uint8_t nb_buffers
void(* set_volume)(uint8_t volume)
void(* setup)(uint32_t sample_rate_hz, uint8_t num_channels, uint8_t bits_per_sample, bool swap_channels, void(*callback)(uint32_t arg), uint32_t callback_opt, uint32_t pba_hz)

Referenced by uhd_ctrl_phase_setup().

void(* stop)(void)