我正在从FMOD迁移到OpenAL,但找不到FSOUND_Sample_GetLength()函数的类似物,该函数返回样本中样本的长度(不考虑频率)...我得到OpenAL缓冲区名称来自alutLoadMemoryFromFileImage(),所以我无法通过这种方式获取波形数据。
请帮忙!
您需要自己使用 alGetBufferi() 将其拼凑起来:
ALint sizeInBytes;
ALint channels;
ALint bits;
alGetBufferi(bufferID, AL_SIZE, &sizeInBytes);
alGetBufferi(bufferID, AL_CHANNELS, &channels);
alGetBufferi(bufferID, AL_BITS, &bits);
lengthInSamples = sizeInBytes * 8 / (channels * bits);
持续时间以秒为单位:
ALint frequency;
alGetBufferi(bufferID, AL_FREQUENCY, &frequency);
durationInSeconds = (float)lengthInSamples / (float)frequency;