[DEV] create audi format normalisation
This commit is contained in:
commit
3eb8544eaa
22
.gitignore
vendored
Normal file
22
.gitignore
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
###################################
|
||||||
|
# backup files
|
||||||
|
###################################
|
||||||
|
*~
|
||||||
|
*.swp
|
||||||
|
*.old
|
||||||
|
*.bck
|
||||||
|
|
||||||
|
###################################
|
||||||
|
# Packages #
|
||||||
|
###################################
|
||||||
|
# it's better to unpack these files and commit the raw source
|
||||||
|
# git has its own built in compression methods
|
||||||
|
*.7z
|
||||||
|
*.dmg
|
||||||
|
*.gz
|
||||||
|
*.iso
|
||||||
|
*.jar
|
||||||
|
*.rar
|
||||||
|
*.tar
|
||||||
|
*.zip
|
||||||
|
|
131
audio/channel.cpp
Normal file
131
audio/channel.cpp
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <audio/channel.h>
|
||||||
|
#include <audio/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream& audio::operator <<(std::ostream& _os, enum audio::channel _obj) {
|
||||||
|
_os << getChannelString(_obj);
|
||||||
|
return _os;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string audio::getChannelString(enum audio::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 audio::getChannelString(const std::vector<enum audio::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& audio::operator <<(std::ostream& _os, const std::vector<enum audio::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& audio::operator <<(std::ostream& _os, const std::vector<std::vector<enum audio::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 audio::channel> audio::getChannelFromString(const std::string& _value) {
|
||||||
|
std::vector<enum audio::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;
|
||||||
|
}
|
35
audio/channel.h
Normal file
35
audio/channel.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __AUDIO_CORE_CHANNEL_H__
|
||||||
|
#define __AUDIO_CORE_CHANNEL_H__
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace audio {
|
||||||
|
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 audio::channel _obj);
|
||||||
|
std::string getChannelString(const std::vector<enum audio::channel>& _obj);
|
||||||
|
std::vector<enum audio::channel> getChannelFromString(const std::string& _value);
|
||||||
|
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<std::vector<enum audio::channel>>& _obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
13
audio/debug.cpp
Normal file
13
audio/debug.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <audio/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
int32_t audio::getLogId() {
|
||||||
|
static int32_t g_val = etk::log::registerInstance("audio");
|
||||||
|
return g_val;
|
||||||
|
}
|
50
audio/debug.h
Normal file
50
audio/debug.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __AUDIO_DEBUG_H__
|
||||||
|
#define __AUDIO_DEBUG_H__
|
||||||
|
|
||||||
|
#include <etk/log.h>
|
||||||
|
|
||||||
|
namespace audio {
|
||||||
|
int32_t getLogId();
|
||||||
|
};
|
||||||
|
// TODO : Review this problem of multiple intanciation of "std::stringbuf sb"
|
||||||
|
#define AUDIO_BASE(info,data) \
|
||||||
|
do { \
|
||||||
|
if (info <= etk::log::getLevel(audio::getLogId())) { \
|
||||||
|
std::stringbuf sb; \
|
||||||
|
std::ostream tmpStream(&sb); \
|
||||||
|
tmpStream << data; \
|
||||||
|
etk::log::logStream(audio::getLogId(), info, __LINE__, __class__, __func__, tmpStream); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
#define AUDIO_CRITICAL(data) AUDIO_BASE(1, data)
|
||||||
|
#define AUDIO_ERROR(data) AUDIO_BASE(2, data)
|
||||||
|
#define AUDIO_WARNING(data) AUDIO_BASE(3, data)
|
||||||
|
#ifdef DEBUG
|
||||||
|
#define AUDIO_INFO(data) AUDIO_BASE(4, data)
|
||||||
|
#define AUDIO_DEBUG(data) AUDIO_BASE(5, data)
|
||||||
|
#define AUDIO_VERBOSE(data) AUDIO_BASE(6, data)
|
||||||
|
#define AUDIO_TODO(data) AUDIO_BASE(4, "TODO : " << data)
|
||||||
|
#else
|
||||||
|
#define AUDIO_INFO(data) do { } while(false)
|
||||||
|
#define AUDIO_DEBUG(data) do { } while(false)
|
||||||
|
#define AUDIO_VERBOSE(data) do { } while(false)
|
||||||
|
#define AUDIO_TODO(data) do { } while(false)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define AUDIO_ASSERT(cond,data) \
|
||||||
|
do { \
|
||||||
|
if (!(cond)) { \
|
||||||
|
AUDIO_CRITICAL(data); \
|
||||||
|
assert(!#cond); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
22
audio/debugRemove.h
Normal file
22
audio/debugRemove.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license BSD 3 clauses (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __AUDIO_DEBUG_H__
|
||||||
|
#undef __AUDIO_DEBUG_H__
|
||||||
|
|
||||||
|
#undef AUDIO_BASE
|
||||||
|
#undef AUDIO_CRITICAL
|
||||||
|
#undef AUDIO_ERROR
|
||||||
|
#undef AUDIO_WARNING
|
||||||
|
#undef AUDIO_INFO
|
||||||
|
#undef AUDIO_DEBUG
|
||||||
|
#undef AUDIO_VERBOSE
|
||||||
|
#undef AUDIO_TODO
|
||||||
|
#undef AUDIO_ASSERT
|
||||||
|
#endif
|
||||||
|
|
61
audio/format.cpp
Normal file
61
audio/format.cpp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <audio/debug.h>
|
||||||
|
#include <audio/format.h>
|
||||||
|
|
||||||
|
std::ostream& audio::operator <<(std::ostream& _os, enum audio::format _obj) {
|
||||||
|
_os << getFormatString(_obj);
|
||||||
|
return _os;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& audio::operator <<(std::ostream& _os, const std::vector<enum audio::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 audio::getFormatString(enum audio::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 audio::format audio::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;
|
||||||
|
}
|
28
audio/format.h
Normal file
28
audio/format.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __AUDIO_CORE_FORMAT_H__
|
||||||
|
#define __AUDIO_CORE_FORMAT_H__
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace audio {
|
||||||
|
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 audio::format);
|
||||||
|
enum audio::format getFormatFromString(const std::string& _value);
|
||||||
|
std::ostream& operator <<(std::ostream& _os, enum audio::format _obj);
|
||||||
|
std::ostream& operator <<(std::ostream& _os, const std::vector<enum audio::format>& _obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
32
lutin_audio.py
Normal file
32
lutin_audio.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import lutinModule as module
|
||||||
|
import lutinTools as tools
|
||||||
|
import lutinDebug as debug
|
||||||
|
|
||||||
|
def get_desc():
|
||||||
|
return "audio : Basic audio types"
|
||||||
|
|
||||||
|
|
||||||
|
def create(target):
|
||||||
|
myModule = module.Module(__file__, 'audio', 'LIBRARY')
|
||||||
|
|
||||||
|
myModule.add_src_file([
|
||||||
|
'audio/debug.cpp',
|
||||||
|
'audio/channel.cpp',
|
||||||
|
'audio/format.cpp'
|
||||||
|
])
|
||||||
|
|
||||||
|
myModule.add_module_depend(['etk'])
|
||||||
|
myModule.add_export_path(tools.get_current_path(__file__))
|
||||||
|
|
||||||
|
# add the currrent module at the
|
||||||
|
return myModule
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user