Skip to content
Snippets Groups Projects
Commit 20299383 authored by Florent Berthaut's avatar Florent Berthaut
Browse files

Removed audio output by default

parent 7a3d74eb
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#include "gui/GuiListener.hpp" #include "gui/GuiListener.hpp"
#include "osc/OscManager.hpp" #include "osc/OscManager.hpp"
#include "osc/OscListener.hpp" #include "osc/OscListener.hpp"
#include "audio/AudioManager.hpp"
using namespace std; using namespace std;
...@@ -85,6 +86,13 @@ Reveal::Reveal() : GroupModule() { ...@@ -85,6 +86,13 @@ Reveal::Reveal() : GroupModule() {
Attribute::ACTION_ATTRIBUTE, Attribute::ACTION_ATTRIBUTE,
quitCallback, this, Attribute::LOCAL, quitCallback, this, Attribute::LOCAL,
false)); false));
addAttribute(new Attribute("audio_output",
Attribute::BOOL_ATTRIBUTE,
audioOutputCallback,this,1,Attribute::GLOBAL));
m_audioOut=false;
/*
addAttribute(new Attribute("ressources_folder", addAttribute(new Attribute("ressources_folder",
Attribute::FOLDER_OPEN_ATTRIBUTE, Attribute::FOLDER_OPEN_ATTRIBUTE,
ressourcesCallback, this, Attribute::LOCAL, ressourcesCallback, this, Attribute::LOCAL,
...@@ -92,6 +100,7 @@ Reveal::Reveal() : GroupModule() { ...@@ -92,6 +100,7 @@ Reveal::Reveal() : GroupModule() {
addAttribute(new Attribute("ressource_upload", addAttribute(new Attribute("ressource_upload",
Attribute::ACTION_STRING_ATTRIBUTE, Attribute::ACTION_STRING_ATTRIBUTE,
uploadCallback,this,2,Attribute::GLOBAL,false)); uploadCallback,this,2,Attribute::GLOBAL,false));
*/
addAttribute(new Attribute("debug_osc_input", addAttribute(new Attribute("debug_osc_input",
Attribute::BOOL_ATTRIBUTE, Attribute::BOOL_ATTRIBUTE,
debugOscCallback,this,1,Attribute::GLOBAL)); debugOscCallback,this,1,Attribute::GLOBAL));
...@@ -192,6 +201,12 @@ GLFWwindow* Reveal::getPreviewWindow() { ...@@ -192,6 +201,12 @@ GLFWwindow* Reveal::getPreviewWindow() {
return m_preview->getWindow(); return m_preview->getWindow();
} }
void Reveal::setAudioOutput(const bool& aud) {
if(aud) {
AudioManager::getInstance()->init();
}
}
void Reveal::planOpen(std::string opSt) { void Reveal::planOpen(std::string opSt) {
//FIXME find better strategy for delaying text //FIXME find better strategy for delaying text
m_openPlanned=10; m_openPlanned=10;
......
...@@ -128,14 +128,18 @@ class Reveal : public GroupModule { ...@@ -128,14 +128,18 @@ class Reveal : public GroupModule {
dynamic_cast<Reveal*>(mod)->uploadRessource(vf); dynamic_cast<Reveal*>(mod)->uploadRessource(vf);
} }
void uploadRessource(const std::vector<std::string>& vf); void uploadRessource(const std::vector<std::string>& vf);
static void debugOscCallback(Module* mod, static void debugOscCallback(Module* mod, const std::vector<bool>& vf) {
const std::vector<bool>& vf
) {
dynamic_cast<Reveal*>(mod)->debugOSC(vf[0]); dynamic_cast<Reveal*>(mod)->debugOSC(vf[0]);
} }
void debugOSC(const bool& deb){m_debugOSC=deb;} void debugOSC(const bool& deb){m_debugOSC=deb;}
const bool& getDebugOSC() {return m_debugOSC;} const bool& getDebugOSC() {return m_debugOSC;}
static void audioOutputCallback(Module* mod,
const std::vector<bool>& vf) {
dynamic_cast<Reveal*>(mod)->setAudioOutput(vf[0]);
}
void setAudioOutput(const bool& aud);
virtual void load(xmlNodePtr); virtual void load(xmlNodePtr);
void addUpdateObserver(Module* upObs); void addUpdateObserver(Module* upObs);
...@@ -218,6 +222,7 @@ class Reveal : public GroupModule { ...@@ -218,6 +222,7 @@ class Reveal : public GroupModule {
PreviewModule* m_preview; PreviewModule* m_preview;
OutputManagerModule* m_output; OutputManagerModule* m_output;
bool m_debugOSC; bool m_debugOSC;
bool m_audioOut;
int m_openPlanned; int m_openPlanned;
std::string m_openPlannedName; std::string m_openPlannedName;
......
...@@ -78,7 +78,7 @@ int AudioManager::rtaudio_callback(void *outbuf, void *inbuf, unsigned int nFram ...@@ -78,7 +78,7 @@ int AudioManager::rtaudio_callback(void *outbuf, void *inbuf, unsigned int nFram
} }
else { else {
memset(buf, 0, nFrames*data->nChannel*sizeof(float)); memset(buf, 0, nFrames*data->nChannel*sizeof(float));
cout<<"AudioManager : Could not read buffer"<<endl; // cout<<"AudioManager : Could not read buffer"<<endl;
} }
} }
else { else {
...@@ -96,6 +96,10 @@ int AudioManager::rtaudio_callback(void *outbuf, void *inbuf, unsigned int nFram ...@@ -96,6 +96,10 @@ int AudioManager::rtaudio_callback(void *outbuf, void *inbuf, unsigned int nFram
} }
AudioManager::AudioManager() { AudioManager::AudioManager() {
m_init=false;
}
void AudioManager::init() {
//audio = new RtAudio(RtAudio::LINUX_PULSE); //audio = new RtAudio(RtAudio::LINUX_PULSE);
m_rtAudio = new RtAudio(RtAudio::UNIX_JACK); m_rtAudio = new RtAudio(RtAudio::UNIX_JACK);
param = new RtAudio::StreamParameters(); param = new RtAudio::StreamParameters();
...@@ -128,10 +132,12 @@ AudioManager::AudioManager() { ...@@ -128,10 +132,12 @@ AudioManager::AudioManager() {
memset(&data.mixBuffer[0], 0, data.mixSize*sizeof(float)); memset(&data.mixBuffer[0], 0, data.mixSize*sizeof(float));
m_thread = new std::thread(audioThreadFunction, this); m_thread = new std::thread(audioThreadFunction, this);
m_init = true;
} }
void AudioManager::changeBuf(float* outputBuf, float maxSinValue) { void AudioManager::changeBuf(float* outputBuf, float maxSinValue) {
if(m_init) {
//check if there is space to write the new values //check if there is space to write the new values
size_t write_space = ringbuffer_write_space(data.ringBuffer); size_t write_space = ringbuffer_write_space(data.ringBuffer);
...@@ -170,5 +176,6 @@ void AudioManager::changeBuf(float* outputBuf, float maxSinValue) { ...@@ -170,5 +176,6 @@ void AudioManager::changeBuf(float* outputBuf, float maxSinValue) {
//cout<<"AudioManager : Could not write buffer"<<endl; //cout<<"AudioManager : Could not write buffer"<<endl;
} }
} }
}
...@@ -66,6 +66,7 @@ class AudioManager { ...@@ -66,6 +66,7 @@ class AudioManager {
static AudioManager* getInstance(); static AudioManager* getInstance();
~AudioManager(); ~AudioManager();
void init();
void changeBuf(float* outputBuf, float maxSinValue); void changeBuf(float* outputBuf, float maxSinValue);
int getRate(); int getRate();
int getBufferSize(); int getBufferSize();
...@@ -87,6 +88,7 @@ class AudioManager { ...@@ -87,6 +88,7 @@ class AudioManager {
CallbackData data; CallbackData data;
std::mutex mtx_audio; std::mutex mtx_audio;
bool m_init;
static int rtaudio_callback(void *outbuf, void *inbuf, static int rtaudio_callback(void *outbuf, void *inbuf,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment