我无法在 PortAudio 中生成特定频率,每当我尝试更改频率内部的频率时sin(n * FREQ * 2 * PI / SAMPLE_RATE)
,频率保持不变,但声音似乎确实在音色上发生了变化,我放在那里的频率值越高,声音就越难看,然而相同的频率。这就是我的patestCallback
循环中的内容:
static int patestCallback( const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
const PaStreamCallbackTimeInfo *timeInfo,
PaStreamCallbackFlags statusFlags,
void *userData )
{
paTestData *data = (paTestData*)userData;
float *out = (float*)outputBuffer;
(void) timeInfo;
(void) statusFlags;
(void) inputBuffer;
unsigned long n = 0;
for(unsigned long i = 0; i<framesPerBuffer;i++,n++){
float v = sin ( 261.626 * 2 * M_PI * ((float) n / (float) TABLE_SIZE) );
*out++ = v;
*out++ = v;
}
return paContinue;
}