I extended OgreAL a little bit. I now use newer version of OpenAL implementation from github:
* https://github.com/kcat/openal-soft
* I also implemented audio spectrum analysis with beat detection. I orientated on: https://www.parallelcube.com/2018/03/10 ... d-and-ue4/
* For fft I use the library kiss_fft (https://github.com/berndporr/kiss-fft), which is now part of OgreAL.
See scenario:
If somebody wants to use the OgreAL extension in its own projects. It can be downloaded from this site:
https://sourceforge.net/p/nowa-engine/s ... al/OgreAL/
Code example:
Code: Select all
// Create sound and use (streaming = true)
int spectrumProcessingSize = 1024;
int numberOfBands= 30;
float minHeight = 0.05f;
float maxHeight = 16.0f;
sound->enableSpectrumAnalysis(true, spectrumProcessingSize, numberOfBands, OgreAL::MathWindowType::BARLETT, OgreAL::SpectrumPreparationType::LOGARITHMIC, 0);
sound->addSoundSpectrumHandler(SimpleSoundComponent::soundSpectrumFuncPtr);
void SimpleSoundComponent::soundSpectrumFuncPtr(OgreAL::Sound* sound)
{
OgreAL::Sound::SpectrumParameter* spectrumParameter = sound->getSpectrumParameter();
if (nullptr != spectrumParameter)
{
auto levelData = sound:getLevelData();
if (sound->isInstrument(OgreAL::Instrument::KICK_DRUM))
{
// do something
}
if (sound->isInstrument(OgreAL::Instrument::SNARE_DRUM))
{
// do something
}
if (sound:isSpectrumArea(OgreAL::SpectrumArea::DEEP_BASS))
{
// do something
}
for (int i = 0; i < sound->getActualSpectrumSize() - 1; i++)
{
local newY = minHeight + (levelData[i] * (maxHeight - minHeight) * 0.5f);
lines->setStartPosition(i, Vector3(i * 0.2f, 0, 0));
lines->setWidth(i, 0.2f);
lines->setHeight(i, newY);
}
}
}

Best Regards
Lax