[DEV] add bagic get float and getFormatBytes error
This commit is contained in:
parent
e6429f109f
commit
d8867378ce
@ -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
|
||||
*****************************************************/
|
||||
|
@ -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
|
||||
*****************************************************/
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
*****************************************************/
|
||||
|
@ -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
|
||||
*****************************************************/
|
||||
|
@ -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
|
||||
*****************************************************/
|
||||
|
@ -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
|
||||
*****************************************************/
|
||||
|
@ -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
|
||||
*****************************************************/
|
||||
|
@ -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
|
||||
*****************************************************/
|
||||
|
@ -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
|
||||
*****************************************************/
|
||||
|
@ -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
|
||||
*****************************************************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user