[DEV] add bagic get float and getFormatBytes error

This commit is contained in:
Edouard DUPIN 2015-04-21 21:08:38 +02:00
parent e6429f109f
commit d8867378ce
11 changed files with 65 additions and 1 deletions

View File

@ -39,6 +39,12 @@ namespace audio {
double get() const {
return m_data;
}
float getFloat() const {
return m_data;
}
double getDouble() const {
return m_data;
}
/* ****************************************************
* = assigment
*****************************************************/

View File

@ -39,6 +39,12 @@ namespace audio {
float get() const {
return m_data;
}
float getFloat() const {
return m_data;
}
double getDouble() const {
return m_data;
}
/* ****************************************************
* = assigment
*****************************************************/

View File

@ -65,13 +65,17 @@ std::vector<enum audio::format> audio::getListFormatFromString(const std::string
uint32_t audio::getFormatBytes(audio::format _format) {
switch(_format) {
case audio::format_unknow:
return 1;
case audio::format_int8:
return sizeof(int8_t);
case audio::format_int8_on_int16:
case audio::format_int16:
return sizeof(int16_t);
case audio::format_int16_on_int32:
case audio::format_int24:
return 3;
case audio::format_int16_on_int32:
case audio::format_int24_on_int32:
case audio::format_int32:
return sizeof(int32_t);
case audio::format_int32_on_int64:

View File

@ -48,6 +48,12 @@ namespace audio {
int16_t get() const {
return m_data;
}
float getFloat() const {
return getDouble();
}
double getDouble() const {
return double(m_data)/(double(INT16_MAX)+1);
}
/* ****************************************************
* = assigment
*****************************************************/

View File

@ -46,6 +46,12 @@ namespace audio {
int32_t get() const {
return m_data;
}
float getFloat() const {
return getDouble();
}
double getDouble() const {
return double(m_data)/double(INT16_MAX)*0.5;
}
/* ****************************************************
* = assigment
*****************************************************/

View File

@ -46,6 +46,12 @@ namespace audio {
int32_t get() const {
return m_data;
}
float getFloat() const {
return getDouble();
}
double getDouble() const {
return double(m_data)/double(INT24_MAX)*0.5;
}
/* ****************************************************
* = assigment
*****************************************************/

View File

@ -46,6 +46,12 @@ namespace audio {
int32_t get() const {
return m_data;
}
float getFloat() const {
return getDouble();
}
double getDouble() const {
return double(m_data)/double(INT16_MAX);
}
/* ****************************************************
* = assigment
*****************************************************/

View File

@ -39,6 +39,12 @@ namespace audio {
int64_t get() const {
return m_data;
}
float getFloat() const {
return getDouble();
}
double getDouble() const {
return double(m_data)/double(INT32_MAX)*0.5;
}
/* ****************************************************
* = assigment
*****************************************************/

View File

@ -41,6 +41,12 @@ namespace audio {
int64_t get() const {
return m_data;
}
float getFloat() const {
return getDouble();
}
double getDouble() const {
return double(m_data)/double(INT64_MAX);
}
/* ****************************************************
* = assigment
*****************************************************/

View File

@ -46,6 +46,12 @@ namespace audio {
int16_t get() const {
return m_data;
}
float getFloat() const {
return getDouble();
}
double getDouble() const {
return double(m_data)/double(INT8_MAX)*0.5;
}
/* ****************************************************
* = assigment
*****************************************************/

View File

@ -46,6 +46,12 @@ namespace audio {
int8_t get() const {
return m_data;
}
float getFloat() const {
return getDouble();
}
double getDouble() const {
return double(m_data)/double(INT8_MAX);
}
/* ****************************************************
* = assigment
*****************************************************/