[DEV] start work on dynamic chain
This commit is contained in:
parent
12a60900cc
commit
29f8b24b2b
@ -13,6 +13,7 @@
|
||||
#include <airtalgo/EndPointCallback.h>
|
||||
#include <airtalgo/EndPointWrite.h>
|
||||
#include <airtalgo/EndPointRead.h>
|
||||
#include <airtalgo/Volume.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
@ -43,6 +44,13 @@ bool airtio::Interface::init(const std::string& _name,
|
||||
|
||||
// Create convertion interface
|
||||
if (m_node->isInput() == true) {
|
||||
// add all time the volume stage :
|
||||
std::shared_ptr<airtalgo::Volume> algo = airtalgo::Volume::create();
|
||||
algo->setInputFormat(airtalgo::IOFormatInterface(m_node->getMap(), m_node->getFormat(), m_node->getFrequency()));
|
||||
algo->setName("volume");
|
||||
m_process->pushBack(algo);
|
||||
AIRTIO_INFO("add basic volume stage");
|
||||
/*
|
||||
// TODO : Set an auto update of IO
|
||||
if (m_map != m_node->getMap()) {
|
||||
std::shared_ptr<airtalgo::ChannelReorder> algo = airtalgo::ChannelReorder::create();
|
||||
@ -65,23 +73,15 @@ bool airtio::Interface::init(const std::string& _name,
|
||||
m_process->pushBack(algo);
|
||||
AIRTIO_INFO("convert " << m_node->getFormat() << " -> " << m_format);
|
||||
}
|
||||
// by default we add a read node
|
||||
if (true) {
|
||||
std::shared_ptr<airtalgo::EndPointRead> algo = airtalgo::EndPointRead::create();
|
||||
algo->setInputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq));
|
||||
algo->setOutputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq));
|
||||
m_process->pushBack(algo);
|
||||
AIRTIO_INFO("add default read node ...");
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
// by default we add a write node:
|
||||
if (true) {
|
||||
std::shared_ptr<airtalgo::EndPointWrite> algo = airtalgo::EndPointWrite::create();
|
||||
algo->setInputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq));
|
||||
algo->setOutputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq));
|
||||
// add all time the volume stage :
|
||||
std::shared_ptr<airtalgo::Volume> algo = airtalgo::Volume::create();
|
||||
algo->setOutputFormat(airtalgo::IOFormatInterface(m_node->getMap(), m_node->getFormat(), m_node->getFrequency()));
|
||||
algo->setName("volume");
|
||||
m_process->pushBack(algo);
|
||||
AIRTIO_INFO("add default write node ...");
|
||||
}
|
||||
AIRTIO_INFO("add basic volume stage");
|
||||
/*
|
||||
// TODO : Set an auto update of IO
|
||||
if (m_format != m_node->getFormat()) {
|
||||
std::shared_ptr<airtalgo::FormatUpdate> algo = airtalgo::FormatUpdate::create();
|
||||
@ -104,6 +104,7 @@ bool airtio::Interface::init(const std::string& _name,
|
||||
m_process->pushBack(algo);
|
||||
AIRTIO_INFO("convert " << m_map << " -> " << m_node->getMap());
|
||||
}
|
||||
*/
|
||||
}
|
||||
//m_node->interfaceAdd(shared_from_this());
|
||||
return true;
|
||||
@ -125,7 +126,31 @@ airtio::Interface::~Interface() {
|
||||
//m_node->interfaceRemove(shared_from_this());
|
||||
m_process.reset();
|
||||
}
|
||||
/*
|
||||
bool airtio::Interface::hasEndPoint() {
|
||||
|
||||
}
|
||||
*/
|
||||
void airtio::Interface::setReadwrite() {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
if (m_process->hasType<airtalgo::EndPoint>() ) {
|
||||
AIRTIO_ERROR("Endpoint is already present ==> can not change");
|
||||
return;
|
||||
}
|
||||
if (m_node->isInput() == true) {
|
||||
m_process->removeIfLast<airtalgo::EndPoint>();
|
||||
std::shared_ptr<airtalgo::EndPointRead> algo = airtalgo::EndPointRead::create();
|
||||
///algo->setInputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq));
|
||||
algo->setOutputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq));
|
||||
m_process->pushBack(algo);
|
||||
} else {
|
||||
m_process->removeIfFirst<airtalgo::EndPoint>();
|
||||
std::shared_ptr<airtalgo::EndPointWrite> algo = airtalgo::EndPointWrite::create();
|
||||
algo->setInputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq));
|
||||
//algo->setOutputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq));
|
||||
m_process->pushBack(algo);
|
||||
}
|
||||
}
|
||||
|
||||
void airtio::Interface::setOutputCallback(size_t _chunkSize, airtalgo::needDataFunction _function) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
@ -133,7 +158,7 @@ void airtio::Interface::setOutputCallback(size_t _chunkSize, airtalgo::needDataF
|
||||
std::shared_ptr<airtalgo::Algo> algo = airtalgo::EndPointCallback::create(_function);
|
||||
AIRTIO_INFO("set property: " << m_map << " " << m_format << " " << m_freq);
|
||||
algo->setInputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq));
|
||||
algo->setOutputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq));
|
||||
//algo->setOutputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq));
|
||||
m_process->pushFront(algo);
|
||||
}
|
||||
|
||||
@ -141,7 +166,7 @@ void airtio::Interface::setInputCallback(size_t _chunkSize, airtalgo::haveNewDat
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
m_process->removeIfLast<airtalgo::EndPoint>();
|
||||
std::shared_ptr<airtalgo::Algo> algo = airtalgo::EndPointCallback::create(_function);
|
||||
algo->setInputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq));
|
||||
//algo->setInputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq));
|
||||
algo->setOutputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq));
|
||||
m_process->pushBack(algo);
|
||||
}
|
||||
@ -158,6 +183,7 @@ void airtio::Interface::setWriteCallback(airtalgo::needDataFunctionWrite _functi
|
||||
void airtio::Interface::start(const std::chrono::system_clock::time_point& _time) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
AIRTIO_DEBUG("start [BEGIN]");
|
||||
m_process->updateInterAlgo();
|
||||
m_node->interfaceAdd(shared_from_this());
|
||||
AIRTIO_DEBUG("start [ END ]");
|
||||
}
|
||||
@ -165,6 +191,7 @@ void airtio::Interface::start(const std::chrono::system_clock::time_point& _time
|
||||
void airtio::Interface::stop(bool _fast, bool _abort) {
|
||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||
AIRTIO_DEBUG("stop [BEGIN]");
|
||||
m_process->removeAlgoDynamic();
|
||||
m_node->interfaceRemove(shared_from_this());
|
||||
AIRTIO_DEBUG("stop [ END]");
|
||||
}
|
||||
@ -285,4 +312,6 @@ void airtio::Interface::systemNeedOutputData(std::chrono::system_clock::time_poi
|
||||
m_process->pull(_time, _data, _nbChunk, _chunkSize);
|
||||
}
|
||||
|
||||
bool airtio::Interface::systemSetVolume(const std::string& _parameter, const std::string& _value);
|
||||
bool airtio::Interface::systemSetVolume(const std::string& _parameter, const std::string& _value) {
|
||||
return false;
|
||||
}
|
@ -61,13 +61,29 @@ namespace airtio {
|
||||
const std::vector<airtalgo::channel>& _map,
|
||||
airtalgo::format _format,
|
||||
const std::shared_ptr<airtio::io::Node>& _node);
|
||||
public:
|
||||
/**
|
||||
* @brief When we want to implement a Callback Mode :
|
||||
* @brief set the read/write mode enable.
|
||||
*/
|
||||
virtual void setReadwrite();
|
||||
/**
|
||||
* @brief When we want to implement a Callback Mode:
|
||||
*/
|
||||
virtual void setWriteCallback(airtalgo::needDataFunctionWrite _function);
|
||||
virtual void setOutputCallback(size_t _chunkSize, airtalgo::needDataFunction _function);
|
||||
virtual void setInputCallback(size_t _chunkSize, airtalgo::haveNewDataFunction _function);
|
||||
/**
|
||||
* @brief Add a volume group of the current channel.
|
||||
* @note If you do not call this function with the group "FLOW" you chan not have a channel volume.
|
||||
* @note the set volume stage can not be set after the start.
|
||||
* @param[in] _name Name of the group classicle common group:
|
||||
* - FLOW for channel volume.
|
||||
* - MEDIA for multimedia volume control (audio player, player video, web streaming ...).
|
||||
* - TTS for Test-to-speech volume control.
|
||||
* - COMMUNICATION for user communication volume control.
|
||||
* - NOTIFICATION for urgent notification volume control.
|
||||
* - NOISE for small nose volume control.
|
||||
*/
|
||||
virtual void addVolumeGroup(const std::string& _name) {}
|
||||
public:
|
||||
/**
|
||||
* @brief Start the Audio interface flow.
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "io/Manager.h"
|
||||
#include "io/Node.h"
|
||||
#include "debug.h"
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Manager"
|
||||
@ -21,9 +22,7 @@ std::shared_ptr<airtio::Manager> airtio::Manager::create(const std::string& _app
|
||||
|
||||
airtio::Manager::Manager(const std::string& _applicationUniqueId) :
|
||||
m_applicationUniqueId(_applicationUniqueId),
|
||||
m_listOpenInterface(),
|
||||
m_masterVolume(0.0f),
|
||||
m_masterVolumeRange(std::make_pair(-120.0f, 0.0f)) {
|
||||
m_listOpenInterface() {
|
||||
|
||||
}
|
||||
|
||||
@ -45,7 +44,7 @@ std::vector<std::pair<std::string,std::string> > airtio::Manager::getListStreamO
|
||||
}
|
||||
|
||||
|
||||
bool setParameter(const std::string& _flow, const std::string& _filter, const std::string& _parameter, const std::string& _value) {
|
||||
bool airtio::Manager::setParameter(const std::string& _flow, const std::string& _filter, const std::string& _parameter, const std::string& _value) {
|
||||
AIRTIO_DEBUG("setParameter [BEGIN] : '" << _flow << "':'" << _filter << "':'" << _parameter << "':'" << _value << "'");
|
||||
bool out = false;
|
||||
if ( _filter == "volume"
|
||||
@ -56,7 +55,7 @@ bool setParameter(const std::string& _flow, const std::string& _filter, const st
|
||||
AIRTIO_DEBUG("setParameter [ END ] : '" << out << "'");
|
||||
return out;
|
||||
}
|
||||
std::string getParameter(const std::string& _flow, const std::string& _filter, const std::string& _parameter) const {
|
||||
std::string airtio::Manager::getParameter(const std::string& _flow, const std::string& _filter, const std::string& _parameter) const {
|
||||
AIRTIO_DEBUG("getParameter [BEGIN] : '" << _flow << "':'" << _filter << "':'" << _parameter << "'");
|
||||
std::string out;
|
||||
AIRTIO_TODO(" IMPLEMENT");
|
||||
@ -64,7 +63,7 @@ std::string getParameter(const std::string& _flow, const std::string& _filter, c
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string getParameterProperty(const std::string& _flow, const std::string& _filter, const std::string& _parameter) const {
|
||||
std::string airtio::Manager::getParameterProperty(const std::string& _flow, const std::string& _filter, const std::string& _parameter) const {
|
||||
AIRTIO_DEBUG("getParameterProperty [BEGIN] : '" << _flow << "':'" << _filter << "':'" << _parameter << "'");
|
||||
std::string out;
|
||||
AIRTIO_TODO(" IMPLEMENT");
|
||||
@ -72,47 +71,6 @@ std::string getParameterProperty(const std::string& _flow, const std::string& _f
|
||||
return out;
|
||||
}
|
||||
|
||||
// TODO : Deprecated ...
|
||||
void airtio::Manager::setMasterOutputVolume(float _gainDB) {
|
||||
if (_gainDB < m_masterVolumeRange.first) {
|
||||
//throw std::range_error(std::string(_gainDB) + " is out of bonds : [" + m_masterVolumeRange.first + ".." + m_masterVolumeRange.second + "]");
|
||||
return;
|
||||
}
|
||||
if (_gainDB > m_masterVolumeRange.second) {
|
||||
//throw std::range_error(std::string(_gainDB) + " is out of bonds : [" + m_masterVolumeRange.first + ".." + m_masterVolumeRange.second + "]");
|
||||
return;
|
||||
}
|
||||
m_masterVolume = _gainDB;
|
||||
for (auto &it : m_listOpenInterface) {
|
||||
std::shared_ptr<airtio::Interface> tmpElem = it.lock();
|
||||
if (tmpElem == nullptr) {
|
||||
continue;
|
||||
}
|
||||
// TODO : Deprecated ...
|
||||
//tmpElem->setMasterVolume(m_masterVolume);
|
||||
}
|
||||
}
|
||||
|
||||
float airtio::Manager::getMasterOutputVolume() {
|
||||
return m_masterVolume;
|
||||
}
|
||||
|
||||
std::pair<float,float> airtio::Manager::getMasterOutputVolumeRange() {
|
||||
return m_masterVolumeRange;
|
||||
}
|
||||
|
||||
void airtio::Manager::setSectionVolume(const std::string& _section, float _gainDB) {
|
||||
|
||||
}
|
||||
|
||||
float airtio::Manager::getSectionVolume(const std::string& _section) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
std::pair<float,float> airtio::Manager::getSectionVolumeRange(const std::string& _section) {
|
||||
return std::make_pair(0.0f, 0.0f);
|
||||
}
|
||||
|
||||
std::shared_ptr<airtio::Interface>
|
||||
airtio::Manager::createOutput(float _freq,
|
||||
const std::vector<airtalgo::channel>& _map,
|
||||
|
30
data/hardware.json
Normal file
30
data/hardware.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
microphone:{ # name of the device
|
||||
io:"input", # input or output
|
||||
map-on:{ # select hardware interface and name
|
||||
interface:"alsa", # interface : "alsa", "pulse", "core", ...
|
||||
name:"default", # name of the interface
|
||||
},
|
||||
frequency:48000, # frequency to open device
|
||||
channel-map:[ # mapping of the harware device (to change map if needed)
|
||||
"front-left", "front-right",
|
||||
"read-left", "rear-right",
|
||||
],
|
||||
type:"int16", # format to open device (int8, int16, int16-on-ont32, int24, int32, float)
|
||||
nb-chunk:1024 # number of chunk to open device (create the latency anf the frequency to call user)
|
||||
},
|
||||
speaker:{
|
||||
io:"output",
|
||||
map-on:{
|
||||
interface:"alsa",
|
||||
name:"default",
|
||||
},
|
||||
frequency:48000,
|
||||
channel-map:[
|
||||
"front-left", "front-right",
|
||||
],
|
||||
type:"int16",
|
||||
nb-chunk:1024,
|
||||
volume-name:"MASTER"
|
||||
}
|
||||
}
|
29
data/virtual.json
Normal file
29
data/virtual.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
microphone:{ # name of the virtual interface
|
||||
io:"input", # input or output
|
||||
map-on:"microphone", # name of the harware device
|
||||
resampling-type:"speexdsp", # name of the resampler
|
||||
resampling-option:"quality=10" # some option to the resampler
|
||||
},
|
||||
speaker:{
|
||||
io:"output",
|
||||
map-on:"speaker",
|
||||
resampling-type:"speexdsp",
|
||||
resampling-option:"quality=10"
|
||||
},
|
||||
feedback:{
|
||||
io:"input",
|
||||
map-on:"speaker",
|
||||
resampling-type:"speexdsp",
|
||||
resampling-option:"quality=10"
|
||||
},
|
||||
microphone-cleaned:{
|
||||
io:"input",
|
||||
map-on:"speaker",
|
||||
resampling-type:"speexdsp",
|
||||
resampling-option:"quality=10",
|
||||
aec-map-on:"microphone", the second input of the AEC (get a single
|
||||
aec-type:"airtio-remover", # some type is "airtio-remover",
|
||||
aec-option:"mode=cutter"
|
||||
}
|
||||
}
|
@ -32,6 +32,7 @@ class testOutWrite {
|
||||
airtalgo::format_int16,
|
||||
"default",
|
||||
"WriteMode");
|
||||
m_interface->setReadwrite();
|
||||
}
|
||||
void run() {
|
||||
double phase=0;
|
||||
@ -100,6 +101,7 @@ class testOutWriteCallback {
|
||||
airtalgo::format_int16,
|
||||
"default",
|
||||
"WriteMode+Callback");
|
||||
m_interface->setReadwrite();
|
||||
m_interface->setWriteCallback(std::bind(&testOutWriteCallback::onDataNeeded,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
@ -232,6 +234,7 @@ class testInRead {
|
||||
airtalgo::format_int16,
|
||||
"default",
|
||||
"WriteMode");
|
||||
m_interface->setReadwrite();
|
||||
}
|
||||
void run() {
|
||||
m_interface->start();
|
||||
@ -468,10 +471,10 @@ TEST(TestALL, testFormat) {
|
||||
std::shared_ptr<airtio::Manager> manager;
|
||||
manager = airtio::Manager::create("testApplication");
|
||||
std::vector<airtalgo::format> listFormat;
|
||||
listFormat.push_back(airtalgo::format_int16);
|
||||
listFormat.push_back(airtalgo::format_int16_on_int32);
|
||||
//listFormat.push_back(airtalgo::format_int16);
|
||||
//listFormat.push_back(airtalgo::format_int16_on_int32);
|
||||
listFormat.push_back(airtalgo::format_int32);
|
||||
listFormat.push_back(airtalgo::format_float);
|
||||
//listFormat.push_back(airtalgo::format_float);
|
||||
for (auto &it : listFormat) {
|
||||
std::shared_ptr<testOutCallbackType> process = std::make_shared<testOutCallbackType>(manager, 48000, 2, it);
|
||||
process->run();
|
||||
|
Loading…
x
Reference in New Issue
Block a user