[DEV] remove format and channel description

This commit is contained in:
Edouard DUPIN 2015-02-04 22:39:05 +01:00
parent 8396ae4496
commit 8f29bd608b
19 changed files with 218 additions and 401 deletions

View File

@ -39,17 +39,24 @@ void airtalgo::Algo::configurationChange() {
m_needProcess = true;
}
switch (m_output.getFormat()) {
case format_int16:
case audio::format_int8:
m_formatSize = sizeof(int8_t);
break;
case audio::format_int16:
m_formatSize = sizeof(int16_t);
break;
case format_int16_on_int32:
case format_int32:
case audio::format_int24:
case audio::format_int16_on_int32:
case audio::format_int32:
m_formatSize = sizeof(int32_t);
break;
case format_float:
case audio::format_float:
m_formatSize = sizeof(float);
break;
case format_unknow:
case audio::format_double:
m_formatSize = sizeof(double);
break;
case audio::format_unknow:
AIRTALGO_ERROR("format not configured...");
m_formatSize = 8;
break;

View File

@ -11,8 +11,8 @@
#include <string>
#include <vector>
#include <stdint.h>
#include <airtalgo/format.h>
#include <airtalgo/channel.h>
#include <audio/format.h>
#include <audio/channel.h>
#include <chrono>
#include <functional>
#include <memory>
@ -122,38 +122,38 @@ namespace airtalgo{
*/
virtual size_t needInputData(size_t _output);
protected: // note when nothing ==> support all type
std::vector<airtalgo::format> m_supportedFormat;
std::vector<audio::format> m_supportedFormat;
public:
virtual std::vector<airtalgo::format> getFormatSupportedInput() {
virtual std::vector<audio::format> getFormatSupportedInput() {
if (m_output.getConfigured() == true) {
std::vector<airtalgo::format> out;
std::vector<audio::format> out;
out.push_back(m_output.getFormat());
return out;
}
return m_supportedFormat;
};
virtual std::vector<airtalgo::format> getFormatSupportedOutput() {
virtual std::vector<audio::format> getFormatSupportedOutput() {
if (m_input.getConfigured() == true) {
std::vector<airtalgo::format> out;
std::vector<audio::format> out;
out.push_back(m_input.getFormat());
return out;
}
return m_supportedFormat;
};
protected: // note when nothing ==> support all type
std::vector<std::vector<airtalgo::channel>> m_supportedMap;
std::vector<std::vector<audio::channel>> m_supportedMap;
public:
virtual std::vector<std::vector<airtalgo::channel>> getMapSupportedInput() {
virtual std::vector<std::vector<audio::channel>> getMapSupportedInput() {
if (m_output.getConfigured() == true) {
std::vector<std::vector<airtalgo::channel>> out;
std::vector<std::vector<audio::channel>> out;
out.push_back(m_output.getMap());
return out;
}
return m_supportedMap;
};
virtual std::vector<std::vector<airtalgo::channel>> getMapSupportedOutput() {
virtual std::vector<std::vector<audio::channel>> getMapSupportedOutput() {
if (m_input.getConfigured() == true) {
std::vector<std::vector<airtalgo::channel>> out;
std::vector<std::vector<audio::channel>> out;
out.push_back(m_input.getMap());
return out;
}

View File

@ -71,16 +71,15 @@ bool airtalgo::ChannelReorder::process(std::chrono::system_clock::time_point& _t
_output = &(m_outputData[0]);
// real process: (only depend of data size):
switch (m_output.getFormat()) {
default:
case format_int16:
case audio::format_int8:
{
AIRTALGO_VERBOSE("convert " << m_input.getMap() << " ==> " << m_output.getMap() << " format=" << int32_t(m_formatSize));
int16_t* in = static_cast<int16_t*>(_input);
int16_t* out = static_cast<int16_t*>(_output);
int8_t* in = static_cast<int8_t*>(_input);
int8_t* out = static_cast<int8_t*>(_output);
for (size_t kkk=0; kkk<m_output.getMap().size(); ++kkk) {
int32_t convertId = -1;
if ( m_input.getMap().size() == 1
&& m_input.getMap()[0] == airtalgo::channel_frontCenter) {
&& m_input.getMap()[0] == audio::channel_frontCenter) {
convertId = 0;
} else {
for (size_t jjj=0; jjj<m_input.getMap().size(); ++jjj) {
@ -103,9 +102,42 @@ bool airtalgo::ChannelReorder::process(std::chrono::system_clock::time_point& _t
}
}
break;
case format_int16_on_int32:
case format_int32:
case format_float:
default:
case audio::format_int16:
{
AIRTALGO_VERBOSE("convert " << m_input.getMap() << " ==> " << m_output.getMap() << " format=" << int32_t(m_formatSize));
int16_t* in = static_cast<int16_t*>(_input);
int16_t* out = static_cast<int16_t*>(_output);
for (size_t kkk=0; kkk<m_output.getMap().size(); ++kkk) {
int32_t convertId = -1;
if ( m_input.getMap().size() == 1
&& m_input.getMap()[0] == audio::channel_frontCenter) {
convertId = 0;
} else {
for (size_t jjj=0; jjj<m_input.getMap().size(); ++jjj) {
if (m_output.getMap()[kkk] == m_input.getMap()[jjj]) {
convertId = jjj;
break;
}
}
}
AIRTALGO_VERBOSE(" " << convertId << " ==> " << kkk);
if (convertId == -1) {
for (size_t iii=0; iii<_outputNbChunk; ++iii) {
out[iii*m_output.getMap().size()+kkk] = 0;
}
} else {
for (size_t iii=0; iii<_outputNbChunk; ++iii) {
out[iii*m_output.getMap().size()+kkk] = in[iii*m_input.getMap().size()+convertId];
}
}
}
}
break;
case audio::format_int16_on_int32:
case audio::format_int24:
case audio::format_int32:
case audio::format_float:
{
AIRTALGO_VERBOSE("convert (2) " << m_input.getMap() << " ==> " << m_output.getMap());
uint32_t* in = static_cast<uint32_t*>(_input);
@ -113,7 +145,37 @@ bool airtalgo::ChannelReorder::process(std::chrono::system_clock::time_point& _t
for (size_t kkk=0; kkk<m_output.getMap().size(); ++kkk) {
int32_t convertId = -1;
if ( m_input.getMap().size() == 1
&& m_input.getMap()[0] == airtalgo::channel_frontCenter) {
&& m_input.getMap()[0] == audio::channel_frontCenter) {
convertId = 0;
} else {
for (size_t jjj=0; jjj<m_input.getMap().size(); ++jjj) {
if (m_output.getMap()[kkk] == m_input.getMap()[jjj]) {
convertId = jjj;
break;
}
}
}
if (convertId == -1) {
for (size_t iii=0; iii<_outputNbChunk; ++iii) {
out[iii*m_output.getMap().size()+kkk] = 0;
}
} else {
for (size_t iii=0; iii<_outputNbChunk; ++iii) {
out[iii*m_output.getMap().size()+kkk] = in[iii*m_input.getMap().size()+convertId];
}
}
}
}
break;
case audio::format_double:
{
AIRTALGO_VERBOSE("convert (2) " << m_input.getMap() << " ==> " << m_output.getMap());
uint64_t* in = static_cast<uint64_t*>(_input);
uint64_t* out = static_cast<uint64_t*>(_output);
for (size_t kkk=0; kkk<m_output.getMap().size(); ++kkk) {
int32_t convertId = -1;
if ( m_input.getMap().size() == 1
&& m_input.getMap()[0] == audio::channel_frontCenter) {
convertId = 0;
} else {
for (size_t jjj=0; jjj<m_input.getMap().size(); ++jjj) {

View File

@ -14,14 +14,14 @@
namespace airtalgo {
typedef std::function<void (const std::chrono::system_clock::time_point& _playTime,
size_t _nbChunk,
const std::vector<airtalgo::channel>& _map,
const std::vector<audio::channel>& _map,
void* _data,
enum airtalgo::format _type)> needDataFunction;
enum audio::format _type)> needDataFunction;
typedef std::function<void (const std::chrono::system_clock::time_point& _readTime,
size_t _nbChunk,
const std::vector<airtalgo::channel>& _map,
const std::vector<audio::channel>& _map,
const void* _data,
enum airtalgo::format _type)> haveNewDataFunction;
enum audio::format _type)> haveNewDataFunction;
class EndPointCallback : public EndPoint {
private:
needDataFunction m_outputFunction;

View File

@ -14,8 +14,8 @@
namespace airtalgo{
typedef std::function<void (const std::chrono::system_clock::time_point& _playTime,
const size_t& _nbChunk,
const std::vector<airtalgo::channel>& _map,
enum airtalgo::format _type)> needDataFunctionWrite;
const std::vector<audio::channel>& _map,
enum audio::format _type)> needDataFunctionWrite;
class EndPointWrite : public EndPoint {
private:
std::vector<int8_t> m_tmpData;

View File

@ -159,82 +159,82 @@ void airtalgo::FormatUpdate::configurationChange() {
}
switch (m_input.getFormat()) {
default:
case format_int16:
case audio::format_int16:
switch (m_output.getFormat()) {
default:
case format_int16:
case audio::format_int16:
AIRTALGO_ERROR(" Impossible case 1");
break;
case format_int16_on_int32:
case audio::format_int16_on_int32:
m_functionConvert = &convert__int16__to__int16_on_int32;
AIRTALGO_DEBUG(" use converter : 'convert__int16__to__int16_on_int32' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
case format_int32:
case audio::format_int32:
m_functionConvert = &convert__int16__to__int32;
AIRTALGO_DEBUG(" use converter : 'convert__int16__to__int32' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
case format_float:
case audio::format_float:
m_functionConvert = &convert__int16__to__float;
AIRTALGO_DEBUG(" use converter : 'convert__int16__to__float' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
}
break;
case format_int16_on_int32:
case audio::format_int16_on_int32:
switch (m_output.getFormat()) {
default:
case format_int16:
case audio::format_int16:
m_functionConvert = &convert__int16_on_int32__to__int16;
AIRTALGO_DEBUG(" use converter : 'convert__int16_on_int32__to__int16' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
case format_int16_on_int32:
case audio::format_int16_on_int32:
AIRTALGO_ERROR(" Impossible case 2");
break;
case format_int32:
case audio::format_int32:
m_functionConvert = &convert__int16_on_int32__to__int32;
AIRTALGO_DEBUG(" use converter : 'convert__int16_on_int32__to__int32' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
case format_float:
case audio::format_float:
m_functionConvert = &convert__int16_on_int32__to__float;
AIRTALGO_DEBUG(" use converter : 'convert__int16_on_int32__to__float' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
}
break;
case format_int32:
case audio::format_int32:
switch (m_output.getFormat()) {
default:
case format_int16:
case audio::format_int16:
m_functionConvert = &convert__int32__to__int16;
AIRTALGO_DEBUG(" use converter : 'convert__int32__to__int16' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
case format_int16_on_int32:
case audio::format_int16_on_int32:
m_functionConvert = &convert__int32__to__int16_on_int32;
AIRTALGO_DEBUG(" use converter : 'convert__int32__to__int16_on_int32' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
case format_int32:
case audio::format_int32:
AIRTALGO_ERROR(" Impossible case 3");
break;
case format_float:
case audio::format_float:
m_functionConvert = &convert__int32__to__float;
AIRTALGO_DEBUG(" use converter : 'convert__int32__to__float' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
}
break;
case format_float:
case audio::format_float:
switch (m_output.getFormat()) {
default:
case format_int16:
case audio::format_int16:
m_functionConvert = &convert__float__to__int16;
AIRTALGO_DEBUG(" use converter : 'convert__float__to__int16' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
case format_int16_on_int32:
case audio::format_int16_on_int32:
m_functionConvert = &convert__float__to__int16_on_int32;
AIRTALGO_DEBUG(" use converter : 'convert__float__to__int16_on_int32' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
case format_int32:
case audio::format_int32:
m_functionConvert = &convert__float__to__int32;
AIRTALGO_DEBUG(" use converter : 'convert__float__to__int32' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
case format_float:
case audio::format_float:
AIRTALGO_ERROR(" Impossible case 4");
break;
}

View File

@ -26,14 +26,14 @@ std::ostream& airtalgo::operator <<(std::ostream& _os, const IOFormatInterface&
airtalgo::IOFormatInterface::IOFormatInterface() :
m_configured(false),
m_format(airtalgo::format_unknow),
m_format(audio::format_unknow),
m_map(),
m_frequency(0) {
m_map.push_back(airtalgo::channel_frontLeft);
m_map.push_back(airtalgo::channel_frontRight);
m_map.push_back(audio::channel_frontLeft);
m_map.push_back(audio::channel_frontRight);
}
airtalgo::IOFormatInterface::IOFormatInterface(std::vector<airtalgo::channel> _map, airtalgo::format _format, float _frequency) :
airtalgo::IOFormatInterface::IOFormatInterface(std::vector<audio::channel> _map, audio::format _format, float _frequency) :
m_configured(true),
m_format(_format),
m_map(_map),
@ -41,7 +41,7 @@ airtalgo::IOFormatInterface::IOFormatInterface(std::vector<airtalgo::channel> _m
}
void airtalgo::IOFormatInterface::set(std::vector<airtalgo::channel> _map, airtalgo::format _format, float _frequency) {
void airtalgo::IOFormatInterface::set(std::vector<audio::channel> _map, audio::format _format, float _frequency) {
bool hasChange = false;
if (m_map != _map) {
m_map = _map;
@ -69,11 +69,11 @@ bool airtalgo::IOFormatInterface::getConfigured() const {
return m_configured;
}
airtalgo::format airtalgo::IOFormatInterface::getFormat() const {
audio::format airtalgo::IOFormatInterface::getFormat() const {
return m_format;
}
void airtalgo::IOFormatInterface::setFormat(airtalgo::format _value) {
void airtalgo::IOFormatInterface::setFormat(audio::format _value) {
if (m_format == _value) {
return;
}
@ -82,11 +82,11 @@ void airtalgo::IOFormatInterface::setFormat(airtalgo::format _value) {
configurationChange();
}
const std::vector<airtalgo::channel>& airtalgo::IOFormatInterface::getMap() const{
const std::vector<audio::channel>& airtalgo::IOFormatInterface::getMap() const{
return m_map;
}
void airtalgo::IOFormatInterface::setMap(const std::vector<airtalgo::channel>& _value) {
void airtalgo::IOFormatInterface::setMap(const std::vector<audio::channel>& _value) {
if (m_map == _value) {
return;
}

View File

@ -11,8 +11,8 @@
#include <string>
#include <vector>
#include <stdint.h>
#include <airtalgo/format.h>
#include <airtalgo/channel.h>
#include <audio/format.h>
#include <audio/channel.h>
#include <chrono>
#include <functional>
#include <memory>
@ -23,39 +23,39 @@ namespace airtalgo{
class IOFormatInterface {
public:
IOFormatInterface();
IOFormatInterface(std::vector<airtalgo::channel> _map, airtalgo::format _format=airtalgo::format_int16, float _frequency=48000.0f);
void set(std::vector<airtalgo::channel> _map, airtalgo::format _format=airtalgo::format_int16, float _frequency=48000.0f);
IOFormatInterface(std::vector<audio::channel> _map, audio::format _format=audio::format_int16, float _frequency=48000.0f);
void set(std::vector<audio::channel> _map, audio::format _format=audio::format_int16, float _frequency=48000.0f);
protected:
bool m_configured;
public:
void setConfigured(bool _value);
bool getConfigured() const;
protected:
airtalgo::format m_format; //!< input Algo Format
audio::format m_format; //!< input Algo Format
public:
/**
* @brief Get the algo format.
* @return the current Format.
*/
airtalgo::format getFormat() const;
audio::format getFormat() const;
/**
* @brief Set the algo format.
* @param[in] _value New Format.
*/
void setFormat(airtalgo::format _value);
void setFormat(audio::format _value);
protected:
std::vector<airtalgo::channel> m_map; //!< input channel Map
std::vector<audio::channel> m_map; //!< input channel Map
public:
/**
* @brief Get the algo channel Map.
* @return the current channel Map.
*/
const std::vector<airtalgo::channel>& getMap() const;
const std::vector<audio::channel>& getMap() const;
/**
* @brief Set the algo channel Map.
* @param[in] _value New channel Map.
*/
void setMap(const std::vector<airtalgo::channel>& _value);
void setMap(const std::vector<audio::channel>& _value);
protected:
float m_frequency; //!< input Algo Format
public:

View File

@ -9,8 +9,8 @@
#include <string>
#include <vector>
#include <stdint.h>
#include <airtalgo/format.h>
#include <airtalgo/channel.h>
#include <audio/format.h>
#include <audio/channel.h>
#include <airtalgo/Process.h>
#include <airtalgo/ChannelReorder.h>
#include <airtalgo/FormatUpdate.h>
@ -190,13 +190,13 @@ void airtalgo::Process::updateInterAlgo() {
std::vector<float> freqIn = m_listAlgo[iii]->getFrequencySupportedInput();
std::vector<float> freq = getUnion<float>(freqOut, freqIn);
// step 2 : Check map:
std::vector<std::vector<airtalgo::channel>> mapOut = m_listAlgo[iii-1]->getMapSupportedOutput();
std::vector<std::vector<airtalgo::channel>> mapIn = m_listAlgo[iii]->getMapSupportedInput();
std::vector<std::vector<airtalgo::channel>> map = getUnion<std::vector<airtalgo::channel>>(mapOut, mapIn);
std::vector<std::vector<audio::channel>> mapOut = m_listAlgo[iii-1]->getMapSupportedOutput();
std::vector<std::vector<audio::channel>> mapIn = m_listAlgo[iii]->getMapSupportedInput();
std::vector<std::vector<audio::channel>> map = getUnion<std::vector<audio::channel>>(mapOut, mapIn);
// step 3 : Check Format:
std::vector<airtalgo::format> formatOut = m_listAlgo[iii-1]->getFormatSupportedOutput();
std::vector<airtalgo::format> formatIn = m_listAlgo[iii]->getFormatSupportedInput();
std::vector<airtalgo::format> format = getUnion<airtalgo::format>(formatOut, formatIn);
std::vector<audio::format> formatOut = m_listAlgo[iii-1]->getFormatSupportedOutput();
std::vector<audio::format> formatIn = m_listAlgo[iii]->getFormatSupportedInput();
std::vector<audio::format> format = getUnion<audio::format>(formatOut, formatIn);
if ( freq.size() >= 1
&& map.size() >= 1
@ -288,13 +288,13 @@ void airtalgo::Process::updateInterAlgo() {
if (out.getFrequency() != in.getFrequency()) {
// TODO : Do it better: special check for resampler : only support int16_t
if ( out.getFormat() != format_int16
if ( out.getFormat() != audio::format_int16
/* && out.getFormat() != format_float */) {
// need add a format Updater
std::shared_ptr<airtalgo::FormatUpdate> algo = airtalgo::FormatUpdate::create();
algo->setTemporary();
algo->setInputFormat(out);
out.setFormat(format_int16);
out.setFormat(audio::format_int16);
algo->setOutputFormat(out);
m_listAlgo.insert(m_listAlgo.begin()+iii, algo);
AIRTALGO_INFO("convert " << out.getFormat() << " -> " << in.getFormat());

View File

@ -11,8 +11,8 @@
#include <string>
#include <vector>
#include <stdint.h>
#include <airtalgo/format.h>
#include <airtalgo/channel.h>
#include <audio/format.h>
#include <audio/channel.h>
#include <airtalgo/Algo.h>
#include <chrono>
#include <memory>

View File

@ -23,7 +23,7 @@ airtalgo::Resampler::Resampler() :
void airtalgo::Resampler::init() {
airtalgo::Algo::init();
m_type = "Resampler";
m_supportedFormat.push_back(format_int16);
m_supportedFormat.push_back(audio::format_int16);
}
std::shared_ptr<airtalgo::Resampler> airtalgo::Resampler::create() {
@ -47,7 +47,7 @@ void airtalgo::Resampler::configurationChange() {
AIRTALGO_ERROR("can not support Format Change ...");
m_needProcess = false;
}
if (m_input.getFormat() != format_int16) {
if (m_input.getFormat() != audio::format_int16) {
AIRTALGO_ERROR("can not support Format other than int16_t ...");
m_needProcess = false;
return;

View File

@ -20,8 +20,8 @@ airtalgo::Volume::Volume() :
void airtalgo::Volume::init() {
airtalgo::Algo::init();
m_type = "Volume";
m_supportedFormat.push_back(format_int16);
m_supportedFormat.push_back(format_int16_on_int32);
m_supportedFormat.push_back(audio::format_int16);
m_supportedFormat.push_back(audio::format_int16_on_int32);
}
std::shared_ptr<airtalgo::Volume> airtalgo::Volume::create() {
@ -90,50 +90,50 @@ void airtalgo::Volume::configurationChange() {
airtalgo::Algo::configurationChange();
switch (m_input.getFormat()) {
default:
case format_int16:
case audio::format_int16:
switch (m_output.getFormat()) {
default:
case format_int16:
case audio::format_int16:
m_functionConvert = &convert__int16__to__int16;
AIRTALGO_DEBUG("Use converter : 'convert__int16__to__int16' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
case format_int16_on_int32:
case format_int32:
case audio::format_int16_on_int32:
case audio::format_int32:
m_functionConvert = &convert__int16__to__int32;
AIRTALGO_DEBUG("Use converter : 'convert__int16__to__int32' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
case format_float:
case audio::format_float:
AIRTALGO_ERROR("Impossible case 1");
break;
}
break;
case format_int16_on_int32:
case format_int32:
case audio::format_int16_on_int32:
case audio::format_int32:
switch (m_output.getFormat()) {
default:
case format_int16:
case audio::format_int16:
m_functionConvert = &convert__int32__to__int16;
AIRTALGO_DEBUG("Use converter : 'convert__int32__to__int16' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
case format_int16_on_int32:
case format_int32:
case audio::format_int16_on_int32:
case audio::format_int32:
m_functionConvert = &convert__int32__to__int32;
AIRTALGO_DEBUG("Use converter : 'convert__int32__to__int32' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
case format_float:
case audio::format_float:
AIRTALGO_ERROR("Impossible case 2");
break;
}
break;
case format_float:
case audio::format_float:
switch (m_output.getFormat()) {
default:
case format_int16:
case format_int16_on_int32:
case format_int32:
case audio::format_int16:
case audio::format_int16_on_int32:
case audio::format_int32:
AIRTALGO_ERROR("Impossible case 4");
break;
case format_float:
case audio::format_float:
m_functionConvert = &convert__float__to__float;
AIRTALGO_DEBUG("Use converter : 'convert__float__to__float' for " << m_input.getFormat() << " to " << m_output.getFormat());
break;
@ -165,10 +165,10 @@ void airtalgo::Volume::volumeChange() {
m_volumeAppli = std::pow(10.0f, volumedB/20.0f);
switch (m_input.getFormat()) {
default:
case format_int16:
case audio::format_int16:
switch (m_output.getFormat()) {
default:
case format_int16:
case audio::format_int16:
if (m_volumeAppli <= 1.0f) {
m_volumeCoef = m_volumeAppli*float(1<<16);
m_volumeDecalage = 16;
@ -178,7 +178,7 @@ void airtalgo::Volume::volumeChange() {
m_volumeDecalage = 16-neareast;
}
break;
case format_int16_on_int32:
case audio::format_int16_on_int32:
if (m_volumeAppli <= 1.0f) {
m_volumeCoef = m_volumeAppli*float(1<<16);
m_volumeDecalage = 16;
@ -188,19 +188,19 @@ void airtalgo::Volume::volumeChange() {
m_volumeDecalage = 16-neareast;
}
break;
case format_int32:
case audio::format_int32:
m_volumeCoef = m_volumeAppli*float(1<<16);
m_volumeDecalage = 0;
break;
case format_float:
case audio::format_float:
AIRTALGO_ERROR("Impossible case 1");
break;
}
break;
case format_int16_on_int32:
case audio::format_int16_on_int32:
switch (m_output.getFormat()) {
default:
case format_int16:
case audio::format_int16:
if (m_volumeAppli <= 1.0f) {
m_volumeCoef = m_volumeAppli*float(1<<16);
m_volumeDecalage = 16;
@ -210,7 +210,7 @@ void airtalgo::Volume::volumeChange() {
m_volumeDecalage = 16-neareast;
}
break;
case format_int16_on_int32:
case audio::format_int16_on_int32:
if (m_volumeAppli <= 1.0f) {
m_volumeCoef = m_volumeAppli*float(1<<16);
m_volumeDecalage = 16;
@ -220,19 +220,19 @@ void airtalgo::Volume::volumeChange() {
m_volumeDecalage = 16-neareast;
}
break;
case format_int32:
case audio::format_int32:
m_volumeCoef = m_volumeAppli*float(1<<16);
m_volumeDecalage = 0;
break;
case format_float:
case audio::format_float:
AIRTALGO_ERROR("Impossible case 2");
break;
}
break;
case format_int32:
case audio::format_int32:
switch (m_output.getFormat()) {
default:
case format_int16:
case audio::format_int16:
if (m_volumeAppli <= 1.0f) {
m_volumeCoef = m_volumeAppli*float(1<<16);
m_volumeDecalage = 32;
@ -242,7 +242,7 @@ void airtalgo::Volume::volumeChange() {
m_volumeDecalage = 32-neareast;
}
break;
case format_int16_on_int32:
case audio::format_int16_on_int32:
if (m_volumeAppli <= 1.0f) {
m_volumeCoef = m_volumeAppli*float(1<<16);
m_volumeDecalage = 32;
@ -252,48 +252,48 @@ void airtalgo::Volume::volumeChange() {
m_volumeDecalage = 32-neareast;
}
break;
case format_int32:
case audio::format_int32:
m_volumeCoef = m_volumeAppli*float(1<<16);
m_volumeDecalage = 16;
break;
case format_float:
case audio::format_float:
AIRTALGO_ERROR("Impossible case 3");
break;
}
break;
case format_float:
case audio::format_float:
// nothing to do (use m_volumeAppli)
break;
}
}
std::vector<airtalgo::format> airtalgo::Volume::getFormatSupportedInput() {
std::vector<airtalgo::format> tmp;
if (m_output.getFormat() == format_float) {
tmp.push_back(format_float);
std::vector<audio::format> airtalgo::Volume::getFormatSupportedInput() {
std::vector<audio::format> tmp;
if (m_output.getFormat() == audio::format_float) {
tmp.push_back(audio::format_float);
}
if ( m_output.getFormat() == format_int16
|| m_output.getFormat() == format_int16_on_int32
|| m_output.getFormat() == format_int32) {
tmp.push_back(format_int16);
tmp.push_back(format_int16_on_int32);
tmp.push_back(format_int32);
if ( m_output.getFormat() == audio::format_int16
|| m_output.getFormat() == audio::format_int16_on_int32
|| m_output.getFormat() == audio::format_int32) {
tmp.push_back(audio::format_int16);
tmp.push_back(audio::format_int16_on_int32);
tmp.push_back(audio::format_int32);
}
return tmp;
};
std::vector<airtalgo::format> airtalgo::Volume::getFormatSupportedOutput() {
std::vector<airtalgo::format> tmp;
if (m_input.getFormat() == format_float) {
tmp.push_back(format_float);
std::vector<audio::format> airtalgo::Volume::getFormatSupportedOutput() {
std::vector<audio::format> tmp;
if (m_input.getFormat() == audio::format_float) {
tmp.push_back(audio::format_float);
}
if ( m_input.getFormat() == format_int16
|| m_input.getFormat() == format_int16_on_int32
|| m_input.getFormat() == format_int32) {
tmp.push_back(format_int16);
tmp.push_back(format_int16_on_int32);
tmp.push_back(format_int32);
if ( m_input.getFormat() == audio::format_int16
|| m_input.getFormat() == audio::format_int16_on_int32
|| m_input.getFormat() == audio::format_int32) {
tmp.push_back(audio::format_int16);
tmp.push_back(audio::format_int16_on_int32);
tmp.push_back(audio::format_int32);
}
return tmp;
};
@ -338,6 +338,7 @@ void airtalgo::Volume::addVolumeStage(const std::shared_ptr<VolumeElement>& _vol
continue;
}
if (it == _volume) {
// already done ...
return;
}
if (it->getName() == _volume->getName()) {
@ -360,7 +361,11 @@ bool airtalgo::Volume::setParameter(const std::string& _parameter, const std::st
if (sscanf(_value.c_str(), "%fdB", &value) != 1) {
return false;
}
// TODO : Check if out of range ...
if ( value < -300
|| value > 300) {
AIRTALGO_ERROR("Can not set volume ... : '" << _parameter << "' out of range : [-300..300]");
return false;
}
it->setVolume(value);
AIRTALGO_DEBUG("Set volume : FLOW = " << value << " dB (from:" << _value << ")");
volumeChange();

View File

@ -74,8 +74,8 @@ namespace airtalgo {
void*& _output,
size_t& _outputNbChunk);
public:
virtual std::vector<airtalgo::format> getFormatSupportedInput();
virtual std::vector<airtalgo::format> getFormatSupportedOutput();
virtual std::vector<audio::format> getFormatSupportedInput();
virtual std::vector<audio::format> getFormatSupportedOutput();
public:
virtual void addVolumeStage(const std::shared_ptr<airtalgo::VolumeElement>& _volume);
virtual bool setParameter(const std::string& _parameter, const std::string& _value);

View File

@ -8,7 +8,7 @@
#define __AIRT_ALGO_CORE_H__
#include <string>
#include <airtalgo/format.h>
#include <audio/format.h>
#include <airtalgo/channel.h>
#include <chrono>

View File

@ -1,131 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <airtalgo/channel.h>
#include "debug.h"
std::ostream& airtalgo::operator <<(std::ostream& _os, enum airtalgo::channel _obj) {
_os << getChannelString(_obj);
return _os;
}
std::string airtalgo::getChannelString(enum airtalgo::channel _value) {
switch (_value) {
case channel_frontLeft:
return "front-left";
break;
case channel_frontCenter:
return "front-center";
break;
case channel_frontRight:
return "front-right";
break;
case channel_rearLeft:
return "rear-left";
break;
case channel_rearCenter:
return "rear-center";
break;
case channel_rearRight:
return "rear-right";
break;
case channel_surroundLeft:
return "surround-left";
break;
case channel_surroundRight:
return "surround-right";
break;
case channel_subWoofer:
return "sub-woofer";
break;
case channel_lfe:
return "lfe";
break;
};
}
std::string airtalgo::getChannelString(const std::vector<enum airtalgo::channel>& _value) {
std::string out;
for (size_t iii=0; iii<_value.size(); ++iii) {
if (iii != 0) {
out += ";";
}
out += getChannelString(_value[iii]);
}
return out;
}
std::ostream& airtalgo::operator <<(std::ostream& _os, const std::vector<enum airtalgo::channel>& _obj) {
_os << std::string("{");
for (size_t iii=0; iii<_obj.size(); ++iii) {
if (iii!=0) {
_os << std::string(";");
}
_os << _obj[iii];
}
_os << std::string("}");
return _os;
}
std::ostream& airtalgo::operator <<(std::ostream& _os, const std::vector<std::vector<enum airtalgo::channel>>& _obj) {
_os << std::string("{");
for (size_t iii=0; iii<_obj.size(); ++iii) {
if (iii!=0) {
_os << std::string(";");
}
_os << _obj[iii];
}
_os << std::string("}");
return _os;
}
static std::vector<std::string> split(const std::string& _input, char _val) {
std::vector<std::string> list;
size_t lastStartPos = 0;
for(size_t iii=0; iii<_input.size(); iii++) {
if (_input[iii]==_val) {
list.push_back(std::string(_input, lastStartPos, iii - lastStartPos));
lastStartPos = iii+1;
}
}
if (lastStartPos<_input.size()) {
list.push_back(std::string(_input, lastStartPos));
}
return list;
}
std::vector<enum airtalgo::channel> airtalgo::getChannelFromString(const std::string& _value) {
std::vector<enum airtalgo::channel> out;
std::vector<std::string> listIO = split(_value, ';');
for (size_t iii=0; iii<listIO.size(); ++iii) {
if (listIO[iii] == "front-left") {
out.push_back(channel_frontLeft);
} else if (listIO[iii] == "front-right") {
out.push_back(channel_frontRight);
} else if (listIO[iii] == "front-center") {
out.push_back(channel_frontCenter);
} else if (listIO[iii] == "rear-left") {
out.push_back(channel_rearLeft);
} else if (listIO[iii] == "rear-right") {
out.push_back(channel_rearRight);
} else if (listIO[iii] == "rear-center") {
out.push_back(channel_rearCenter);
} else if (listIO[iii] == "surround-right") {
out.push_back(channel_surroundLeft);
} else if (listIO[iii] == "surround-left") {
out.push_back(channel_surroundRight);
} else if (listIO[iii] == "lfe") {
out.push_back(channel_lfe);
} else if (listIO[iii] == "sub-woofer") {
out.push_back(channel_subWoofer);
} else {
//ROS_ERROR("Unknow: '%s' in [front-left;front-right;front-center;rear-left;rear-right;rear-center;surround-right;surround-left;lfe;subwoofer]", listIO[iii].c_str());
}
}
return out;
}

View File

@ -1,35 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#ifndef __AIRT_ALGO_CORE_CHANNEL_H__
#define __AIRT_ALGO_CORE_CHANNEL_H__
#include <string>
#include <vector>
namespace airtalgo{
enum channel {
channel_frontLeft, //!< channel Front Left
channel_frontCenter, //!< channel Front Center
channel_frontRight, //!< channel Front Right
channel_rearLeft, //!< channel rear Left
channel_rearCenter, //!< channel rear Center
channel_rearRight, //!< channel rear Right
channel_surroundLeft, //!< channel surround Left
channel_surroundRight, //!< channel surround Right
channel_subWoofer, //!< channel Sub-woofer
channel_lfe, //!< channel Low frequency
};
std::string getChannelString(enum airtalgo::channel);
std::string getChannelString(const std::vector<enum airtalgo::channel>&);
std::vector<enum airtalgo::channel> getChannelFromString(const std::string& _value);
std::ostream& operator <<(std::ostream& _os, enum airtalgo::channel _obj);
std::ostream& operator <<(std::ostream& _os, const std::vector<enum airtalgo::channel>& _obj);
std::ostream& operator <<(std::ostream& _os, const std::vector<std::vector<enum airtalgo::channel>>& _obj);
};
#endif

View File

@ -1,61 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include "debug.h"
#include <airtalgo/format.h>
std::ostream& airtalgo::operator <<(std::ostream& _os, enum airtalgo::format _obj) {
_os << getFormatString(_obj);
return _os;
}
std::ostream& airtalgo::operator <<(std::ostream& _os, const std::vector<enum airtalgo::format>& _obj) {
_os << std::string("{");
for (size_t iii=0; iii<_obj.size(); ++iii) {
if (iii!=0) {
_os << std::string(";");
}
_os << _obj[iii];
}
_os << std::string("}");
return _os;
}
std::string airtalgo::getFormatString(enum airtalgo::format _value) {
switch (_value) {
case format_unknow:
return "format_unknow";
break;
case format_int16:
return "format_int16";
break;
case format_int16_on_int32:
return "format_int16_on_int32";
break;
case format_int32:
return "format_int32";
break;
case format_float:
return "format_float";
break;
};
}
enum airtalgo::format airtalgo::getFormatFromString(const std::string& _value) {
if (_value == "format_int16") {
return format_int16;
}
if (_value == "format_int16_on_int32") {
return format_int16_on_int32;
}
if (_value == "format_int32") {
return format_int32;
}
if (_value == "format_float") {
return format_float;
}
return format_unknow;
}

View File

@ -1,28 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#ifndef __AIRT_ALGO_CORE_FORMAT_H__
#define __AIRT_ALGO_CORE_FORMAT_H__
#include <string>
namespace airtalgo{
enum format {
format_unknow,
format_int16, //!< Signed 16 bits
format_int16_on_int32, //!< Signed 16 bits on 32bits data (16 bit fixpoint value)
format_int32, //!< Signed 32 bits
format_float, //!< Floating point (single precision)
};
std::string getFormatString(enum airtalgo::format);
enum airtalgo::format getFormatFromString(const std::string& _value);
std::ostream& operator <<(std::ostream& _os, enum airtalgo::format _obj);
std::ostream& operator <<(std::ostream& _os, const std::vector<enum airtalgo::format>& _obj);
};
#endif

View File

@ -14,13 +14,11 @@ def create(target):
'airtalgo/debug.cpp',
'airtalgo/airtalgo.cpp',
'airtalgo/Algo.cpp',
'airtalgo/channel.cpp',
'airtalgo/ChannelReorder.cpp',
'airtalgo/EndPointCallback.cpp',
'airtalgo/EndPoint.cpp',
'airtalgo/EndPointRead.cpp',
'airtalgo/EndPointWrite.cpp',
'airtalgo/format.cpp',
'airtalgo/FormatUpdate.cpp',
'airtalgo/Process.cpp',
'airtalgo/Resampler.cpp',
@ -31,7 +29,7 @@ def create(target):
# TODO: myModule.add_optional_module_depend('speexdsp', "HAVE_SPEEX_DSP_RESAMPLE")
myModule.compile_flags_CC("-DHAVE_SPEEX_DSP_RESAMPLE")
myModule.add_module_depend(['etk', 'speexdsp'])
myModule.add_module_depend(['etk', 'audio', 'speexdsp'])
myModule.add_export_path(tools.get_current_path(__file__))
# add the currrent module at the