[DEV] start integration of RTAUDIO
This commit is contained in:
parent
b666eb194d
commit
f60aa1be66
@ -15,7 +15,7 @@ namespace eaudiofx {
|
||||
class GeneratorFile : public eaudiofx::BlockGenerator {
|
||||
public:
|
||||
GeneratorFile(void) {};
|
||||
~GeneratorFile(void) {};
|
||||
virtual ~GeneratorFile(void) {};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -7,5 +7,20 @@
|
||||
*/
|
||||
|
||||
#include <eaudiofx/base/GeneratorRtAudio.h>
|
||||
#include <eaudiofx/core/BufferAudioRaw.h>
|
||||
#include <rtaudio/RtAudio.h>
|
||||
|
||||
eaudiofx::GeneratorRtAudio::GeneratorRtAudio(void) {
|
||||
// set output :
|
||||
m_io.insert(
|
||||
std::pair<std::string, eaudiofx::Block::IOProperty>(
|
||||
"out",
|
||||
eaudiofx::Block::IOProperty(
|
||||
eaudiofx::Block::ioOutput,
|
||||
"",
|
||||
new eaudiofx::BufferAudioRaw(*this, 48000, 2)
|
||||
) ) );
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
namespace eaudiofx {
|
||||
class GeneratorRtAudio : public eaudiofx::BlockGenerator {
|
||||
public:
|
||||
GeneratorRtAudio(void) {};
|
||||
~GeneratorRtAudio(void) {};
|
||||
GeneratorRtAudio(void);
|
||||
virtual ~GeneratorRtAudio(void) {};
|
||||
};
|
||||
};
|
||||
|
||||
|
27
eaudiofx/base/GeneratorSignal.cpp
Normal file
27
eaudiofx/base/GeneratorSignal.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <eaudiofx/base/GeneratorSignal.h>
|
||||
#include <eaudiofx/core/BufferAudioRaw.h>
|
||||
|
||||
|
||||
|
||||
eaudiofx::GeneratorSignal::GeneratorSignal(void) :
|
||||
m_phase(0) {
|
||||
// set output :
|
||||
m_io.insert(
|
||||
std::pair<std::string, eaudiofx::Block::IOProperty>(
|
||||
"out",
|
||||
eaudiofx::Block::IOProperty(
|
||||
eaudiofx::Block::ioOutput,
|
||||
"",
|
||||
new eaudiofx::BufferAudioRaw(*this, 48000, 2)
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
26
eaudiofx/base/GeneratorSignal.h
Normal file
26
eaudiofx/base/GeneratorSignal.h
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EAUDIOFX_GENERATOR_SIGNAL_H__
|
||||
#define __EAUDIOFX_GENERATOR_SIGNAL_H__
|
||||
|
||||
#include <eaudiofx/core/BlockGenerator.h>
|
||||
|
||||
namespace eaudiofx {
|
||||
class GeneratorSignal : public eaudiofx::BlockGenerator {
|
||||
protected:
|
||||
float m_phase;
|
||||
public:
|
||||
GeneratorSignal(void);
|
||||
virtual ~GeneratorSignal(void) {};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace eaudiofx {
|
||||
class ReceiverFile : public eaudiofx::BlockReceiver {
|
||||
public:
|
||||
ReceiverFile(void) {};
|
||||
~ReceiverFile(void) {};
|
||||
virtual ~ReceiverFile(void) {};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -7,5 +7,105 @@
|
||||
*/
|
||||
|
||||
#include <eaudiofx/base/ReceiverRtAudio.h>
|
||||
#include <eaudiofx/core/BufferAudioRaw.h>
|
||||
#include <eaudiofx/debug.h>
|
||||
#include <rtaudio/RtAudio.h>
|
||||
|
||||
int eaudiofx::ReceiverRtAudio::rtAudioCallBack(void *_outputBuffer,
|
||||
void *_inputBuffer,
|
||||
unsigned int _nBufferFrames,
|
||||
double _streamTime,
|
||||
RtAudioStreamStatus _status,
|
||||
void* _userData) {
|
||||
if (_userData == NULL) {
|
||||
EAUDIOFX_ERROR("Null class pointer");
|
||||
return -1;
|
||||
}
|
||||
if (_outputBuffer == NULL) {
|
||||
EAUDIOFX_ERROR("Null output buffer pointer");
|
||||
return -1;
|
||||
}
|
||||
eaudiofx::ReceiverRtAudio* classPointer = static_cast<eaudiofx::ReceiverRtAudio*>(_userData);
|
||||
if (classPointer == NULL) {
|
||||
EAUDIOFX_ERROR("Wrong class pointer data");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return classPointer->needData((float*)_outputBuffer, _nBufferFrames, _streamTime, _status);
|
||||
}
|
||||
|
||||
int32_t eaudiofx::ReceiverRtAudio::needData(float* _outputBuffer,
|
||||
size_t _nBufferFrames,
|
||||
double _streamTime,
|
||||
RtAudioStreamStatus _status) {
|
||||
// TODO: reset output:
|
||||
// Request block input:
|
||||
int32_t nbSampleOne = _nBufferFrames/2;
|
||||
int32_t ret = eaudiofx::Block::pull(_streamTime, nbSampleOne, (float)nbSampleOne/48000.0f);
|
||||
if (ret != eaudiofx::ERR_NONE) {
|
||||
return -1;
|
||||
}
|
||||
auto it = m_io.find("in");
|
||||
if (it == m_io.end()) {
|
||||
EAUDIOFX_WARNING("no IO plugged");
|
||||
return 0;
|
||||
}
|
||||
// TODO : Do the copy of data ...
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
eaudiofx::ReceiverRtAudio::ReceiverRtAudio(void) {
|
||||
// set output :
|
||||
m_io.insert(
|
||||
std::pair<std::string, eaudiofx::Block::IOProperty>(
|
||||
"in",
|
||||
eaudiofx::Block::IOProperty(
|
||||
eaudiofx::Block::ioInput,
|
||||
"",
|
||||
new eaudiofx::BufferAudioRaw(*this, 48000, 2)
|
||||
) ) );
|
||||
|
||||
};
|
||||
|
||||
|
||||
int32_t eaudiofx::ReceiverRtAudio::Init(void) {
|
||||
EAUDIOFX_DEBUG("Create RTAudio generator ...");
|
||||
if ( m_dac.getDeviceCount() < 1 ) {
|
||||
EAUDIOFX_ERROR("No audio devices found!");
|
||||
exit( 0 );
|
||||
}
|
||||
EAUDIOFX_DEBUG("nb devices :" << m_dac.getDeviceCount() << " default device ID : " << m_dac.getDefaultOutputDevice());
|
||||
RtAudio::StreamParameters parameters;
|
||||
m_parameters.deviceId = m_dac.getDefaultOutputDevice();
|
||||
m_parameters.nChannels = 2;
|
||||
m_parameters.firstChannel = 0;
|
||||
unsigned int bufferFrames = 256;
|
||||
try {
|
||||
EAUDIOFX_DEBUG("OPEN Stream ...");
|
||||
m_dac.openStream( &m_parameters, NULL, RTAUDIO_FLOAT32, 48000, &bufferFrames, &rtAudioCallBack, (void *)this );
|
||||
m_dac.startStream();
|
||||
}catch ( RtError& e ) {
|
||||
e.printMessage();
|
||||
exit( 0 );
|
||||
}
|
||||
return eaudiofx::ERR_NONE;
|
||||
};
|
||||
|
||||
int32_t eaudiofx::ReceiverRtAudio::UnInit(void) {
|
||||
try {
|
||||
EAUDIOFX_DEBUG("STOP Stream ...");
|
||||
// Stop the stream
|
||||
m_dac.stopStream();
|
||||
} catch (RtError& e) {
|
||||
e.printMessage();
|
||||
return eaudiofx::ERR_NONE;
|
||||
}
|
||||
if ( m_dac.isStreamOpen() ) {
|
||||
m_dac.closeStream();
|
||||
}
|
||||
return eaudiofx::ERR_NONE;
|
||||
};
|
||||
|
||||
|
||||
|
@ -10,14 +10,32 @@
|
||||
#define __EAUDIOFX_RECEIVER_RTAUDIO_H__
|
||||
|
||||
#include <eaudiofx/core/BlockReceiver.h>
|
||||
#include <rtaudio/RtAudio.h>
|
||||
|
||||
namespace eaudiofx {
|
||||
class ReceiverRtAudio : public eaudiofx::BlockReceiver {
|
||||
private:
|
||||
static int rtAudioCallBack(void *_outputBuffer,
|
||||
void *_inputBuffer,
|
||||
unsigned int _nBufferFrames,
|
||||
double _streamTime,
|
||||
RtAudioStreamStatus _status,
|
||||
void* _userData);
|
||||
// class callback
|
||||
int32_t needData(float* _outputBuffer,
|
||||
size_t _nBufferFrames,
|
||||
double _streamTime,
|
||||
RtAudioStreamStatus _status);
|
||||
public:
|
||||
ReceiverRtAudio(void) {};
|
||||
~ReceiverRtAudio(void) {};
|
||||
ReceiverRtAudio(void);
|
||||
virtual ~ReceiverRtAudio(void) {};
|
||||
public: // herieted function :
|
||||
virtual int32_t Init(void);
|
||||
virtual int32_t UnInit(void);
|
||||
private:
|
||||
RtAudio m_dac;
|
||||
RtAudio::StreamParameters m_parameters;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -59,32 +59,35 @@ void eaudiofx::Block::onRemoveBuffer(const eaudiofx::Buffer* _buffer) {
|
||||
}
|
||||
}
|
||||
|
||||
void eaudiofx::Block::linkBuffer(eaudiofx::Buffer* _buffer, const std::string& _name) {
|
||||
int32_t eaudiofx::Block::linkBuffer(eaudiofx::Buffer* _buffer, const std::string& _name) {
|
||||
for (auto &it : m_io) {
|
||||
if (it.first == _name) {
|
||||
if (it.second.m_type == ioOutput) {
|
||||
throw eaudiofx::exeption::StdExeption(std::string("[") + std::to_string(getUID()) + "Can not overwrite output buffer");
|
||||
EAUDIOFX_ERROR("[" << getUID() << "Can not overwrite output buffer...");
|
||||
return eaudiofx::ERR_FORBIDEN;
|
||||
}
|
||||
it.second.m_buffer = _buffer;
|
||||
return;
|
||||
return eaudiofx::ERR_NONE;
|
||||
}
|
||||
}
|
||||
throw eaudiofx::exeption::StdExeption(std::string("[") + std::to_string(getUID()) + "Input or buffer does not existed");
|
||||
return eaudiofx::ERR_NO_IO;
|
||||
}
|
||||
|
||||
void eaudiofx::Block::getBuffer(eaudiofx::Buffer*& _buffer, const std::string& _name) {
|
||||
int32_t eaudiofx::Block::getBuffer(eaudiofx::Buffer*& _buffer, const std::string& _name) {
|
||||
for (auto &it : m_io) {
|
||||
if (it.first == _name) {
|
||||
if (it.second.m_type == ioInput) {
|
||||
throw eaudiofx::exeption::StdExeption(std::string("[") + std::to_string(getUID()) + "Can not Request Input buffer...");
|
||||
EAUDIOFX_ERROR("[" << getUID() << "Can not Request Input buffer...");
|
||||
return eaudiofx::ERR_FORBIDEN;
|
||||
}
|
||||
if (it.second.m_type == ioParameter) {
|
||||
throw eaudiofx::exeption::StdExeption(std::string("[") + std::to_string(getUID()) + "Can not Request Parameter buffer...");
|
||||
EAUDIOFX_ERROR("[" << getUID() << "Can not Request Parameter buffer...");
|
||||
return eaudiofx::ERR_FORBIDEN;
|
||||
}
|
||||
_buffer = it.second.m_buffer;
|
||||
return;
|
||||
return eaudiofx::ERR_NONE;
|
||||
}
|
||||
}
|
||||
throw eaudiofx::exeption::StdExeption(std::string("[") + std::to_string(getUID()) + "Input or buffer does not existed");
|
||||
return eaudiofx::ERR_NO_IO;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace eaudiofx {
|
||||
class Block {
|
||||
public:
|
||||
Block(void);
|
||||
~Block(void);
|
||||
virtual ~Block(void);
|
||||
protected:
|
||||
std::mutex m_mutex; //!< Block mutex access
|
||||
private:
|
||||
@ -105,35 +105,63 @@ namespace eaudiofx {
|
||||
return "";
|
||||
};
|
||||
public:
|
||||
/**
|
||||
* @brief Init the block with the properties
|
||||
* @return A generic error.
|
||||
*/
|
||||
virtual int32_t Init(void) {
|
||||
return eaudiofx::ERR_NONE;
|
||||
};
|
||||
/**
|
||||
* @brief UnInit the block with the properties
|
||||
* @return A generic error.
|
||||
*/
|
||||
virtual int32_t UnInit(void) {
|
||||
return eaudiofx::ERR_NONE;
|
||||
};
|
||||
/**
|
||||
* @brief Call by downstream to request some data
|
||||
* @param[in] _currentTime Current stream time (in second)
|
||||
* @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 void pull(double _currentTime, int32_t _request, float _timeout) {};
|
||||
virtual int32_t pull(double _currentTime, int32_t _request, float _timeout) {
|
||||
return eaudiofx::ERR_NONE;
|
||||
};
|
||||
/**
|
||||
* @brief Get The total stream size (in byte for streaming byte element, in second for time streaming)
|
||||
* @return Get total streaming time (-1 for unknown)
|
||||
* @param[out] _value Get total streaming time (-1 for unknown)
|
||||
* @return generic error
|
||||
*/
|
||||
virtual double getTotal(void) {
|
||||
return -1.0;
|
||||
virtual int32_t getTotal(double& _value) {
|
||||
_value = -1;
|
||||
return eaudiofx::ERR_NONE;
|
||||
};
|
||||
/**
|
||||
* @brief Seek to a specific position in the stream (in byte for streaming byte element, in second for time streaming)
|
||||
* @param[out] _pos position to seek (0 for starting)
|
||||
* @return generic error
|
||||
*/
|
||||
virtual void seekTo(double _pos) {};
|
||||
virtual int32_t seekTo(double _pos) {
|
||||
return eaudiofx::ERR_NONE;
|
||||
};
|
||||
/**
|
||||
* @brief Request a flush of the current buffer
|
||||
* @param[in] _currentTime Current stream time (in second)
|
||||
* @param[in] _timeout system time to be obsolet (for realTime streaming) (-1 for no realTime streaming)
|
||||
* @return generic error
|
||||
*/
|
||||
virtual void flush(double _currentTime, float _timeout) {};
|
||||
virtual int32_t flush(double _currentTime, float _timeout) {
|
||||
return eaudiofx::ERR_NONE;
|
||||
};
|
||||
/**
|
||||
* @brief Reset the block
|
||||
* @return generic error
|
||||
*/
|
||||
virtual void reset(void) {};
|
||||
virtual int32_t reset(void) {
|
||||
return eaudiofx::ERR_NONE;
|
||||
};
|
||||
public:
|
||||
/**
|
||||
* @brief Call when a buffer is removed from the system (current).
|
||||
@ -158,6 +186,17 @@ namespace eaudiofx {
|
||||
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(void) :
|
||||
m_type(ioUnknow),
|
||||
m_internal(false),
|
||||
@ -170,15 +209,16 @@ namespace eaudiofx {
|
||||
* @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 void linkBuffer(eaudiofx::Buffer* _buffer, const std::string& _name);
|
||||
virtual int32_t linkBuffer(eaudiofx::Buffer* _buffer, 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 void getBuffer(eaudiofx::Buffer*& _buffer, const std::string& _name);
|
||||
|
||||
virtual int32_t getBuffer(eaudiofx::Buffer*& _buffer, const std::string& _name);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -9,3 +9,7 @@
|
||||
#include <eaudiofx/core/BlockDecoder.h>
|
||||
|
||||
|
||||
|
||||
eaudiofx::BlockDecoder::BlockDecoder(void) {
|
||||
setType(eaudiofx::blockTypeDecoder);
|
||||
}
|
||||
|
@ -14,8 +14,8 @@
|
||||
namespace eaudiofx {
|
||||
class BlockDecoder : public eaudiofx::Block {
|
||||
public:
|
||||
BlockDecoder(void) {};
|
||||
~BlockDecoder(void) {};
|
||||
BlockDecoder(void);
|
||||
virtual ~BlockDecoder(void) {};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -9,3 +9,7 @@
|
||||
#include <eaudiofx/core/BlockEncoder.h>
|
||||
|
||||
|
||||
|
||||
eaudiofx::BlockEncoder::BlockEncoder(void) {
|
||||
setType(eaudiofx::blockTypeEncoder);
|
||||
}
|
||||
|
@ -14,8 +14,8 @@
|
||||
namespace eaudiofx {
|
||||
class BlockEncoder : public eaudiofx::Block {
|
||||
public:
|
||||
BlockEncoder(void) {};
|
||||
~BlockEncoder(void) {};
|
||||
BlockEncoder(void);
|
||||
virtual ~BlockEncoder(void) {};
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -8,4 +8,6 @@
|
||||
|
||||
#include <eaudiofx/core/BlockFilter.h>
|
||||
|
||||
|
||||
eaudiofx::BlockFilter::BlockFilter(void) {
|
||||
setType(eaudiofx::blockTypeFilter);
|
||||
}
|
||||
|
@ -14,8 +14,8 @@
|
||||
namespace eaudiofx {
|
||||
class BlockFilter : public eaudiofx::Block {
|
||||
public:
|
||||
BlockFilter(void) {};
|
||||
~BlockFilter(void) {};
|
||||
BlockFilter(void);
|
||||
virtual ~BlockFilter(void) {};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -9,3 +9,8 @@
|
||||
#include <eaudiofx/core/BlockGenerator.h>
|
||||
|
||||
|
||||
|
||||
eaudiofx::BlockGenerator::BlockGenerator(void) {
|
||||
setType(eaudiofx::blockTypeGenerator);
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
namespace eaudiofx {
|
||||
class BlockGenerator : public eaudiofx::Block {
|
||||
public:
|
||||
BlockGenerator(void) {};
|
||||
~BlockGenerator(void) {};
|
||||
BlockGenerator(void);
|
||||
virtual ~BlockGenerator(void) {};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <eaudiofx/debug.h>
|
||||
#include <eaudiofx/core/BlockMeta.h>
|
||||
|
||||
|
||||
@ -27,9 +28,10 @@ eaudiofx::BlockMeta::~BlockMeta(void) {
|
||||
m_list.clear();
|
||||
}
|
||||
|
||||
void eaudiofx::BlockMeta::addBlock(eaudiofx::Block* _block) {
|
||||
int32_t eaudiofx::BlockMeta::addBlock(eaudiofx::Block* _block) {
|
||||
if (_block == NULL) {
|
||||
throw eaudiofx::exeption::StdExeption(std::string("[") + std::to_string(getUID()) + "] Add NULL block");
|
||||
EAUDIOFX_ERROR("[" << getUID() << "] Add NULL block");
|
||||
return eaudiofx::ERR_INPUT_NULL;
|
||||
}
|
||||
if (_block->getName().size() > 0 ) {
|
||||
// Check if name exist :
|
||||
@ -38,37 +40,45 @@ void eaudiofx::BlockMeta::addBlock(eaudiofx::Block* _block) {
|
||||
continue;
|
||||
}
|
||||
if (it->getName() == _block->getName()) {
|
||||
throw eaudiofx::exeption::StdExeption(std::string("[") + std::to_string(getUID()) + "] Add block name '" + _block->getName() + "' already exist");
|
||||
EAUDIOFX_ERROR("[" << getUID() << "] Add block name '" << _block->getName() << "' already exist");
|
||||
return eaudiofx::ERR_ALREADY_EXIST;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_list.push_back(_block);
|
||||
return eaudiofx::ERR_NONE;
|
||||
}
|
||||
|
||||
void eaudiofx::BlockMeta::addBlock(const std::string& _blockType, const std::string& _name) {
|
||||
throw eaudiofx::exeption::StdExeption("NOT IMPLEMENTED");
|
||||
int32_t eaudiofx::BlockMeta::addBlock(const std::string& _blockType, const std::string& _name) {
|
||||
EAUDIOFX_ERROR("NOT IMPLEMENTED");
|
||||
return eaudiofx::ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void eaudiofx::BlockMeta::removeBlock(const std::string& _name) {
|
||||
throw eaudiofx::exeption::StdExeption("NOT IMPLEMENTED");
|
||||
int32_t eaudiofx::BlockMeta::removeBlock(const std::string& _name) {
|
||||
EAUDIOFX_ERROR("NOT IMPLEMENTED");
|
||||
return eaudiofx::ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void eaudiofx::BlockMeta::replaceFilter(const std::string& _nameUnLink, const std::string& _nameLink) {
|
||||
throw eaudiofx::exeption::StdExeption("NOT IMPLEMENTED");
|
||||
int32_t eaudiofx::BlockMeta::replaceFilter(const std::string& _nameUnLink, const std::string& _nameLink) {
|
||||
EAUDIOFX_ERROR("NOT IMPLEMENTED");
|
||||
return eaudiofx::ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void eaudiofx::BlockMeta::linkBlock(const std::string& _generatorBlockName,
|
||||
const std::string& _generatorIoName,
|
||||
const std::string& _receiverBlockName,
|
||||
const std::string& _receiverIoName) {
|
||||
int32_t eaudiofx::BlockMeta::linkBlock(const std::string& _generatorBlockName,
|
||||
const std::string& _generatorIoName,
|
||||
const std::string& _receiverBlockName,
|
||||
const std::string& _receiverIoName) {
|
||||
|
||||
return eaudiofx::ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void eaudiofx::BlockMeta::openFile(const std::string& _fileName) {
|
||||
throw eaudiofx::exeption::StdExeption("NOT IMPLEMENTED");
|
||||
int32_t eaudiofx::BlockMeta::openFile(const std::string& _fileName) {
|
||||
EAUDIOFX_ERROR("NOT IMPLEMENTED");
|
||||
return eaudiofx::ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void eaudiofx::BlockMeta::openStream(const std::string& _stream) {
|
||||
throw eaudiofx::exeption::StdExeption("NOT IMPLEMENTED");
|
||||
int32_t eaudiofx::BlockMeta::openStream(const std::string& _stream) {
|
||||
EAUDIOFX_ERROR("NOT IMPLEMENTED");
|
||||
return eaudiofx::ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
@ -16,55 +16,62 @@ namespace eaudiofx {
|
||||
class BlockMeta : public eaudiofx::Block {
|
||||
public:
|
||||
BlockMeta(void);
|
||||
~BlockMeta(void);
|
||||
virtual ~BlockMeta(void);
|
||||
private:
|
||||
std::vector<eaudiofx::Block*> m_list; //!< list of all block to process.
|
||||
public:
|
||||
/**
|
||||
* @brief Add a block in the Meta-block
|
||||
* @param[in] _block Pointer on the block (do not free yourself)
|
||||
* @return generic error
|
||||
*/
|
||||
void addBlock(eaudiofx::Block* _block);
|
||||
int32_t addBlock(eaudiofx::Block* _block);
|
||||
/**
|
||||
* @brief Add a block in the Meta-block.
|
||||
* @param[in] _blockType Name of the type of block to add.
|
||||
* @param[in] _name Name of the block to add.
|
||||
* @return generic error
|
||||
*/
|
||||
void addBlock(const std::string& _blockType, const std::string& _name = "");
|
||||
int32_t addBlock(const std::string& _blockType, const std::string& _name = "");
|
||||
/**
|
||||
* @brief Remove a block from the Meta-block
|
||||
* @param[in] _name Name of the block to remove
|
||||
* @note This free the block pointer
|
||||
* @return generic error
|
||||
*/
|
||||
void 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
|
||||
*/
|
||||
void replaceFilter(const std::string& _nameUnLink, const std::string& _nameLink);
|
||||
int32_t replaceFilter(const std::string& _nameUnLink, const std::string& _nameLink);
|
||||
/**
|
||||
* @brief Link 2 IO.
|
||||
* @param[in] _generatorBlockName Name ot the generator Block
|
||||
* @param[in] _generatorIoName Name of the outout
|
||||
* @param[in] _receiverBlockName Name ot the receiver Block
|
||||
* @param[in] _receiverIoName Name of the input
|
||||
* @return generic error
|
||||
*/
|
||||
void linkBlock(const std::string& _generatorBlockName,
|
||||
const std::string& _generatorIoName,
|
||||
const std::string& _receiverBlockName,
|
||||
const std::string& _receiverIoName);
|
||||
int32_t linkBlock(const std::string& _generatorBlockName,
|
||||
const std::string& _generatorIoName,
|
||||
const std::string& _receiverBlockName,
|
||||
const std::string& _receiverIoName);
|
||||
/**
|
||||
* @brief Open file property
|
||||
* @param[in] _fileName Name of the file to open
|
||||
* @return generic error
|
||||
*/
|
||||
void openFile(const std::string& _fileName);
|
||||
int32_t openFile(const std::string& _fileName);
|
||||
/**
|
||||
* @brief Open stream property
|
||||
* @param[in] _stream data stream to open
|
||||
* @return generic error
|
||||
*/
|
||||
void openStream(const std::string& _stream);
|
||||
int32_t openStream(const std::string& _stream);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -8,4 +8,8 @@
|
||||
|
||||
#include <eaudiofx/core/BlockReceiver.h>
|
||||
|
||||
eaudiofx::BlockReceiver::BlockReceiver(void) {
|
||||
setType(eaudiofx::blockTypeReceiver);
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
namespace eaudiofx {
|
||||
class BlockReceiver : public eaudiofx::Block {
|
||||
public:
|
||||
BlockReceiver(void) {};
|
||||
~BlockReceiver(void) {};
|
||||
BlockReceiver(void);
|
||||
virtual ~BlockReceiver(void) {};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -9,3 +9,10 @@
|
||||
#include <eaudiofx/core/Buffer.h>
|
||||
|
||||
|
||||
|
||||
eaudiofx::Buffer::Buffer(eaudiofx::Block& _parent) :
|
||||
m_parent(_parent),
|
||||
m_timestamp(0),
|
||||
m_time(0) {
|
||||
|
||||
}
|
@ -16,11 +16,8 @@ namespace eaudiofx {
|
||||
class Block;
|
||||
class Buffer {
|
||||
public:
|
||||
Buffer(eaudiofx::Block& _parent) :
|
||||
m_parent(_parent) {
|
||||
|
||||
};
|
||||
~Buffer(void) {};
|
||||
Buffer(eaudiofx::Block& _parent);
|
||||
virtual ~Buffer(void) {};
|
||||
protected:
|
||||
eaudiofx::Block& m_parent; //!< parrent Block of this Buffer
|
||||
protected:
|
||||
|
@ -13,7 +13,16 @@ eaudiofx::BufferAudio::BufferAudio(eaudiofx::Block& _parent) :
|
||||
eaudiofx::Buffer(_parent),
|
||||
m_frequency(0),
|
||||
m_nbChannel(0),
|
||||
m_data(0),
|
||||
m_data(NULL),
|
||||
m_allocated(0) {
|
||||
memset(m_channelType, 0, sizeof(m_channelType));
|
||||
}
|
||||
|
||||
eaudiofx::BufferAudio::BufferAudio(eaudiofx::Block& _parent, int32_t _frequency, int32_t _nbChannel) :
|
||||
eaudiofx::Buffer(_parent),
|
||||
m_frequency(_frequency),
|
||||
m_nbChannel(_nbChannel),
|
||||
m_data(NULL),
|
||||
m_allocated(0) {
|
||||
memset(m_channelType, 0, sizeof(m_channelType));
|
||||
}
|
||||
@ -30,6 +39,7 @@ void eaudiofx::BufferAudio::resize(size_t _newSize) {
|
||||
delete[] m_data;
|
||||
m_data = NULL;
|
||||
}
|
||||
EAUDIOFX_ERROR("Request allocate of " << _newSize << " samples");
|
||||
m_data = new float[_newSize];
|
||||
if (m_data == NULL) {
|
||||
EAUDIOFX_ERROR("Can not allocate Buffer Audio");
|
||||
|
@ -15,7 +15,8 @@ namespace eaudiofx {
|
||||
class BufferAudio : public eaudiofx::Buffer {
|
||||
public:
|
||||
BufferAudio(eaudiofx::Block& _parent);
|
||||
~BufferAudio(void);
|
||||
BufferAudio(eaudiofx::Block& _parent, int32_t _frequency, int32_t _nbChannel);
|
||||
virtual ~BufferAudio(void);
|
||||
protected:
|
||||
int32_t m_frequency;
|
||||
int32_t m_nbChannel;
|
||||
|
@ -15,7 +15,7 @@ namespace eaudiofx {
|
||||
class BufferAudioFreq : public eaudiofx::BufferAudio {
|
||||
public:
|
||||
BufferAudioFreq(eaudiofx::Block& _parent);
|
||||
~BufferAudioFreq(void) {};
|
||||
virtual ~BufferAudioFreq(void) {};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -6,11 +6,22 @@
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <eaudiofx/debug.h>
|
||||
#include <eaudiofx/core/BufferAudioRaw.h>
|
||||
|
||||
|
||||
eaudiofx::BufferAudioRaw::BufferAudioRaw(eaudiofx::Block& _parent) :
|
||||
eaudiofx::BufferAudio(_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);
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ namespace eaudiofx {
|
||||
class BufferAudioRaw : public eaudiofx::BufferAudio {
|
||||
public:
|
||||
BufferAudioRaw(eaudiofx::Block& _parent);
|
||||
~BufferAudioRaw(void) {};
|
||||
BufferAudioRaw(eaudiofx::Block& _parent, int32_t _frequency, int32_t _nbChannel, int32_t _nbSample = -1);
|
||||
virtual ~BufferAudioRaw(void) {};
|
||||
protected:
|
||||
size_t m_allocatedSample; //!< generate with m_allocatedBytes/sizeof(**m_audioFormat**) / m_nbChannel;
|
||||
protected:
|
||||
|
@ -22,7 +22,7 @@ namespace eaudiofx {
|
||||
class BufferMessage : public eaudiofx::Buffer {
|
||||
public:
|
||||
BufferMessage(eaudiofx::Block& _parent, int32_t _message = eaudiofx::bufferMessageEndOfStream);
|
||||
~BufferMessage(void) {};
|
||||
virtual ~BufferMessage(void) {};
|
||||
protected:
|
||||
int32_t m_messageId; //!< message ID
|
||||
public:
|
||||
|
@ -15,7 +15,7 @@ namespace eaudiofx {
|
||||
class BufferStream : public eaudiofx::Buffer {
|
||||
public:
|
||||
BufferStream(eaudiofx::Block& _parent);
|
||||
~BufferStream(void);
|
||||
virtual ~BufferStream(void);
|
||||
protected:
|
||||
void* m_data; //!< buffer data
|
||||
size_t m_allocated; //!< number of byte allocated
|
||||
|
@ -9,3 +9,7 @@
|
||||
#include <eaudiofx/core/Processing.h>
|
||||
|
||||
|
||||
int32_t eaudiofx::Processing::process(void) {
|
||||
|
||||
return eaudiofx::ERR_NONE;
|
||||
}
|
@ -12,14 +12,17 @@
|
||||
#include <eaudiofx/core/audio.h>
|
||||
#include <eaudiofx/core/Buffer.h>
|
||||
#include <eaudiofx/core/Block.h>
|
||||
#include <eaudiofx/core/BlockMeta.h>
|
||||
#include <vector>
|
||||
|
||||
namespace eaudiofx {
|
||||
class Processing {
|
||||
class Processing : public eaudiofx::BlockMeta {
|
||||
public:
|
||||
Processing(void) {};
|
||||
~Processing(void) {};
|
||||
private:
|
||||
virtual ~Processing(void) {};
|
||||
public:
|
||||
int32_t process(void);
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
11
eaudiofx/core/audio.cpp
Normal file
11
eaudiofx/core/audio.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <eaudiofx/core/audio.h>
|
||||
|
||||
|
@ -74,33 +74,13 @@ namespace eaudiofx {
|
||||
#define CHANNEL_HEIGHT_TOP 0x04
|
||||
#define CHANNEL_HEIGHT_BOTTOM 0x08
|
||||
|
||||
namespace exeption {
|
||||
class StdExeption: public std::exception {
|
||||
private:
|
||||
std::string m_comment;
|
||||
public:
|
||||
StdExeption(const char* _comment) :
|
||||
m_comment(_comment) {
|
||||
|
||||
}
|
||||
StdExeption(const std::string& _comment) :
|
||||
m_comment(_comment) {
|
||||
|
||||
}
|
||||
virtual const char* what() const throw() {
|
||||
if (m_comment.size() == 0) {
|
||||
return "No exeption comment define ...";
|
||||
} else {
|
||||
return m_comment.c_str();
|
||||
}
|
||||
};
|
||||
};
|
||||
extern const StdExeption g_nullInput;
|
||||
extern const StdExeption g_blockAlreadyExist;
|
||||
extern const StdExeption g_blockHasNoInput;
|
||||
extern const StdExeption g_blockHasNoOuput;
|
||||
extern const StdExeption g_blockHasNoParameter;
|
||||
extern const StdExeption g_forbiden;
|
||||
enum {
|
||||
ERR_NONE = 0,
|
||||
ERR_NOT_IMPLEMENTED,
|
||||
ERR_ALREADY_EXIST,
|
||||
ERR_INPUT_NULL,
|
||||
ERR_FORBIDEN,
|
||||
ERR_NO_IO,
|
||||
};
|
||||
};
|
||||
|
||||
|
19
eaudiofx/eaudiofx.h
Normal file
19
eaudiofx/eaudiofx.h
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EAUDIOFX_H__
|
||||
#define __EAUDIOFX_H__
|
||||
|
||||
#include <eaudiofx/core/audio.h>
|
||||
#include <eaudiofx/core/Block.h>
|
||||
#include <eaudiofx/core/Buffer.h>
|
||||
#include <eaudiofx/core/Processing.h>
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -33,11 +33,12 @@ def create(target):
|
||||
'eaudiofx/base/GeneratorFile.cpp',
|
||||
'eaudiofx/base/ReceiverFile.cpp',
|
||||
'eaudiofx/base/GeneratorRtAudio.cpp',
|
||||
'eaudiofx/base/ReceiverRtAudio.cpp'
|
||||
'eaudiofx/base/ReceiverRtAudio.cpp',
|
||||
'eaudiofx/base/GeneratorSignal.cpp'
|
||||
])
|
||||
|
||||
# name of the dependency
|
||||
myModule.add_module_depend(['etk', 'rtaudio'])
|
||||
myModule.add_module_depend(['ewol', 'rtaudio'])
|
||||
|
||||
myModule.add_export_path(tools.get_current_path(__file__))
|
||||
|
||||
|
@ -12,8 +12,8 @@ def create(target):
|
||||
# basic GUI :
|
||||
myModule.add_src_file([
|
||||
'test/debug.cpp',
|
||||
'test/main.cpp',
|
||||
'test/windows.cpp',
|
||||
'test/Main.cpp',
|
||||
'test/Windows.cpp',
|
||||
])
|
||||
|
||||
# name of the dependency
|
||||
|
@ -11,12 +11,11 @@
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/context/commandLine.h>
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <appl/Windows.h>
|
||||
#include <test/debug.h>
|
||||
#include <test/Windows.h>
|
||||
#include <ewol/object/Object.h>
|
||||
#include <ewol/widget/Manager.h>
|
||||
#include <ewol/context/Context.h>
|
||||
#include <appl/widget/VectorDisplay.h>
|
||||
|
||||
|
||||
/**
|
||||
@ -42,8 +41,6 @@ bool APP_Init(ewol::Context& _context) {
|
||||
_context.getFontDefault().setUseExternal(true);
|
||||
_context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19);
|
||||
|
||||
appl::widget::VectorDisplay::init(_context.getWidgetManager());
|
||||
|
||||
ewol::widget::Windows* basicWindows = new appl::Windows();
|
||||
// create the specific windows
|
||||
_context.setWindows(basicWindows);
|
||||
|
@ -11,6 +11,9 @@
|
||||
#include <test/Windows.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
#include <etk/tool.h>
|
||||
#include <eaudiofx/eaudiofx.h>
|
||||
#include <eaudiofx/base/GeneratorSignal.h>
|
||||
#include <eaudiofx/base/ReceiverRtAudio.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Windows"
|
||||
@ -59,11 +62,33 @@ void appl::Windows::onObjectRemove(ewol::Object * _removeObject) {
|
||||
|
||||
|
||||
void appl::Windows::onReceiveMessage(const ewol::object::Message& _msg) {
|
||||
if (_msg.getMessage() == g_eventChangeValues) {
|
||||
|
||||
if (_msg.getMessage() == g_eventPlay1) {
|
||||
APPL_ERROR("Play Requested ...");
|
||||
eaudiofx::Processing* process = new eaudiofx::Processing();
|
||||
if (process == NULL) {
|
||||
APPL_ERROR("can not create processing ...");
|
||||
return;
|
||||
}
|
||||
APPL_ERROR("Create Generator ...");
|
||||
eaudiofx::GeneratorSignal* generator = new eaudiofx::GeneratorSignal();
|
||||
if (generator == NULL) {
|
||||
APPL_ERROR("can not create Generator ...");
|
||||
return;
|
||||
}
|
||||
generator->setName("myGenerator");
|
||||
process->addBlock(generator);
|
||||
APPL_ERROR("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->process();
|
||||
return;
|
||||
}
|
||||
if (_msg.getMessage() == g_eventAutoMode) {
|
||||
if (_msg.getMessage() == g_eventPlay2) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -7,6 +7,6 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <test/debug.h>
|
||||
|
||||
const char * applLogName = "example ";
|
||||
const char * applLogName = "ea-fx TT ";
|
||||
|
Loading…
Reference in New Issue
Block a user