[DEV] update new time mode
This commit is contained in:
parent
d3e2aa1d43
commit
3f1ac849a8
@ -30,13 +30,15 @@ bool river::Interface::init(const std::string& _name,
|
|||||||
float _freq,
|
float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::shared_ptr<river::io::Node>& _node) {
|
const std::shared_ptr<river::io::Node>& _node,
|
||||||
|
bool _isInput) {
|
||||||
m_name = _name;
|
m_name = _name;
|
||||||
m_node = _node;
|
m_node = _node;
|
||||||
m_freq = _freq;
|
m_freq = _freq;
|
||||||
m_map = _map;
|
m_map = _map;
|
||||||
m_format = _format;
|
m_format = _format;
|
||||||
m_volume = 0.0f;
|
m_volume = 0.0f;
|
||||||
|
m_isInput = _isInput;
|
||||||
// register interface to be notify from the volume change.
|
// register interface to be notify from the volume change.
|
||||||
m_node->registerAsRemote(shared_from_this());
|
m_node->registerAsRemote(shared_from_this());
|
||||||
// Create convertion interface
|
// Create convertion interface
|
||||||
@ -76,9 +78,10 @@ std::shared_ptr<river::Interface> river::Interface::create(const std::string& _n
|
|||||||
float _freq,
|
float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::shared_ptr<river::io::Node>& _node) {
|
const std::shared_ptr<river::io::Node>& _node,
|
||||||
|
bool _isInput) {
|
||||||
std::shared_ptr<river::Interface> out = std::shared_ptr<river::Interface>(new river::Interface());
|
std::shared_ptr<river::Interface> out = std::shared_ptr<river::Interface>(new river::Interface());
|
||||||
out->init(_name, _freq, _map, _format, _node);
|
out->init(_name, _freq, _map, _format, _node, _isInput);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,15 @@ namespace river {
|
|||||||
virtual std::string getName() {
|
virtual std::string getName() {
|
||||||
return m_name;
|
return m_name;
|
||||||
};
|
};
|
||||||
|
protected:
|
||||||
|
bool m_isInput;
|
||||||
|
public:
|
||||||
|
bool isInput() {
|
||||||
|
return m_isInput;
|
||||||
|
}
|
||||||
|
bool isOutput() {
|
||||||
|
return !m_isInput;
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
@ -50,7 +59,8 @@ namespace river {
|
|||||||
float _freq,
|
float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::shared_ptr<river::io::Node>& _node);
|
const std::shared_ptr<river::io::Node>& _node,
|
||||||
|
bool _isInput);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
@ -60,7 +70,8 @@ namespace river {
|
|||||||
float _freq,
|
float _freq,
|
||||||
const std::vector<audio::channel>& _map,
|
const std::vector<audio::channel>& _map,
|
||||||
audio::format _format,
|
audio::format _format,
|
||||||
const std::shared_ptr<river::io::Node>& _node);
|
const std::shared_ptr<river::io::Node>& _node,
|
||||||
|
bool _isInput);
|
||||||
/**
|
/**
|
||||||
* @brief set the read/write mode enable.
|
* @brief set the read/write mode enable.
|
||||||
*/
|
*/
|
||||||
|
@ -64,10 +64,10 @@ std::shared_ptr<river::Interface> river::Manager::createOutput(float _freq,
|
|||||||
// get global hardware interface:
|
// get global hardware interface:
|
||||||
std::shared_ptr<river::io::Manager> manager = river::io::Manager::getInstance();
|
std::shared_ptr<river::io::Manager> manager = river::io::Manager::getInstance();
|
||||||
// get the output or input channel :
|
// get the output or input channel :
|
||||||
std::shared_ptr<river::io::Node> node = manager->getNode(_streamName);//, false);
|
std::shared_ptr<river::io::Node> node = manager->getNode(_streamName);
|
||||||
// create user iterface:
|
// create user iterface:
|
||||||
std::shared_ptr<river::Interface> interface;
|
std::shared_ptr<river::Interface> interface;
|
||||||
interface = river::Interface::create(_name, _freq, _map, _format, node);
|
interface = river::Interface::create(_name, _freq, _map, _format, node, false);
|
||||||
// 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);
|
||||||
return interface;
|
return interface;
|
||||||
@ -81,10 +81,10 @@ std::shared_ptr<river::Interface> river::Manager::createInput(float _freq,
|
|||||||
// get global hardware interface:
|
// get global hardware interface:
|
||||||
std::shared_ptr<river::io::Manager> manager = river::io::Manager::getInstance();
|
std::shared_ptr<river::io::Manager> manager = river::io::Manager::getInstance();
|
||||||
// get the output or input channel :
|
// get the output or input channel :
|
||||||
std::shared_ptr<river::io::Node> node = manager->getNode(_streamName);//, true);
|
std::shared_ptr<river::io::Node> node = manager->getNode(_streamName);
|
||||||
// create user iterface:
|
// create user iterface:
|
||||||
std::shared_ptr<river::Interface> interface;
|
std::shared_ptr<river::Interface> interface;
|
||||||
interface = river::Interface::create(_name, _freq, _map, _format, node);
|
interface = river::Interface::create(_name, _freq, _map, _format, node, true);
|
||||||
// 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);
|
||||||
return interface;
|
return interface;
|
||||||
|
@ -25,36 +25,58 @@
|
|||||||
#define INT32_MIN (-INT32_MAX - 1L)
|
#define INT32_MIN (-INT32_MAX - 1L)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t river::io::Node::rtAudioCallback(void* _outputBuffer,
|
std::string asString(const std::chrono::system_clock::time_point& tp) {
|
||||||
|
// convert to system time:
|
||||||
|
std::time_t t = std::chrono::system_clock::to_time_t(tp);
|
||||||
|
// convert in human string
|
||||||
|
std::string ts = std::ctime(&t);
|
||||||
|
// remove \n
|
||||||
|
ts.resize(ts.size()-1);
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
std::ostream& operator <<(std::ostream& _os, const std::chrono::system_clock::time_point& _obj) {
|
||||||
|
std::chrono::microseconds us = std::chrono::duration_cast<std::chrono::microseconds>(_obj.time_since_epoch());
|
||||||
|
_os << us.count();
|
||||||
|
return _os;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t river::io::Node::airtAudioCallback(void* _outputBuffer,
|
||||||
void* _inputBuffer,
|
void* _inputBuffer,
|
||||||
unsigned int _nBufferFrames,
|
uint32_t _nbChunk,
|
||||||
double _streamTime,
|
const std::chrono::system_clock::time_point& _time,
|
||||||
airtaudio::status _status) {
|
airtaudio::status _status) {
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
std::chrono::system_clock::time_point ttime = std::chrono::system_clock::time_point();//std::chrono::system_clock::now();
|
//RIVER_INFO("Time=" << _time);
|
||||||
/*
|
/*
|
||||||
for (int32_t iii=0; iii<400; ++iii) {
|
for (int32_t iii=0; iii<400; ++iii) {
|
||||||
RIVER_VERBOSE("dummy=" << uint64_t(dummy[iii]));
|
RIVER_VERBOSE("dummy=" << uint64_t(dummy[iii]));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (_outputBuffer != nullptr) {
|
if (_outputBuffer != nullptr) {
|
||||||
RIVER_VERBOSE("data Output size request :" << _nBufferFrames << " [BEGIN] status=" << _status);
|
RIVER_VERBOSE("data Output size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size());
|
||||||
std::vector<int32_t> output;
|
std::vector<int32_t> output;
|
||||||
RIVER_VERBOSE("resize=" << _nBufferFrames*m_process.getInputConfig().getMap().size());
|
RIVER_VERBOSE("resize=" << _nbChunk*m_process.getInputConfig().getMap().size());
|
||||||
output.resize(_nBufferFrames*m_process.getInputConfig().getMap().size(), 0);
|
output.resize(_nbChunk*m_process.getInputConfig().getMap().size(), 0);
|
||||||
const int32_t* outputTmp = nullptr;
|
const int32_t* outputTmp = nullptr;
|
||||||
std::vector<uint8_t> outputTmp2;
|
std::vector<uint8_t> outputTmp2;
|
||||||
RIVER_VERBOSE("resize=" << sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nBufferFrames);
|
RIVER_VERBOSE("resize=" << sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nbChunk);
|
||||||
outputTmp2.resize(sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nBufferFrames, 0);
|
outputTmp2.resize(sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nbChunk, 0);
|
||||||
int32_t id = 1;
|
|
||||||
for (auto &it : m_list) {
|
for (auto &it : m_list) {
|
||||||
RIVER_VERBOSE(" IO : " << id << "/" << m_list.size() << " pointer : " << uint64_t(&(*it)));
|
if (it == nullptr) {
|
||||||
if (it != nullptr) {
|
continue;
|
||||||
RIVER_VERBOSE(" name="<< it->getName());
|
}
|
||||||
|
if (it->isOutput() == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
RIVER_VERBOSE(" IO name="<< it->getName());
|
||||||
// clear datas ...
|
// clear datas ...
|
||||||
memset(&outputTmp2[0], 0, sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nBufferFrames);
|
memset(&outputTmp2[0], 0, sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nbChunk);
|
||||||
RIVER_VERBOSE(" request Data="<< _nBufferFrames);
|
RIVER_VERBOSE(" request Data="<< _nbChunk);
|
||||||
it->systemNeedOutputData(ttime, &outputTmp2[0], _nBufferFrames, sizeof(int32_t)*m_process.getInputConfig().getMap().size());
|
it->systemNeedOutputData(_time, &outputTmp2[0], _nbChunk, sizeof(int32_t)*m_process.getInputConfig().getMap().size());
|
||||||
RIVER_VERBOSE(" Mix it ...");
|
RIVER_VERBOSE(" Mix it ...");
|
||||||
outputTmp = reinterpret_cast<const int32_t*>(&outputTmp2[0]);
|
outputTmp = reinterpret_cast<const int32_t*>(&outputTmp2[0]);
|
||||||
// Add data to the output tmp buffer :
|
// Add data to the output tmp buffer :
|
||||||
@ -62,23 +84,32 @@ int32_t river::io::Node::rtAudioCallback(void* _outputBuffer,
|
|||||||
output[kkk] += outputTmp[kkk];
|
output[kkk] += outputTmp[kkk];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++id;
|
|
||||||
}
|
|
||||||
RIVER_VERBOSE(" End stack process data ...");
|
RIVER_VERBOSE(" End stack process data ...");
|
||||||
m_process.processIn(&outputTmp2[0], _nBufferFrames, _outputBuffer, _nBufferFrames);
|
m_process.processIn(&outputTmp2[0], _nbChunk, _outputBuffer, _nbChunk);
|
||||||
// TODO : Call feedback ...
|
RIVER_VERBOSE(" Feedback :");
|
||||||
RIVER_VERBOSE("data Output size request :" << _nBufferFrames << " [ END ]");
|
for (auto &it : m_list) {
|
||||||
|
if (it == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (it->isInput() == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
RIVER_VERBOSE(" IO name="<< it->getName() << " (feedback)");
|
||||||
|
it->systemNewInputData(_time, _outputBuffer, _nbChunk);
|
||||||
|
}
|
||||||
|
RIVER_VERBOSE("data Output size request :" << _nbChunk << " [ END ]");
|
||||||
}
|
}
|
||||||
if (_inputBuffer != nullptr) {
|
if (_inputBuffer != nullptr) {
|
||||||
RIVER_VERBOSE("data Input size request :" << _nBufferFrames << " [BEGIN]");
|
RIVER_VERBOSE("data Input size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size());
|
||||||
int16_t* inputBuffer = static_cast<int16_t *>(_inputBuffer);
|
int16_t* inputBuffer = static_cast<int16_t *>(_inputBuffer);
|
||||||
for (size_t iii=0; iii< m_list.size(); ++iii) {
|
for (auto &it : m_list) {
|
||||||
if (m_list[iii] != nullptr) {
|
if (it == nullptr) {
|
||||||
RIVER_INFO(" IO : " << iii+1 << "/" << m_list.size() << " name="<< m_list[iii]->getName());
|
continue;
|
||||||
m_list[iii]->systemNewInputData(ttime, inputBuffer, _nBufferFrames);
|
|
||||||
}
|
}
|
||||||
|
RIVER_INFO(" IO name="<< it->getName());
|
||||||
|
it->systemNewInputData(_time, inputBuffer, _nbChunk);
|
||||||
}
|
}
|
||||||
RIVER_VERBOSE("data Input size request :" << _nBufferFrames << " [ END ]");
|
RIVER_VERBOSE("data Input size request :" << _nbChunk << " [ END ]");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -215,7 +246,7 @@ river::io::Node::Node(const std::string& _name, const std::shared_ptr<const ejso
|
|||||||
if (m_isInput == true) {
|
if (m_isInput == true) {
|
||||||
err = m_adac.openStream(nullptr, ¶ms,
|
err = m_adac.openStream(nullptr, ¶ms,
|
||||||
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
|
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
|
||||||
std::bind(&river::io::Node::rtAudioCallback,
|
std::bind(&river::io::Node::airtAudioCallback,
|
||||||
this,
|
this,
|
||||||
std::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std::placeholders::_2,
|
std::placeholders::_2,
|
||||||
@ -226,7 +257,7 @@ river::io::Node::Node(const std::string& _name, const std::shared_ptr<const ejso
|
|||||||
} else {
|
} else {
|
||||||
err = m_adac.openStream(¶ms, nullptr,
|
err = m_adac.openStream(¶ms, nullptr,
|
||||||
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
|
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
|
||||||
std::bind(&river::io::Node::rtAudioCallback,
|
std::bind(&river::io::Node::airtAudioCallback,
|
||||||
this,
|
this,
|
||||||
std::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std::placeholders::_2,
|
std::placeholders::_2,
|
||||||
|
@ -53,10 +53,10 @@ namespace river {
|
|||||||
airtaudio::DeviceInfo m_info;
|
airtaudio::DeviceInfo m_info;
|
||||||
unsigned int m_rtaudioFrameSize;
|
unsigned int m_rtaudioFrameSize;
|
||||||
public:
|
public:
|
||||||
int32_t rtAudioCallback(void* _outputBuffer,
|
int32_t airtAudioCallback(void* _outputBuffer,
|
||||||
void * _inputBuffer,
|
void * _inputBuffer,
|
||||||
unsigned int _nBufferFrames,
|
uint32_t _nbChunk,
|
||||||
double _streamTime,
|
const std::chrono::system_clock::time_point& _time,
|
||||||
airtaudio::status _status);
|
airtaudio::status _status);
|
||||||
private:
|
private:
|
||||||
std::string m_name; //!< Harware.json configuration name
|
std::string m_name; //!< Harware.json configuration name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user