[DEV] work on anroid basic wav test

This commit is contained in:
Edouard DUPIN 2014-03-20 10:25:53 +01:00
parent baf70033f3
commit 5f94203fff
20 changed files with 119 additions and 23 deletions

BIN
data/Font/FreeSerif.ttf Normal file

Binary file not shown.

BIN
data/Font/FreeSerifBold.ttf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/menu.ogg Normal file

Binary file not shown.

BIN
data/menu.wav Normal file

Binary file not shown.

View File

@ -44,6 +44,7 @@ int32_t eaudiofx::GeneratorFile::pull(double _currentTime, int32_t _request, flo
buffer->setProperty(_request); buffer->setProperty(_request);
uint8_t* data = buffer->getData(); uint8_t* data = buffer->getData();
if (m_file == NULL) { if (m_file == NULL) {
EAUDIOFX_ERROR("Buffer output error ==> !!ERROR!!");
return eaudiofx::ERR_FAIL; return eaudiofx::ERR_FAIL;
} }
int64_t nbRead = m_file->fileRead(data, sizeof(uint8_t), _request); 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) { 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) { if (m_file == NULL) {
EAUDIOFX_ERROR("Can not allocate the input file ..."); EAUDIOFX_ERROR("Can not allocate the input file ...");
return eaudiofx::ERR_FAIL; return eaudiofx::ERR_FAIL;
@ -72,8 +73,12 @@ int32_t eaudiofx::GeneratorFile::unInit(void) {
} }
if (m_file->fileClose() == false) { if (m_file->fileClose() == false) {
EAUDIOFX_ERROR("Can not close the input file ..."); EAUDIOFX_ERROR("Can not close the input file ...");
delete(m_file);
m_file = NULL;
return eaudiofx::ERR_FAIL; return eaudiofx::ERR_FAIL;
} }
delete(m_file);
m_file = NULL;
return eaudiofx::ERR_NONE; return eaudiofx::ERR_NONE;
} }

View File

