Audio 如何从UPD paquets打开一条流?
我想使用PortAudio库来播放音频数据。此音频数据来自UDP paquets 我看到有一个Pa_OpenDefaultStream()(和Pa_OpenStream()非常相似)函数来打开一个流:Audio 如何从UPD paquets打开一条流?,audio,streaming,portaudio,Audio,Streaming,Portaudio,我想使用PortAudio库来播放音频数据。此音频数据来自UDP paquets 我看到有一个Pa_OpenDefaultStream()(和Pa_OpenStream()非常相似)函数来打开一个流: PaStream *stream; PaError err; /* Open an audio I/O stream. */ err = Pa_OpenDefaultStream( &stream, 0, /* no
PaStream *stream;
PaError err;
/* Open an audio I/O stream. */
err = Pa_OpenDefaultStream( &stream,
0, /* no input channels */
2, /* stereo output */
paFloat32, /* 32 bit floating point output */
SAMPLE_RATE,
256, /* frames per buffer, i.e. the number
of sample frames that PortAudio will
request from the callback. Many apps
may want to use
paFramesPerBufferUnspecified, which
tells PortAudio to pick the best,
possibly changing, buffer size.*/
patestCallback, /* this is your callback function */
&data ); /*This is a pointer that will be passed to
your callback*/
我想我必须用它来玩我的paquets,但我不知道如何使用它:
- 第一个参数是什么
- 为什么我必须定义回调函数李>
谢谢。第一个参数是指向输入/输出流的指针,类型为PaStream。音频数据将从此流中读取/写入 您需要编写一个回调函数,PortAudio库在需要向您的电脑读写音频时将调用该函数。您要执行的任何其他音频处理(如DSP)也将在此处完成。一个简单的回调函数只需将输入复制到输出,用于流式I/O。如果您在使用回调时遇到问题,请改用阻塞API,这样可能更容易理解 编译并运行示例以了解详细信息(例如,patest_read_record.c),其中包含大量信息。如何编写“简单回调函数”?我严格地想编码(边听边录)。谢谢