libspatialaudio
libspatialaudio copied to clipboard
SIGSEGV when running the example provided in the Readme
Using the tag 0.3.0, I have extracted this example and tried to run it :
#include <catch2/catch_all.hpp>
#include <AmbisonicEncoder.h>
#include <AmbisonicDecoder.h>
// Just some demo code from https://github.com/videolabs/libspatialaudio
TEST_CASE("libspatialaudio smoke test", "[libspatialaudio]")
{
float sinewave[512];
for(int ni = 0; ni < 512; ni++)
sinewave[ni] = (float)sin((ni / 128.f) * (M_PI * 2));
// CBFormat as 1st order 3D, and 512 samples
CBFormat myBFormat;
// Ambisonic encoder, also 3rd order 3D
CAmbisonicEncoder myEncoder;
myEncoder.Configure(1, true, 0);
// Set test signal's position in the soundfield
PolarPoint position;
position.fAzimuth = 0;
position.fElevation = 0;
position.fDistance = 5;
myEncoder.SetPosition(position);
myEncoder.Refresh();
// Encode test signal into BFormat buffer
myEncoder.Process(sinewave, 512, &myBFormat);
// Ambisonic decoder, also 1st order 3D, for a 5.0 setup
CAmbisonicDecoder myDecoder;
myDecoder.Configure(1, true, kAmblib_50, 5);
// Allocate buffers for speaker feeds
float** ppfSpeakerFeeds = new float*[5];
for(int niSpeaker = 0; niSpeaker < 5; niSpeaker++)
ppfSpeakerFeeds[niSpeaker] = new float[512];
// Decode to get the speaker feeds
myDecoder.Process(&myBFormat, 512, ppfSpeakerFeeds);
// De-allocate speaker feed buffers
for(int niSpeaker = 0; niSpeaker < 5; niSpeaker++)
delete [] ppfSpeakerFeeds[niSpeaker];
delete [] ppfSpeakerFeeds;
}
When I run this test, It segfaults. A gdb session tells me that it crashed here :
at _deps/libspatialaudio-src/source/AmbisonicEncoder.cpp:48
48 pfDst->m_ppfChannels[niChannel][niSample] = pfSrc[niSample] * m_pfCoeff[niChannel];
Which pointer is NULL?
(gdb) p pfDst->m_ppfChannels $4 = std::unique_ptr<float *[]> = {get() = 0x0}
I have same issues when running example code. is there a lack of reserve the memory? can some help to fix the issue?