Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGSEGV when running the example provided in the Readme #37

Open
jrialland opened this issue Oct 14, 2022 · 3 comments
Open

SIGSEGV when running the example provided in the Readme #37

jrialland opened this issue Oct 14, 2022 · 3 comments

Comments

@jrialland
Copy link

jrialland commented Oct 14, 2022

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];
@jbkempf
Copy link
Collaborator

jbkempf commented Oct 14, 2022

Which pointer is NULL?

@jrialland
Copy link
Author

(gdb) p pfDst->m_ppfChannels
$4 = std::unique_ptr<float *[]> = {get() = 0x0}

@SongLi89
Copy link

I have same issues when running example code. is there a lack of reserve the memory? can some help to fix the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants