Пытаюсь разобраться с OpenAL, необходимо генерировать некий синусоидальный сигнал с заданными параметрами и соответственно воспроизводить его. Но вместо сгенерированного сигнала всегда воспроизводиться какая-то фигня и всегда одинаковая. Каторая вообще ни от чего не зависит. Да же если весь буфер заполнять одним значением.
Код:
ALerror = alGetError();
pDevice = alcOpenDevice(ui->comboBox->itemText(ui->comboBox->currentIndex()).toAscii());
if(pDevice)
{
pContext = alcCreateContext(pDevice, NULL);
if (pContext)
{
qDebug() << QString("Opened %1 Device").arg(alcGetString(pDevice, ALC_DEVICE_SPECIFIER));
}
else
{
alcCloseDevice(pDevice);
this->getSoundError();
this->showError(QString("Error open device"));
exit(-1);
}
}
else
{
this->showError(QString("Error open device"));
exit(-1);
}
alcMakeContextCurrent(pContext);
this->getSoundError();
alGenBuffers( 1, &uiBuffer );
this->getSoundError();
alGenSources(1, &sources);
this->getSoundError();
this->fillBuffer(Buffer, 1, ui->lineEdit->text().toInt(), Freq);
alBufferData(uiBuffer, AL_FORMAT_MONO16, Buffer, 1*Freq, Freq);
this->getSoundError();
alSourcei(sources, AL_BUFFER, uiBuffer);
this->getSoundError();
alSourcePlay(sources);
this->getSoundError();
do
{
qApp->processEvents();
alGetSourcei(sources, AL_SOURCE_STATE, &iState);
} while (iState == AL_PLAYING);
alSourceStop(sources);
alDeleteSources(1, &sources);
alDeleteBuffers(1, &uiBuffer);
this->getSoundError();
alcMakeContextCurrent(NULL);
alcDestroyContext(pContext);
alcCloseDevice(pDevice);
this->getSoundError();