Hi there. Because I am developing dualchannel "jack" scope I of course need stereo recording. Problem is that in
SoundRecorder.hpp the predefined record type is set as AL_FORMAT_MONO16. I have started to solve this problem with overriding
void SoundRecorder::Start(unsigned int SampleRate = 44100); but I am not sure if it's the best solution. If I try to compile, I get a lot of compile errors:
../libjop/jop_signalcatcher.cpp: In member function ‘void MyRecorder::Start(unsigned int)’:
../libjop/jop_signalcatcher.cpp:111: error: ‘CaptureDevice’ was not declared in this scope
../libjop/jop_signalcatcher.cpp:120: error: ‘CaptureDevice’ was not declared in this scope
../libjop/jop_signalcatcher.cpp:120: error: ‘AL_FORMAT_STEREO16’ was not declared in this scope
../libjop/jop_signalcatcher.cpp:120: error: ‘alcCaptureOpenDevice’ was not declared in this scope
../libjop/jop_signalcatcher.cpp:122: error: ‘CaptureDevice’ was not declared in this scope
../libjop/jop_signalcatcher.cpp:122: error: ‘AL_FORMAT_MONO16’ was not declared in this scope
../libjop/jop_signalcatcher.cpp:122: error: ‘alcCaptureOpenDevice’ was not declared in this scope
../libjop/jop_signalcatcher.cpp:124: error: ‘CaptureDevice’ was not declared in this scope
/usr/include/SFML/Audio/SoundRecorder.hpp:141: error: ‘unsigned int sf::SoundRecorder::mySampleRate’ is private
../libjop/jop_signalcatcher.cpp:134: error: within this context
/usr/include/SFML/Audio/SoundRecorder.hpp:100: error: ‘virtual bool sf::SoundRecorder::OnStart()’ is private
../libjop/jop_signalcatcher.cpp:137: error: within this context
/usr/include/SFML/Audio/SoundRecorder.hpp:100: error: ‘virtual bool sf::SoundRecorder::OnStart()’ is private
../libjop/jop_signalcatcher.cpp:137: error: within this context
../libjop/jop_signalcatcher.cpp:140: error: ‘CaptureDevice’ was not declared in this scope
../libjop/jop_signalcatcher.cpp:140: error: ‘alcCaptureStart’ was not declared in this scope
/usr/include/SFML/Audio/SoundRecorder.hpp:142: error: ‘bool sf::SoundRecorder::myIsCapturing’ is private
../libjop/jop_signalcatcher.cpp:143: error: within this context
/usr/include/SFML/System/Unix/Thread.hpp:69: error: ‘void sf::Thread::Launch()’ is inaccessible
../libjop/jop_signalcatcher.cpp:144: error: within this context
/usr/include/SFML/System/Unix/Thread.hpp:69: error: ‘void sf::Thread::Launch()’ is inaccessible
../libjop/jop_signalcatcher.cpp:144: error: within this context
../libjop/jop_signalcatcher.cpp:144: error: ‘sf::Thread’ is not an accessible base of ‘MyRecorder’
I have found that in
SoundRecorder.cpp are defined following includes:
00028 #include <SFML/Audio/SoundRecorder.hpp>
00029 #include <SFML/Audio/AudioDevice.hpp>
00030 #include <SFML/Audio/OpenAL.hpp>
00031 #include <SFML/System/Sleep.hpp>
00032 #include <iostream>
The problem is AudioDevice.hpp and OpenAL.hpp are not found, if I try to include them in the file with my new SoundRecorder::Start(...) definition .. I know it is ok because these headers aren't located in
/usr/include/SFML/Audio. These libraries are located only in sfml source. So how can I get rid of these errors? Will I have to add sfml sources to my project?? Or if my solution is bad please suggest cleaner solution. I believe I have described my problem enough. Thanks in advance for any solutions or suggestions :wink:
For a better explanation I included my sources:
JOP_Signal_Catcher.h#ifndef JOP_SIGNALCATCHER_H
#define JOP_SIGNALCATCHER_H
#include <SFML/Audio.hpp>
#include <SFML/Audio/SoundRecorder.hpp>
#include "jop_core.h"
class MyRecorder : public QObject, public sf::SoundRecorder
{
Q_OBJECT
private:
bool loop;
public:
MyRecorder(int myLimit, bool loop);
MyRecorder();
virtual bool OnProcessSamples(const sf::Int16* Samples, std::size_t SamplesCount);
// predefinovani defaultni funkce start -> uprava pro spusteni stereo nahravani
void Start(unsigned int SampleRate);
std::vector<sf::Int16> mySamples;
std::size_t myLimit;
signals:
void processFinished();
};
JOP_Signal_Catcher.cpp#include "jop_signalcatcher.h"
#include <SFML/Audio/SoundRecorder.hpp>
#include <SFML/Audio/SoundRecorder.hpp>
#include <SFML/Audio/AudioDevice.hpp> // error, not found
#include <SFML/Audio/OpenAL.hpp> // error, not found
#include <SFML/System/Sleep.hpp>
#include <iostream>
// copied from sfml, changed only capture mod (AL_FORMAT_MONO16 ->AL_FORMAT_STEREO16)
void MyRecorder::Start(unsigned int SampleRate)
{
// Check if the device can do audio capture
if (!CanCapture())
{
std::cerr << "Failed to start capture : your system cannot capture audio data (call SoundRecorder::CanCapture to check it)" << std::endl;
return;
}
// Check that another capture is not already running
if (CaptureDevice)
{
std::cerr << "Trying to start audio capture, but another capture is already running" << std::endl;
return;
}
// Open the capture device for capturing 16 bits MONO or STEREO samples
// -> depends on [bool] loop (modificated)
if(this->loop)
CaptureDevice = alcCaptureOpenDevice(NULL, SampleRate, AL_FORMAT_STEREO16, SampleRate);
else
CaptureDevice = alcCaptureOpenDevice(NULL, SampleRate, AL_FORMAT_MONO16, SampleRate);
if (!CaptureDevice)
{
std::cerr << "Failed to open the audio capture device" << std::endl;
return;
}
// Clear the sample array
mySamples.clear();
// Store the sample rate
mySampleRate = SampleRate;
// Notify derived class
if (OnStart())
{
// Start the capture
alcCaptureStart(CaptureDevice);
// Start the capture in a new thread, to avoid blocking the main thread
myIsCapturing = true;
Launch();
}
}