[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);
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;
}

View File

@ -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;

View File

@ -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;
};

View File

@ -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;

View File

@ -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

View File

@ -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)

View File

@ -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;
}

View File

@ -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;
};

View File

@ -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);
};
};

View File

@ -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 {

View File

@ -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();
}

View File

@ -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 <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
return myModule

View File

@ -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

View File

@ -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) {