I think it's smart to rather use ALSA directly instead of PortAudio. ALSA is push AFAIK, and talking about it here at the hackspace, seems like the better choice. It's a bit lower level, but anyway everything speaks ALSA anyway. It's not like there's any reason to use PortAudio at all. It's just an extra abstraction. Coding for ALSA it'll also work with Pulseaudio and esd. Do people really use other sound systems than Pulseaudio, esd or plain ALSA? I can't think of it. I really the idea about building a small tool first. I'll do that. Also thought about making a small blikning cursor/text output, and syncing a BEEP-sound to that, so that I can test around with throwing in lots and lots of latency between "me" and the video, and try to sync it anyway. I should be able to read back from the sound card (or pulse audio underneath, it will just work with alsa as the abstraction) how long it takes for the bytes I'm pushing to reach the speakers, and do some buffer tuning on that.
27 lines
500 B
C
27 lines
500 B
C
#include <unistd.h>
|
|
#include <stdint.h>
|
|
#include "alsa.c"
|
|
|
|
#define SAMPLE_RATE 44100
|
|
|
|
int16_t quiet[SAMPLE_RATE], noisy[SAMPLE_RATE];
|
|
|
|
void main () {
|
|
|
|
for (int i=0; i<SAMPLE_RATE; i++)
|
|
{
|
|
quiet[i] = 0;
|
|
noisy[i] = i%30000;
|
|
}
|
|
audio_start(44100, 2);
|
|
|
|
for (int i=0; i<10; i++)
|
|
{
|
|
audio_write(noisy, SAMPLE_RATE);
|
|
printf("=================================\n");
|
|
audio_write(quiet, SAMPLE_RATE);
|
|
printf("\n");
|
|
}
|
|
|
|
audio_stop();
|
|
}
|