@ -42,7 +42,6 @@ int32_t eaudiofx::GeneratorSignal::pull(double _currentTime, int32_t _request, f
//request outpuffer needed size : //request outpuffer needed size :
buffer->setProperty(48000, 2, _request); buffer->setProperty(48000, 2, _request);
float* data = buffer->getData(); float* data = buffer->getData();
for (int32_t iii=0; iii<_request; ++iii) { for (int32_t iii=0; iii<_request; ++iii) {
for (int32_t jjj=0; jjj<2; ++jjj) { for (int32_t jjj=0; jjj<2; ++jjj) {
*data++ = cos(m_phase)*0.5f; *data++ = cos(m_phase)*0.5f;

View File

@ -38,10 +38,16 @@ int32_t eaudiofx::ReceiverRtAudio::needData(float* _outputBuffer,
size_t _nBufferFrames, size_t _nBufferFrames,
double _streamTime, double _streamTime,
airtaudio::streamStatus _status) { airtaudio::streamStatus _status) {
if (m_processStarted == false) {
for (int32_t iii=0; iii<_nBufferFrames*2; ++iii) {
_outputBuffer[iii] = 0;
}
return 0;
}
// Request block input: // Request block input:
int32_t ret = eaudiofx::Block::pull(_streamTime, _nBufferFrames, (float)_nBufferFrames/48000.0f); int32_t ret = eaudiofx::Block::pull(_streamTime, _nBufferFrames, (float)_nBufferFrames/48000.0f);
if (ret != eaudiofx::ERR_NONE) { if (ret != eaudiofx::ERR_NONE) {
EAUDIOFX_ERROR("wan not get data ..."); EAUDIOFX_ERROR("can not get data ...");
return -1; return -1;
} }
auto it = m_io.find("in"); auto it = m_io.find("in");
@ -56,7 +62,8 @@ int32_t eaudiofx::ReceiverRtAudio::needData(float* _outputBuffer,
} }
float* data = buffer->getData(); float* data = buffer->getData();
for (int32_t iii=0; iii<_nBufferFrames*2; ++iii) { 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"); 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); setLive(true);
// set output : // set output :
m_io.insert( m_io.insert(
@ -85,18 +93,19 @@ eaudiofx::ReceiverRtAudio::ReceiverRtAudio(void) {
int32_t eaudiofx::ReceiverRtAudio::init(void) { int32_t eaudiofx::ReceiverRtAudio::init(void) {
EAUDIOFX_DEBUG("Intanciat AirTAudio Interface ...");
m_dac.instanciate(); m_dac.instanciate();
EAUDIOFX_DEBUG("Create RTAudio generator ..."); EAUDIOFX_DEBUG("Create RTAudio receiver ...");
if ( m_dac.getDeviceCount() < 1 ) { if ( m_dac.getDeviceCount() < 1 ) {
EAUDIOFX_ERROR("No audio devices found!"); 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()); EAUDIOFX_DEBUG("nb devices :" << m_dac.getDeviceCount() << " default device ID : " << m_dac.getDefaultOutputDevice());
m_parameters.deviceId = m_dac.getDefaultOutputDevice(); m_parameters.deviceId = m_dac.getDefaultOutputDevice();
m_parameters.nChannels = 2; m_parameters.nChannels = 2;
m_parameters.firstChannel = 0; m_parameters.firstChannel = 0;
unsigned int bufferFrames = 256; unsigned int bufferFrames = 256;
EAUDIOFX_DEBUG("OPEN Stream ..."); EAUDIOFX_DEBUG("init Stream ...");
// TODO : Check return error // TODO : Check return error
m_dac.openStream(&m_parameters, NULL, airtaudio::FLOAT32, 48000, &bufferFrames, &rtAudioCallBack, (void *)this); m_dac.openStream(&m_parameters, NULL, airtaudio::FLOAT32, 48000, &bufferFrames, &rtAudioCallBack, (void *)this);
// TODO : Check return error // TODO : Check return error
@ -106,7 +115,7 @@ int32_t eaudiofx::ReceiverRtAudio::init(void) {
}; };
int32_t eaudiofx::ReceiverRtAudio::unInit(void) { int32_t eaudiofx::ReceiverRtAudio::unInit(void) {
EAUDIOFX_DEBUG("STOP Stream ..."); EAUDIOFX_DEBUG("un-init Stream ...");
// Stop the stream // Stop the stream
m_dac.stopStream(); m_dac.stopStream();
// TODO : Check return error // TODO : Check return error
@ -117,4 +126,15 @@ int32_t eaudiofx::ReceiverRtAudio::unInit(void) {
return eaudiofx::ERR_NONE; 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;
};

View File

@ -32,6 +32,11 @@ namespace eaudiofx {
public: // herieted function : public: // herieted function :
virtual int32_t init(void); virtual int32_t init(void);
virtual int32_t unInit(void); virtual int32_t unInit(void);
private:
bool m_processStarted;
public:
virtual int32_t start(void);
virtual int32_t stop(void);
protected: protected:
airtaudio::Interface m_dac; airtaudio::Interface m_dac;
airtaudio::StreamParameters m_parameters; airtaudio::StreamParameters m_parameters;

View File

@ -41,8 +41,10 @@ eaudiofx::Block::~Block(void) {
int32_t eaudiofx::Block::pull(double _currentTime, int32_t _request, float _timeout) { int32_t eaudiofx::Block::pull(double _currentTime, int32_t _request, float _timeout) {
int32_t ret = eaudiofx::ERR_NONE; int32_t ret = eaudiofx::ERR_NONE;
//EAUDIOFX_DEBUG("Pull request for " << m_io.size() << " IO(s)");
for (auto &it : m_io) { for (auto &it : m_io) {
if (it.second.m_buffer == NULL) { if (it.second.m_buffer == NULL) {
EAUDIOFX_DEBUG(" ==> null buffer");
continue; continue;
} }
if ( it.second.m_type != eaudiofx::Block::ioInput if ( it.second.m_type != eaudiofx::Block::ioInput

View File

@ -119,6 +119,12 @@ namespace eaudiofx {
virtual int32_t unInit(void) { virtual int32_t unInit(void) {
return eaudiofx::ERR_NONE; 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 * @brief Call by downstream to request some data
* @param[in] _currentTime Current stream time (in second) * @param[in] _currentTime Current stream time (in second)

View File

@ -37,7 +37,6 @@ eaudiofx::BlockDecoder::BlockDecoder(void) :
} }
int32_t eaudiofx::BlockDecoder::pull(double _currentTime, int32_t _request, float _timeout) { int32_t eaudiofx::BlockDecoder::pull(double _currentTime, int32_t _request, float _timeout) {
auto itOut = m_io.find("out"); auto itOut = m_io.find("out");
if (itOut == m_io.end()) { if (itOut == m_io.end()) {
EAUDIOFX_WARNING("request to pull data with no output !!!"); 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); bufferOut->setProperty(48000, 2, _request);
float* dataOut = bufferOut->getData(); float* dataOut = bufferOut->getData();
int32_t offset = 0; int32_t offset = 0;
EAUDIOFX_DEBUG("Request data : " << (_request*2) ); //EAUDIOFX_DEBUG("Request data : " << (_request*2) );
while (1) { while (1) {
int32_t nbSampleToCopy = etk_min(m_nbSampleIn, _request*2 - offset); int32_t nbSampleToCopy = etk_min(m_nbSampleIn, _request*2 - offset);
if (m_nbSampleIn > 0) { 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) { for (int32_t iii=0; iii < MAX_DATA_IN_BUFFER-nbSampleToCopy; ++iii) {
m_tmpBuffer[iii] = m_tmpBuffer[nbSampleToCopy+iii]; m_tmpBuffer[iii] = m_tmpBuffer[nbSampleToCopy+iii];
} }
} else {
m_nbSampleIn = 0;
} }
if (offset == _request*2) { 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 // putput have enought data
return eaudiofx::ERR_NONE; return eaudiofx::ERR_NONE;
} }
@ -117,7 +114,7 @@ int32_t eaudiofx::BlockDecoder::pull(double _currentTime, int32_t _request, floa
m_nbSampleIn++; m_nbSampleIn++;
} }
} }
EAUDIOFX_DEBUG("internal FIFO : " << m_nbSampleIn ); //EAUDIOFX_DEBUG("internal FIFO : " << m_nbSampleIn );
} }
return eaudiofx::ERR_NONE; return eaudiofx::ERR_NONE;
} }

View File

@ -151,3 +151,38 @@ int32_t eaudiofx::BlockMeta::unInit(void) {
return ret; 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;
};

View File

@ -82,6 +82,8 @@ namespace eaudiofx {
public: // herited function public: // herited function
virtual int32_t init(void); virtual int32_t init(void);
virtual int32_t unInit(void); virtual int32_t unInit(void);
virtual int32_t start(void);
virtual int32_t stop(void);
}; };
}; };

View File

@ -34,8 +34,8 @@ void eaudiofx::BufferStream::resize(size_t _newSize) {
m_data = NULL; m_data = NULL;
m_allocated = 0; m_allocated = 0;
} }
EAUDIOFX_ERROR("Request allocate of " << _newSize << " samples"); EAUDIOFX_ERROR("Request allocate of " << _newSize << " bytes");
m_data = new uint8_t[_newSize]; m_data = new uint8_t[_newSize*2];
if (m_data == NULL) { if (m_data == NULL) {
EAUDIOFX_ERROR("Can not allocate Buffer Audio"); EAUDIOFX_ERROR("Can not allocate Buffer Audio");
} else { } else {

View File

@ -17,11 +17,19 @@ int32_t eaudiofx::Processing::process(void) {
int32_t eaudiofx::Processing::start(void) { int32_t eaudiofx::Processing::start(void) {
EAUDIOFX_INFO("Start Processing : '" << getName() << "'"); 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) { int32_t eaudiofx::Processing::stop(void) {
EAUDIOFX_INFO("Stop Processing : '" << getName() << "'"); EAUDIOFX_INFO("Stop Processing : '" << getName() << "'");
int32_t ret = eaudiofx::BlockMeta::stop();
if (ret != eaudiofx::ERR_NONE) {
return ret;
}
return unInit(); return unInit();
} }

View File

@ -8,7 +8,7 @@ def get_desc():
def create(target): def create(target):
myModule = module.Module(__file__, 'eaudiofx_test', 'BINARY') myModule = module.Module(__file__, 'eaudiofx_test', 'PACKAGE')
# basic GUI : # basic GUI :
myModule.add_src_file([ myModule.add_src_file([
'test/debug.cpp', 'test/debug.cpp',
@ -21,6 +21,24 @@ def create(target):
myModule.add_export_path(tools.get_current_path(__file__)) 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 <yui.heero@gmail.com>"])
#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 # add the currrent module at the
return myModule return myModule

View File

@ -38,8 +38,8 @@ bool APP_Init(ewol::Context& _context) {
_context.setSize(vec2(800, 600)); _context.setSize(vec2(800, 600));
// select internal data for font ... // select internal data for font ...
_context.getFontDefault().setUseExternal(true); _context.getFontDefault().setUseExternal(false);
_context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19); _context.getFontDefault().set("FreeSerif", 30);
ewol::widget::Windows* basicWindows = new appl::Windows(); ewol::widget::Windows* basicWindows = new appl::Windows();
// create the specific windows // create the specific windows

View File

@ -96,7 +96,6 @@ void appl::Windows::onReceiveMessage(const ewol::object::Message& _msg) {
process->start(); process->start();
return; return;
#else #else
APPL_INFO("Play Requested ..."); APPL_INFO("Play Requested ...");
process = new eaudiofx::Processing(); process = new eaudiofx::Processing();
if (process == NULL) { if (process == NULL) {