Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Jaylight

Pages: [1]
1
Audio / Re: Undefined Reference to `sf::SoundBuffer::loadFromSamples`
« on: March 16, 2016, 08:40:20 pm »
It seems it was a typo in my link command. I had -L/path_to_include_files instead of -L/path_to_lib_files. It was such a silly mistake. I should not have bothered posting the problem.

2
Audio / Re: Undefined Reference to `sf::SoundBuffer::loadFromSamples`
« on: March 16, 2016, 06:26:00 pm »
Thanks, but I fixed it.

3
Audio / Undefined Reference to `sf::SoundBuffer::loadFromSamples`
« on: March 15, 2016, 01:45:35 am »
Hi. I am trying to create a small audio based application that uses a class that inherits from SoundRecorder, and overrides the onProcessSamples function.

I am getting an error that says:

"In function `NoiseCancellor::onProcessSamples(short const*, unsigned long)': NoiseCancellor.cpp: (.text+0xef): undefined reference to `sf::SoundBuffer::loadFromSamples(short const*, unsigned long long, unsigned int, unsigned int)'
colled2: error: ld return 1 exit status

First of all I AM linking all of the sfml libraries, including -lsfml-audio.

I am using Linux Mint 17.1 (Rebecca) (Ubuntu 14) 64 bit on a 64 bit machine.

My NoiseCancellor.cpp file looks like this:

#include "NoiseCancellor.hpp"

bool NoiseCancellor::onProcessSamples(const sf::Int16* samples, std::size_t sampleCount)
{
    sf::Int16* cancelSamples = new sf::Int16[sampleCount];

    for (size_t i = 0; i < sampleCount; ++i) {
        cancelSamples[i] = -samples[i];
    }

    sf::SoundBuffer cancelBuffer;
    cancelBuffer.loadFromSamples(cancelSamples, sizeof(cancelSamples) * sampleCount, 1, getSampleRate());

    sf::Sound cancelSound(cancelBuffer);
    cancelSound.play();

    return true;
}
 

~   

And my NoiseCancellor.hpp looks like this:

#ifndef NOISE_CANCELLOR_HPP
#define NOISE_CANCELLOR_HPP

#include <SFML/Audio.hpp>

class NoiseCancellor : public sf::SoundRecorder {
        bool onProcessSamples(const sf::Int16* samples, std::size_t sampleCount);
};

#endif
 

I tried to fix it by forcing the parameters to be handled as the types `const Int16 *samples, std::size_t sampleCount, unsigned int channelCount, unsigned int sampleRate`, to exactly coincide with the documentation on the function, by static_casting all the variables as I was passing them into the function, but the error message didn't go away. Then I even tried const_casting the first parameter (since it const), and static casting all the rest. The error still didn't go away. I've been trying to search the internet to see if I could find a solution to this problem, but I didn't. Any help with this would be much appreciated. Thank you.

Pages: [1]