[DEV] start dev of time control engine
This commit is contained in:
parent
e1e95e46e0
commit
411ee20918
@ -8,12 +8,17 @@
|
|||||||
|
|
||||||
#include <eaudiofx/debug.h>
|
#include <eaudiofx/debug.h>
|
||||||
#include <eaudiofx/base/GeneratorSignal.h>
|
#include <eaudiofx/base/GeneratorSignal.h>
|
||||||
#include <eaudiofx/core/BufferAudioRaw.h>
|
#include <eaudiofx/core/BufferAudio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
|
void eaudiofx::GeneratorSignal::init() {
|
||||||
|
eaudiofx::Block::init();
|
||||||
|
}
|
||||||
|
|
||||||
eaudiofx::GeneratorSignal::GeneratorSignal() :
|
eaudiofx::GeneratorSignal::GeneratorSignal() :
|
||||||
m_phase(0) {
|
m_phase(0) {
|
||||||
|
/*
|
||||||
// set output :
|
// set output :
|
||||||
m_io.insert(
|
m_io.insert(
|
||||||
std::pair<std::string, eaudiofx::Block::IOProperty>(
|
std::pair<std::string, eaudiofx::Block::IOProperty>(
|
||||||
@ -21,11 +26,17 @@ eaudiofx::GeneratorSignal::GeneratorSignal() :
|
|||||||
eaudiofx::Block::IOProperty(
|
eaudiofx::Block::IOProperty(
|
||||||
eaudiofx::Block::ioOutput,
|
eaudiofx::Block::ioOutput,
|
||||||
"{ type:'audio', compression:'raw', frequency:48000, channel:2, format:'float' }",
|
"{ type:'audio', compression:'raw', frequency:48000, channel:2, format:'float' }",
|
||||||
new eaudiofx::BufferAudioRaw(*this, 48000, 2)
|
new eaudiofx::BufferAudio(*this)
|
||||||
) ) );
|
) ) );
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t eaudiofx::GeneratorSignal::algoProcess(int64_t _currentTime, int64_t _processTimeSlot) {
|
||||||
|
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
int32_t eaudiofx::GeneratorSignal::pull(double _currentTime, int32_t _request, float _timeout) {
|
int32_t eaudiofx::GeneratorSignal::pull(double _currentTime, int32_t _request, float _timeout) {
|
||||||
auto it = m_io.find("out");
|
auto it = m_io.find("out");
|
||||||
if (it == m_io.end()) {
|
if (it == m_io.end()) {
|
||||||
@ -59,3 +70,4 @@ int32_t eaudiofx::GeneratorSignal::pull(double _currentTime, int32_t _request, f
|
|||||||
*/
|
*/
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -9,17 +9,20 @@
|
|||||||
#ifndef __EAUDIOFX_GENERATOR_SIGNAL_H__
|
#ifndef __EAUDIOFX_GENERATOR_SIGNAL_H__
|
||||||
#define __EAUDIOFX_GENERATOR_SIGNAL_H__
|
#define __EAUDIOFX_GENERATOR_SIGNAL_H__
|
||||||
|
|
||||||
#include <eaudiofx/core/BlockGenerator.h>
|
#include <eaudiofx/core/Block.h>
|
||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
class GeneratorSignal : public eaudiofx::BlockGenerator {
|
class GeneratorSignal : public eaudiofx::Block {
|
||||||
protected:
|
protected:
|
||||||
float m_phase;
|
float m_phase;
|
||||||
public:
|
protected:
|
||||||
GeneratorSignal();
|
GeneratorSignal();
|
||||||
|
void init();
|
||||||
|
public:
|
||||||
|
DECLARE_FACTORY(GeneratorSignal);
|
||||||
virtual ~GeneratorSignal() {};
|
virtual ~GeneratorSignal() {};
|
||||||
public:
|
public:
|
||||||
int32_t pull(double _currentTime, int32_t _request, float _timeout);
|
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,6 +6,92 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <eaudiofx/debug.h>
|
||||||
#include <eaudiofx/base/ReceiverFile.h>
|
#include <eaudiofx/base/ReceiverFile.h>
|
||||||
|
|
||||||
|
|
||||||
|
eaudiofx::ReceiverFile::ReceiverFile() :
|
||||||
|
m_file(nullptr),
|
||||||
|
m_channels(4),
|
||||||
|
m_frequency(16000),
|
||||||
|
m_requestSize(256),
|
||||||
|
m_processStarted(false) {
|
||||||
|
// set input :
|
||||||
|
m_io.insert(
|
||||||
|
std::pair<std::string, eaudiofx::Block::IOProperty>(
|
||||||
|
"in",
|
||||||
|
eaudiofx::Block::IOProperty(
|
||||||
|
eaudiofx::Block::ioInput,
|
||||||
|
"{ type:'audio', compression:'raw', frequency:16000, channel:4, format:'int16_t' }",
|
||||||
|
NULL
|
||||||
|
) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t eaudiofx::ReceiverFile::init() {
|
||||||
|
m_file = new etk::FSNode("ouput.raw");
|
||||||
|
if (m_file == NULL) {
|
||||||
|
EAUDIOFX_ERROR("Can not allocate the output file ...");
|
||||||
|
return eaudiofx::ERR_FAIL;
|
||||||
|
}
|
||||||
|
if (m_file->fileOpenWrite() == false) {
|
||||||
|
EAUDIOFX_ERROR("Can not open the output file ...");
|
||||||
|
return eaudiofx::ERR_FAIL;
|
||||||
|
}
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
|
};
|
||||||
|
|
||||||
|
int32_t eaudiofx::ReceiverFile::unInit() {
|
||||||
|
EAUDIOFX_DEBUG("un-init Stream ...");
|
||||||
|
if (m_file == NULL) {
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
int32_t eaudiofx::ReceiverFile::start() {
|
||||||
|
EAUDIOFX_DEBUG("Start stream ...");
|
||||||
|
m_processStarted = true;
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
|
};
|
||||||
|
|
||||||
|
int32_t eaudiofx::ReceiverFile::stop() {
|
||||||
|
EAUDIOFX_DEBUG("Stop Stream ...");
|
||||||
|
m_processStarted = false;
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
int32_t eaudiofx::ReceiverFile::pull(double _currentTime, int32_t _request, float _timeout) {
|
||||||
|
auto it = m_io.find("out");
|
||||||
|
if (it == m_io.end()) {
|
||||||
|
EAUDIOFX_WARNING("request to pull data with no output !!!");
|
||||||
|
return eaudiofx::ERR_FAIL;
|
||||||
|
}
|
||||||
|
eaudiofx::BufferStream* buffer = dynamic_cast<eaudiofx::BufferStream*>(it->second.m_buffer);
|
||||||
|
//EAUDIOFX_ERROR("Generate data, request : " << _request << " at time : " << _currentTime);
|
||||||
|
if (buffer == NULL) {
|
||||||
|
// !! impossible case => a buffer can not be removed ...
|
||||||
|
EAUDIOFX_ERROR("Buffer has been removed... OR change type ...");
|
||||||
|
return eaudiofx::ERR_FAIL;
|
||||||
|
}
|
||||||
|
//request outpuffer needed size :
|
||||||
|
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);
|
||||||
|
buffer->setAvaillableSize(nbRead);
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
@ -10,12 +10,25 @@
|
|||||||
#define __EAUDIOFX_RECEIVER_FILE_H__
|
#define __EAUDIOFX_RECEIVER_FILE_H__
|
||||||
|
|
||||||
#include <eaudiofx/core/BlockReceiver.h>
|
#include <eaudiofx/core/BlockReceiver.h>
|
||||||
|
#include <etk/os/FSNode.h>
|
||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
class ReceiverFile : public eaudiofx::BlockReceiver {
|
class ReceiverFile : public eaudiofx::BlockReceiver {
|
||||||
public:
|
public:
|
||||||
ReceiverFile() {};
|
ReceiverFile();
|
||||||
virtual ~ReceiverFile() {};
|
virtual ~ReceiverFile() {};
|
||||||
|
public: // herieted function :
|
||||||
|
virtual int32_t init();
|
||||||
|
virtual int32_t unInit();
|
||||||
|
private:
|
||||||
|
etk::FSNode* m_file;
|
||||||
|
uint32_t m_channels;
|
||||||
|
uint32_t m_frequency;
|
||||||
|
uint32_t m_requestSize;
|
||||||
|
bool m_processStarted;
|
||||||
|
public:
|
||||||
|
virtual int32_t start();
|
||||||
|
virtual int32_t stop();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include <eaudiofx/debug.h>
|
#include <eaudiofx/debug.h>
|
||||||
#include <eaudiofx/base/ReceiverRtAudio.h>
|
#include <eaudiofx/base/ReceiverRtAudio.h>
|
||||||
#include <eaudiofx/core/BufferAudioRaw.h>
|
#include <eaudiofx/core/BufferAudio.h>
|
||||||
#include <airtaudio/Interface.h>
|
#include <airtaudio/Interface.h>
|
||||||
|
|
||||||
int eaudiofx::ReceiverRtAudio::rtAudioCallBack(void *_outputBuffer,
|
int eaudiofx::ReceiverRtAudio::rtAudioCallBack(void *_outputBuffer,
|
||||||
@ -33,7 +33,7 @@ int eaudiofx::ReceiverRtAudio::rtAudioCallBack(void *_outputBuffer,
|
|||||||
|
|
||||||
return classPointer->needData((float*)_outputBuffer, _nBufferFrames, _streamTime, _status);
|
return classPointer->needData((float*)_outputBuffer, _nBufferFrames, _streamTime, _status);
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
int32_t eaudiofx::ReceiverRtAudio::needData(float* _outputBuffer,
|
int32_t eaudiofx::ReceiverRtAudio::needData(float* _outputBuffer,
|
||||||
size_t _nBufferFrames,
|
size_t _nBufferFrames,
|
||||||
double _streamTime,
|
double _streamTime,
|
||||||
@ -73,12 +73,21 @@ int32_t eaudiofx::ReceiverRtAudio::needData(float* _outputBuffer,
|
|||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
int32_t eaudiofx::GeneratorSignal::algoProcess(int64_t _currentTime, int64_t _processTimeSlot) {
|
||||||
|
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void eaudiofx::ReceiverRtAudio::init() {
|
||||||
|
eaudiofx::Block::init();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
eaudiofx::ReceiverRtAudio::ReceiverRtAudio() :
|
eaudiofx::ReceiverRtAudio::ReceiverRtAudio() :
|
||||||
m_processStarted(false) {
|
m_processStarted(false) {
|
||||||
setLive(true);
|
/*
|
||||||
// set output :
|
// set output :
|
||||||
m_io.insert(
|
m_io.insert(
|
||||||
std::pair<std::string, eaudiofx::Block::IOProperty>(
|
std::pair<std::string, eaudiofx::Block::IOProperty>(
|
||||||
@ -88,11 +97,11 @@ eaudiofx::ReceiverRtAudio::ReceiverRtAudio() :
|
|||||||
"{ type:'audio', compression:'raw', frequency:48000, channel:2, format:'float' }",
|
"{ type:'audio', compression:'raw', frequency:48000, channel:2, format:'float' }",
|
||||||
NULL
|
NULL
|
||||||
) ) );
|
) ) );
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int32_t eaudiofx::ReceiverRtAudio::init() {
|
int32_t eaudiofx::ReceiverRtAudio::algoInit() {
|
||||||
EAUDIOFX_DEBUG("Intanciat AirTAudio Interface ...");
|
EAUDIOFX_DEBUG("Intanciat AirTAudio Interface ...");
|
||||||
m_dac.instanciate();
|
m_dac.instanciate();
|
||||||
EAUDIOFX_DEBUG("Create RTAudio receiver ...");
|
EAUDIOFX_DEBUG("Create RTAudio receiver ...");
|
||||||
@ -114,7 +123,7 @@ int32_t eaudiofx::ReceiverRtAudio::init() {
|
|||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t eaudiofx::ReceiverRtAudio::unInit() {
|
int32_t eaudiofx::ReceiverRtAudio::algoUnInit() {
|
||||||
EAUDIOFX_DEBUG("un-init Stream ...");
|
EAUDIOFX_DEBUG("un-init Stream ...");
|
||||||
// Stop the stream
|
// Stop the stream
|
||||||
m_dac.stopStream();
|
m_dac.stopStream();
|
||||||
@ -126,13 +135,13 @@ int32_t eaudiofx::ReceiverRtAudio::unInit() {
|
|||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t eaudiofx::ReceiverRtAudio::start() {
|
int32_t eaudiofx::ReceiverRtAudio::algoStart() {
|
||||||
EAUDIOFX_DEBUG("Start stream ...");
|
EAUDIOFX_DEBUG("Start stream ...");
|
||||||
m_processStarted = true;
|
m_processStarted = true;
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t eaudiofx::ReceiverRtAudio::stop() {
|
int32_t eaudiofx::ReceiverRtAudio::algoStop() {
|
||||||
EAUDIOFX_DEBUG("Stop Stream ...");
|
EAUDIOFX_DEBUG("Stop Stream ...");
|
||||||
m_processStarted = false;
|
m_processStarted = false;
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
#ifndef __EAUDIOFX_RECEIVER_RTAUDIO_H__
|
#ifndef __EAUDIOFX_RECEIVER_RTAUDIO_H__
|
||||||
#define __EAUDIOFX_RECEIVER_RTAUDIO_H__
|
#define __EAUDIOFX_RECEIVER_RTAUDIO_H__
|
||||||
|
|
||||||
#include <eaudiofx/core/BlockReceiver.h>
|
#include <eaudiofx/core/Block.h>
|
||||||
#include <airtaudio/Interface.h>
|
#include <airtaudio/Interface.h>
|
||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
class ReceiverRtAudio : public eaudiofx::BlockReceiver {
|
class ReceiverRtAudio : public eaudiofx::Block {
|
||||||
private:
|
private:
|
||||||
static int rtAudioCallBack(void *_outputBuffer,
|
static int rtAudioCallBack(void *_outputBuffer,
|
||||||
void *_inputBuffer,
|
void *_inputBuffer,
|
||||||
@ -26,20 +26,27 @@ namespace eaudiofx {
|
|||||||
size_t _nBufferFrames,
|
size_t _nBufferFrames,
|
||||||
double _streamTime,
|
double _streamTime,
|
||||||
airtaudio::streamStatus _status);
|
airtaudio::streamStatus _status);
|
||||||
public:
|
protected:
|
||||||
ReceiverRtAudio();
|
ReceiverRtAudio();
|
||||||
|
void init();
|
||||||
|
public:
|
||||||
|
DECLARE_FACTORY(ReceiverRtAudio);
|
||||||
virtual ~ReceiverRtAudio() {};
|
virtual ~ReceiverRtAudio() {};
|
||||||
public: // herieted function :
|
public: // herieted function :
|
||||||
virtual int32_t init();
|
virtual int32_t algoInit();
|
||||||
virtual int32_t unInit();
|
virtual int32_t algoUnInit();
|
||||||
private:
|
private:
|
||||||
bool m_processStarted;
|
bool m_processStarted;
|
||||||
public:
|
public:
|
||||||
virtual int32_t start();
|
virtual int32_t algoStart();
|
||||||
virtual int32_t stop();
|
virtual int32_t algoStop();
|
||||||
protected:
|
protected:
|
||||||
airtaudio::Interface m_dac;
|
airtaudio::Interface m_dac;
|
||||||
airtaudio::StreamParameters m_parameters;
|
airtaudio::StreamParameters m_parameters;
|
||||||
|
public:
|
||||||
|
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot) {
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,233 +13,143 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <ewol/object/Object.h>
|
||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class BlockMeta;
|
class BlockMeta;
|
||||||
enum blockType {
|
|
||||||
blockTypeUnknow,
|
class Block : public ewol::Object {
|
||||||
blockTypeFilter,
|
protected:
|
||||||
blockTypeGenerator,
|
|
||||||
blockTypeReceiver,
|
|
||||||
blockTypeDecoder,
|
|
||||||
blockTypeEncoder,
|
|
||||||
};
|
|
||||||
class Block {
|
|
||||||
public:
|
|
||||||
Block();
|
Block();
|
||||||
|
void init() {
|
||||||
|
ewol::Object::init();
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
DECLARE_FACTORY(Block);
|
||||||
virtual ~Block();
|
virtual ~Block();
|
||||||
protected:
|
protected:
|
||||||
std::mutex m_mutex; //!< Block mutex access
|
std::mutex m_mutex; //!< Block mutex access
|
||||||
private:
|
|
||||||
size_t m_uid; //!< Unique block ID
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Get the Block Unique ID
|
|
||||||
* @return the UID
|
|
||||||
*/
|
|
||||||
size_t getUID() {
|
|
||||||
return m_uid;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
std::string m_name; //!< name of the block
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Set the block name
|
|
||||||
* @param[in] _name New name of the Block
|
|
||||||
*/
|
|
||||||
virtual void setName(const std::string& _name) {
|
|
||||||
m_name = _name;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Set the block name.
|
|
||||||
* @return The block name.
|
|
||||||
*/
|
|
||||||
virtual const std::string& getName() {
|
|
||||||
return m_name;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
enum blockType m_type; // Type of the current block
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Get block type
|
|
||||||
*/
|
|
||||||
virtual enum blockType getType() {
|
|
||||||
return m_type;
|
|
||||||
};
|
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* @brief Set type of the block ==> detect generator and receiver
|
|
||||||
*/
|
|
||||||
virtual void setType(enum blockType _type) {
|
|
||||||
m_type = _type;
|
|
||||||
};
|
|
||||||
protected:
|
|
||||||
eaudiofx::BlockMeta* m_parent;
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Get parrent ob this block
|
|
||||||
* @return Pointer on the parrent if one is set.
|
|
||||||
*/
|
|
||||||
virtual eaudiofx::BlockMeta* getParrent() {
|
|
||||||
return m_parent;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @brief Set the parrent pointer.
|
|
||||||
* @param[in] _meta Pointer on the parrent.
|
|
||||||
*/
|
|
||||||
virtual void setParrent(eaudiofx::BlockMeta* _meta) {
|
|
||||||
m_parent = _meta;
|
|
||||||
};
|
|
||||||
protected:
|
|
||||||
// TODO : set properties ...
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Set a property
|
|
||||||
*/
|
|
||||||
virtual void setProperty(const std::string& _name, const std::string& _property) {};
|
|
||||||
/**
|
|
||||||
* @brief Get a property
|
|
||||||
*/
|
|
||||||
virtual std::string setProperty(const std::string& _name) {
|
|
||||||
return "";
|
|
||||||
};
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Init the block with the properties
|
* @brief Init the block with the properties
|
||||||
* @return A generic error.
|
* @return A generic error.
|
||||||
*/
|
*/
|
||||||
virtual int32_t init() {
|
virtual int32_t algoInit() {
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @brief UnInit the block with the properties
|
* @brief UnInit the block with the properties
|
||||||
* @return A generic error.
|
* @return A generic error.
|
||||||
*/
|
*/
|
||||||
virtual int32_t unInit() {
|
virtual int32_t algoUnInit() {
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
};
|
};
|
||||||
virtual int32_t start() {
|
virtual int32_t algoStart() {
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
};
|
};
|
||||||
virtual int32_t stop() {
|
virtual int32_t algoStop() {
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
};
|
};
|
||||||
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Call by downstream to request some data
|
* @brief get if the block support the native push interface
|
||||||
* @param[in] _currentTime Current stream time (in second)
|
* @return true if the mode is supported
|
||||||
* @param[in] _requestTime Data requested (can be chunk number 256 samples, or data byte for stream) (-1 for automatic)
|
|
||||||
* @param[in] _timeout system time to be obsolet (for realTime streaming) (-1 for no realTime streaming)
|
|
||||||
* @return generic error
|
|
||||||
*/
|
*/
|
||||||
virtual int32_t pull(double _currentTime, int32_t _request, float _timeout);
|
virtual bool supportNativePush() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Get The total stream size (in byte for streaming byte element, in second for time streaming)
|
* @brief get if the block support the native pull interface
|
||||||
* @param[out] _value Get total streaming time (-1 for unknown)
|
* @return true if the mode is supported
|
||||||
* @return generic error
|
|
||||||
*/
|
*/
|
||||||
virtual int32_t getTotal(double& _value) {
|
virtual bool supportNativePull() {
|
||||||
_value = -1;
|
return false;
|
||||||
return eaudiofx::ERR_NONE;
|
}
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* @brief Seek to a specific position in the stream (in byte for streaming byte element, in second for time streaming)
|
* @brief get if the block support the native Time interface
|
||||||
* @param[out] _pos position to seek (0 for starting)
|
* @return true if the mode is supported
|
||||||
* @return generic error
|
|
||||||
*/
|
*/
|
||||||
virtual int32_t seekTo(double _pos) {
|
virtual bool supportNativeTime() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/* *****************************************************************
|
||||||
|
** INPUTS **
|
||||||
|
***************************************************************** */
|
||||||
|
protected:
|
||||||
|
std::vector<std::pair<std::string, std::string>> m_inputCapabilities; //!< Description of the capabilities of all the inputs (name, capacity)
|
||||||
|
public:
|
||||||
|
int32_t getNumberOfInput() {
|
||||||
|
return m_inputCapabilities.size();
|
||||||
|
}
|
||||||
|
int32_t addInput(const std::string& _name, const std::string& _description) {
|
||||||
|
// TODO :Add check of input already exist
|
||||||
|
m_inputCapabilities.push_back(std::make_pair(_name,_description));
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
};
|
}
|
||||||
/**
|
protected:
|
||||||
* @brief Request a flush of the current buffer
|
std::vector<std::string> m_inputLink; //!< Name of output linked
|
||||||
* @param[in] _currentTime Current stream time (in second)
|
public:
|
||||||
* @param[in] _timeout system time to be obsolet (for realTime streaming) (-1 for no realTime streaming)
|
void setInputName(size_t _inputId, const std::string& _nameDistantLink);
|
||||||
* @return generic error
|
void setInputName(const std::string& _nameInput, const std::string& _nameDistantLink);
|
||||||
*/
|
protected:
|
||||||
virtual int32_t flush(double _currentTime, float _timeout) {
|
std::vector<std::shared_ptr<eaudiofx::Buffer>> m_inputs; //!< Link on the input buffer
|
||||||
|
public:
|
||||||
|
virtual int32_t linkAllInputs() {
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
};
|
}
|
||||||
|
virtual int32_t unLinkAllInputs() {
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* *****************************************************************
|
||||||
|
** OUTPUTS **
|
||||||
|
***************************************************************** */
|
||||||
|
protected:
|
||||||
|
std::vector<std::pair<std::string, std::string>> m_outputCapabilities; //!< Description of the capabilities of all the outputs (name, capacity)
|
||||||
|
public:
|
||||||
|
int32_t getNumberOfOutput() {
|
||||||
|
return m_outputCapabilities.size();
|
||||||
|
}
|
||||||
|
int32_t addOutput(const std::string& _name, const std::string& _description) {
|
||||||
|
// TODO :Add check of output already exist
|
||||||
|
m_outputCapabilities.push_back(std::make_pair(_name,_description));
|
||||||
|
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
std::vector<std::string> m_outputLink; //!< Name of output linked
|
||||||
|
public:
|
||||||
|
void setOutputName(size_t _inputId, const std::string& _nameDistantLink);
|
||||||
|
void setOutputName(const std::string& _nameInput, const std::string& _nameDistantLink);
|
||||||
|
protected:
|
||||||
|
std::vector<std::shared_ptr<eaudiofx::Buffer>> m_outputs;
|
||||||
|
public:
|
||||||
|
virtual int32_t allocateAllOutputs(int64_t _processTimeSlot) {
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
|
}
|
||||||
|
virtual int32_t cleanAllOutputs() {
|
||||||
|
return eaudiofx::ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reset the block
|
* @brief Reset the block
|
||||||
* @return generic error
|
* @return generic error
|
||||||
*/
|
*/
|
||||||
virtual int32_t reset() {
|
virtual int32_t algoReset() {
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
};
|
};
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Call when a buffer is removed from the system (current).
|
|
||||||
* @param[in] _buffer Pointer on the removed buffer.
|
|
||||||
*/
|
|
||||||
virtual void onRemoveBuffer(const eaudiofx::Buffer* _buffer);
|
|
||||||
/**
|
|
||||||
* @brief A child call his parrent that it is removing a buffer.
|
|
||||||
* @param[in] _buffer Pointer on the removed buffer.
|
|
||||||
*/
|
|
||||||
virtual void subRemoveBuffer(const eaudiofx::Buffer* _buffer);
|
|
||||||
protected:
|
|
||||||
enum typeIO {
|
|
||||||
ioUnknow,
|
|
||||||
ioInput,
|
|
||||||
ioOutput,
|
|
||||||
ioParameter,
|
|
||||||
};
|
|
||||||
class IOProperty {
|
|
||||||
public:
|
|
||||||
enum typeIO m_type;
|
|
||||||
std::string m_description;
|
|
||||||
bool m_internal;
|
|
||||||
eaudiofx::Buffer* m_buffer;
|
|
||||||
IOProperty(enum typeIO _type,
|
|
||||||
const std::string& _description="",
|
|
||||||
eaudiofx::Buffer* _buffer = NULL) :
|
|
||||||
m_type(_type),
|
|
||||||
m_description(_description),
|
|
||||||
m_internal(true),
|
|
||||||
m_buffer(_buffer) {
|
|
||||||
if (m_type == ioParameter) {
|
|
||||||
// TODO : Autogenerate buffer for parameter ...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IOProperty() :
|
|
||||||
m_type(ioUnknow),
|
|
||||||
m_internal(false),
|
|
||||||
m_buffer(NULL) {
|
|
||||||
|
|
||||||
}
|
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot) {
|
||||||
};
|
|
||||||
std::map<std::string, eaudiofx::Block::IOProperty> m_io; //!< All IO in the Block
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Link the provided buffer to the IO name.
|
|
||||||
* @param[in] _buffer Pointer on the buffer to link.
|
|
||||||
* @param[in] _name Name of the IO;
|
|
||||||
* @return A generic error.
|
|
||||||
*/
|
|
||||||
virtual int32_t linkBuffer(eaudiofx::Buffer* _buffer, const std::string& _name);
|
|
||||||
/**
|
|
||||||
* @brief Un link a speific buffer to the IO name.
|
|
||||||
* @param[in] _buffer Pointer on the buffer to unlink.
|
|
||||||
* @param[in] _name Name of the IO to unlink;
|
|
||||||
* @return A generic error.
|
|
||||||
*/
|
|
||||||
virtual int32_t unLinkBuffer(const eaudiofx::Buffer* _buffer);
|
|
||||||
//! @previous
|
|
||||||
virtual int32_t unLinkBuffer(const std::string& _name);
|
|
||||||
/**
|
|
||||||
* @brief Request a buffer pointer on the IO named.
|
|
||||||
* @param[out] _buffer Pointer on the buffer to link.
|
|
||||||
* @param[in] _name Name of the IO;
|
|
||||||
* @return A generic error.
|
|
||||||
*/
|
|
||||||
virtual int32_t getBuffer(eaudiofx::Buffer*& _buffer, const std::string& _name);
|
|
||||||
/**
|
|
||||||
* @brief Update the IO property
|
|
||||||
* @return A generic error.
|
|
||||||
*/
|
|
||||||
virtual int32_t UpdateIOProperty() {
|
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
};
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,134 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <eaudiofx/debug.h>
|
|
||||||
#include <eaudiofx/base/GeneratorSignal.h>
|
|
||||||
#include <eaudiofx/core/BufferStream.h>
|
|
||||||
#include <eaudiofx/core/BufferAudioRaw.h>
|
|
||||||
#include <eaudiofx/core/BlockDecoder.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
eaudiofx::BlockDecoder::BlockDecoder() :
|
|
||||||
m_nbSampleIn(0) {
|
|
||||||
setType(eaudiofx::blockTypeDecoder);
|
|
||||||
// set input :
|
|
||||||
m_io.insert(
|
|
||||||
std::pair<std::string, eaudiofx::Block::IOProperty>(
|
|
||||||
"in",
|
|
||||||
eaudiofx::Block::IOProperty(
|
|
||||||
eaudiofx::Block::ioInput,
|
|
||||||
"{ type:'bitstream', format:'file', extention:['wav','ogg'] }"
|
|
||||||
) ) );
|
|
||||||
// set output :
|
|
||||||
m_io.insert(
|
|
||||||
std::pair<std::string, eaudiofx::Block::IOProperty>(
|
|
||||||
"out",
|
|
||||||
eaudiofx::Block::IOProperty(
|
|
||||||
eaudiofx::Block::ioOutput,
|
|
||||||
"{ type:'audio', compression:'raw', frequency:48000, channel:2, format:'float' }",
|
|
||||||
new eaudiofx::BufferAudioRaw(*this, 48000, 2, 4096)
|
|
||||||
) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
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 !!!");
|
|
||||||
return eaudiofx::ERR_FAIL;
|
|
||||||
}
|
|
||||||
auto itIn = m_io.find("in");
|
|
||||||
if (itIn == m_io.end()) {
|
|
||||||
EAUDIOFX_WARNING("request to pull data with no Input !!!");
|
|
||||||
return eaudiofx::ERR_FAIL;
|
|
||||||
}
|
|
||||||
eaudiofx::BufferAudioRaw* bufferOut = dynamic_cast<eaudiofx::BufferAudioRaw*>(itOut->second.m_buffer);
|
|
||||||
if (bufferOut == NULL) {
|
|
||||||
// !! impossible case => a buffer can not be removed ...
|
|
||||||
EAUDIOFX_ERROR("Buffer has been removed... OR change type ...");
|
|
||||||
return eaudiofx::ERR_FAIL;
|
|
||||||
}
|
|
||||||
//request outpuffer needed size :
|
|
||||||
bufferOut->setProperty(48000, 2, _request);
|
|
||||||
float* dataOut = bufferOut->getData();
|
|
||||||
int32_t offset = 0;
|
|
||||||
//EAUDIOFX_DEBUG("Request data : " << (_request*2) );
|
|
||||||
while (1) {
|
|
||||||
int32_t nbSampleToCopy = std::min(m_nbSampleIn, _request*2 - offset);
|
|
||||||
if (m_nbSampleIn > 0) {
|
|
||||||
// no pull needed ==> just copy data to output ...
|
|
||||||
for (int32_t iii=0; iii < nbSampleToCopy; ++iii) {
|
|
||||||
dataOut[offset + iii] = m_tmpBuffer[iii];
|
|
||||||
}
|
|
||||||
offset += nbSampleToCopy;
|
|
||||||
m_nbSampleIn -= nbSampleToCopy;
|
|
||||||
if (m_nbSampleIn > 0) {
|
|
||||||
// some data in the buffer ==> move it ...
|
|
||||||
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) {
|
|
||||||
// putput have enought data
|
|
||||||
return eaudiofx::ERR_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request block input:
|
|
||||||
int32_t ret = eaudiofx::Block::pull(_currentTime, 256, _timeout);
|
|
||||||
|
|
||||||
if (ret != eaudiofx::ERR_NONE) {
|
|
||||||
EAUDIOFX_ERROR("can not get data ...");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
eaudiofx::BufferStream* bufferIn = dynamic_cast<eaudiofx::BufferStream*>(itIn->second.m_buffer);
|
|
||||||
if (bufferIn == NULL) {
|
|
||||||
// !! impossible case => a buffer can not be removed ...
|
|
||||||
EAUDIOFX_ERROR("Buffer has been removed... OR change type ...");
|
|
||||||
return eaudiofx::ERR_FAIL;
|
|
||||||
}
|
|
||||||
if (bufferIn->setAvaillableSize() == 0) {
|
|
||||||
for (size_t iii=0; iii<64; ++iii) {
|
|
||||||
m_tmpBuffer[m_nbSampleIn] = 0.0f;
|
|
||||||
m_nbSampleIn++;
|
|
||||||
m_tmpBuffer[m_nbSampleIn] = 0.0f;
|
|
||||||
m_nbSampleIn++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (true == true) {
|
|
||||||
// wav input :
|
|
||||||
// TODO : Do it better ...
|
|
||||||
size_t provideData = bufferIn->setAvaillableSize();
|
|
||||||
int16_t* inputData = (int16_t*)bufferIn->getData();
|
|
||||||
for (size_t iii=0; iii<provideData/2; ++iii) {
|
|
||||||
m_tmpBuffer[m_nbSampleIn] = ((double)inputData[iii]) * 0.000030518; // 1/32768
|
|
||||||
m_nbSampleIn++;
|
|
||||||
m_tmpBuffer[m_nbSampleIn] = ((double)inputData[iii]) * 0.000030518; // 1/32768
|
|
||||||
m_nbSampleIn++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//EAUDIOFX_DEBUG("internal FIFO : " << m_nbSampleIn );
|
|
||||||
}
|
|
||||||
return eaudiofx::ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32_t eaudiofx::BlockDecoder::init() {
|
|
||||||
|
|
||||||
return eaudiofx::ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32_t eaudiofx::BlockDecoder::unInit() {
|
|
||||||
|
|
||||||
return eaudiofx::ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __EAUDIOFX_BLOCK_DECODER_H__
|
|
||||||
#define __EAUDIOFX_BLOCK_DECODER_H__
|
|
||||||
|
|
||||||
#include <eaudiofx/core/Block.h>
|
|
||||||
|
|
||||||
namespace eaudiofx {
|
|
||||||
class BlockDecoder : public eaudiofx::Block {
|
|
||||||
#define MAX_DATA_IN_BUFFER (8*1024)
|
|
||||||
public:
|
|
||||||
BlockDecoder();
|
|
||||||
virtual ~BlockDecoder() {};
|
|
||||||
public: // herited function
|
|
||||||
int32_t pull(double _currentTime, int32_t _request, float _timeout);
|
|
||||||
int32_t init();
|
|
||||||
int32_t unInit();
|
|
||||||
protected:
|
|
||||||
float m_tmpBuffer[MAX_DATA_IN_BUFFER]; //!< internal buffer with data ...
|
|
||||||
int32_t m_nbSampleIn; //<! number of sample in the tmpBuffer.
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <eaudiofx/core/BlockEncoder.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
eaudiofx::BlockEncoder::BlockEncoder() {
|
|
||||||
setType(eaudiofx::blockTypeEncoder);
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __EAUDIOFX_BLOCK_ENCODER_H__
|
|
||||||
#define __EAUDIOFX_BLOCK_ENCODER_H__
|
|
||||||
|
|
||||||
#include <eaudiofx/core/Block.h>
|
|
||||||
|
|
||||||
namespace eaudiofx {
|
|
||||||
class BlockEncoder : public eaudiofx::Block {
|
|
||||||
public:
|
|
||||||
BlockEncoder();
|
|
||||||
virtual ~BlockEncoder() {};
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <eaudiofx/core/BlockFilter.h>
|
|
||||||
|
|
||||||
eaudiofx::BlockFilter::BlockFilter() {
|
|
||||||
setType(eaudiofx::blockTypeFilter);
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __EAUDIOFX_BLOCK_FILTER_H__
|
|
||||||
#define __EAUDIOFX_BLOCK_FILTER_H__
|
|
||||||
|
|
||||||
#include <eaudiofx/core/Block.h>
|
|
||||||
|
|
||||||
namespace eaudiofx {
|
|
||||||
class BlockFilter : public eaudiofx::Block {
|
|
||||||
public:
|
|
||||||
BlockFilter();
|
|
||||||
virtual ~BlockFilter() {};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <eaudiofx/core/BlockGenerator.h>
|
|
||||||
|
|
||||||
eaudiofx::BlockGenerator::BlockGenerator() :
|
|
||||||
m_isLive(false) {
|
|
||||||
setType(eaudiofx::blockTypeGenerator);
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __EAUDIOFX_BLOCK_GENERATOR_H__
|
|
||||||
#define __EAUDIOFX_BLOCK_GENERATOR_H__
|
|
||||||
|
|
||||||
#include <eaudiofx/core/Block.h>
|
|
||||||
|
|
||||||
namespace eaudiofx {
|
|
||||||
class BlockGenerator : public eaudiofx::Block {
|
|
||||||
public:
|
|
||||||
BlockGenerator();
|
|
||||||
virtual ~BlockGenerator() {};
|
|
||||||
private:
|
|
||||||
bool m_isLive; //!< a generator mark as a live element is manage by an external event system like IO interuption
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Get if the genertor is a live stream
|
|
||||||
* @return true This is a live stream
|
|
||||||
* @return false This is not a live stream
|
|
||||||
*/
|
|
||||||
bool getLive() {
|
|
||||||
return m_isLive;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Set the new status of live stream.
|
|
||||||
* @param[in] _isLive status requested.
|
|
||||||
*/
|
|
||||||
void setLive(bool _isLive=true) {
|
|
||||||
m_isLive = _isLive;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -14,25 +14,30 @@
|
|||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
class BlockMeta : public eaudiofx::Block {
|
class BlockMeta : public eaudiofx::Block {
|
||||||
public:
|
protected:
|
||||||
BlockMeta();
|
BlockMeta();
|
||||||
|
void init() {
|
||||||
|
eaudiofx::Block();
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
DECLARE_FACTORY(BlockMeta);
|
||||||
virtual ~BlockMeta();
|
virtual ~BlockMeta();
|
||||||
private:
|
private:
|
||||||
std::vector<eaudiofx::Block*> m_list; //!< list of all block to process.
|
std::vector<std::shared_ptr<eaudiofx::Block>> m_list; //!< list of all block to process.
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief Get a pointer on a specific block.
|
* @brief Get a pointer on a specific block.
|
||||||
* @param[in] _name Name of the block.
|
* @param[in] _name Name of the block.
|
||||||
* @return generic error
|
* @return generic error
|
||||||
*/
|
*/
|
||||||
eaudiofx::Block* getBlock(const std::string& _name);
|
std::shared_ptr<eaudiofx::Block> getBlock(const std::string& _name);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Add a block in the Meta-block
|
* @brief Add a block in the Meta-block
|
||||||
* @param[in] _block Pointer on the block (do not free yourself)
|
* @param[in] _block Pointer on the block (do not free yourself)
|
||||||
* @return generic error
|
* @return generic error
|
||||||
*/
|
*/
|
||||||
int32_t addBlock(eaudiofx::Block* _block);
|
int32_t addBlock(std::shared_ptr<eaudiofx::Block> _block);
|
||||||
/**
|
/**
|
||||||
* @brief Add a block in the Meta-block.
|
* @brief Add a block in the Meta-block.
|
||||||
* @param[in] _blockType Name of the type of block to add.
|
* @param[in] _blockType Name of the type of block to add.
|
||||||
@ -47,14 +52,6 @@ namespace eaudiofx {
|
|||||||
* @return generic error
|
* @return generic error
|
||||||
*/
|
*/
|
||||||
int32_t removeBlock(const std::string& _name);
|
int32_t removeBlock(const std::string& _name);
|
||||||
/**
|
|
||||||
* @brief Replace a block with an other
|
|
||||||
* @param[in] _nameUnLink Name of the block to UnLink
|
|
||||||
* @param[in] _nameLink Name of the block to Link
|
|
||||||
* @note This free the block pointer
|
|
||||||
* @return generic error
|
|
||||||
*/
|
|
||||||
int32_t replaceFilter(const std::string& _nameUnLink, const std::string& _nameLink);
|
|
||||||
/**
|
/**
|
||||||
* @brief Link 2 IO.
|
* @brief Link 2 IO.
|
||||||
* @param[in] _generatorBlockName Name ot the generator Block
|
* @param[in] _generatorBlockName Name ot the generator Block
|
||||||
@ -80,10 +77,10 @@ namespace eaudiofx {
|
|||||||
*/
|
*/
|
||||||
int32_t openStream(const std::string& _stream);
|
int32_t openStream(const std::string& _stream);
|
||||||
public: // herited function
|
public: // herited function
|
||||||
virtual int32_t init();
|
virtual int32_t algoInit();
|
||||||
virtual int32_t unInit();
|
virtual int32_t algoUnInit();
|
||||||
virtual int32_t start();
|
virtual int32_t algoStart();
|
||||||
virtual int32_t stop();
|
virtual int32_t algoStop();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <eaudiofx/core/BlockReceiver.h>
|
|
||||||
|
|
||||||
eaudiofx::BlockReceiver::BlockReceiver() :
|
|
||||||
m_isLive(false) {
|
|
||||||
setType(eaudiofx::blockTypeReceiver);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __EAUDIOFX_BLOCK_RECEIVER_H__
|
|
||||||
#define __EAUDIOFX_BLOCK_RECEIVER_H__
|
|
||||||
|
|
||||||
#include <eaudiofx/core/Block.h>
|
|
||||||
|
|
||||||
namespace eaudiofx {
|
|
||||||
class BlockReceiver : public eaudiofx::Block {
|
|
||||||
public:
|
|
||||||
BlockReceiver();
|
|
||||||
virtual ~BlockReceiver() {};
|
|
||||||
private:
|
|
||||||
bool m_isLive; //!< a generator mark as a live element is manage by an external event system like IO interuption
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Get if the genertor is a live stream
|
|
||||||
* @return true This is a live stream
|
|
||||||
* @return false This is not a live stream
|
|
||||||
*/
|
|
||||||
bool getLive() {
|
|
||||||
return m_isLive;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Set the new status of live stream.
|
|
||||||
* @param[in] _isLive status requested.
|
|
||||||
*/
|
|
||||||
void setLive(bool _isLive=true) {
|
|
||||||
m_isLive = _isLive;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -21,27 +21,8 @@ namespace eaudiofx {
|
|||||||
protected:
|
protected:
|
||||||
eaudiofx::Block& m_parent; //!< parrent Block of this Buffer
|
eaudiofx::Block& m_parent; //!< parrent Block of this Buffer
|
||||||
protected:
|
protected:
|
||||||
double m_timestamp; //!< current buffer time;
|
int64_t m_timestamp; //!< current buffer time
|
||||||
double m_time; //!< current buffer data time size;
|
int64_t m_timeSize; //!< current buffer data time size
|
||||||
public:
|
|
||||||
int32_t pull(double _currentTime, int32_t _request, float _timeout);
|
|
||||||
protected:
|
|
||||||
bool m_negociated; //!< negiciation status.
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Get if the IO buffer status is negociated.
|
|
||||||
* @return true if buffer is negosiated.
|
|
||||||
* @return false Not negociated.
|
|
||||||
*/
|
|
||||||
bool isNegociated() {
|
|
||||||
return m_negociated;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief uset the negociation status of the buffer.
|
|
||||||
*/
|
|
||||||
void requestNewNegociation() {
|
|
||||||
m_negociated = false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,30 +12,53 @@
|
|||||||
#include <eaudiofx/core/Buffer.h>
|
#include <eaudiofx/core/Buffer.h>
|
||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
|
enum audioFormat {
|
||||||
|
audioFormatInt8,
|
||||||
|
audioFormatInt16,
|
||||||
|
audioFormatInt24,
|
||||||
|
audioFormatInt32,
|
||||||
|
audioFormatIntFloat,
|
||||||
|
audioFormatIntDouble,
|
||||||
|
audioFormatInt16OverInt32
|
||||||
|
};
|
||||||
|
enum audioChannel {
|
||||||
|
audioChannelFrontLeft, //!< channel Front Left
|
||||||
|
audioChannelFrontCenter, //!< channel Front Center
|
||||||
|
audioChannelFrontRight, //!< channel Front Right
|
||||||
|
audioChannelRearLeft, //!< channel rear Left
|
||||||
|
audioChannelRearCenter, //!< channel rear Center
|
||||||
|
audioChannelRearRight, //!< channel rear Right
|
||||||
|
audioChannelSurroundLeft, //!< channel surround Left
|
||||||
|
audioChannelSurroundRight, //!< channel surround Right
|
||||||
|
audioChannelSubWoofer, //!< channel Sub-woofer
|
||||||
|
audioChannelLFE //!< channel Low frequency
|
||||||
|
};
|
||||||
class BufferAudio : public eaudiofx::Buffer {
|
class BufferAudio : public eaudiofx::Buffer {
|
||||||
public:
|
public:
|
||||||
BufferAudio(eaudiofx::Block& _parent);
|
BufferAudio(eaudiofx::Block& _parent);
|
||||||
BufferAudio(eaudiofx::Block& _parent, int32_t _frequency, int32_t _nbChannel);
|
BufferAudio(eaudiofx::Block& _parent,
|
||||||
|
int32_t _frequency=48000,
|
||||||
|
const std::vector<enum audioChannel>& _map={audioChannelFrontLeft,audioChannelFrontRight},
|
||||||
|
enum audioFormat _format=audioFormatInt16);
|
||||||
|
BufferAudio(eaudiofx::Block& _parent,
|
||||||
|
const std::string& _description);
|
||||||
virtual ~BufferAudio();
|
virtual ~BufferAudio();
|
||||||
protected:
|
protected:
|
||||||
int32_t m_frequency;
|
int32_t m_frequency;
|
||||||
int32_t m_nbChannel;
|
std::vector<enum audioChannel> m_channelMap;
|
||||||
enum channelPosition m_channelType[MAX_NUMBER_OF_SIMULTANEOUS_CHANNEL];
|
enum audioFormat m_format;
|
||||||
protected:
|
protected:
|
||||||
float* m_data; //!< pointer on the data.
|
int8_t* m_data; //!< pointer on the data.
|
||||||
|
int8_t m_sampleSize; //!< Size of one sample
|
||||||
|
int8_t m_chunkSize; //!< Size of one chunk Size
|
||||||
size_t m_allocated; //!< number of sample allocated
|
size_t m_allocated; //!< number of sample allocated
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* @brief Reallocate the Buffer data.
|
|
||||||
*/
|
|
||||||
virtual void resize(size_t _newSize);
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Get the buffer casted in float*
|
* @brief Get the buffer casted in float*
|
||||||
* @return Pointer on the buffer with correct cast.
|
* @return Pointer on the buffer with correct cast.
|
||||||
*/
|
*/
|
||||||
float* getData() {
|
template<typename T> T* getData() {
|
||||||
return m_data;
|
return static_cast<T*>(m_data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <eaudiofx/debug.h>
|
|
||||||
#include <eaudiofx/core/BufferAudioRaw.h>
|
|
||||||
|
|
||||||
|
|
||||||
eaudiofx::BufferAudioRaw::BufferAudioRaw(eaudiofx::Block& _parent) :
|
|
||||||
eaudiofx::BufferAudio(_parent),
|
|
||||||
m_allocatedSample(0) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
eaudiofx::BufferAudioRaw::BufferAudioRaw(eaudiofx::Block& _parent, int32_t _frequency, int32_t _nbChannel, int32_t _nbSample) :
|
|
||||||
eaudiofx::BufferAudio(_parent, _frequency, _nbChannel),
|
|
||||||
m_allocatedSample(_nbSample) {
|
|
||||||
if (_nbSample < 0) {
|
|
||||||
m_allocatedSample = 512;
|
|
||||||
}
|
|
||||||
EAUDIOFX_INFO("Resize the buffer : " << m_frequency << "Hz, " << m_nbChannel << " channel(s), " << m_allocatedSample << " sample(s)");
|
|
||||||
resize(m_nbChannel*m_allocatedSample);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void eaudiofx::BufferAudioRaw::setProperty(int32_t _frequency, int32_t _nbChannel, int32_t _nbSample) {
|
|
||||||
bool increaseSize = false;
|
|
||||||
if (_nbSample > m_allocatedSample) {
|
|
||||||
m_allocatedSample = _nbSample;
|
|
||||||
increaseSize = true;
|
|
||||||
}
|
|
||||||
if (_nbChannel > m_nbChannel) {
|
|
||||||
increaseSize = true;
|
|
||||||
}
|
|
||||||
m_nbChannel = _nbChannel;
|
|
||||||
m_frequency = _frequency;
|
|
||||||
if (increaseSize == true) {
|
|
||||||
EAUDIOFX_INFO("Resize the buffer : " << m_frequency << "Hz, " << m_nbChannel << " channel(s), " << m_allocatedSample << " sample(s)");
|
|
||||||
resize(m_nbChannel*m_allocatedSample);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __EAUDIOFX_BUFFER_AUDIO_RAW_H__
|
|
||||||
#define __EAUDIOFX_BUFFER_AUDIO_RAW_H__
|
|
||||||
|
|
||||||
#include <eaudiofx/core/BufferAudio.h>
|
|
||||||
|
|
||||||
namespace eaudiofx {
|
|
||||||
class BufferAudioRaw : public eaudiofx::BufferAudio {
|
|
||||||
public:
|
|
||||||
BufferAudioRaw(eaudiofx::Block& _parent);
|
|
||||||
BufferAudioRaw(eaudiofx::Block& _parent, int32_t _frequency, int32_t _nbChannel, int32_t _nbSample = -1);
|
|
||||||
virtual ~BufferAudioRaw() {};
|
|
||||||
protected:
|
|
||||||
size_t m_allocatedSample; //!< generate with m_allocatedBytes/sizeof(**m_audioFormat**) / m_nbChannel;
|
|
||||||
protected:
|
|
||||||
size_t m_size; //!< number of sample for each channels provided in this buffer ... (write by the upstream (can be 0))
|
|
||||||
protected:
|
|
||||||
size_t m_sizeRequested; //!< in pull mode, number of sample for each channels requested by the next Filter
|
|
||||||
public:
|
|
||||||
void setProperty(int32_t _frequency, int32_t _nbChannel, int32_t _nbSample);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <eaudiofx/core/BufferMessage.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
eaudiofx::BufferMessage::BufferMessage(eaudiofx::Block& _parent, int32_t _message) :
|
|
||||||
eaudiofx::Buffer(_parent),
|
|
||||||
m_messageId(_message) {
|
|
||||||
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __EAUDIOFX_BUFFER_MESSAGE_H__
|
|
||||||
#define __EAUDIOFX_BUFFER_MESSAGE_H__
|
|
||||||
|
|
||||||
#include <eaudiofx/core/Buffer.h>
|
|
||||||
|
|
||||||
namespace eaudiofx {
|
|
||||||
enum {
|
|
||||||
bufferMessageEndOfStream = 0x00000001,
|
|
||||||
bufferMessageFlush = 0x00000002,
|
|
||||||
bufferMessageReset = 0x00000004,
|
|
||||||
bufferMessageQuery = 0x00000008,
|
|
||||||
bufferMessageQualityOfService = 0x00000010
|
|
||||||
};
|
|
||||||
class BufferMessage : public eaudiofx::Buffer {
|
|
||||||
public:
|
|
||||||
BufferMessage(eaudiofx::Block& _parent, int32_t _message = eaudiofx::bufferMessageEndOfStream);
|
|
||||||
virtual ~BufferMessage() {};
|
|
||||||
protected:
|
|
||||||
int32_t m_messageId; //!< message ID
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Get the message.
|
|
||||||
* @return The ID of the message (if value is < 0 : custom message ...)
|
|
||||||
*/
|
|
||||||
int32_t getMessage() {
|
|
||||||
return m_messageId;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Set the message.
|
|
||||||
* @param[in] _message The ID of the message (if value is < 0 : custom message ...)
|
|
||||||
*/
|
|
||||||
void getMessage(int32_t _messageId) {
|
|
||||||
m_messageId = _messageId;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
std::string m_query;
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief get the query complete message
|
|
||||||
* @return The requested data
|
|
||||||
*/
|
|
||||||
const std::string& getQuery() {
|
|
||||||
return m_query;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief get the query complete message
|
|
||||||
* @return The requested data
|
|
||||||
*/
|
|
||||||
void setQuery(const std::string& _answer) {
|
|
||||||
m_query = _answer;
|
|
||||||
// reset query:
|
|
||||||
if (m_answer.size() != 0) {
|
|
||||||
m_answer = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
std::string m_answer;
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief get the answer of the query
|
|
||||||
* @return The requested data
|
|
||||||
*/
|
|
||||||
const std::string& getAnswer() {
|
|
||||||
return m_answer;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief get the answer of the query
|
|
||||||
* @return The requested data
|
|
||||||
*/
|
|
||||||
void setAnswer(const std::string& _answer) {
|
|
||||||
m_answer = _answer;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <eaudiofx/debug.h>
|
|
||||||
#include <eaudiofx/core/BufferStream.h>
|
|
||||||
|
|
||||||
eaudiofx::BufferStream::BufferStream(eaudiofx::Block& _parent) :
|
|
||||||
eaudiofx::Buffer(_parent),
|
|
||||||
m_data(NULL),
|
|
||||||
m_allocated(0),
|
|
||||||
m_size(0) {
|
|
||||||
|
|
||||||
}
|
|
||||||
eaudiofx::BufferStream::~BufferStream() {
|
|
||||||
if (m_data != NULL) {
|
|
||||||
delete[] m_data;
|
|
||||||
m_data = NULL;
|
|
||||||
m_allocated = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void eaudiofx::BufferStream::resize(size_t _newSize) {
|
|
||||||
if (m_allocated >= _newSize) {
|
|
||||||
// nothing to do, enought data ...
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (m_data != NULL) {
|
|
||||||
delete[] m_data;
|
|
||||||
m_data = NULL;
|
|
||||||
m_allocated = 0;
|
|
||||||
}
|
|
||||||
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 {
|
|
||||||
m_allocated = _newSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void eaudiofx::BufferStream::setProperty(int32_t _dataSize) {
|
|
||||||
if (_dataSize<=0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
resize(_dataSize);
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __EAUDIOFX_BUFFER_STREAM_H__
|
|
||||||
#define __EAUDIOFX_BUFFER_STREAM_H__
|
|
||||||
|
|
||||||
#include <eaudiofx/core/Buffer.h>
|
|
||||||
|
|
||||||
namespace eaudiofx {
|
|
||||||
class BufferStream : public eaudiofx::Buffer {
|
|
||||||
public:
|
|
||||||
BufferStream(eaudiofx::Block& _parent);
|
|
||||||
virtual ~BufferStream();
|
|
||||||
protected:
|
|
||||||
uint8_t* m_data; //!< buffer data
|
|
||||||
size_t m_allocated; //!< number of byte allocated
|
|
||||||
protected:
|
|
||||||
size_t m_size; //!< number of byte provided in this buffer ... (write by the upstream (can be 0))
|
|
||||||
public:
|
|
||||||
void setAvaillableSize(size_t _availlableSize) {
|
|
||||||
m_size = _availlableSize;
|
|
||||||
}
|
|
||||||
size_t setAvaillableSize() {
|
|
||||||
return m_size;
|
|
||||||
}
|
|
||||||
public:
|
|
||||||
void setProperty(int32_t _dataSize);
|
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* @brief Reallocate the Buffer data.
|
|
||||||
*/
|
|
||||||
virtual void resize(size_t _newSize);
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Get the buffer casted in float*
|
|
||||||
* @return Pointer on the buffer with correct cast.
|
|
||||||
*/
|
|
||||||
uint8_t* getData() {
|
|
||||||
return m_data;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -17,17 +17,19 @@
|
|||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
class Processing : public eaudiofx::BlockMeta {
|
class Processing : public eaudiofx::BlockMeta {
|
||||||
public:
|
protected:
|
||||||
Processing() {};
|
Processing() {};
|
||||||
|
void init() {
|
||||||
|
eaudiofx::BlockMeta::init();
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
DECLARE_FACTORY(Processing);
|
||||||
virtual ~Processing() {};
|
virtual ~Processing() {};
|
||||||
public:
|
public:
|
||||||
int32_t process();
|
int32_t process();
|
||||||
int32_t start();
|
int32_t start();
|
||||||
int32_t stop();
|
int32_t stop();
|
||||||
int32_t waitEndOfProcess();
|
int32_t waitEndOfProcess();
|
||||||
bool isLiveStream() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -10,70 +10,9 @@
|
|||||||
#define __EAUDIOFX_AUDIO_H__
|
#define __EAUDIOFX_AUDIO_H__
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <etk/types.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
// defien type : uintXX_t and intXX_t
|
|
||||||
#ifndef __STDC_LIMIT_MACROS
|
|
||||||
#define __STDC_LIMIT_MACROS
|
|
||||||
#endif
|
|
||||||
// note in android include the macro of min max are overwitten
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
enum channelPosition {
|
|
||||||
// From channels
|
|
||||||
channelPositionFrontCenter = 0x10,
|
|
||||||
channelPositionFrontLeft = 0x11,
|
|
||||||
channelPositionFrontRight = 0x12,
|
|
||||||
channelPositionFrontTopCenter = 0x14,
|
|
||||||
channelPositionFrontTopLeft = 0x15,
|
|
||||||
channelPositionFrontTopRight = 0x16,
|
|
||||||
channelPositionFrontBottomCenter = 0x18,
|
|
||||||
channelPositionFrontBottomLeft = 0x19,
|
|
||||||
channelPositionFrontBottomRight = 0x1A,
|
|
||||||
// Side channels
|
|
||||||
channelPositionSideLeft = 0x21,
|
|
||||||
channelPositionSideRight = 0x22,
|
|
||||||
channelPositionSideTopLeft = 0x25,
|
|
||||||
channelPositionSideTopRight = 0x26,
|
|
||||||
channelPositionSideBottomLeft = 0x29,
|
|
||||||
channelPositionSideBottomRight = 0x2A,
|
|
||||||
// Back/rear channels
|
|
||||||
channelPositionRearCenter = 0x40,
|
|
||||||
channelPositionRearLeft = 0x41,
|
|
||||||
channelPositionRearRight = 0x42,
|
|
||||||
channelPositionRearTopCenter = 0x44,
|
|
||||||
channelPositionRearTopLeft = 0x45,
|
|
||||||
channelPositionRearTopRight = 0x56,
|
|
||||||
channelPositionRearBottomCenter = 0x48,
|
|
||||||
channelPositionRearBottomLeft = 0x49,
|
|
||||||
channelPositionRearBottomRight = 0x4A,
|
|
||||||
// Other special channels
|
|
||||||
channelPositionSubwoofer = 0x80
|
|
||||||
};
|
|
||||||
#define MAX_NUMBER_OF_SIMULTANEOUS_CHANNEL (8)
|
|
||||||
#define CHANNEL_3D_MASK 0xF0
|
|
||||||
#define CHANNEL_3D_FRONT 0x10
|
|
||||||
#define CHANNEL_3D_SIDE 0x20
|
|
||||||
#define CHANNEL_3D_REAR 0x40
|
|
||||||
#define CHANNEL_3D_OTHER 0x80
|
|
||||||
|
|
||||||
#define CHANNEL_POS_MASK 0x03
|
|
||||||
#define CHANNEL_POS_CENTER 0x00
|
|
||||||
#define CHANNEL_POS_LEFT 0x01
|
|
||||||
#define CHANNEL_POS_RIGHT 0x02
|
|
||||||
|
|
||||||
#define CHANNEL_HEIGHT_MASK 0x0B
|
|
||||||
#define CHANNEL_HEIGHT_MEDIUM 0x00
|
|
||||||
#define CHANNEL_HEIGHT_TOP 0x04
|
|
||||||
#define CHANNEL_HEIGHT_BOTTOM 0x08
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ERR_NONE = 0,
|
ERR_NONE = 0,
|
||||||
ERR_NOT_IMPLEMENTED,
|
ERR_NOT_IMPLEMENTED,
|
||||||
|
@ -16,23 +16,15 @@ def create(target):
|
|||||||
'eaudiofx/core/Processing.cpp',
|
'eaudiofx/core/Processing.cpp',
|
||||||
'eaudiofx/core/Block.cpp',
|
'eaudiofx/core/Block.cpp',
|
||||||
'eaudiofx/core/BlockMeta.cpp',
|
'eaudiofx/core/BlockMeta.cpp',
|
||||||
'eaudiofx/core/BlockGenerator.cpp',
|
|
||||||
'eaudiofx/core/BlockReceiver.cpp',
|
|
||||||
'eaudiofx/core/BlockFilter.cpp',
|
|
||||||
'eaudiofx/core/BlockDecoder.cpp',
|
|
||||||
'eaudiofx/core/BlockEncoder.cpp',
|
|
||||||
'eaudiofx/core/Buffer.cpp',
|
'eaudiofx/core/Buffer.cpp',
|
||||||
'eaudiofx/core/BufferMessage.cpp',
|
|
||||||
'eaudiofx/core/BufferStream.cpp',
|
|
||||||
'eaudiofx/core/BufferAudio.cpp',
|
'eaudiofx/core/BufferAudio.cpp',
|
||||||
'eaudiofx/core/BufferAudioFreq.cpp',
|
'eaudiofx/core/BufferAudioFreq.cpp'
|
||||||
'eaudiofx/core/BufferAudioRaw.cpp'
|
|
||||||
])
|
])
|
||||||
# basic nodes:
|
# basic nodes:
|
||||||
myModule.add_src_file([
|
myModule.add_src_file([
|
||||||
'eaudiofx/base/GeneratorFile.cpp',
|
#'eaudiofx/base/GeneratorFile.cpp',
|
||||||
'eaudiofx/base/ReceiverFile.cpp',
|
#'eaudiofx/base/ReceiverFile.cpp',
|
||||||
'eaudiofx/base/GeneratorRtAudio.cpp',
|
#'eaudiofx/base/GeneratorRtAudio.cpp',
|
||||||
'eaudiofx/base/ReceiverRtAudio.cpp',
|
'eaudiofx/base/ReceiverRtAudio.cpp',
|
||||||
'eaudiofx/base/GeneratorSignal.cpp'
|
'eaudiofx/base/GeneratorSignal.cpp'
|
||||||
])
|
])
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
#include <eaudiofx/eaudiofx.h>
|
#include <eaudiofx/eaudiofx.h>
|
||||||
#include <ewol/widget/Button.h>
|
#include <ewol/widget/Button.h>
|
||||||
|
|
||||||
#include <eaudiofx/base/GeneratorFile.h>
|
|
||||||
#include <eaudiofx/core/BlockDecoder.h>
|
|
||||||
#include <eaudiofx/base/GeneratorSignal.h>
|
#include <eaudiofx/base/GeneratorSignal.h>
|
||||||
#include <eaudiofx/base/ReceiverRtAudio.h>
|
#include <eaudiofx/base/ReceiverRtAudio.h>
|
||||||
|
|
||||||
@ -59,46 +57,18 @@ void appl::Windows::init() {
|
|||||||
composerBind(ewol::widget::Button, "bt-play2", signalPressed, shared_from_this(), &appl::Windows::onCallbackStop);
|
composerBind(ewol::widget::Button, "bt-play2", signalPressed, shared_from_this(), &appl::Windows::onCallbackStop);
|
||||||
}
|
}
|
||||||
|
|
||||||
eaudiofx::Processing* process = NULL;
|
std::shared_ptr<eaudiofx::Processing> process = NULL;
|
||||||
|
|
||||||
void appl::Windows::onCallbackPlay() {
|
void appl::Windows::onCallbackPlay() {
|
||||||
#if 0
|
#if 0
|
||||||
APPL_INFO("Play Requested ...");
|
APPL_INFO("Play Requested ...");
|
||||||
process = new eaudiofx::Processing();
|
process = eaudiofx::Processing::create();
|
||||||
if (process == NULL) {
|
if (process == NULL) {
|
||||||
APPL_ERROR("can not create processing ...");
|
APPL_ERROR("can not create processing ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
APPL_INFO("Create Generator ...");
|
APPL_INFO("Create Generator ...");
|
||||||
eaudiofx::GeneratorSignal* generator = new eaudiofx::GeneratorSignal();
|
std::shared_ptr<eaudiofx::GeneratorFile> generator = eaudiofx::GeneratorFile::create();
|
||||||
if (generator == NULL) {
|
|
||||||
APPL_ERROR("can not create Generator ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
generator->setName("myGenerator");
|
|
||||||
process->addBlock(generator);
|
|
||||||
APPL_INFO("Create Receiver ...");
|
|
||||||
eaudiofx::ReceiverRtAudio* receiver = new eaudiofx::ReceiverRtAudio();
|
|
||||||
if (receiver == NULL) {
|
|
||||||
APPL_ERROR("can not create Receiver ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
receiver->setName("myReceiver");
|
|
||||||
process->addBlock(receiver);
|
|
||||||
|
|
||||||
process->linkBlock("myGenerator", "out","myReceiver", "in");
|
|
||||||
|
|
||||||
process->start();
|
|
||||||
return;
|
|
||||||
#else
|
|
||||||
APPL_INFO("Play Requested ...");
|
|
||||||
process = new eaudiofx::Processing();
|
|
||||||
if (process == NULL) {
|
|
||||||
APPL_ERROR("can not create processing ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
APPL_INFO("Create Generator ...");
|
|
||||||
eaudiofx::GeneratorFile* generator = new eaudiofx::GeneratorFile();
|
|
||||||
if (generator == NULL) {
|
if (generator == NULL) {
|
||||||
APPL_ERROR("can not create Generator ...");
|
APPL_ERROR("can not create Generator ...");
|
||||||
return;
|
return;
|
||||||
@ -107,7 +77,7 @@ void appl::Windows::onCallbackPlay() {
|
|||||||
process->addBlock(generator);
|
process->addBlock(generator);
|
||||||
|
|
||||||
APPL_INFO("Create DECODER ...");
|
APPL_INFO("Create DECODER ...");
|
||||||
eaudiofx::BlockDecoder* decoder = new eaudiofx::BlockDecoder();
|
std::shared_ptr<eaudiofx::BlockDecoder> decoder = eaudiofx::BlockDecoder::create();
|
||||||
if (decoder == NULL) {
|
if (decoder == NULL) {
|
||||||
APPL_ERROR("can not create Generator ...");
|
APPL_ERROR("can not create Generator ...");
|
||||||
return;
|
return;
|
||||||
@ -116,7 +86,7 @@ void appl::Windows::onCallbackPlay() {
|
|||||||
process->addBlock(decoder);
|
process->addBlock(decoder);
|
||||||
|
|
||||||
APPL_INFO("Create Receiver ...");
|
APPL_INFO("Create Receiver ...");
|
||||||
eaudiofx::ReceiverRtAudio* receiver = new eaudiofx::ReceiverRtAudio();
|
std::shared_ptr<eaudiofx::ReceiverRtAudio> receiver = eaudiofx::ReceiverRtAudio::create();
|
||||||
if (receiver == NULL) {
|
if (receiver == NULL) {
|
||||||
APPL_ERROR("can not create Receiver ...");
|
APPL_ERROR("can not create Receiver ...");
|
||||||
return;
|
return;
|
||||||
@ -127,6 +97,35 @@ void appl::Windows::onCallbackPlay() {
|
|||||||
process->linkBlock("myGenerator", "out","myDecoder", "in");
|
process->linkBlock("myGenerator", "out","myDecoder", "in");
|
||||||
process->linkBlock("myDecoder", "out","myReceiver", "in");
|
process->linkBlock("myDecoder", "out","myReceiver", "in");
|
||||||
|
|
||||||
|
process->start();
|
||||||
|
return;
|
||||||
|
#else
|
||||||
|
APPL_INFO("Play Requested ...");
|
||||||
|
process = eaudiofx::Processing::create();
|
||||||
|
if (process == NULL) {
|
||||||
|
APPL_ERROR("can not create processing ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
APPL_INFO("Create Generator Sinus");
|
||||||
|
std::shared_ptr<eaudiofx::GeneratorSignal> generator = eaudiofx::GeneratorSignal::create();
|
||||||
|
if (generator == NULL) {
|
||||||
|
APPL_ERROR("can not create Generator ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
generator->setName("myGeneratorSinus");
|
||||||
|
process->addBlock(generator);
|
||||||
|
|
||||||
|
APPL_INFO("Create Receiver ...");
|
||||||
|
std::shared_ptr<eaudiofx::ReceiverRtAudio> receiver = eaudiofx::ReceiverRtAudio::create();
|
||||||
|
if (receiver == NULL) {
|
||||||
|
APPL_ERROR("can not create Receiver ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
receiver->setName("myReceiver");
|
||||||
|
process->addBlock(receiver);
|
||||||
|
|
||||||
|
process->linkBlock("myGenerator", "out","myReceiver", "in");
|
||||||
|
|
||||||
process->start();
|
process->start();
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user