[DEV] change basic parsing
This commit is contained in:
parent
3eb8544eaa
commit
69bfa46ec6
@ -7,6 +7,20 @@
|
|||||||
#include <audio/channel.h>
|
#include <audio/channel.h>
|
||||||
#include <audio/debug.h>
|
#include <audio/debug.h>
|
||||||
|
|
||||||
|
static const char* listValues[] = {
|
||||||
|
"front-left",
|
||||||
|
"front-center",
|
||||||
|
"front-right",
|
||||||
|
"rear-left",
|
||||||
|
"rear-center",
|
||||||
|
"rear-right",
|
||||||
|
"surround-left",
|
||||||
|
"surround-right",
|
||||||
|
"sub-woofer",
|
||||||
|
"lfe"
|
||||||
|
};
|
||||||
|
static int32_t listValuesSize = sizeof(listValues)/sizeof(char*);
|
||||||
|
|
||||||
|
|
||||||
std::ostream& audio::operator <<(std::ostream& _os, enum audio::channel _obj) {
|
std::ostream& audio::operator <<(std::ostream& _os, enum audio::channel _obj) {
|
||||||
_os << getChannelString(_obj);
|
_os << getChannelString(_obj);
|
||||||
@ -14,38 +28,7 @@ std::ostream& audio::operator <<(std::ostream& _os, enum audio::channel _obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string audio::getChannelString(enum audio::channel _value) {
|
std::string audio::getChannelString(enum audio::channel _value) {
|
||||||
switch (_value) {
|
return listValues[_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 audio::getChannelString(const std::vector<enum audio::channel>& _value) {
|
std::string audio::getChannelString(const std::vector<enum audio::channel>& _value) {
|
||||||
@ -103,28 +86,15 @@ std::vector<enum audio::channel> audio::getChannelFromString(const std::string&
|
|||||||
std::vector<enum audio::channel> out;
|
std::vector<enum audio::channel> out;
|
||||||
std::vector<std::string> listIO = split(_value, ';');
|
std::vector<std::string> listIO = split(_value, ';');
|
||||||
for (size_t iii=0; iii<listIO.size(); ++iii) {
|
for (size_t iii=0; iii<listIO.size(); ++iii) {
|
||||||
if (listIO[iii] == "front-left") {
|
int32_t tmpCount = out.size();
|
||||||
out.push_back(channel_frontLeft);
|
for (int32_t jjj=0; jjj<listValuesSize; ++jjj) {
|
||||||
} else if (listIO[iii] == "front-right") {
|
if (listIO[iii] == listValues[jjj]) {
|
||||||
out.push_back(channel_frontRight);
|
out.push_back(static_cast<enum audio::channel>(jjj));
|
||||||
} else if (listIO[iii] == "front-center") {
|
break;
|
||||||
out.push_back(channel_frontCenter);
|
}
|
||||||
} else if (listIO[iii] == "rear-left") {
|
}
|
||||||
out.push_back(channel_rearLeft);
|
if (tmpCount == out.size()) {
|
||||||
} else if (listIO[iii] == "rear-right") {
|
AUDIO_ERROR("Can not convert : '" << _value << "' ...");
|
||||||
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;
|
return out;
|
||||||
|
@ -7,6 +7,18 @@
|
|||||||
#include <audio/debug.h>
|
#include <audio/debug.h>
|
||||||
#include <audio/format.h>
|
#include <audio/format.h>
|
||||||
|
|
||||||
|
static const char* listValues[] = {
|
||||||
|
"unknow",
|
||||||
|
"int8",
|
||||||
|
"int16",
|
||||||
|
"int16_on_int32",
|
||||||
|
"int24",
|
||||||
|
"int32",
|
||||||
|
"float",
|
||||||
|
"double"
|
||||||
|
};
|
||||||
|
static int32_t listValuesSize = sizeof(listValues)/sizeof(char*);
|
||||||
|
|
||||||
std::ostream& audio::operator <<(std::ostream& _os, enum audio::format _obj) {
|
std::ostream& audio::operator <<(std::ostream& _os, enum audio::format _obj) {
|
||||||
_os << getFormatString(_obj);
|
_os << getFormatString(_obj);
|
||||||
return _os;
|
return _os;
|
||||||
@ -25,37 +37,14 @@ std::ostream& audio::operator <<(std::ostream& _os, const std::vector<enum audio
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string audio::getFormatString(enum audio::format _value) {
|
std::string audio::getFormatString(enum audio::format _value) {
|
||||||
switch (_value) {
|
return listValues[_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 audio::format audio::getFormatFromString(const std::string& _value) {
|
enum audio::format audio::getFormatFromString(const std::string& _value) {
|
||||||
if (_value == "format_int16") {
|
for (int32_t iii=0; iii<listValuesSize; ++iii) {
|
||||||
return format_int16;
|
if (_value == listValues[iii]) {
|
||||||
}
|
return static_cast<enum audio::format>(iii);
|
||||||
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;
|
return format_unknow;
|
||||||
}
|
}
|
@ -12,10 +12,13 @@
|
|||||||
namespace audio {
|
namespace audio {
|
||||||
enum format {
|
enum format {
|
||||||
format_unknow,
|
format_unknow,
|
||||||
|
format_int8, //!< Signed 8 bits
|
||||||
format_int16, //!< Signed 16 bits
|
format_int16, //!< Signed 16 bits
|
||||||
format_int16_on_int32, //!< Signed 16 bits on 32bits data (16 bit fixpoint value)
|
format_int16_on_int32, //!< Signed 16 bits on 32bits data (16 bit fixpoint value)
|
||||||
|
format_int24, //!< Signed 24 bits
|
||||||
format_int32, //!< Signed 32 bits
|
format_int32, //!< Signed 32 bits
|
||||||
format_float, //!< Floating point (single precision)
|
format_float, //!< Floating point (single precision)
|
||||||
|
format_double //!< Floating point (double precision)
|
||||||
};
|
};
|
||||||
std::string getFormatString(enum audio::format);
|
std::string getFormatString(enum audio::format);
|
||||||
enum audio::format getFormatFromString(const std::string& _value);
|
enum audio::format getFormatFromString(const std::string& _value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user