[DEV] basic volume group work corectly
This commit is contained in:
@@ -53,7 +53,7 @@ std::shared_ptr<airtalgo::VolumeElement> airtio::io::Manager::getVolumeGroup(con
|
||||
continue;
|
||||
}
|
||||
if (it->getName() == _name) {
|
||||
return nullptr;
|
||||
return it;
|
||||
}
|
||||
}
|
||||
AIRTIO_DEBUG("Add a new volume group : '" << _name << "'");
|
||||
@@ -62,69 +62,32 @@ std::shared_ptr<airtalgo::VolumeElement> airtio::io::Manager::getVolumeGroup(con
|
||||
return tmpVolume;
|
||||
}
|
||||
|
||||
|
||||
bool airtio::io::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 ( _flow == ""
|
||||
&& _filter == "volume") {
|
||||
// set IO volume
|
||||
float value = 0;
|
||||
if (sscanf(_value.c_str(), "%fdB", &value) != 1) {
|
||||
AIRTIO_ERROR("Can not parse the value of audio volume : '" << _value << "'");
|
||||
return false;
|
||||
}
|
||||
for (auto &it : m_volumeGroup) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (it->getName() == _parameter) {
|
||||
it->setVolume(value);
|
||||
for (auto &it2 : m_list) {
|
||||
std::shared_ptr<airtio::io::Node> val = it2.lock();
|
||||
if (val != nullptr) {
|
||||
// TODO : notify nodes ...
|
||||
// val->
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool airtio::io::Manager::setVolume(const std::string& _volumeName, float _valuedB) {
|
||||
std::shared_ptr<airtalgo::VolumeElement> volume = getVolumeGroup(_volumeName);
|
||||
if (volume == nullptr) {
|
||||
AIRTIO_ERROR("Can not get volume ... : '" << _volumeName << "'");
|
||||
return false;
|
||||
}
|
||||
// TODO : Check range ...
|
||||
volume->setVolume(_valuedB);
|
||||
for (auto &it2 : m_list) {
|
||||
std::shared_ptr<airtio::io::Node> val = it2.lock();
|
||||
if (val != nullptr) {
|
||||
val->volumeChange();
|
||||
}
|
||||
}
|
||||
AIRTIO_TODO(" IMPLEMENT");
|
||||
AIRTIO_DEBUG("setParameter [ END ] : '" << out << "'");
|
||||
return out;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string airtio::io::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;
|
||||
if ( _flow == ""
|
||||
&& _filter == "volume") {
|
||||
// get IO volume
|
||||
for (auto &it : m_volumeGroup) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (it->getName() == _parameter) {
|
||||
return std::to_string(it->getVolume()) + "dB";;
|
||||
}
|
||||
}
|
||||
float airtio::io::Manager::getVolume(const std::string& _volumeName) {
|
||||
std::shared_ptr<airtalgo::VolumeElement> volume = getVolumeGroup(_volumeName);
|
||||
if (volume == nullptr) {
|
||||
AIRTIO_ERROR("Can not get volume ... : '" << _volumeName << "'");
|
||||
return 0.0f;
|
||||
}
|
||||
AIRTIO_TODO(" IMPLEMENT");
|
||||
AIRTIO_DEBUG("getParameter [ END ] : '" << out << "'");
|
||||
return out;
|
||||
return volume->getVolume();
|
||||
}
|
||||
|
||||
std::string airtio::io::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;
|
||||
if ( _flow == ""
|
||||
&& _filter == "volume") {
|
||||
// return generic volumes
|
||||
return "[-300..300]dB";
|
||||
}
|
||||
AIRTIO_TODO(" IMPLEMENT");
|
||||
AIRTIO_DEBUG("getParameterProperty [ END ] : '" << out << "'");
|
||||
return out;
|
||||
std::pair<float,float> airtio::io::Manager::getVolumeRange(const std::string& _volumeName) const {
|
||||
return std::make_pair<float,float>(-300, 300);
|
||||
}
|
||||
|
@@ -44,39 +44,30 @@ namespace airtio {
|
||||
std::vector<std::shared_ptr<airtalgo::VolumeElement>> m_volumeGroup;
|
||||
public:
|
||||
std::shared_ptr<airtalgo::VolumeElement> getVolumeGroup(const std::string& _name);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set a parameter in the stream flow
|
||||
* @param[in] _flow Low level Flow name (see json config file)
|
||||
* @param[in] _filter name of the filter (if you added some personels)
|
||||
* @param[in] _parameter Parameter name.
|
||||
* @param[in] _value Value to set.
|
||||
* @brief Set a volume for a specific group
|
||||
* @param[in] _volumeName Name of the volume (MASTER, MATER_BT ...)
|
||||
* @param[in] _value Volume in dB to set.
|
||||
* @return true set done
|
||||
* @return false An error occured
|
||||
* @example : setParameter("", "volume", "MASTER", "-3dB");
|
||||
* @example : setParameter("microphone", "LowPassFilter", "cutFrequency", "1000Hz");
|
||||
* @example : setVolume("MASTER", -3.0f);
|
||||
*/
|
||||
virtual bool setParameter(const std::string& _flow, const std::string& _filter, const std::string& _parameter, const std::string& _value);
|
||||
virtual bool setVolume(const std::string& _volumeName, float _valuedB);
|
||||
/**
|
||||
* @brief Get a volume value
|
||||
* @param[in] _volumeName Name of the volume (MASTER, MATER_BT ...)
|
||||
* @return The Volume value in dB.
|
||||
* @example ret = getVolume("MASTER"); can return something like ret = -3.0f
|
||||
*/
|
||||
virtual float getVolume(const std::string& _volumeName);
|
||||
/**
|
||||
* @brief Get a parameter value
|
||||
* @param[in] _flow Low level Flow name (see json config file)
|
||||
* @param[in] _filter name of the filter (if you added some personels)
|
||||
* @param[in] _parameter Parameter name.
|
||||
* @return The requested value.
|
||||
* @example : getParameter("", "volume", "MASTER"); can return something like "-3dB"
|
||||
* @example : getParameter("microphone", "LowPassFilter", "cutFrequency"); can return something like "[-120..0]dB"
|
||||
* @param[in] _volumeName Name of the volume (MASTER, MATER_BT ...)
|
||||
* @return The requested value Range.
|
||||
* @example ret = getVolumeRange("MASTER"); can return something like ret=(-120.0f,0.0f)
|
||||
*/
|
||||
virtual std::string getParameter(const std::string& _flow, const std::string& _filter, const std::string& _parameter) const;
|
||||
/**
|
||||
* @brief Get a parameter value
|
||||
* @param[in] _flow Low level Flow name (see json config file)
|
||||
* @param[in] _filter name of the filter (if you added some personels)
|
||||
* @param[in] _parameter Parameter name.
|
||||
* @return The requested value.
|
||||
* @example : getParameter("", "volume", "MASTER"); can return something like "[-120..0]dB"
|
||||
* @example : getParameter("microphone", "LowPassFilter", "cutFreqiency"); can return something like "]100..10000]Hz"
|
||||
*/
|
||||
virtual std::string getParameterProperty(const std::string& _flow, const std::string& _filter, const std::string& _parameter) const;
|
||||
virtual std::pair<float,float> getVolumeRange(const std::string& _volumeName) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -311,6 +311,17 @@ void airtio::io::Node::stop() {
|
||||
}
|
||||
}
|
||||
|
||||
void airtio::io::Node::registerAsRemote(const std::shared_ptr<airtio::Interface>& _interface) {
|
||||
auto it = m_listAvaillable.begin();
|
||||
while (it != m_listAvaillable.end()) {
|
||||
if (it->expired() == true) {
|
||||
it = m_listAvaillable.erase(it);
|
||||
}
|
||||
++it;
|
||||
}
|
||||
m_listAvaillable.push_back(_interface);
|
||||
}
|
||||
|
||||
void airtio::io::Node::interfaceAdd(const std::shared_ptr<airtio::Interface>& _interface) {
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
@@ -344,3 +355,12 @@ void airtio::io::Node::interfaceRemove(const std::shared_ptr<airtio::Interface>&
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void airtio::io::Node::volumeChange() {
|
||||
for (auto &it : m_listAvaillable) {
|
||||
std::shared_ptr<airtio::Interface> node = it.lock();
|
||||
if (node != nullptr) {
|
||||
node->systemVolumeChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -42,8 +42,10 @@ namespace airtio {
|
||||
*/
|
||||
virtual ~Node();
|
||||
private:
|
||||
std::vector<std::weak_ptr<airtio::Interface> > m_listAvaillable; //!< List of all interface that exist on this Node
|
||||
std::vector<std::shared_ptr<airtio::Interface> > m_list;
|
||||
public:
|
||||
void registerAsRemote(const std::shared_ptr<airtio::Interface>& _interface);
|
||||
void interfaceAdd(const std::shared_ptr<airtio::Interface>& _interface);
|
||||
void interfaceRemove(const std::shared_ptr<airtio::Interface>& _interface);
|
||||
private:
|
||||
@@ -86,6 +88,8 @@ namespace airtio {
|
||||
const std::shared_ptr<airtalgo::VolumeElement>& getVolume() {
|
||||
return m_volume;
|
||||
}
|
||||
public:
|
||||
void volumeChange();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user