Skip to content

Group ns-audio

Modules > ns-audio

Classes

Type Name
struct ns_audadc_cfg_t
AUDADC Configuration.
struct ns_audio_cfg
struct ns_pdm_cfg_t
PDM Configuration.

Public Types

Type Name
enum ns_audio_api_mode_e
Audio IPC Modes.
typedef void(* ns_audio_callback_cb
Invoked by IRQ when audio buffer is ready.
enum ns_audio_clksel_e
Audio Clock Source.
typedef struct ns_audio_cfg ns_audio_config_t
enum ns_audio_pdm_clock_e
PDM Clock Frequency.
enum ns_audio_pdm_micsel_e
PDM Microphone Selection.
enum ns_audio_source_e
Audio Source (current only AUDADC and PDM are supported)

Public Attributes

Type Name
ns_audio_config_t * g_ns_audio_config
Audio Configuration and State.
const ns_core_api_t ns_audio_V0_0_1
const ns_core_api_t ns_audio_V1_0_0
const ns_core_api_t ns_audio_V2_0_0
const ns_core_api_t ns_audio_V2_1_0
const ns_core_api_t ns_audio_current_version
const ns_core_api_t ns_audio_oldest_supported_version

Public Functions

Type Name
void ns_audio_getPCM (int16_t * pcm, uint32_t * raw, int16_t len)
Extract int16 PCM from data collected by ADC.
void ns_audio_getPCM_v2 (ns_audio_config_t * config, void * pcm)
Extract int16 PCM from AUDADC or PDM sources.
uint32_t ns_audio_init (ns_audio_config_t * cfg)
Initialize NeuralSPOT audio capture library.
uint32_t ns_end_audio (ns_audio_config_t * cfg)
Stop audio capture.
uint32_t ns_start_audio (ns_audio_config_t * cfg)
Start audio capture, must be called after ns_audio_init.

Macros

Type Name
define NS_AUDIO_API_ID 0xCA0001
define NS_AUDIO_CURRENT_VERSION NS_AUDIO_V2_1_0
define NS_AUDIO_DMA_BUFFER_SIZE 480
define NS_AUDIO_OLDEST_SUPPORTED_VERSION NS_AUDIO_V0_0_1
define NS_AUDIO_V0_0_1 { .major = 0, .minor = 0, .revision = 1 }
define NS_AUDIO_V1_0_0 { .major = 1, .minor = 0, .revision = 0 }
define NS_AUDIO_V2_0_0 { .major = 2, .minor = 0, .revision = 0 }
define NS_AUDIO_V2_1_0 { .major = 2, .minor = 1, .revision = 0 }

Public Types Documentation

enum ns_audio_api_mode_e

enum ns_audio_api_mode_e {
    NS_AUDIO_API_CALLBACK,
    NS_AUDIO_API_RINGBUFFER,
    NS_AUDIO_API_TASK
};

typedef ns_audio_callback_cb

typedef void(* ns_audio_callback_cb) (struct ns_audio_cfg *, uint16_t);

enum ns_audio_clksel_e

enum ns_audio_clksel_e {
    NS_CLKSEL_XTHS,
    NS_CLKSEL_HFXTAL,
    NS_CLKSEL_HFRC,
    NS_CLKSEL_HFRC2,
    NS_CLKSEL_HFRC2_ADJ
};

typedef ns_audio_config_t

typedef struct ns_audio_cfg ns_audio_config_t;

NeuralSPOT Audio API Configuration Struct

Audio configuration is via this struct, which also serves as a handle after ns_audio_init() has been invoked

enum ns_audio_pdm_clock_e

enum ns_audio_pdm_clock_e {
    NS_AUDIO_PDM_CLK_750KHZ,
    NS_AUDIO_PDM_CLK_1_5MHZ
};

enum ns_audio_pdm_micsel_e

enum ns_audio_pdm_micsel_e {
    NS_AUDIO_PDM_MICBOARD_0 = 0,
    NS_AUDIO_PDM_MICBOARD_1 = 2,
    NS_AUDIO_PDM_MICBOARD_2 = 1
};

enum ns_audio_source_e

enum ns_audio_source_e {
    NS_AUDIO_SOURCE_AUDADC,
    NS_AUDIO_SOURCE_PDM
};

Public Attributes Documentation

variable g_ns_audio_config

ns_audio_config_t* g_ns_audio_config;

variable ns_audio_V0_0_1

const ns_core_api_t ns_audio_V0_0_1;

variable ns_audio_V1_0_0

const ns_core_api_t ns_audio_V1_0_0;

variable ns_audio_V2_0_0

const ns_core_api_t ns_audio_V2_0_0;

variable ns_audio_V2_1_0

const ns_core_api_t ns_audio_V2_1_0;

variable ns_audio_current_version

const ns_core_api_t ns_audio_current_version;

variable ns_audio_oldest_supported_version

const ns_core_api_t ns_audio_oldest_supported_version;

Public Functions Documentation

function ns_audio_getPCM

Extract int16 PCM from data collected by ADC.

void ns_audio_getPCM (
    int16_t * pcm,
    uint32_t * raw,
    int16_t len
) 

Parameters:

  • pcm - resulting PCM data
  • raw - incoming data from ADC engine
  • len - number of sample words to convert

function ns_audio_getPCM_v2

Extract int16 PCM from AUDADC or PDM sources.

void ns_audio_getPCM_v2 (
    ns_audio_config_t * config,
    void * pcm
) 

Parameters:

  • config - ns audio config
  • pcm - resulting PCM data

function ns_audio_init

Initialize NeuralSPOT audio capture library.

uint32_t ns_audio_init (
    ns_audio_config_t * cfg
) 

Parameters:

  • cfg : desired configuration

function ns_end_audio

Stop audio capture.

uint32_t ns_end_audio (
    ns_audio_config_t * cfg
) 

Parameters:

  • cfg : desired configuration

function ns_start_audio

Start audio capture, must be called after ns_audio_init.

uint32_t ns_start_audio (
    ns_audio_config_t * cfg
) 

Parameters:

  • cfg : desired configuration

Macro Definition Documentation

define NS_AUDIO_API_ID

#define NS_AUDIO_API_ID 0xCA0001

define NS_AUDIO_CURRENT_VERSION

#define NS_AUDIO_CURRENT_VERSION NS_AUDIO_V2_1_0

define NS_AUDIO_DMA_BUFFER_SIZE

#define NS_AUDIO_DMA_BUFFER_SIZE 480

define NS_AUDIO_OLDEST_SUPPORTED_VERSION

#define NS_AUDIO_OLDEST_SUPPORTED_VERSION NS_AUDIO_V0_0_1

define NS_AUDIO_V0_0_1

#define NS_AUDIO_V0_0_1 { .major = 0, .minor = 0, .revision = 1 }

define NS_AUDIO_V1_0_0

#define NS_AUDIO_V1_0_0 { .major = 1, .minor = 0, .revision = 0 }

define NS_AUDIO_V2_0_0

#define NS_AUDIO_V2_0_0 { .major = 2, .minor = 0, .revision = 0 }

define NS_AUDIO_V2_1_0

#define NS_AUDIO_V2_1_0 { .major = 2, .minor = 1, .revision = 0 }