[DEV] Add ros channel compatibility
This commit is contained in:
parent
b4a452d025
commit
a19377860c
@ -103,3 +103,19 @@ namespace etk {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> audio::convertChannel(const std::vector<enum audio::channel>& _obj) {
|
||||||
|
std::vector<uint8_t> out;
|
||||||
|
for (size_t iii=0; iii<_obj.size(); ++iii) {
|
||||||
|
out.push_back(static_cast<uint8_t>(_obj[iii]));
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<enum audio::channel> audio::convertChannel(const std::vector<uint8_t>& _obj) {
|
||||||
|
std::vector<enum audio::channel> out;
|
||||||
|
for (size_t iii=0; iii<_obj.size(); ++iii) {
|
||||||
|
out.push_back(static_cast<enum audio::channel>(_obj[iii]));
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
@ -9,7 +9,25 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#ifdef ETK_EXTERN_FRAMEWORK_ROS
|
||||||
|
#include <ros/ros.h>
|
||||||
|
#include "audio_msg/AudioBuffer.h"
|
||||||
|
namespace audio {
|
||||||
|
enum channel {
|
||||||
|
channel_unknow = audio_msg::AudioBuffer::CHANNEL_UNKNOW,
|
||||||
|
channel_frontLeft = audio_msg::AudioBuffer::CHANNEL_FRONT_LEFT,
|
||||||
|
channel_frontCenter = audio_msg::AudioBuffer::CHANNEL_FRONT_CENTER,
|
||||||
|
channel_frontRight = audio_msg::AudioBuffer::CHANNEL_FRONT_RIGHT,
|
||||||
|
channel_rearLeft = audio_msg::AudioBuffer::CHANNEL_REAR_LEFT,
|
||||||
|
channel_rearCenter = audio_msg::AudioBuffer::CHANNEL_REAR_CENTER,
|
||||||
|
channel_rearRight = audio_msg::AudioBuffer::CHANNEL_REAR_RIGHT,
|
||||||
|
channel_surroundLeft = audio_msg::AudioBuffer::CHANNEL_SURROUND_LEFT,
|
||||||
|
channel_surroundRight = audio_msg::AudioBuffer::CHANNEL_SURROUND_RIGHT,
|
||||||
|
channel_subWoofer = audio_msg::AudioBuffer::CHANNEL_SUBWOOFER,
|
||||||
|
channel_lfe = audio_msg::AudioBuffer::CHANNEL_LFE
|
||||||
|
};
|
||||||
|
};
|
||||||
|
#else
|
||||||
namespace audio {
|
namespace audio {
|
||||||
enum channel {
|
enum channel {
|
||||||
channel_unknow, //!< Error channel ...
|
channel_unknow, //!< Error channel ...
|
||||||
@ -24,6 +42,9 @@ namespace audio {
|
|||||||
channel_subWoofer, //!< channel Sub-woofer
|
channel_subWoofer, //!< channel Sub-woofer
|
||||||
channel_lfe, //!< channel Low frequency
|
channel_lfe, //!< channel Low frequency
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
namespace audio {
|
||||||
std::string getChannelString(enum audio::channel _obj);
|
std::string getChannelString(enum audio::channel _obj);
|
||||||
std::string getChannelString(const std::vector<enum audio::channel>& _obj);
|
std::string getChannelString(const std::vector<enum audio::channel>& _obj);
|
||||||
enum audio::channel getChannelFromString(const std::string& _value);
|
enum audio::channel getChannelFromString(const std::string& _value);
|
||||||
@ -31,6 +52,9 @@ namespace audio {
|
|||||||
std::ostream& operator <<(std::ostream& _os, enum audio::channel _obj);
|
std::ostream& operator <<(std::ostream& _os, enum audio::channel _obj);
|
||||||
std::ostream& operator <<(std::ostream& _os, const std::vector<enum audio::channel>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<enum audio::channel>& _obj);
|
||||||
std::ostream& operator <<(std::ostream& _os, const std::vector<std::vector<enum audio::channel> >& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<std::vector<enum audio::channel> >& _obj);
|
||||||
|
// For ROS Interface:
|
||||||
|
std::vector<uint8_t> convertChannel(const std::vector<enum audio::channel>& _obj);
|
||||||
|
std::vector<enum audio::channel> convertChannel(const std::vector<uint8_t>& _obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,19 +63,22 @@ std::vector<enum audio::format> audio::getListFormatFromString(const std::string
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t audio::getFormatBytes(audio::format _format) {
|
uint32_t audio::getFormatBytes(audio::format _format) {
|
||||||
if (_format == audio::format_int8) {
|
switch(_format) {
|
||||||
|
case audio::format_int8:
|
||||||
return sizeof(int8_t);
|
return sizeof(int8_t);
|
||||||
} else if (_format == audio::format_int16) {
|
case audio::format_int8_on_int16:
|
||||||
|
case audio::format_int16:
|
||||||
return sizeof(int16_t);
|
return sizeof(int16_t);
|
||||||
} else if (_format == audio::format_int16_on_int32) {
|
case audio::format_int16_on_int32:
|
||||||
|
case audio::format_int24:
|
||||||
|
case audio::format_int32:
|
||||||
return sizeof(int32_t);
|
return sizeof(int32_t);
|
||||||
} else if (_format == audio::format_int24) {
|
case audio::format_int32_on_int64:
|
||||||
return sizeof(int32_t);
|
case audio::format_int64:
|
||||||
} else if (_format == audio::format_int32) {
|
return sizeof(int64_t);
|
||||||
return sizeof(int32_t);
|
case audio::format_float:
|
||||||
} else if (_format == audio::format_float) {
|
|
||||||
return sizeof(float);
|
return sizeof(float);
|
||||||
} else if (_format == audio::format_double) {
|
case audio::format_double:
|
||||||
return sizeof(double);
|
return sizeof(double);
|
||||||
}
|
}
|
||||||
AUDIO_ERROR("undefined format : " << _format);
|
AUDIO_ERROR("undefined format : " << _format);
|
||||||
@ -98,3 +101,27 @@ namespace etk {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> audio::convertFormat(const std::vector<enum audio::format>& _obj) {
|
||||||
|
std::vector<uint8_t> out;
|
||||||
|
for (size_t iii=0; iii<_obj.size(); ++iii) {
|
||||||
|
out.push_back(static_cast<uint8_t>(_obj[iii]));
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<enum audio::format> audio::convertFormat(const std::vector<uint8_t>& _obj) {
|
||||||
|
std::vector<enum audio::format> out;
|
||||||
|
for (size_t iii=0; iii<_obj.size(); ++iii) {
|
||||||
|
out.push_back(static_cast<enum audio::format>(_obj[iii]));
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t audio::convertFormat(enum audio::format _obj) {
|
||||||
|
return static_cast<uint8_t>(_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum audio::format audio::convertFormat(uint8_t _obj) {
|
||||||
|
return static_cast<enum audio::format>(_obj);
|
||||||
|
}
|
||||||
|
@ -9,6 +9,25 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef ETK_EXTERN_FRAMEWORK_ROS
|
||||||
|
#include <ros/ros.h>
|
||||||
|
#include "audio_msg/AudioBuffer.h"
|
||||||
|
namespace audio {
|
||||||
|
enum format {
|
||||||
|
format_unknow = audio_msg::AudioBuffer::FORMAT_UNKNOW,
|
||||||
|
format_int8 = audio_msg::AudioBuffer::FORMAT_INT8,
|
||||||
|
format_int8_on_int16 = audio_msg::AudioBuffer::FORMAT_INT8_ON_INT16,
|
||||||
|
format_int16 = audio_msg::AudioBuffer::FORMAT_INT16,
|
||||||
|
format_int16_on_int32 = audio_msg::AudioBuffer::FORMAT_INT16_ON_INT32,
|
||||||
|
format_int24 = audio_msg::AudioBuffer::FORMAT_INT24,
|
||||||
|
format_int32 = audio_msg::AudioBuffer::FORMAT_INT32,
|
||||||
|
format_int32_on_int64 = audio_msg::AudioBuffer::FORMAT_INT32_ON_INT64,
|
||||||
|
format_int64 = audio_msg::AudioBuffer::FORMAT_INT64,
|
||||||
|
format_float = audio_msg::AudioBuffer::FORMAT_FLOAT,
|
||||||
|
format_double = audio_msg::AudioBuffer::FORMAT_DOUBLE
|
||||||
|
};
|
||||||
|
};
|
||||||
|
#else
|
||||||
namespace audio {
|
namespace audio {
|
||||||
enum format {
|
enum format {
|
||||||
format_unknow,
|
format_unknow,
|
||||||
@ -23,12 +42,21 @@ namespace audio {
|
|||||||
format_float, //!< Floating point 32 bits (single precision)
|
format_float, //!< Floating point 32 bits (single precision)
|
||||||
format_double //!< Floating point 64 bits (double precision)
|
format_double //!< Floating point 64 bits (double precision)
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace audio {
|
||||||
std::string getFormatString(enum audio::format _format);
|
std::string getFormatString(enum audio::format _format);
|
||||||
enum audio::format getFormatFromString(const std::string& _value);
|
enum audio::format getFormatFromString(const std::string& _value);
|
||||||
std::vector<enum audio::format> getListFormatFromString(const std::string& _value);
|
std::vector<enum audio::format> getListFormatFromString(const std::string& _value);
|
||||||
std::ostream& operator <<(std::ostream& _os, enum audio::format _obj);
|
std::ostream& operator <<(std::ostream& _os, enum audio::format _obj);
|
||||||
std::ostream& operator <<(std::ostream& _os, const std::vector<enum audio::format>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<enum audio::format>& _obj);
|
||||||
uint32_t getFormatBytes(enum audio::format _format);
|
uint32_t getFormatBytes(enum audio::format _format);
|
||||||
|
// For ROS Interface:
|
||||||
|
std::vector<uint8_t> convertFormat(const std::vector<enum audio::format>& _obj);
|
||||||
|
std::vector<enum audio::format> convertFormat(const std::vector<uint8_t>& _obj);
|
||||||
|
uint8_t convertFormat(enum audio::format _obj);
|
||||||
|
enum audio::format convertFormat(uint8_t _obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
|
|||||||
## is used, also find other catkin packages
|
## is used, also find other catkin packages
|
||||||
find_package(catkin REQUIRED COMPONENTS
|
find_package(catkin REQUIRED COMPONENTS
|
||||||
etk
|
etk
|
||||||
|
audio_msg
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ add_library(${PROJECT_NAME}
|
|||||||
../${PROJECT_NAME}/format.cpp
|
../${PROJECT_NAME}/format.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "-std=c++11 -DDEBUG_LEVEL=3 -DDEBUG=1 -D__CPP_VERSION__=2011")
|
set(CMAKE_CXX_FLAGS "-std=c++11 -DDEBUG_LEVEL=3 -DDEBUG=1 -D__CPP_VERSION__=2011 -DETK_EXTERN_FRAMEWORK_ROS")
|
||||||
|
|
||||||
|
|
||||||
## Add cmake target dependencies of the executable/library
|
## Add cmake target dependencies of the executable/library
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
<maintainer email="yui.heero@gmail.com">Edouard DUPIN</maintainer>
|
<maintainer email="yui.heero@gmail.com">Edouard DUPIN</maintainer>
|
||||||
<license>Apache-2.0</license>
|
<license>Apache-2.0</license>
|
||||||
<build_depend>etk</build_depend>
|
<build_depend>etk</build_depend>
|
||||||
|
<build_depend>audio_msg</build_depend>
|
||||||
<buildtool_depend>catkin</buildtool_depend>
|
<buildtool_depend>catkin</buildtool_depend>
|
||||||
<run_depend>etk</run_depend>
|
<run_depend>etk</run_depend>
|
||||||
|
<run_depend>audio_msg</run_depend>
|
||||||
</package>
|
</package>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user