diff --git a/data/Font/FreeSerif.ttf b/data/Font/FreeSerif.ttf new file mode 100644 index 0000000..b8906f5 Binary files /dev/null and b/data/Font/FreeSerif.ttf differ diff --git a/data/Font/FreeSerifBold.ttf b/data/Font/FreeSerifBold.ttf new file mode 100644 index 0000000..59a7a90 Binary files /dev/null and b/data/Font/FreeSerifBold.ttf differ diff --git a/data/Font/FreeSerifBoldItalic.ttf b/data/Font/FreeSerifBoldItalic.ttf new file mode 100644 index 0000000..c187d0e Binary files /dev/null and b/data/Font/FreeSerifBoldItalic.ttf differ diff --git a/data/Font/FreeSerifItalic.ttf b/data/Font/FreeSerifItalic.ttf new file mode 100644 index 0000000..7367418 Binary files /dev/null and b/data/Font/FreeSerifItalic.ttf differ diff --git a/data/menu.ogg b/data/menu.ogg new file mode 100644 index 0000000..1f318ce Binary files /dev/null and b/data/menu.ogg differ diff --git a/data/menu.wav b/data/menu.wav new file mode 100644 index 0000000..61ee3d1 Binary files /dev/null and b/data/menu.wav differ diff --git a/eaudiofx/base/GeneratorFile.cpp b/eaudiofx/base/GeneratorFile.cpp index 8e91cba..44e52e9 100644 --- a/eaudiofx/base/GeneratorFile.cpp +++ b/eaudiofx/base/GeneratorFile.cpp @@ -44,6 +44,7 @@ int32_t eaudiofx::GeneratorFile::pull(double _currentTime, int32_t _request, flo buffer->setProperty(_request); uint8_t* data = buffer->getData(); if (m_file == NULL) { + EAUDIOFX_ERROR("Buffer output error ==> !!ERROR!!"); return eaudiofx::ERR_FAIL; } int64_t nbRead = m_file->fileRead(data, sizeof(uint8_t), _request); @@ -53,7 +54,7 @@ int32_t eaudiofx::GeneratorFile::pull(double _currentTime, int32_t _request, flo int32_t eaudiofx::GeneratorFile::init(void) { - m_file = new etk::FSNode("./menu.wav"); + m_file = new etk::FSNode("DATA:menu.wav"); if (m_file == NULL) { EAUDIOFX_ERROR("Can not allocate the input file ..."); return eaudiofx::ERR_FAIL; @@ -72,8 +73,12 @@ int32_t eaudiofx::GeneratorFile::unInit(void) { } if (m_file->fileClose() == false) { EAUDIOFX_ERROR("Can not close the input file ..."); + delete(m_file); + m_file = NULL; return eaudiofx::ERR_FAIL; } + delete(m_file); + m_file = NULL; return eaudiofx::ERR_NONE; } diff --git a/eaudiofx/base/GeneratorSignal.cpp b/eaudiofx/base/GeneratorSignal.cpp index df9d5f2..979ad79 100644 --- a/eaudiofx/base/GeneratorSignal.cpp +++ b/eaudiofx/base/GeneratorSignal.cpp @@ -42,7 +42,6 @@ int32_t eaudiofx::GeneratorSignal::pull(double _currentTime, int32_t _request, f //request outpuffer needed size : buffer->setProperty(48000, 2, _request); float* data = buffer->getData(); - for (int32_t iii=0; iii<_request; ++iii) { for (int32_t jjj=0; jjj<2; ++jjj) { *data++ = cos(m_phase)*0.5f; diff --git a/eaudiofx/base/ReceiverRtAudio.cpp b/eaudiofx/base/ReceiverRtAudio.cpp index 513da71..b79fa02 100644 --- a/eaudiofx/base/ReceiverRtAudio.cpp +++ b/eaudiofx/base/ReceiverRtAudio.cpp @@ -38,10 +38,16 @@ int32_t eaudiofx::ReceiverRtAudio::needData(float* _outputBuffer, size_t _nBufferFrames, double _streamTime, airtaudio::streamStatus _status) { + if (m_processStarted == false) { + for (int32_t iii=0; iii<_nBufferFrames*2; ++iii) { + _outputBuffer[iii] = 0; + } + return 0; + } // Request block input: int32_t ret = eaudiofx::Block::pull(_streamTime, _nBufferFrames, (float)_nBufferFrames/48000.0f); if (ret != eaudiofx::ERR_NONE) { - EAUDIOFX_ERROR("wan not get data ..."); + EAUDIOFX_ERROR("can not get data ..."); return -1; } auto it = m_io.find("in"); @@ -56,7 +62,8 @@ int32_t eaudiofx::ReceiverRtAudio::needData(float* _outputBuffer, } float* data = buffer->getData(); for (int32_t iii=0; iii<_nBufferFrames*2; ++iii) { - _outputBuffer[iii] = data[iii]*0.05f; + _outputBuffer[iii] = data[iii]*0.5f; + //EAUDIOFX_ERROR("write : " << data[iii]); } /* FILE* plopppp = fopen("plopout.raw", "a"); @@ -69,7 +76,8 @@ int32_t eaudiofx::ReceiverRtAudio::needData(float* _outputBuffer, -eaudiofx::ReceiverRtAudio::ReceiverRtAudio(void) { +eaudiofx::ReceiverRtAudio::ReceiverRtAudio(void) : + m_processStarted(false) { setLive(true); // set output : m_io.insert( @@ -85,18 +93,19 @@ eaudiofx::ReceiverRtAudio::ReceiverRtAudio(void) { int32_t eaudiofx::ReceiverRtAudio::init(void) { + EAUDIOFX_DEBUG("Intanciat AirTAudio Interface ..."); m_dac.instanciate(); - EAUDIOFX_DEBUG("Create RTAudio generator ..."); + EAUDIOFX_DEBUG("Create RTAudio receiver ..."); if ( m_dac.getDeviceCount() < 1 ) { EAUDIOFX_ERROR("No audio devices found!"); - exit( 0 ); + return eaudiofx::ERR_FAIL; } EAUDIOFX_DEBUG("nb devices :" << m_dac.getDeviceCount() << " default device ID : " << m_dac.getDefaultOutputDevice()); m_parameters.deviceId = m_dac.getDefaultOutputDevice(); m_parameters.nChannels = 2; m_parameters.firstChannel = 0; unsigned int bufferFrames = 256; - EAUDIOFX_DEBUG("OPEN Stream ..."); + EAUDIOFX_DEBUG("init Stream ..."); // TODO : Check return error m_dac.openStream(&m_parameters, NULL, airtaudio::FLOAT32, 48000, &bufferFrames, &rtAudioCallBack, (void *)this); // TODO : Check return error @@ -106,7 +115,7 @@ int32_t eaudiofx::ReceiverRtAudio::init(void) { }; int32_t eaudiofx::ReceiverRtAudio::unInit(void) { - EAUDIOFX_DEBUG("STOP Stream ..."); + EAUDIOFX_DEBUG("un-init Stream ..."); // Stop the stream m_dac.stopStream(); // TODO : Check return error @@ -117,4 +126,15 @@ int32_t eaudiofx::ReceiverRtAudio::unInit(void) { return eaudiofx::ERR_NONE; }; +int32_t eaudiofx::ReceiverRtAudio::start(void) { + EAUDIOFX_DEBUG("Start stream ..."); + m_processStarted = true; + return eaudiofx::ERR_NONE; +}; + +int32_t eaudiofx::ReceiverRtAudio::stop(void) { + EAUDIOFX_DEBUG("Stop Stream ..."); + m_processStarted = false; + return eaudiofx::ERR_NONE; +}; diff --git a/eaudiofx/base/ReceiverRtAudio.h b/eaudiofx/base/ReceiverRtAudio.h index 1b0fe84..6a119cf 100644 --- a/eaudiofx/base/ReceiverRtAudio.h +++ b/eaudiofx/base/ReceiverRtAudio.h @@ -32,6 +32,11 @@ namespace eaudiofx { public: // herieted function : virtual int32_t init(void); virtual int32_t unInit(void); + private: + bool m_processStarted; + public: + virtual int32_t start(void); + virtual int32_t stop(void); protected: airtaudio::Interface m_dac; airtaudio::StreamParameters m_parameters; diff --git a/eaudiofx/core/Block.cpp b/eaudiofx/core/Block.cpp index 434af81..d72e0a4 100644 --- a/eaudiofx/core/Block.cpp +++ b/eaudiofx/core/Block.cpp @@ -41,8 +41,10 @@ eaudiofx::Block::~Block(void) { int32_t eaudiofx::Block::pull(double _currentTime, int32_t _request, float _timeout) { int32_t ret = eaudiofx::ERR_NONE; + //EAUDIOFX_DEBUG("Pull request for " << m_io.size() << " IO(s)"); for (auto &it : m_io) { if (it.second.m_buffer == NULL) { + EAUDIOFX_DEBUG(" ==> null buffer"); continue; } if ( it.second.m_type != eaudiofx::Block::ioInput diff --git a/eaudiofx/core/Block.h b/eaudiofx/core/Block.h index 12d4e6a..e4df8a2 100644 --- a/eaudiofx/core/Block.h +++ b/eaudiofx/core/Block.h @@ -119,6 +119,12 @@ namespace eaudiofx { virtual int32_t unInit(void) { return eaudiofx::ERR_NONE; }; + virtual int32_t start(void) { + return eaudiofx::ERR_NONE; + }; + virtual int32_t stop(void) { + return eaudiofx::ERR_NONE; + }; /** * @brief Call by downstream to request some data * @param[in] _currentTime Current stream time (in second) diff --git a/eaudiofx/core/BlockDecoder.cpp b/eaudiofx/core/BlockDecoder.cpp index 1630e67..6625955 100644 --- a/eaudiofx/core/BlockDecoder.cpp +++ b/eaudiofx/core/BlockDecoder.cpp @@ -37,7 +37,6 @@ eaudiofx::BlockDecoder::BlockDecoder(void) : } int32_t eaudiofx::BlockDecoder::pull(double _currentTime, int32_t _request, float _timeout) { - auto itOut = m_io.find("out"); if (itOut == m_io.end()) { EAUDIOFX_WARNING("request to pull data with no output !!!"); @@ -58,7 +57,7 @@ int32_t eaudiofx::BlockDecoder::pull(double _currentTime, int32_t _request, floa bufferOut->setProperty(48000, 2, _request); float* dataOut = bufferOut->getData(); int32_t offset = 0; - EAUDIOFX_DEBUG("Request data : " << (_request*2) ); + //EAUDIOFX_DEBUG("Request data : " << (_request*2) ); while (1) { int32_t nbSampleToCopy = etk_min(m_nbSampleIn, _request*2 - offset); if (m_nbSampleIn > 0) { @@ -73,12 +72,10 @@ int32_t eaudiofx::BlockDecoder::pull(double _currentTime, int32_t _request, floa for (int32_t iii=0; iii < MAX_DATA_IN_BUFFER-nbSampleToCopy; ++iii) { m_tmpBuffer[iii] = m_tmpBuffer[nbSampleToCopy+iii]; } + } else { + m_nbSampleIn = 0; } if (offset == _request*2) { - FILE* plopppp = fopen("plopDEC.raw", "a"); - fwrite(dataOut, sizeof(float), _request*2, plopppp); - fflush(plopppp); - fclose(plopppp); // putput have enought data return eaudiofx::ERR_NONE; } @@ -117,7 +114,7 @@ int32_t eaudiofx::BlockDecoder::pull(double _currentTime, int32_t _request, floa m_nbSampleIn++; } } - EAUDIOFX_DEBUG("internal FIFO : " << m_nbSampleIn ); + //EAUDIOFX_DEBUG("internal FIFO : " << m_nbSampleIn ); } return eaudiofx::ERR_NONE; } diff --git a/eaudiofx/core/BlockMeta.cpp b/eaudiofx/core/BlockMeta.cpp index b9e8a5b..29542de 100644 --- a/eaudiofx/core/BlockMeta.cpp +++ b/eaudiofx/core/BlockMeta.cpp @@ -151,3 +151,38 @@ int32_t eaudiofx::BlockMeta::unInit(void) { return ret; }; + +int32_t eaudiofx::BlockMeta::start(void) { + EAUDIOFX_INFO("[" << getUID() << "] Start Meta block : '" << getName() << "'"); + int32_t ret = eaudiofx::ERR_NONE; + for (auto &it : m_list) { + if (it == NULL) { + continue; + } + if (it->start() != eaudiofx::ERR_NONE) { + ret = eaudiofx::ERR_FAIL; + } + } + if (ret != eaudiofx::ERR_NONE) { + EAUDIOFX_WARNING("Pb when start the Meta-block '" << getName() << "' "); + } + return ret; +}; + +int32_t eaudiofx::BlockMeta::stop(void) { + EAUDIOFX_INFO("[" << getUID() << "] Stop Meta block : '" << getName() << "'"); + int32_t ret = eaudiofx::ERR_NONE; + for (auto &it : m_list) { + if (it == NULL) { + continue; + } + if (it->stop() != eaudiofx::ERR_NONE) { + ret = eaudiofx::ERR_FAIL; + } + } + if (ret != eaudiofx::ERR_NONE) { + EAUDIOFX_WARNING("Pb when stop the Meta-block '" << getName() << "' "); + } + return ret; +}; + diff --git a/eaudiofx/core/BlockMeta.h b/eaudiofx/core/BlockMeta.h index 056e456..a6a746d 100644 --- a/eaudiofx/core/BlockMeta.h +++ b/eaudiofx/core/BlockMeta.h @@ -82,6 +82,8 @@ namespace eaudiofx { public: // herited function virtual int32_t init(void); virtual int32_t unInit(void); + virtual int32_t start(void); + virtual int32_t stop(void); }; }; diff --git a/eaudiofx/core/BufferStream.cpp b/eaudiofx/core/BufferStream.cpp index 8152f88..aa62a8f 100644 --- a/eaudiofx/core/BufferStream.cpp +++ b/eaudiofx/core/BufferStream.cpp @@ -34,8 +34,8 @@ void eaudiofx::BufferStream::resize(size_t _newSize) { m_data = NULL; m_allocated = 0; } - EAUDIOFX_ERROR("Request allocate of " << _newSize << " samples"); - m_data = new uint8_t[_newSize]; + EAUDIOFX_ERROR("Request allocate of " << _newSize << " bytes"); + m_data = new uint8_t[_newSize*2]; if (m_data == NULL) { EAUDIOFX_ERROR("Can not allocate Buffer Audio"); } else { diff --git a/eaudiofx/core/Processing.cpp b/eaudiofx/core/Processing.cpp index 03f3166..5c6664a 100644 --- a/eaudiofx/core/Processing.cpp +++ b/eaudiofx/core/Processing.cpp @@ -17,11 +17,19 @@ int32_t eaudiofx::Processing::process(void) { int32_t eaudiofx::Processing::start(void) { EAUDIOFX_INFO("Start Processing : '" << getName() << "'"); - return init(); + int32_t ret = init(); + if (ret != eaudiofx::ERR_NONE) { + return ret; + } + return eaudiofx::BlockMeta::start(); } int32_t eaudiofx::Processing::stop(void) { EAUDIOFX_INFO("Stop Processing : '" << getName() << "'"); + int32_t ret = eaudiofx::BlockMeta::stop(); + if (ret != eaudiofx::ERR_NONE) { + return ret; + } return unInit(); } diff --git a/lutin_eaudiofx_test.py b/lutin_eaudiofx_test.py index 6865574..f4111f4 100644 --- a/lutin_eaudiofx_test.py +++ b/lutin_eaudiofx_test.py @@ -8,7 +8,7 @@ def get_desc(): def create(target): - myModule = module.Module(__file__, 'eaudiofx_test', 'BINARY') + myModule = module.Module(__file__, 'eaudiofx_test', 'PACKAGE') # basic GUI : myModule.add_src_file([ 'test/debug.cpp', @@ -21,6 +21,24 @@ def create(target): myModule.add_export_path(tools.get_current_path(__file__)) + myModule.copy_folder("data/Font/Free*.ttf","fonts/") + myModule.copy_folder("data/menu*","") + + # set the package properties : + myModule.pkg_set("VERSION", "0.0.0") + myModule.pkg_set("COMPAGNY_TYPE", "org") + myModule.pkg_set("COMPAGNY_NAME", "Edouard DUPIN") + myModule.pkg_set("MAINTAINER", ["Mr DUPIN Edouard "]) + #if target.name=="MacOs": + # myModule.pkg_set("ICON", tools.get_current_path(__file__) + "/../data/icon.icns") + #else: + # myModule.pkg_set("ICON", tools.get_current_path(__file__) + "/../data/icon.png") + + myModule.pkg_set("SECTION", ["Test"]) + myModule.pkg_set("PRIORITY", "optional") + myModule.pkg_set("DESCRIPTION", "Test tool of e-audio-FX") + myModule.pkg_set("NAME", "e-audio-FX test") + # add the currrent module at the return myModule diff --git a/test/Main.cpp b/test/Main.cpp index 1b2283a..55c0c3a 100644 --- a/test/Main.cpp +++ b/test/Main.cpp @@ -38,8 +38,8 @@ bool APP_Init(ewol::Context& _context) { _context.setSize(vec2(800, 600)); // select internal data for font ... - _context.getFontDefault().setUseExternal(true); - _context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19); + _context.getFontDefault().setUseExternal(false); + _context.getFontDefault().set("FreeSerif", 30); ewol::widget::Windows* basicWindows = new appl::Windows(); // create the specific windows diff --git a/test/Windows.cpp b/test/Windows.cpp index 822327e..033d364 100644 --- a/test/Windows.cpp +++ b/test/Windows.cpp @@ -96,7 +96,6 @@ void appl::Windows::onReceiveMessage(const ewol::object::Message& _msg) { process->start(); return; #else - APPL_INFO("Play Requested ..."); process = new eaudiofx::Processing(); if (process == NULL) {