<alp/audio.h> — PDM In + I²S Out
Microphone capture, speaker playback, and the ALP-default DSP chain.
Header
#include <alp/audio.h>
Capture (PDM microphone)
alp_audio_in_t *mic = alp_audio_in_open(&(alp_audio_in_config_t){
.source = ALP_AUDIO_SRC_PDM,
.sample_rate_hz = 16000,
.channels = 1,
.bit_depth = 16,
});
int16_t samples[1024];
size_t got;
alp_audio_in_read(mic, samples, sizeof(samples)/sizeof(samples[0]), &got);
alp_audio_in_close(mic);
Playback (I²S speaker)
alp_audio_out_t *spkr = alp_audio_out_open(&(alp_audio_out_config_t){
.sink = ALP_AUDIO_SINK_I2S,
.sample_rate_hz = 44100,
.channels = 2,
.bit_depth = 16,
});
alp_audio_out_set_volume(spkr, 80); // 0..100 (software linear scale on Yocto)
alp_audio_out_write(spkr, pcm_buffer, n_frames);
Backends
| Backend | Implementation |
|---|---|
| Zephyr | I²S subsystem + PDM controller driver. |
| Yocto | ALSA (snd_pcm_*). peripheral_id == 0 → "default"; peripheral_id == N → "hw:N-1,0". |
| Bare-metal | Vendor HAL. |
The application API is identical across backends.
ALP default DSP chain
alp_audio_in_open installs an ALP-default chain (high-pass + AGC + noise gate) when no custom chain is provided. Pass your own <alp/dsp.h> chain to override.
See also
<alp/dsp.h>— FIR/IIR/FFT chains<alp/i2s.h>— raw I²S
Questions about this page? Discuss in Community Forum