Files
2025-07-27 15:06:10 -07:00

30 lines
808 B
C

#ifndef AUDIOCAPTURE_H
#define AUDIOCAPTURE_H
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <alsa/asoundlib.h>
#include <alsa/control.h>
#include <alsa/pcm.h>
// NOTE: find this via `arecord -l`
#define ALSA_MIC_HARDWARE_DEVICE "hw:3"
#define ALSA_SPEAKER_HARDWARE_DEVICE "default"
// Captures audio for given seconds, and returns file name that we captured the
// audio into
char *audio_capture(uint seconds);
/* count: how many bytes in the buffer
* returns int: 0 if success, -1 if failure
* NOTE: This function assumes that the audio data is using:
* - linear16 formatting (each sample is 16 bits)
* - one channel (1 sample)
* - with 48000 HZ sampling rate
* Hence, it's 2 bytes per frame.
*/
int audio_play(char *buf, size_t byte_count);
#endif // AUDIOCAPTURE_H