[DEV] update new ejson interface
This commit is contained in:
parent
c9bb77e8d6
commit
aa5df52e14
@ -28,12 +28,12 @@ bool audio::river::Interface::init(float _freq,
|
|||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::shared_ptr<audio::river::io::Node>& _node,
|
const std::shared_ptr<audio::river::io::Node>& _node,
|
||||||
const std::shared_ptr<const ejson::Object>& _config) {
|
const ejson::Object& _config) {
|
||||||
std::vector<audio::channel> map(_map);
|
std::vector<audio::channel> map(_map);
|
||||||
m_node = _node;
|
m_node = _node;
|
||||||
m_config = _config;
|
m_config = _config;
|
||||||
m_mode = audio::river::modeInterface_unknow;
|
m_mode = audio::river::modeInterface_unknow;
|
||||||
std::string type = m_config->getStringValue("io", "error");
|
std::string type = m_config.getStringValue("io", "error");
|
||||||
static int32_t uid=0;
|
static int32_t uid=0;
|
||||||
m_name = _node->getName() + "__" + (_node->isInput()==true?"input":"output") + "__" + type + "__" + etk::to_string(uid++);
|
m_name = _node->getName() + "__" + (_node->isInput()==true?"input":"output") + "__" + type + "__" + etk::to_string(uid++);
|
||||||
if (type == "output") {
|
if (type == "output") {
|
||||||
@ -99,7 +99,7 @@ std::shared_ptr<audio::river::Interface> audio::river::Interface::create(float _
|
|||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::shared_ptr<audio::river::io::Node>& _node,
|
const std::shared_ptr<audio::river::io::Node>& _node,
|
||||||
const std::shared_ptr<const ejson::Object>& _config) {
|
const ejson::Object& _config) {
|
||||||
std::shared_ptr<audio::river::Interface> out = std::shared_ptr<audio::river::Interface>(new audio::river::Interface());
|
std::shared_ptr<audio::river::Interface> out = std::shared_ptr<audio::river::Interface>(new audio::river::Interface());
|
||||||
out->init(_freq, _map, _format, _node, _config);
|
out->init(_freq, _map, _format, _node, _config);
|
||||||
return out;
|
return out;
|
||||||
|
@ -66,7 +66,7 @@ namespace audio {
|
|||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::shared_ptr<audio::river::io::Node>& _node,
|
const std::shared_ptr<audio::river::io::Node>& _node,
|
||||||
const std::shared_ptr<const ejson::Object>& _config);
|
const ejson::Object& _config);
|
||||||
/**
|
/**
|
||||||
* @brief Factory of this interface (called by class audio::river::Manager)
|
* @brief Factory of this interface (called by class audio::river::Manager)
|
||||||
* @param[in] _freq Frequency.
|
* @param[in] _freq Frequency.
|
||||||
@ -81,7 +81,7 @@ namespace audio {
|
|||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::shared_ptr<audio::river::io::Node>& _node,
|
const std::shared_ptr<audio::river::io::Node>& _node,
|
||||||
const std::shared_ptr<const ejson::Object>& _config);
|
const ejson::Object& _config);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
@ -89,7 +89,7 @@ namespace audio {
|
|||||||
virtual ~Interface();
|
virtual ~Interface();
|
||||||
protected:
|
protected:
|
||||||
mutable std::recursive_mutex m_mutex; //!< Local mutex to protect data
|
mutable std::recursive_mutex m_mutex; //!< Local mutex to protect data
|
||||||
std::shared_ptr<const ejson::Object> m_config; //!< configuration set by the user.
|
ejson::Object m_config; //!< configuration set by the user.
|
||||||
protected:
|
protected:
|
||||||
enum modeInterface m_mode; //!< interface type (input/output/feedback)
|
enum modeInterface m_mode; //!< interface type (input/output/feedback)
|
||||||
public:
|
public:
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include <ejson/ejson.h>
|
#include <ejson/ejson.h>
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "Manager"
|
|
||||||
static std::mutex g_mutex;
|
static std::mutex g_mutex;
|
||||||
static std::vector<std::weak_ptr<audio::river::Manager> > g_listOfAllManager;
|
static std::vector<std::weak_ptr<audio::river::Manager> > g_listOfAllManager;
|
||||||
|
|
||||||
@ -165,8 +163,8 @@ std::shared_ptr<audio::river::Interface> audio::river::Manager::createOutput(flo
|
|||||||
}
|
}
|
||||||
// create user iterface:
|
// create user iterface:
|
||||||
std::shared_ptr<audio::river::Interface> interface;
|
std::shared_ptr<audio::river::Interface> interface;
|
||||||
std::shared_ptr<ejson::Object> tmpOption = ejson::Object::create(_options);
|
ejson::Object tmpOption = ejson::Object(_options);
|
||||||
tmpOption->addString("io", "output");
|
tmpOption.addString("io", "output");
|
||||||
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
|
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
|
||||||
// store it in a list (needed to apply some parameters).
|
// store it in a list (needed to apply some parameters).
|
||||||
m_listOpenInterface.push_back(interface);
|
m_listOpenInterface.push_back(interface);
|
||||||
@ -196,8 +194,8 @@ std::shared_ptr<audio::river::Interface> audio::river::Manager::createInput(floa
|
|||||||
}
|
}
|
||||||
// create user iterface:
|
// create user iterface:
|
||||||
std::shared_ptr<audio::river::Interface> interface;
|
std::shared_ptr<audio::river::Interface> interface;
|
||||||
std::shared_ptr<ejson::Object> tmpOption = ejson::Object::create(_options);
|
ejson::Object tmpOption = ejson::Object(_options);
|
||||||
tmpOption->addString("io", "input");
|
tmpOption.addString("io", "input");
|
||||||
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
|
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
|
||||||
// store it in a list (needed to apply some parameters).
|
// store it in a list (needed to apply some parameters).
|
||||||
m_listOpenInterface.push_back(interface);
|
m_listOpenInterface.push_back(interface);
|
||||||
@ -228,8 +226,8 @@ std::shared_ptr<audio::river::Interface> audio::river::Manager::createFeedback(f
|
|||||||
}
|
}
|
||||||
// create user iterface:
|
// create user iterface:
|
||||||
std::shared_ptr<audio::river::Interface> interface;
|
std::shared_ptr<audio::river::Interface> interface;
|
||||||
std::shared_ptr<ejson::Object> tmpOption = ejson::Object::create(_options);
|
ejson::Object tmpOption = ejson::Object(_options);
|
||||||
tmpOption->addString("io", "feedback");
|
tmpOption.addString("io", "feedback");
|
||||||
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
|
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
|
||||||
// store it in a list (needed to apply some parameters).
|
// store it in a list (needed to apply some parameters).
|
||||||
m_listOpenInterface.push_back(interface);
|
m_listOpenInterface.push_back(interface);
|
||||||
|
@ -18,15 +18,15 @@
|
|||||||
void audio::river::io::Group::createFrom(const ejson::Document& _obj, const std::string& _name) {
|
void audio::river::io::Group::createFrom(const ejson::Document& _obj, const std::string& _name) {
|
||||||
RIVER_INFO("Create Group[" << _name << "] (START) ___________________________");
|
RIVER_INFO("Create Group[" << _name << "] (START) ___________________________");
|
||||||
for (size_t iii=0; iii<_obj.size(); ++iii) {
|
for (size_t iii=0; iii<_obj.size(); ++iii) {
|
||||||
const std::shared_ptr<const ejson::Object> tmpObject = _obj.getObject(_obj.getKey(iii));
|
const ejson::Object tmpObject = _obj[iii].toObject();
|
||||||
if (tmpObject == nullptr) {
|
if (tmpObject.exist() == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std::string groupName = tmpObject->getStringValue("group", "");
|
std::string groupName = tmpObject.getStringValue("group", "");
|
||||||
if (groupName == _name) {
|
if (groupName == _name) {
|
||||||
RIVER_INFO("Add element in Group[" << _name << "]: " << _obj.getKey(iii));
|
RIVER_INFO("Add element in Group[" << _name << "]: " << _obj.getKey(iii));
|
||||||
// get type : io
|
// get type : io
|
||||||
std::string ioType = tmpObject->getStringValue("io", "error");
|
std::string ioType = tmpObject.getStringValue("io", "error");
|
||||||
#ifdef AUDIO_RIVER_BUILD_ORCHESTRA
|
#ifdef AUDIO_RIVER_BUILD_ORCHESTRA
|
||||||
if ( ioType == "input"
|
if ( ioType == "input"
|
||||||
|| ioType == "output") {
|
|| ioType == "output") {
|
||||||
|
@ -108,13 +108,13 @@ std::vector<std::string> audio::river::io::Manager::getListStreamInput() {
|
|||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
std::vector<std::string> output;
|
std::vector<std::string> output;
|
||||||
std::vector<std::string> keys = m_config.getKeys();
|
std::vector<std::string> keys = m_config.getKeys();
|
||||||
for (size_t iii=0; iii<keys.size(); ++iii) {
|
for (auto &it : keys) {
|
||||||
const std::shared_ptr<const ejson::Object> tmppp = m_config.getObject(keys[iii]);
|
const ejson::Object tmppp = m_config[it].toObject();
|
||||||
if (tmppp != nullptr) {
|
if (tmppp.exist() == true) {
|
||||||
std::string type = tmppp->getStringValue("io", "error");
|
std::string type = tmppp.getStringValue("io", "error");
|
||||||
if ( type == "input"
|
if ( type == "input"
|
||||||
|| type == "PAinput") {
|
|| type == "PAinput") {
|
||||||
output.push_back(keys[iii]);
|
output.push_back(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,13 +125,13 @@ std::vector<std::string> audio::river::io::Manager::getListStreamOutput() {
|
|||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
std::vector<std::string> output;
|
std::vector<std::string> output;
|
||||||
std::vector<std::string> keys = m_config.getKeys();
|
std::vector<std::string> keys = m_config.getKeys();
|
||||||
for (size_t iii=0; iii<keys.size(); ++iii) {
|
for (auto &it : keys) {
|
||||||
const std::shared_ptr<const ejson::Object> tmppp = m_config.getObject(keys[iii]);
|
const ejson::Object tmppp = m_config[it].toObject();
|
||||||
if (tmppp != nullptr) {
|
if (tmppp.exist() == true) {
|
||||||
std::string type = tmppp->getStringValue("io", "error");
|
std::string type = tmppp.getStringValue("io", "error");
|
||||||
if ( type == "output"
|
if ( type == "output"
|
||||||
|| type == "PAoutput") {
|
|| type == "PAoutput") {
|
||||||
output.push_back(keys[iii]);
|
output.push_back(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,16 +142,16 @@ std::vector<std::string> audio::river::io::Manager::getListStreamVirtual() {
|
|||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
std::vector<std::string> output;
|
std::vector<std::string> output;
|
||||||
std::vector<std::string> keys = m_config.getKeys();
|
std::vector<std::string> keys = m_config.getKeys();
|
||||||
for (size_t iii=0; iii<keys.size(); ++iii) {
|
for (auto &it : keys) {
|
||||||
const std::shared_ptr<const ejson::Object> tmppp = m_config.getObject(keys[iii]);
|
const ejson::Object tmppp = m_config[it].toObject();
|
||||||
if (tmppp != nullptr) {
|
if (tmppp.exist() == true) {
|
||||||
std::string type = tmppp->getStringValue("io", "error");
|
std::string type = tmppp.getStringValue("io", "error");
|
||||||
if ( type != "input"
|
if ( type != "input"
|
||||||
&& type != "PAinput"
|
&& type != "PAinput"
|
||||||
&& type != "output"
|
&& type != "output"
|
||||||
&& type != "PAoutput"
|
&& type != "PAoutput"
|
||||||
&& type != "error") {
|
&& type != "error") {
|
||||||
output.push_back(keys[iii]);
|
output.push_back(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,12 +162,12 @@ std::vector<std::string> audio::river::io::Manager::getListStream() {
|
|||||||
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
std::vector<std::string> output;
|
std::vector<std::string> output;
|
||||||
std::vector<std::string> keys = m_config.getKeys();
|
std::vector<std::string> keys = m_config.getKeys();
|
||||||
for (size_t iii=0; iii<keys.size(); ++iii) {
|
for (auto &it : keys) {
|
||||||
const std::shared_ptr<const ejson::Object> tmppp = m_config.getObject(keys[iii]);
|
const ejson::Object tmppp = m_config[it].toObject();
|
||||||
if (tmppp != nullptr) {
|
if (tmppp.exist() == true) {
|
||||||
std::string type = tmppp->getStringValue("io", "error");
|
std::string type = tmppp.getStringValue("io", "error");
|
||||||
if (type != "error") {
|
if (type != "error") {
|
||||||
output.push_back(keys[iii]);
|
output.push_back(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,12 +202,12 @@ std::shared_ptr<audio::river::io::Node> audio::river::io::Manager::getNode(const
|
|||||||
}
|
}
|
||||||
RIVER_WARNING("Try create a new one : " << _name);
|
RIVER_WARNING("Try create a new one : " << _name);
|
||||||
// check if the node can be open :
|
// check if the node can be open :
|
||||||
const std::shared_ptr<const ejson::Object> tmpObject = m_config.getObject(_name);
|
const ejson::Object tmpObject = m_config[_name].toObject();
|
||||||
if (tmpObject != nullptr) {
|
if (tmpObject.exist() == true) {
|
||||||
//Check if it is in a group:
|
//Check if it is in a group:
|
||||||
std::string groupName = tmpObject->getStringValue("group", "");
|
std::string groupName = tmpObject.getStringValue("group", "");
|
||||||
// get type : io
|
// get type : io
|
||||||
std::string ioType = tmpObject->getStringValue("io", "error");
|
std::string ioType = tmpObject.getStringValue("io", "error");
|
||||||
if ( groupName != ""
|
if ( groupName != ""
|
||||||
&& ( ioType == "input"
|
&& ( ioType == "input"
|
||||||
|| ioType == "output"
|
|| ioType == "output"
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#define __class__ "io::Node"
|
#define __class__ "io::Node"
|
||||||
|
|
||||||
|
|
||||||
audio::river::io::Node::Node(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) :
|
audio::river::io::Node::Node(const std::string& _name, const ejson::Object& _config) :
|
||||||
m_config(_config),
|
m_config(_config),
|
||||||
m_name(_name),
|
m_name(_name),
|
||||||
m_isInput(false) {
|
m_isInput(false) {
|
||||||
@ -34,7 +34,7 @@ audio::river::io::Node::Node(const std::string& _name, const std::shared_ptr<con
|
|||||||
# muxer/demuxer format type (int8-on-int16, int16-on-int32, int24-on-int32, int32-on-int64, float)
|
# muxer/demuxer format type (int8-on-int16, int16-on-int32, int24-on-int32, int32-on-int64, float)
|
||||||
mux-demux-type:"int16_on_int32",
|
mux-demux-type:"int16_on_int32",
|
||||||
*/
|
*/
|
||||||
std::string interfaceType = m_config->getStringValue("io");
|
std::string interfaceType = m_config.getStringValue("io");
|
||||||
RIVER_INFO("interfaceType=" << interfaceType);
|
RIVER_INFO("interfaceType=" << interfaceType);
|
||||||
if ( interfaceType == "input"
|
if ( interfaceType == "input"
|
||||||
|| interfaceType == "PAinput"
|
|| interfaceType == "PAinput"
|
||||||
@ -45,12 +45,12 @@ audio::river::io::Node::Node(const std::string& _name, const std::shared_ptr<con
|
|||||||
m_isInput = false;
|
m_isInput = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t frequency = m_config->getNumberValue("frequency", 1);
|
int32_t frequency = m_config.getNumberValue("frequency", 1);
|
||||||
// Get audio format type:
|
// Get audio format type:
|
||||||
std::string type = m_config->getStringValue("type", "int16");
|
std::string type = m_config.getStringValue("type", "int16");
|
||||||
enum audio::format formatType = audio::getFormatFromString(type);
|
enum audio::format formatType = audio::getFormatFromString(type);
|
||||||
// Get volume stage :
|
// Get volume stage :
|
||||||
std::string volumeName = m_config->getStringValue("volume-name", "");
|
std::string volumeName = m_config.getStringValue("volume-name", "");
|
||||||
if (volumeName != "") {
|
if (volumeName != "") {
|
||||||
RIVER_INFO("add node volume stage : '" << volumeName << "'");
|
RIVER_INFO("add node volume stage : '" << volumeName << "'");
|
||||||
// use global manager for volume ...
|
// use global manager for volume ...
|
||||||
@ -58,15 +58,15 @@ audio::river::io::Node::Node(const std::string& _name, const std::shared_ptr<con
|
|||||||
}
|
}
|
||||||
// Get map type :
|
// Get map type :
|
||||||
std::vector<audio::channel> map;
|
std::vector<audio::channel> map;
|
||||||
const std::shared_ptr<const ejson::Array> listChannelMap = m_config->getArray("channel-map");
|
const ejson::Array listChannelMap = m_config["channel-map"].toArray();
|
||||||
if ( listChannelMap == nullptr
|
if ( listChannelMap.exist() == false
|
||||||
|| listChannelMap->size() == 0) {
|
|| listChannelMap.size() == 0) {
|
||||||
// set default channel property:
|
// set default channel property:
|
||||||
map.push_back(audio::channel_frontLeft);
|
map.push_back(audio::channel_frontLeft);
|
||||||
map.push_back(audio::channel_frontRight);
|
map.push_back(audio::channel_frontRight);
|
||||||
} else {
|
} else {
|
||||||
for (size_t iii=0; iii<listChannelMap->size(); ++iii) {
|
for (auto it : listChannelMap) {
|
||||||
std::string value = listChannelMap->getStringValue(iii);
|
std::string value = it.toString().get();
|
||||||
map.push_back(audio::getChannelFromString(value));
|
map.push_back(audio::getChannelFromString(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,9 +75,9 @@ audio::river::io::Node::Node(const std::string& _name, const std::shared_ptr<con
|
|||||||
|
|
||||||
std::string muxerDemuxerConfig;
|
std::string muxerDemuxerConfig;
|
||||||
if (m_isInput == true) {
|
if (m_isInput == true) {
|
||||||
muxerDemuxerConfig = m_config->getStringValue("mux-demux-type", "int16");
|
muxerDemuxerConfig = m_config.getStringValue("mux-demux-type", "int16");
|
||||||
} else {
|
} else {
|
||||||
muxerDemuxerConfig = m_config->getStringValue("mux-demux-type", "int16-on-int32");
|
muxerDemuxerConfig = m_config.getStringValue("mux-demux-type", "int16-on-int32");
|
||||||
}
|
}
|
||||||
enum audio::format muxerFormatType = audio::getFormatFromString(muxerDemuxerConfig);
|
enum audio::format muxerFormatType = audio::getFormatFromString(muxerDemuxerConfig);
|
||||||
if (m_isInput == true) {
|
if (m_isInput == true) {
|
||||||
|
@ -39,7 +39,7 @@ namespace audio {
|
|||||||
* @param[in] _name Name of the node.
|
* @param[in] _name Name of the node.
|
||||||
* @param[in] _config Configuration of the node.
|
* @param[in] _config Configuration of the node.
|
||||||
*/
|
*/
|
||||||
Node(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
|
Node(const std::string& _name, const ejson::Object& _config);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
@ -55,7 +55,7 @@ namespace audio {
|
|||||||
};
|
};
|
||||||
protected:
|
protected:
|
||||||
mutable std::mutex m_mutex; //!< prevent open/close/write/read access that is multi-threaded.
|
mutable std::mutex m_mutex; //!< prevent open/close/write/read access that is multi-threaded.
|
||||||
std::shared_ptr<const ejson::Object> m_config; //!< configuration description.
|
const ejson::Object m_config; //!< configuration description.
|
||||||
protected:
|
protected:
|
||||||
audio::drain::Process m_process; //!< Low level algorithms
|
audio::drain::Process m_process; //!< Low level algorithms
|
||||||
public:
|
public:
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "io::NodeAEC"
|
#define __class__ "io::NodeAEC"
|
||||||
|
|
||||||
std::shared_ptr<audio::river::io::NodeAEC> audio::river::io::NodeAEC::create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) {
|
std::shared_ptr<audio::river::io::NodeAEC> audio::river::io::NodeAEC::create(const std::string& _name, const ejson::Object& _config) {
|
||||||
return std::shared_ptr<audio::river::io::NodeAEC>(new audio::river::io::NodeAEC(_name, _config));
|
return std::shared_ptr<audio::river::io::NodeAEC>(new audio::river::io::NodeAEC(_name, _config));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,16 +23,16 @@ std::shared_ptr<audio::river::Interface> audio::river::io::NodeAEC::createInput(
|
|||||||
const std::string& _objectName,
|
const std::string& _objectName,
|
||||||
const std::string& _name) {
|
const std::string& _name) {
|
||||||
// check if the output exist
|
// check if the output exist
|
||||||
const std::shared_ptr<const ejson::Object> tmppp = m_config->getObject(_objectName);
|
const ejson::Object tmppp = m_config[_objectName].toObject();
|
||||||
if (tmppp == nullptr) {
|
if (tmppp.exist() == false) {
|
||||||
RIVER_ERROR("can not open a non existance virtual interface: '" << _objectName << "' not present in : " << m_config->getKeys());
|
RIVER_ERROR("can not open a non existance virtual interface: '" << _objectName << "' not present in : " << m_config.getKeys());
|
||||||
return std::shared_ptr<audio::river::Interface>();
|
return std::shared_ptr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
std::string streamName = tmppp->getStringValue("map-on", "error");
|
std::string streamName = tmppp.getStringValue("map-on", "error");
|
||||||
|
|
||||||
m_nbChunk = m_config->getNumberValue("nb-chunk", 1024);
|
m_nbChunk = m_config.getNumberValue("nb-chunk", 1024);
|
||||||
// check if it is an Output:
|
// check if it is an Output:
|
||||||
std::string type = tmppp->getStringValue("io", "error");
|
std::string type = tmppp.getStringValue("io", "error");
|
||||||
if ( type != "input"
|
if ( type != "input"
|
||||||
&& type != "feedback") {
|
&& type != "feedback") {
|
||||||
RIVER_ERROR("can not open in output a virtual interface: '" << streamName << "' configured has : " << type);
|
RIVER_ERROR("can not open in output a virtual interface: '" << streamName << "' configured has : " << type);
|
||||||
@ -52,7 +52,7 @@ std::shared_ptr<audio::river::Interface> audio::river::io::NodeAEC::createInput(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
audio::river::io::NodeAEC::NodeAEC(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) :
|
audio::river::io::NodeAEC::NodeAEC(const std::string& _name, const ejson::Object& _config) :
|
||||||
Node(_name, _config),
|
Node(_name, _config),
|
||||||
m_P_attaqueTime(1),
|
m_P_attaqueTime(1),
|
||||||
m_P_releaseTime(100),
|
m_P_releaseTime(100),
|
||||||
|
@ -18,14 +18,14 @@ namespace audio {
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*/
|
*/
|
||||||
NodeAEC(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
|
NodeAEC(const std::string& _name, const ejson::Object& _config);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Factory of this Virtual Node.
|
* @brief Factory of this Virtual Node.
|
||||||
* @param[in] _name Name of the node.
|
* @param[in] _name Name of the node.
|
||||||
* @param[in] _config Configuration of the node.
|
* @param[in] _config Configuration of the node.
|
||||||
*/
|
*/
|
||||||
static std::shared_ptr<NodeAEC> create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
|
static std::shared_ptr<NodeAEC> create(const std::string& _name, const ejson::Object& _config);
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
|
@ -37,11 +37,11 @@ int32_t audio::river::io::NodeFile::playbackCallback(void* _outputBuffer,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<audio::river::io::NodeFile> audio::river::io::NodeFile::create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) {
|
std::shared_ptr<audio::river::io::NodeFile> audio::river::io::NodeFile::create(const std::string& _name, const ejson::Object& _config) {
|
||||||
return std::shared_ptr<audio::river::io::NodeFile>(new audio::river::io::NodeFile(_name, _config));
|
return std::shared_ptr<audio::river::io::NodeFile>(new audio::river::io::NodeFile(_name, _config));
|
||||||
}
|
}
|
||||||
|
|
||||||
audio::river::io::NodeFile::NodeFile(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) :
|
audio::river::io::NodeFile::NodeFile(const std::string& _name, const ejson::Object& _config) :
|
||||||
Node(_name, _config) {
|
Node(_name, _config) {
|
||||||
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
||||||
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
||||||
@ -54,23 +54,23 @@ audio::river::io::NodeFile::NodeFile(const std::string& _name, const std::shared
|
|||||||
*/
|
*/
|
||||||
std::string typeInterface = audio::orchestra::type_undefined;
|
std::string typeInterface = audio::orchestra::type_undefined;
|
||||||
std::string streamName = "default";
|
std::string streamName = "default";
|
||||||
const std::shared_ptr<const ejson::Object> tmpObject = m_config->getObject("map-on");
|
const ejson::Object tmpObject = m_config["map-on"].toObject();
|
||||||
if (tmpObject == nullptr) {
|
if (tmpObject.exist() == false) {
|
||||||
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
|
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
|
||||||
} else {
|
} else {
|
||||||
typeInterface = tmpObject->getStringValue("interface", audio::orchestra::type_undefined);
|
typeInterface = tmpObject.getStringValue("interface", audio::orchestra::type_undefined);
|
||||||
if (typeInterface == "auto") {
|
if (typeInterface == "auto") {
|
||||||
typeInterface = audio::orchestra::type_undefined;
|
typeInterface = audio::orchestra::type_undefined;
|
||||||
}
|
}
|
||||||
streamName = tmpObject->getStringValue("name", "default");
|
streamName = tmpObject.getStringValue("name", "default");
|
||||||
}
|
}
|
||||||
int32_t nbChunk = m_config->getNumberValue("nb-chunk", 1024);
|
int32_t nbChunk = m_config.getNumberValue("nb-chunk", 1024);
|
||||||
|
|
||||||
// intanciate specific API ...
|
// intanciate specific API ...
|
||||||
m_interface.instanciate(typeInterface);
|
m_interface.instanciate(typeInterface);
|
||||||
m_interface.setName(_name);
|
m_interface.setName(_name);
|
||||||
// TODO : Check return ...
|
// TODO : Check return ...
|
||||||
std::string type = m_config->getStringValue("type", "int16");
|
std::string type = m_config.getStringValue("type", "int16");
|
||||||
if (streamName == "") {
|
if (streamName == "") {
|
||||||
streamName = "default";
|
streamName = "default";
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ namespace audio {
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*/
|
*/
|
||||||
NodeFile(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
|
NodeFile(const std::string& _name, const ejson::Object& _config);
|
||||||
public:
|
public:
|
||||||
static std::shared_ptr<NodeFile> create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
|
static std::shared_ptr<NodeFile> create(const std::string& _name, const ejson::Object& _config);
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "io::NodeMuxer"
|
#define __class__ "io::NodeMuxer"
|
||||||
|
|
||||||
std::shared_ptr<audio::river::io::NodeMuxer> audio::river::io::NodeMuxer::create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) {
|
std::shared_ptr<audio::river::io::NodeMuxer> audio::river::io::NodeMuxer::create(const std::string& _name, const ejson::Object& _config) {
|
||||||
return std::shared_ptr<audio::river::io::NodeMuxer>(new audio::river::io::NodeMuxer(_name, _config));
|
return std::shared_ptr<audio::river::io::NodeMuxer>(new audio::river::io::NodeMuxer(_name, _config));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,16 +23,16 @@ std::shared_ptr<audio::river::Interface> audio::river::io::NodeMuxer::createInpu
|
|||||||
const std::string& _objectName,
|
const std::string& _objectName,
|
||||||
const std::string& _name) {
|
const std::string& _name) {
|
||||||
// check if the output exist
|
// check if the output exist
|
||||||
const std::shared_ptr<const ejson::Object> tmppp = m_config->getObject(_objectName);
|
const ejson::Object tmppp = m_config[_objectName].toObject();
|
||||||
if (tmppp == nullptr) {
|
if (tmppp.exist() == false) {
|
||||||
RIVER_ERROR("can not open a non existance virtual interface: '" << _objectName << "' not present in : " << m_config->getKeys());
|
RIVER_ERROR("can not open a non existance virtual interface: '" << _objectName << "' not present in : " << m_config.getKeys());
|
||||||
return std::shared_ptr<audio::river::Interface>();
|
return std::shared_ptr<audio::river::Interface>();
|
||||||
}
|
}
|
||||||
std::string streamName = tmppp->getStringValue("map-on", "error");
|
std::string streamName = tmppp.getStringValue("map-on", "error");
|
||||||
|
|
||||||
|
|
||||||
// check if it is an Output:
|
// check if it is an Output:
|
||||||
std::string type = tmppp->getStringValue("io", "error");
|
std::string type = tmppp.getStringValue("io", "error");
|
||||||
if ( type != "input"
|
if ( type != "input"
|
||||||
&& type != "feedback") {
|
&& type != "feedback") {
|
||||||
RIVER_ERROR("can not open in output a virtual interface: '" << streamName << "' configured has : " << type);
|
RIVER_ERROR("can not open in output a virtual interface: '" << streamName << "' configured has : " << type);
|
||||||
@ -52,7 +52,7 @@ std::shared_ptr<audio::river::Interface> audio::river::io::NodeMuxer::createInpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
audio::river::io::NodeMuxer::NodeMuxer(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) :
|
audio::river::io::NodeMuxer::NodeMuxer(const std::string& _name, const ejson::Object& _config) :
|
||||||
Node(_name, _config) {
|
Node(_name, _config) {
|
||||||
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
||||||
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
||||||
@ -88,14 +88,14 @@ audio::river::io::NodeMuxer::NodeMuxer(const std::string& _name, const std::shar
|
|||||||
RIVER_ERROR("Can not opne virtual device ... map-on-input-1 in " << _name);
|
RIVER_ERROR("Can not opne virtual device ... map-on-input-1 in " << _name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::shared_ptr<const ejson::Array> listChannelMap = m_config->getArray("input-1-remap");
|
const ejson::Array listChannelMap = m_config["input-1-remap"].toArray();
|
||||||
if ( listChannelMap == nullptr
|
if ( listChannelMap.exist() == false
|
||||||
|| listChannelMap->size() == 0) {
|
|| listChannelMap.size() == 0) {
|
||||||
m_mapInput1 = m_interfaceInput1->getInterfaceFormat().getMap();
|
m_mapInput1 = m_interfaceInput1->getInterfaceFormat().getMap();
|
||||||
} else {
|
} else {
|
||||||
m_mapInput1.clear();
|
m_mapInput1.clear();
|
||||||
for (size_t iii=0; iii<listChannelMap->size(); ++iii) {
|
for (const auto it : listChannelMap) {
|
||||||
std::string value = listChannelMap->getStringValue(iii);
|
std::string value = it.toString().get();
|
||||||
m_mapInput1.push_back(audio::getChannelFromString(value));
|
m_mapInput1.push_back(audio::getChannelFromString(value));
|
||||||
}
|
}
|
||||||
if (m_mapInput1.size() != m_interfaceInput1->getInterfaceFormat().getMap().size()) {
|
if (m_mapInput1.size() != m_interfaceInput1->getInterfaceFormat().getMap().size()) {
|
||||||
@ -114,14 +114,14 @@ audio::river::io::NodeMuxer::NodeMuxer(const std::string& _name, const std::shar
|
|||||||
RIVER_ERROR("Can not opne virtual device ... map-on-input-2 in " << _name);
|
RIVER_ERROR("Can not opne virtual device ... map-on-input-2 in " << _name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
listChannelMap = m_config->getArray("input-2-remap");
|
const ejson::Array listChannelMap2 = m_config["input-2-remap"].toArray();
|
||||||
if ( listChannelMap == nullptr
|
if ( listChannelMap2.exist() == false
|
||||||
|| listChannelMap->size() == 0) {
|
|| listChannelMap2.size() == 0) {
|
||||||
m_mapInput2 = m_interfaceInput2->getInterfaceFormat().getMap();
|
m_mapInput2 = m_interfaceInput2->getInterfaceFormat().getMap();
|
||||||
} else {
|
} else {
|
||||||
m_mapInput2.clear();
|
m_mapInput2.clear();
|
||||||
for (size_t iii=0; iii<listChannelMap->size(); ++iii) {
|
for (const auto it : listChannelMap2) {
|
||||||
std::string value = listChannelMap->getStringValue(iii);
|
std::string value = it.toString().get();
|
||||||
m_mapInput2.push_back(audio::getChannelFromString(value));
|
m_mapInput2.push_back(audio::getChannelFromString(value));
|
||||||
}
|
}
|
||||||
if (m_mapInput2.size() != m_interfaceInput2->getInterfaceFormat().getMap().size()) {
|
if (m_mapInput2.size() != m_interfaceInput2->getInterfaceFormat().getMap().size()) {
|
||||||
|
@ -18,9 +18,9 @@ namespace audio {
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*/
|
*/
|
||||||
NodeMuxer(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
|
NodeMuxer(const std::string& _name, const ejson::Object& _config);
|
||||||
public:
|
public:
|
||||||
static std::shared_ptr<NodeMuxer> create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
|
static std::shared_ptr<NodeMuxer> create(const std::string& _name, const ejson::Object& _config);
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
|
@ -37,11 +37,11 @@ int32_t audio::river::io::NodeOrchestra::playbackCallback(void* _outputBuffer,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<audio::river::io::NodeOrchestra> audio::river::io::NodeOrchestra::create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) {
|
std::shared_ptr<audio::river::io::NodeOrchestra> audio::river::io::NodeOrchestra::create(const std::string& _name, const ejson::Object& _config) {
|
||||||
return std::shared_ptr<audio::river::io::NodeOrchestra>(new audio::river::io::NodeOrchestra(_name, _config));
|
return std::shared_ptr<audio::river::io::NodeOrchestra>(new audio::river::io::NodeOrchestra(_name, _config));
|
||||||
}
|
}
|
||||||
|
|
||||||
audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) :
|
audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const ejson::Object& _config) :
|
||||||
Node(_name, _config) {
|
Node(_name, _config) {
|
||||||
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
||||||
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
||||||
@ -54,23 +54,23 @@ audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const s
|
|||||||
*/
|
*/
|
||||||
std::string typeInterface = audio::orchestra::type_undefined;
|
std::string typeInterface = audio::orchestra::type_undefined;
|
||||||
std::string streamName = "default";
|
std::string streamName = "default";
|
||||||
const std::shared_ptr<const ejson::Object> tmpObject = m_config->getObject("map-on");
|
const ejson::Object tmpObject = m_config["map-on"].toObject();
|
||||||
if (tmpObject == nullptr) {
|
if (tmpObject.exist() == false) {
|
||||||
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
|
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
|
||||||
} else {
|
} else {
|
||||||
typeInterface = tmpObject->getStringValue("interface", audio::orchestra::type_undefined);
|
typeInterface = tmpObject.getStringValue("interface", audio::orchestra::type_undefined);
|
||||||
if (typeInterface == "auto") {
|
if (typeInterface == "auto") {
|
||||||
typeInterface = audio::orchestra::type_undefined;
|
typeInterface = audio::orchestra::type_undefined;
|
||||||
}
|
}
|
||||||
streamName = tmpObject->getStringValue("name", "default");
|
streamName = tmpObject.getStringValue("name", "default");
|
||||||
}
|
}
|
||||||
int32_t nbChunk = m_config->getNumberValue("nb-chunk", 1024);
|
int32_t nbChunk = m_config.getNumberValue("nb-chunk", 1024);
|
||||||
|
|
||||||
// intanciate specific API ...
|
// intanciate specific API ...
|
||||||
m_interface.instanciate(typeInterface);
|
m_interface.instanciate(typeInterface);
|
||||||
m_interface.setName(_name);
|
m_interface.setName(_name);
|
||||||
// TODO : Check return ...
|
// TODO : Check return ...
|
||||||
std::string type = m_config->getStringValue("type", "int16");
|
std::string type = m_config.getStringValue("type", "int16");
|
||||||
if (streamName == "") {
|
if (streamName == "") {
|
||||||
streamName = "default";
|
streamName = "default";
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const s
|
|||||||
RIVER_CRITICAL("Can not open hardware device with more channel (" << params.nChannels << ") that is autorized by hardware (" << m_info.channels.size() << ").");
|
RIVER_CRITICAL("Can not open hardware device with more channel (" << params.nChannels << ") that is autorized by hardware (" << m_info.channels.size() << ").");
|
||||||
}
|
}
|
||||||
audio::orchestra::StreamOptions option;
|
audio::orchestra::StreamOptions option;
|
||||||
etk::from_string(option.mode, tmpObject->getStringValue("timestamp-mode", "soft"));
|
etk::from_string(option.mode, tmpObject.getStringValue("timestamp-mode", "soft"));
|
||||||
|
|
||||||
RIVER_DEBUG("interfaceFormat=" << interfaceFormat);
|
RIVER_DEBUG("interfaceFormat=" << interfaceFormat);
|
||||||
RIVER_DEBUG("hardwareFormat=" << hardwareFormat);
|
RIVER_DEBUG("hardwareFormat=" << hardwareFormat);
|
||||||
|
@ -24,9 +24,9 @@ namespace audio {
|
|||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*/
|
*/
|
||||||
NodeOrchestra(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
|
NodeOrchestra(const std::string& _name, const ejson::Object& _config);
|
||||||
public:
|
public:
|
||||||
static std::shared_ptr<NodeOrchestra> create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
|
static std::shared_ptr<NodeOrchestra> create(const std::string& _name, const ejson::Object& _config);
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
|
@ -56,11 +56,11 @@ int32_t audio::river::io::NodePortAudio::duplexCallback(const void* _inputBuffer
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<audio::river::io::NodePortAudio> audio::river::io::NodePortAudio::create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) {
|
std::shared_ptr<audio::river::io::NodePortAudio> audio::river::io::NodePortAudio::create(const std::string& _name, const ejson::Object& _config) {
|
||||||
return std::shared_ptr<audio::river::io::NodePortAudio>(new audio::river::io::NodePortAudio(_name, _config));
|
return std::shared_ptr<audio::river::io::NodePortAudio>(new audio::river::io::NodePortAudio(_name, _config));
|
||||||
}
|
}
|
||||||
|
|
||||||
audio::river::io::NodePortAudio::NodePortAudio(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) :
|
audio::river::io::NodePortAudio::NodePortAudio(const std::string& _name, const ejson::Object& _config) :
|
||||||
Node(_name, _config) {
|
Node(_name, _config) {
|
||||||
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
|
||||||
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
|
||||||
@ -72,14 +72,14 @@ audio::river::io::NodePortAudio::NodePortAudio(const std::string& _name, const s
|
|||||||
nb-chunk:1024 # number of chunk to open device (create the latency anf the frequency to call user)
|
nb-chunk:1024 # number of chunk to open device (create the latency anf the frequency to call user)
|
||||||
*/
|
*/
|
||||||
std::string streamName = "default";
|
std::string streamName = "default";
|
||||||
const std::shared_ptr<const ejson::Object> tmpObject = m_config->getObject("map-on");
|
const ejson::Object tmpObject = m_config["map-on"].toObject();
|
||||||
if (tmpObject == nullptr) {
|
if (tmpObject.exist() == false) {
|
||||||
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
|
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
|
||||||
} else {
|
} else {
|
||||||
std::string value = tmpObject->getStringValue("interface", "default");
|
std::string value = tmpObject.getStringValue("interface", "default");
|
||||||
streamName = tmpObject->getStringValue("name", "default");
|
streamName = tmpObject.getStringValue("name", "default");
|
||||||
}
|
}
|
||||||
int32_t nbChunk = m_config->getNumberValue("nb-chunk", 1024);
|
int32_t nbChunk = m_config.getNumberValue("nb-chunk", 1024);
|
||||||
|
|
||||||
PaError err = 0;
|
PaError err = 0;
|
||||||
if (m_isInput == true) {
|
if (m_isInput == true) {
|
||||||
|
@ -15,15 +15,15 @@ namespace audio {
|
|||||||
namespace river {
|
namespace river {
|
||||||
namespace io {
|
namespace io {
|
||||||
class Manager;
|
class Manager;
|
||||||
//! @not-in-doc
|
//! @not_in_doc
|
||||||
class NodePortAudio : public Node {
|
class NodePortAudio : public Node {
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*/
|
*/
|
||||||
NodePortAudio(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
|
NodePortAudio(const std::string& _name, const ejson::Object& _config);
|
||||||
public:
|
public:
|
||||||
static std::shared_ptr<NodePortAudio> create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
|
static std::shared_ptr<NodePortAudio> create(const std::string& _name, const ejson::Object& _config);
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
|
@ -16,36 +16,41 @@ static const std::string configurationRiver =
|
|||||||
" speaker:{\n"
|
" speaker:{\n"
|
||||||
" io:'output',\n"
|
" io:'output',\n"
|
||||||
" map-on:{\n"
|
" map-on:{\n"
|
||||||
" interface:'auto',\n"
|
" interface:'alsa',\n"
|
||||||
" name:'default',\n"
|
" name:'hw:2,0',\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
" frequency:0,\n"
|
" frequency:0,\n"
|
||||||
|
//" channel-map:['front-left', 'front-right', 'rear-left', 'rear-right'],\n"
|
||||||
" channel-map:['front-left', 'front-right'],\n"
|
" channel-map:['front-left', 'front-right'],\n"
|
||||||
" type:'auto',\n"
|
" type:'int32',\n"
|
||||||
" nb-chunk:1024,\n"
|
" nb-chunk:1024,\n"
|
||||||
" volume-name:'MASTER'\n"
|
" volume-name:'MASTER'\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
|
static const int32_t nbChannelMax=8;
|
||||||
|
|
||||||
void onDataNeeded(void* _data,
|
void onDataNeeded(void* _data,
|
||||||
const audio::Time& _time,
|
const audio::Time& _time,
|
||||||
size_t _nbChunk,
|
size_t _nbChunk,
|
||||||
enum audio::format _format,
|
enum audio::format _format,
|
||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map) {
|
const std::vector<audio::channel>& _map) {
|
||||||
static double phase = 0;
|
static double phase[8] = {0,0,0,0,0,0,0,0};
|
||||||
|
|
||||||
if (_format != audio::format_int16) {
|
if (_format != audio::format_int16) {
|
||||||
std::cout << "[ERROR] call wrong type ... (need int16_t)" << std::endl;
|
std::cout << "[ERROR] call wrong type ... (need int16_t)" << std::endl;
|
||||||
}
|
}
|
||||||
|
//std::cout << "Map " << _map << std::endl;
|
||||||
int16_t* data = static_cast<int16_t*>(_data);
|
int16_t* data = static_cast<int16_t*>(_data);
|
||||||
double baseCycle = 2.0*M_PI/(double)48000 * (double)550;
|
double baseCycle = 2.0*M_PI/double(48000) * double(440);
|
||||||
for (int32_t iii=0; iii<_nbChunk; iii++) {
|
for (int32_t iii=0; iii<_nbChunk; iii++) {
|
||||||
for (int32_t jjj=0; jjj<_map.size(); jjj++) {
|
for (int32_t jjj=0; jjj<_map.size(); jjj++) {
|
||||||
data[_map.size()*iii+jjj] = cos(phase) * 30000;
|
data[_map.size()*iii+jjj] = cos(phase[jjj]) * 30000;
|
||||||
|
phase[jjj] += baseCycle*jjj;
|
||||||
|
if (phase[jjj] >= 2*M_PI) {
|
||||||
|
phase[jjj] -= 2*M_PI;
|
||||||
}
|
}
|
||||||
phase += baseCycle;
|
|
||||||
if (phase >= 2*M_PI) {
|
|
||||||
phase -= 2*M_PI;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user