[DEV] replace 'include guard' with 'pragma once' and rework bases classes
This commit is contained in:
parent
18cd4ab32e
commit
b8e25e488e
@ -3,9 +3,7 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __AUDIO_DURATION_H__
|
||||
#define __AUDIO_DURATION_H__
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <chrono>
|
||||
@ -48,4 +46,3 @@ namespace audio {
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::Duration& _obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -3,9 +3,7 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __AUDIO_TIME_H__
|
||||
#define __AUDIO_TIME_H__
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <etk/types.h>
|
||||
@ -42,5 +40,3 @@ namespace audio {
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::Time& _obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -3,9 +3,7 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __AUDIO_CHANNEL_H__
|
||||
#define __AUDIO_CHANNEL_H__
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -141,5 +139,3 @@ namespace audio {
|
||||
std::vector<enum audio::channel> convertChannel(const std::vector<uint8_t>& _obj);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -3,9 +3,7 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __AUDIO_DEBUG_H__
|
||||
#define __AUDIO_DEBUG_H__
|
||||
#pragma once
|
||||
|
||||
#include <etk/log.h>
|
||||
|
||||
@ -37,6 +35,3 @@ namespace audio {
|
||||
assert(!#cond); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,22 +0,0 @@
|
||||
/**
|
||||
* @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,6 +61,117 @@ void audio::double_t::set(int64_t _value, int32_t _flotingPointPosition) {
|
||||
}
|
||||
|
||||
|
||||
void audio::double_t::set(double _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
|
||||
double audio::double_t::get() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
float audio::double_t::getFloat() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
double audio::double_t::getDouble() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
const audio::double_t& audio::double_t::operator= (const audio::double_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool audio::double_t::operator== (const audio::double_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
|
||||
bool audio::double_t::operator!= (const audio::double_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
|
||||
bool audio::double_t::operator< (const audio::double_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::double_t::operator<= (const audio::double_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::double_t::operator> (const audio::double_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::double_t::operator>= (const audio::double_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
|
||||
const audio::double_t& audio::double_t::operator+= (const audio::double_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::double_t audio::double_t::operator+ (const audio::double_t& _obj) const {
|
||||
audio::double_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::double_t& audio::double_t::operator-= (const audio::double_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::double_t audio::double_t::operator- (const audio::double_t& _obj) const {
|
||||
audio::double_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::double_t& audio::double_t::operator*= (const audio::double_t& _obj) {
|
||||
m_data *= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::double_t audio::double_t::operator* (const audio::double_t& _obj) const {
|
||||
audio::double_t tmpp(m_data);
|
||||
tmpp.m_data *= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::double_t& audio::double_t::operator/= (const audio::double_t& _obj) {
|
||||
m_data /= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::double_t audio::double_t::operator/ (const audio::double_t& _obj) const{
|
||||
audio::double_t tmpp(m_data);
|
||||
tmpp.m_data /= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
audio::double_t& audio::double_t::operator++() {
|
||||
m_data += 1.0f;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::double_t audio::double_t::operator++(int _unused) {
|
||||
audio::double_t result(m_data);
|
||||
m_data += 1.0f;
|
||||
return result;
|
||||
}
|
||||
|
||||
audio::double_t& audio::double_t::operator--() {
|
||||
m_data -= 1.0f;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::double_t audio::double_t::operator--(int _unused) {
|
||||
audio::double_t result(m_data);
|
||||
m_data -= 1.0f;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::ostream& audio::operator <<(std::ostream& _os, const audio::double_t& _obj) {
|
||||
_os << "[" << etk::to_string(_obj.get()) << ":d]";
|
||||
return _os;
|
||||
|
124
audio/double_t.h
124
audio/double_t.h
@ -3,20 +3,18 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <audio/types.h>
|
||||
|
||||
#ifndef __AUDIO_TYPE_DOUBLE_T_H__
|
||||
#define __AUDIO_TYPE_DOUBLE_T_H__
|
||||
|
||||
namespace audio {
|
||||
class double_t {
|
||||
private:
|
||||
double m_data;
|
||||
public:
|
||||
double_t() {}
|
||||
double_t(double _value) {
|
||||
m_data = _value;
|
||||
double_t(double _value) :
|
||||
m_data(_value) {
|
||||
// nothing to do
|
||||
}
|
||||
// transformation operator:
|
||||
double_t(const audio::int8_8_t& _val);
|
||||
@ -33,148 +31,80 @@ namespace audio {
|
||||
// set operator
|
||||
double_t(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(double _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
double get() const {
|
||||
return m_data;
|
||||
}
|
||||
float getFloat() const {
|
||||
return m_data;
|
||||
}
|
||||
double getDouble() const {
|
||||
return m_data;
|
||||
}
|
||||
void set(double _value);
|
||||
double get() const;
|
||||
float getFloat() const;
|
||||
double getDouble() const;
|
||||
/* ****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const double_t& operator= (const double_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const double_t& operator= (const double_t& _obj);
|
||||
/* ****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const double_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
bool operator== (const double_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const double_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
bool operator!= (const double_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator< (const audio::double_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
bool operator< (const audio::double_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator<= (const audio::double_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
bool operator<= (const audio::double_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator> (const audio::double_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
bool operator> (const audio::double_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator>= (const audio::double_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
bool operator>= (const audio::double_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const double_t& operator+= (const double_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const double_t& operator+= (const double_t& _obj);
|
||||
/* ****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
double_t operator+ (const double_t& _obj) const {
|
||||
double_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
double_t operator+ (const double_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const double_t& operator-= (const double_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const double_t& operator-= (const double_t& _obj);
|
||||
/* ****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
double_t operator- (const double_t& _obj) const {
|
||||
double_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
double_t operator- (const double_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* *= operator
|
||||
*****************************************************/
|
||||
const double_t& operator*= (const double_t& _obj) {
|
||||
m_data *= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const double_t& operator*= (const double_t& _obj);
|
||||
/* ****************************************************
|
||||
* * operator
|
||||
*****************************************************/
|
||||
double_t operator* (const double_t& _obj) const {
|
||||
double_t tmpp(m_data);
|
||||
tmpp.m_data *= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
double_t operator* (const double_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* /= operator
|
||||
*****************************************************/
|
||||
const double_t& operator/= (const double_t& _obj) {
|
||||
m_data /= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const double_t& operator/= (const double_t& _obj);
|
||||
/* ****************************************************
|
||||
* / operator
|
||||
*****************************************************/
|
||||
double_t operator/ (const double_t& _obj) const{
|
||||
double_t tmpp(m_data);
|
||||
tmpp.m_data /= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
double_t operator/ (const double_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* ++ operator
|
||||
*****************************************************/
|
||||
double_t& operator++() {
|
||||
m_data += 1.0f;
|
||||
return *this;
|
||||
}
|
||||
double_t operator++(int _unused) {
|
||||
double_t result(m_data);
|
||||
m_data += 1.0f;
|
||||
return result;
|
||||
}
|
||||
double_t& operator++();
|
||||
double_t operator++(int _unused);
|
||||
/* ****************************************************
|
||||
* -- operator
|
||||
*****************************************************/
|
||||
double_t& operator--() {
|
||||
m_data -= 1.0f;
|
||||
return *this;
|
||||
}
|
||||
double_t operator--(int _unused) {
|
||||
double_t result(m_data);
|
||||
m_data -= 1.0f;
|
||||
return result;
|
||||
}
|
||||
double_t& operator--();
|
||||
double_t operator--(int _unused);
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::double_t& _obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -60,6 +60,117 @@ void audio::float_t::set(int64_t _value, int32_t _flotingPointPosition) {
|
||||
m_data = float(_value << (31-_flotingPointPosition)) / (float(INT32_MAX)+1.0f);
|
||||
}
|
||||
|
||||
void audio::float_t::set(float _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
|
||||
float audio::float_t::get() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
float audio::float_t::getFloat() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
double audio::float_t::getDouble() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
const audio::float_t& audio::float_t::operator= (const audio::float_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool audio::float_t::operator== (const audio::float_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
|
||||
bool audio::float_t::operator!= (const audio::float_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
|
||||
bool audio::float_t::operator< (const audio::float_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::float_t::operator<= (const audio::float_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::float_t::operator> (const audio::float_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::float_t::operator>= (const audio::float_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
|
||||
const audio::float_t& audio::float_t::operator+= (const audio::float_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::float_t audio::float_t::operator+ (const audio::float_t& _obj) const {
|
||||
audio::float_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::float_t& audio::float_t::operator-= (const audio::float_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::float_t audio::float_t::operator- (const audio::float_t& _obj) const {
|
||||
audio::float_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::float_t& audio::float_t::operator*= (const audio::float_t& _obj) {
|
||||
m_data *= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::float_t audio::float_t::operator* (const audio::float_t& _obj) const {
|
||||
audio::float_t tmpp(m_data);
|
||||
tmpp.m_data *= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::float_t& audio::float_t::operator/= (const audio::float_t& _obj) {
|
||||
m_data /= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::float_t audio::float_t::operator/ (const audio::float_t& _obj) const{
|
||||
audio::float_t tmpp(m_data);
|
||||
tmpp.m_data /= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
audio::float_t& audio::float_t::operator++() {
|
||||
m_data += 1.0f;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::float_t audio::float_t::operator++(int _unused) {
|
||||
audio::float_t result(m_data);
|
||||
m_data += 1.0f;
|
||||
return result;
|
||||
}
|
||||
|
||||
audio::float_t& audio::float_t::operator--() {
|
||||
m_data -= 1.0f;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::float_t audio::float_t::operator--(int _unused) {
|
||||
audio::float_t result(m_data);
|
||||
m_data -= 1.0f;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::ostream& audio::operator <<(std::ostream& _os, const audio::float_t& _obj) {
|
||||
_os << "[" << etk::to_string(_obj.get()) << ":f]";
|
||||
return _os;
|
||||
|
122
audio/float_t.h
122
audio/float_t.h
@ -3,20 +3,19 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <audio/types.h>
|
||||
|
||||
#ifndef __AUDIO_TYPE_FLOAT_T_H__
|
||||
#define __AUDIO_TYPE_FLOAT_T_H__
|
||||
|
||||
namespace audio {
|
||||
class float_t {
|
||||
private:
|
||||
float m_data;
|
||||
public:
|
||||
float_t() {}
|
||||
float_t(float _value) {
|
||||
m_data = _value;
|
||||
float_t(float _value) :
|
||||
m_data(_value) {
|
||||
// nothing to do
|
||||
}
|
||||
// transformation operator:
|
||||
float_t(const audio::int8_8_t& _val);
|
||||
@ -33,148 +32,81 @@ namespace audio {
|
||||
// set operator
|
||||
float_t(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(float _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
float get() const {
|
||||
return m_data;
|
||||
}
|
||||
float getFloat() const {
|
||||
return m_data;
|
||||
}
|
||||
double getDouble() const {
|
||||
return m_data;
|
||||
}
|
||||
void set(float _value);
|
||||
float get() const;
|
||||
float getFloat() const;
|
||||
double getDouble() const;
|
||||
/* ****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const float_t& operator= (const float_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const float_t& operator= (const float_t& _obj);
|
||||
/* ****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const float_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
bool operator== (const float_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const float_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
bool operator!= (const float_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator< (const audio::float_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
bool operator< (const audio::float_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator<= (const audio::float_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
bool operator<= (const audio::float_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator> (const audio::float_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
bool operator> (const audio::float_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator>= (const audio::float_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
bool operator>= (const audio::float_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const float_t& operator+= (const float_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const float_t& operator+= (const float_t& _obj);
|
||||
/* ****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
float_t operator+ (const float_t& _obj) const {
|
||||
float_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
float_t operator+ (const float_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const float_t& operator-= (const float_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const float_t& operator-= (const float_t& _obj);
|
||||
/* ****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
float_t operator- (const float_t& _obj) const {
|
||||
float_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
float_t operator- (const float_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* *= operator
|
||||
*****************************************************/
|
||||
const float_t& operator*= (const float_t& _obj) {
|
||||
m_data *= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const float_t& operator*= (const float_t& _obj);
|
||||
/* ****************************************************
|
||||
* * operator
|
||||
*****************************************************/
|
||||
float_t operator* (const float_t& _obj) const {
|
||||
float_t tmpp(m_data);
|
||||
tmpp.m_data *= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
float_t operator* (const float_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* /= operator
|
||||
*****************************************************/
|
||||
const float_t& operator/= (const float_t& _obj) {
|
||||
m_data /= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const float_t& operator/= (const float_t& _obj);
|
||||
/* ****************************************************
|
||||
* / operator
|
||||
*****************************************************/
|
||||
float_t operator/ (const float_t& _obj) const{
|
||||
float_t tmpp(m_data);
|
||||
tmpp.m_data /= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
float_t operator/ (const float_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* ++ operator
|
||||
*****************************************************/
|
||||
float_t& operator++() {
|
||||
m_data += 1.0f;
|
||||
return *this;
|
||||
}
|
||||
float_t operator++(int _unused) {
|
||||
float_t result(m_data);
|
||||
m_data += 1.0f;
|
||||
return result;
|
||||
}
|
||||
float_t& operator++();
|
||||
float_t operator++(int _unused);
|
||||
/* ****************************************************
|
||||
* -- operator
|
||||
*****************************************************/
|
||||
float_t& operator--() {
|
||||
m_data -= 1.0f;
|
||||
return *this;
|
||||
}
|
||||
float_t operator--(int _unused) {
|
||||
float_t result(m_data);
|
||||
m_data -= 1.0f;
|
||||
return result;
|
||||
}
|
||||
float_t& operator--();
|
||||
float_t operator--(int _unused);
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::float_t& _obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -3,9 +3,7 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __AUDIO_FORMAT_H__
|
||||
#define __AUDIO_FORMAT_H__
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -61,6 +59,3 @@ namespace audio {
|
||||
enum audio::format convertFormat(uint8_t _obj);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -83,6 +83,119 @@ void audio::int16_16_t::set(int64_t _value, int32_t _flotingPointPosition) {
|
||||
m_data = std::avg(int64_t(INT16_MIN), val, int64_t(INT16_MAX));
|
||||
}
|
||||
|
||||
void audio::int16_16_t::set(int16_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
|
||||
int16_t audio::int16_16_t::get() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
float audio::int16_16_t::getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
|
||||
double audio::int16_16_t::getDouble() const {
|
||||
return double(m_data)/(double(INT16_MAX)+1);
|
||||
}
|
||||
|
||||
const audio::int16_16_t& audio::int16_16_t::operator= (const audio::int16_16_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool audio::int16_16_t::operator== (const audio::int16_16_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
|
||||
bool audio::int16_16_t::operator!= (const audio::int16_16_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
|
||||
bool audio::int16_16_t::operator< (const audio::int16_16_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int16_16_t::operator<= (const audio::int16_16_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int16_16_t::operator> (const audio::int16_16_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int16_16_t::operator>= (const audio::int16_16_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
|
||||
const audio::int16_16_t& audio::int16_16_t::operator+= (const audio::int16_16_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int16_16_t audio::int16_16_t::operator+ (const audio::int16_16_t& _obj) const {
|
||||
audio::int16_16_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int16_16_t& audio::int16_16_t::operator-= (const audio::int16_16_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int16_16_t audio::int16_16_t::operator- (const audio::int16_16_t& _obj) const {
|
||||
audio::int16_16_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int16_16_t& audio::int16_16_t::operator*= (const audio::int16_16_t& _obj) {
|
||||
int32_t tmp = int32_t(m_data) * int32_t(_obj.m_data);
|
||||
m_data = int16_t(tmp >> 15);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int16_16_t audio::int16_16_t::operator* (const audio::int16_16_t& _obj) const {
|
||||
audio::int16_16_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int16_16_t& audio::int16_16_t::operator/= (const audio::int16_16_t& _obj) {
|
||||
int32_t tmp = (int32_t(m_data) << 15) / int32_t(_obj.m_data);
|
||||
m_data = int16_t(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int16_16_t audio::int16_16_t::operator/ (const audio::int16_16_t& _obj) const{
|
||||
audio::int16_16_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
audio::int16_16_t& audio::int16_16_t::operator++() {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int16_16_t audio::int16_16_t::operator++(int _unused) {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
audio::int16_16_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
|
||||
audio::int16_16_t& audio::int16_16_t::operator--() {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int16_16_t audio::int16_16_t::operator--(int _unused) {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
audio::int16_16_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::ostream& audio::operator <<(std::ostream& _os, const audio::int16_16_t& _obj) {
|
||||
_os << "[" << etk::to_string(_obj.get()) << ":0.15=";
|
||||
_os << etk::to_string(double(_obj.get())/(double(INT16_MAX)+1));
|
||||
|
@ -3,14 +3,9 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <audio/types.h>
|
||||
|
||||
#ifndef __AUDIO_TYPE_INT16_16_T_H__
|
||||
#define __AUDIO_TYPE_INT16_16_T_H__
|
||||
|
||||
#include <audio/debug.h>
|
||||
|
||||
namespace audio {
|
||||
/**
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
@ -19,13 +14,14 @@ namespace audio {
|
||||
* |BS| < 1.0 |
|
||||
* +--+--------------------------------------------+
|
||||
*/
|
||||
class int16_16_t{
|
||||
class int16_16_t {
|
||||
private:
|
||||
int16_t m_data;
|
||||
public:
|
||||
int16_16_t() {}
|
||||
int16_16_t(int16_t _value) {
|
||||
m_data = _value;
|
||||
int16_16_t(int16_t _value) :
|
||||
m_data(_value) {
|
||||
// nothing to do
|
||||
}
|
||||
// transformation operator:
|
||||
int16_16_t(const audio::int8_8_t& _val);
|
||||
@ -42,152 +38,81 @@ namespace audio {
|
||||
// set operator
|
||||
int16_16_t(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int16_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
int16_t get() const {
|
||||
return m_data;
|
||||
}
|
||||
float getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
double getDouble() const {
|
||||
return double(m_data)/(double(INT16_MAX)+1);
|
||||
}
|
||||
void set(int16_t _value);
|
||||
int16_t get() const;
|
||||
float getFloat() const;
|
||||
double getDouble() const;
|
||||
/* ****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const int16_16_t& operator= (const int16_16_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int16_16_t& operator= (const int16_16_t& _obj);
|
||||
/* ****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const int16_16_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
bool operator== (const int16_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const int16_16_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
bool operator!= (const int16_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator< (const audio::int16_16_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
bool operator< (const audio::int16_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator<= (const audio::int16_16_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
bool operator<= (const audio::int16_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator> (const audio::int16_16_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
bool operator> (const audio::int16_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator>= (const audio::int16_16_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
bool operator>= (const audio::int16_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const int16_16_t& operator+= (const int16_16_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int16_16_t& operator+= (const int16_16_t& _obj);
|
||||
/* ****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
int16_16_t operator+ (const int16_16_t& _obj) const {
|
||||
int16_16_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int16_16_t operator+ (const int16_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const int16_16_t& operator-= (const int16_16_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int16_16_t& operator-= (const int16_16_t& _obj);
|
||||
/* ****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
int16_16_t operator- (const int16_16_t& _obj) const {
|
||||
int16_16_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int16_16_t operator- (const int16_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* *= operator
|
||||
*****************************************************/
|
||||
const int16_16_t& operator*= (const int16_16_t& _obj) {
|
||||
int32_t tmp = int32_t(m_data) * int32_t(_obj.m_data);
|
||||
m_data = int16_t(tmp >> 15);
|
||||
return *this;
|
||||
}
|
||||
const int16_16_t& operator*= (const int16_16_t& _obj);
|
||||
/* ****************************************************
|
||||
* * operator
|
||||
*****************************************************/
|
||||
int16_16_t operator* (const int16_16_t& _obj) const {
|
||||
int16_16_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int16_16_t operator* (const int16_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* /= operator
|
||||
*****************************************************/
|
||||
const int16_16_t& operator/= (const int16_16_t& _obj) {
|
||||
int32_t tmp = (int32_t(m_data) << 15) / int32_t(_obj.m_data);
|
||||
m_data = int16_t(tmp);
|
||||
return *this;
|
||||
}
|
||||
const int16_16_t& operator/= (const int16_16_t& _obj);
|
||||
/* ****************************************************
|
||||
* / operator
|
||||
*****************************************************/
|
||||
int16_16_t operator/ (const int16_16_t& _obj) const{
|
||||
int16_16_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int16_16_t operator/ (const int16_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* ++ operator
|
||||
*****************************************************/
|
||||
int16_16_t& operator++() {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
int16_16_t operator++(int _unused) {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
int16_16_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
int16_16_t& operator++();
|
||||
int16_16_t operator++(int _unused);
|
||||
/* ****************************************************
|
||||
* -- operator
|
||||
*****************************************************/
|
||||
int16_16_t& operator--() {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
int16_16_t operator--(int _unused) {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
int16_16_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
int16_16_t& operator--();
|
||||
int16_16_t operator--(int _unused);
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::int16_16_t& _obj);
|
||||
}
|
||||
|
||||
#include <audio/debugRemove.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -73,6 +73,119 @@ void audio::int16_32_t::set(int64_t _value, int32_t _flotingPointPosition) {
|
||||
m_data = std::avg(int64_t(INT32_MIN), val, int64_t(INT32_MAX));
|
||||
}
|
||||
|
||||
void audio::int16_32_t::set(int32_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
|
||||
int32_t audio::int16_32_t::get() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
float audio::int16_32_t::getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
|
||||
double audio::int16_32_t::getDouble() const {
|
||||
return double(m_data)/double(INT16_MAX)*0.5;
|
||||
}
|
||||
|
||||
const audio::int16_32_t& audio::int16_32_t::operator= (const audio::int16_32_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool audio::int16_32_t::operator== (const audio::int16_32_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
|
||||
bool audio::int16_32_t::operator!= (const audio::int16_32_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
|
||||
bool audio::int16_32_t::operator< (const audio::int16_32_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int16_32_t::operator<= (const audio::int16_32_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int16_32_t::operator> (const audio::int16_32_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int16_32_t::operator>= (const audio::int16_32_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
|
||||
const audio::int16_32_t& audio::int16_32_t::operator+= (const audio::int16_32_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int16_32_t audio::int16_32_t::operator+ (const audio::int16_32_t& _obj) const {
|
||||
audio::int16_32_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int16_32_t& audio::int16_32_t::operator-= (const audio::int16_32_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int16_32_t audio::int16_32_t::operator- (const audio::int16_32_t& _obj) const {
|
||||
audio::int16_32_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int16_32_t& audio::int16_32_t::operator*= (const audio::int16_32_t& _obj) {
|
||||
int64_t tmp = int64_t(m_data) * int64_t(_obj.m_data) + (1<<15);
|
||||
m_data = int32_t(tmp >> 16);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int16_32_t audio::int16_32_t::operator* (const audio::int16_32_t& _obj) const {
|
||||
audio::int16_32_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int16_32_t& audio::int16_32_t::operator/= (const audio::int16_32_t& _obj) {
|
||||
int64_t tmp = (int64_t(m_data) << 16) / int64_t(_obj.m_data);
|
||||
m_data = int32_t(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int16_32_t audio::int16_32_t::operator/ (const audio::int16_32_t& _obj) const{
|
||||
audio::int16_32_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
audio::int16_32_t& audio::int16_32_t::operator++() {
|
||||
m_data += (1<<16);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int16_32_t audio::int16_32_t::operator++(int _unused) {
|
||||
audio::int16_32_t result(m_data);
|
||||
m_data += (1<<16);
|
||||
return result;
|
||||
}
|
||||
|
||||
audio::int16_32_t& audio::int16_32_t::operator--() {
|
||||
m_data -= (1<<16);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int16_32_t audio::int16_32_t::operator--(int _unused) {
|
||||
audio::int16_32_t result(m_data);
|
||||
m_data -= (1<<16);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::ostream& audio::operator <<(std::ostream& _os, const audio::int16_32_t& _obj) {
|
||||
_os << "[" << etk::to_string(_obj.get()) << ":7.16=";
|
||||
_os << etk::to_string(double(_obj.get())/double(INT16_MAX)*0.5);
|
||||
|
@ -3,12 +3,9 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <audio/types.h>
|
||||
|
||||
#ifndef __AUDIO_TYPE_INT16_32_T_H__
|
||||
#define __AUDIO_TYPE_INT16_32_T_H__
|
||||
|
||||
namespace audio {
|
||||
/**
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
@ -22,8 +19,9 @@ namespace audio {
|
||||
int32_t m_data;
|
||||
public:
|
||||
int16_32_t() {}
|
||||
int16_32_t(int32_t _value) {
|
||||
m_data = _value;
|
||||
int16_32_t(int32_t _value) :
|
||||
m_data(_value) {
|
||||
// nothing to do
|
||||
}
|
||||
// transformation operator:
|
||||
int16_32_t(const audio::int8_8_t& _val);
|
||||
@ -40,150 +38,80 @@ namespace audio {
|
||||
// set operator
|
||||
int16_32_t(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int32_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
int32_t get() const {
|
||||
return m_data;
|
||||
}
|
||||
float getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
double getDouble() const {
|
||||
return double(m_data)/double(INT16_MAX)*0.5;
|
||||
}
|
||||
void set(int32_t _value);
|
||||
int32_t get() const;
|
||||
float getFloat() const;
|
||||
double getDouble() const;
|
||||
/* ****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const int16_32_t& operator= (const int16_32_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int16_32_t& operator= (const int16_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const int16_32_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
bool operator== (const int16_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const int16_32_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
bool operator!= (const int16_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator< (const audio::int16_32_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
bool operator< (const audio::int16_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator<= (const audio::int16_32_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
bool operator<= (const audio::int16_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator> (const audio::int16_32_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
bool operator> (const audio::int16_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator>= (const audio::int16_32_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
bool operator>= (const audio::int16_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const int16_32_t& operator+= (const int16_32_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int16_32_t& operator+= (const int16_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
int16_32_t operator+ (const int16_32_t& _obj) const {
|
||||
int16_32_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int16_32_t operator+ (const int16_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const int16_32_t& operator-= (const int16_32_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int16_32_t& operator-= (const int16_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
int16_32_t operator- (const int16_32_t& _obj) const {
|
||||
int16_32_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int16_32_t operator- (const int16_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* *= operator
|
||||
*****************************************************/
|
||||
const int16_32_t& operator*= (const int16_32_t& _obj) {
|
||||
int64_t tmp = int64_t(m_data) * int64_t(_obj.m_data) + (1<<15);
|
||||
m_data = int32_t(tmp >> 16);
|
||||
return *this;
|
||||
}
|
||||
const int16_32_t& operator*= (const int16_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* * operator
|
||||
*****************************************************/
|
||||
int16_32_t operator* (const int16_32_t& _obj) const {
|
||||
int16_32_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int16_32_t operator* (const int16_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* /= operator
|
||||
*****************************************************/
|
||||
const int16_32_t& operator/= (const int16_32_t& _obj) {
|
||||
int64_t tmp = (int64_t(m_data) << 16) / int64_t(_obj.m_data);
|
||||
m_data = int32_t(tmp);
|
||||
return *this;
|
||||
}
|
||||
const int16_32_t& operator/= (const int16_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* / operator
|
||||
*****************************************************/
|
||||
int16_32_t operator/ (const int16_32_t& _obj) const{
|
||||
int16_32_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int16_32_t operator/ (const int16_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* ++ operator
|
||||
*****************************************************/
|
||||
int16_32_t& operator++() {
|
||||
m_data += (1<<16);
|
||||
return *this;
|
||||
}
|
||||
int16_32_t operator++(int _unused) {
|
||||
int16_32_t result(m_data);
|
||||
m_data += (1<<16);
|
||||
return result;
|
||||
}
|
||||
int16_32_t& operator++();
|
||||
int16_32_t operator++(int _unused);
|
||||
/* ****************************************************
|
||||
* -- operator
|
||||
*****************************************************/
|
||||
int16_32_t& operator--() {
|
||||
m_data -= (1<<16);
|
||||
return *this;
|
||||
}
|
||||
int16_32_t operator--(int _unused) {
|
||||
int16_32_t result(m_data);
|
||||
m_data -= (1<<16);
|
||||
return result;
|
||||
}
|
||||
int16_32_t& operator--();
|
||||
int16_32_t operator--(int _unused);
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::int16_32_t& _obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -3,12 +3,9 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <audio/types.h>
|
||||
|
||||
#ifndef __AUDIO_TYPE_INT24_24_T_H__
|
||||
#define __AUDIO_TYPE_INT24_24_T_H__
|
||||
|
||||
namespace audio {
|
||||
/**
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
@ -46,5 +43,3 @@ namespace audio {
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::int24_24_t& _obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,27 +8,6 @@
|
||||
#include <audio/int24_32_t.h>
|
||||
|
||||
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int16_32_t.h>
|
||||
|
||||
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int16_32_t.h>
|
||||
|
||||
|
||||
|
||||
audio::int24_32_t::int24_32_t(const audio::int8_8_t& _val) {
|
||||
m_data = int32_t(_val.get()) << 17;
|
||||
}
|
||||
@ -98,6 +77,118 @@ void audio::int24_32_t::set(int64_t _value, int32_t _flotingPointPosition) {
|
||||
m_data = std::avg(int64_t(INT32_MIN), val, int64_t(INT32_MAX));
|
||||
}
|
||||
|
||||
void audio::int24_32_t::set(int32_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
|
||||
int32_t audio::int24_32_t::get() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
float audio::int24_32_t::getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
|
||||
double audio::int24_32_t::getDouble() const {
|
||||
return double(m_data)/double(INT24_MAX)*0.5;
|
||||
}
|
||||
|
||||
const audio::int24_32_t& audio::int24_32_t::operator= (const audio::int24_32_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool audio::int24_32_t::operator== (const audio::int24_32_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
|
||||
bool audio::int24_32_t::operator!= (const audio::int24_32_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
|
||||
bool audio::int24_32_t::operator< (const audio::int24_32_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int24_32_t::operator<= (const audio::int24_32_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int24_32_t::operator> (const audio::int24_32_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int24_32_t::operator>= (const audio::int24_32_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
|
||||
const audio::int24_32_t& audio::int24_32_t::operator+= (const audio::int24_32_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int24_32_t audio::int24_32_t::operator+ (const audio::int24_32_t& _obj) const {
|
||||
audio::int24_32_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int24_32_t& audio::int24_32_t::operator-= (const audio::int24_32_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int24_32_t audio::int24_32_t::operator- (const audio::int24_32_t& _obj) const {
|
||||
audio::int24_32_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int24_32_t& audio::int24_32_t::operator*= (const audio::int24_32_t& _obj) {
|
||||
int64_t tmp = int64_t(m_data) * int64_t(_obj.m_data);
|
||||
m_data = int32_t(tmp >> 24);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int24_32_t audio::int24_32_t::operator* (const audio::int24_32_t& _obj) const {
|
||||
audio::int24_32_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int24_32_t& audio::int24_32_t::operator/= (const audio::int24_32_t& _obj) {
|
||||
int64_t tmp = (int64_t(m_data) << 24) / int64_t(_obj.m_data);
|
||||
m_data = int32_t(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int24_32_t audio::int24_32_t::operator/ (const audio::int24_32_t& _obj) const{
|
||||
audio::int24_32_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
audio::int24_32_t& audio::int24_32_t::operator++() {
|
||||
m_data += (1<<24);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int24_32_t audio::int24_32_t::operator++(int _unused) {
|
||||
audio::int24_32_t result(m_data);
|
||||
m_data += (1<<24);
|
||||
return result;
|
||||
}
|
||||
|
||||
audio::int24_32_t& audio::int24_32_t::operator--() {
|
||||
m_data -= (1<<24);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int24_32_t audio::int24_32_t::operator--(int _unused) {
|
||||
audio::int24_32_t result(m_data);
|
||||
m_data -= (1<<24);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::ostream& audio::operator <<(std::ostream& _os, const audio::int24_32_t& _obj) {
|
||||
_os << "[" << etk::to_string(_obj.get()) << ":7.24=";
|
||||
|
@ -3,12 +3,9 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <audio/types.h>
|
||||
|
||||
#ifndef __AUDIO_TYPE_INT24_32_T_H__
|
||||
#define __AUDIO_TYPE_INT24_32_T_H__
|
||||
|
||||
namespace audio {
|
||||
/**
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
@ -22,8 +19,9 @@ namespace audio {
|
||||
int32_t m_data;
|
||||
public:
|
||||
int24_32_t() {}
|
||||
int24_32_t(int32_t _value) {
|
||||
m_data = _value;
|
||||
int24_32_t(int32_t _value) :
|
||||
m_data(_value) {
|
||||
// nothing to do
|
||||
}
|
||||
// transformation operator:
|
||||
int24_32_t(const audio::int8_8_t& _val);
|
||||
@ -40,150 +38,81 @@ namespace audio {
|
||||
// set operator
|
||||
int24_32_t(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int32_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
int32_t get() const {
|
||||
return m_data;
|
||||
}
|
||||
float getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
double getDouble() const {
|
||||
return double(m_data)/double(INT24_MAX)*0.5;
|
||||
}
|
||||
void set(int32_t _value);
|
||||
int32_t get() const;
|
||||
float getFloat() const;
|
||||
double getDouble() const;
|
||||
/* ****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const int24_32_t& operator= (const int24_32_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int24_32_t& operator= (const int24_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const int24_32_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
bool operator== (const int24_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const int24_32_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
bool operator!= (const int24_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator< (const audio::int24_32_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
bool operator< (const audio::int24_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator<= (const audio::int24_32_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
bool operator<= (const audio::int24_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator> (const audio::int24_32_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
bool operator> (const audio::int24_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator>= (const audio::int24_32_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
bool operator>= (const audio::int24_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const int24_32_t& operator+= (const int24_32_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int24_32_t& operator+= (const int24_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
int24_32_t operator+ (const int24_32_t& _obj) const {
|
||||
int24_32_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int24_32_t operator+ (const int24_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const int24_32_t& operator-= (const int24_32_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int24_32_t& operator-= (const int24_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
int24_32_t operator- (const int24_32_t& _obj) const {
|
||||
int24_32_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int24_32_t operator- (const int24_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* *= operator
|
||||
*****************************************************/
|
||||
const int24_32_t& operator*= (const int24_32_t& _obj) {
|
||||
int64_t tmp = int64_t(m_data) * int64_t(_obj.m_data);
|
||||
m_data = int32_t(tmp >> 24);
|
||||
return *this;
|
||||
}
|
||||
const int24_32_t& operator*= (const int24_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* * operator
|
||||
*****************************************************/
|
||||
int24_32_t operator* (const int24_32_t& _obj) const {
|
||||
int24_32_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int24_32_t operator* (const int24_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* /= operator
|
||||
*****************************************************/
|
||||
const int24_32_t& operator/= (const int24_32_t& _obj) {
|
||||
int64_t tmp = (int64_t(m_data) << 24) / int64_t(_obj.m_data);
|
||||
m_data = int32_t(tmp);
|
||||
return *this;
|
||||
}
|
||||
const int24_32_t& operator/= (const int24_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* / operator
|
||||
*****************************************************/
|
||||
int24_32_t operator/ (const int24_32_t& _obj) const{
|
||||
int24_32_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int24_32_t operator/ (const int24_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* ++ operator
|
||||
*****************************************************/
|
||||
int24_32_t& operator++() {
|
||||
m_data += (1<<24);
|
||||
return *this;
|
||||
}
|
||||
int24_32_t operator++(int _unused) {
|
||||
int24_32_t result(m_data);
|
||||
m_data += (1<<24);
|
||||
return result;
|
||||
}
|
||||
int24_32_t& operator++();
|
||||
int24_32_t operator++(int _unused);
|
||||
/* ****************************************************
|
||||
* -- operator
|
||||
*****************************************************/
|
||||
int24_32_t& operator--() {
|
||||
m_data -= (1<<24);
|
||||
return *this;
|
||||
}
|
||||
int24_32_t operator--(int _unused) {
|
||||
int24_32_t result(m_data);
|
||||
m_data -= (1<<24);
|
||||
return result;
|
||||
}
|
||||
int24_32_t& operator--();
|
||||
int24_32_t operator--(int _unused);
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::int24_32_t& _obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -7,28 +7,6 @@
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int32_32_t.h>
|
||||
|
||||
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int16_32_t.h>
|
||||
|
||||
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int16_32_t.h>
|
||||
|
||||
|
||||
|
||||
audio::int32_32_t::int32_32_t(const audio::int8_8_t& _val) {
|
||||
m_data = int32_t(_val.get()) << 24;
|
||||
}
|
||||
@ -106,6 +84,118 @@ void audio::int32_32_t::set(int64_t _value, int32_t _flotingPointPosition) {
|
||||
m_data = std::avg(int64_t(INT32_MIN), val, int64_t(INT32_MAX));
|
||||
}
|
||||
|
||||
void audio::int32_32_t::set(int32_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
|
||||
int32_t audio::int32_32_t::get() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
float audio::int32_32_t::getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
|
||||
double audio::int32_32_t::getDouble() const {
|
||||
return double(m_data)/double(INT16_MAX);
|
||||
}
|
||||
|
||||
const audio::int32_32_t& audio::int32_32_t::operator= (const audio::int32_32_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool audio::int32_32_t::operator== (const audio::int32_32_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
|
||||
bool audio::int32_32_t::operator!= (const audio::int32_32_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
|
||||
bool audio::int32_32_t::operator< (const audio::int32_32_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int32_32_t::operator<= (const audio::int32_32_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int32_32_t::operator> (const audio::int32_32_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int32_32_t::operator>= (const audio::int32_32_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
|
||||
const audio::int32_32_t& audio::int32_32_t::operator+= (const audio::int32_32_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int32_32_t audio::int32_32_t::operator+ (const audio::int32_32_t& _obj) const {
|
||||
audio::int32_32_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int32_32_t& audio::int32_32_t::operator-= (const audio::int32_32_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int32_32_t audio::int32_32_t::operator- (const audio::int32_32_t& _obj) const {
|
||||
audio::int32_32_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int32_32_t& audio::int32_32_t::operator*= (const audio::int32_32_t& _obj) {
|
||||
int64_t tmp = int64_t(m_data) * int64_t(_obj.m_data);
|
||||
m_data = int32_t(tmp >> 31);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int32_32_t audio::int32_32_t::operator* (const audio::int32_32_t& _obj) const {
|
||||
audio::int32_32_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int32_32_t& audio::int32_32_t::operator/= (const audio::int32_32_t& _obj) {
|
||||
int64_t tmp = (int64_t(m_data) << 31) / int64_t(_obj.m_data);
|
||||
m_data = int32_t(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int32_32_t audio::int32_32_t::operator/ (const audio::int32_32_t& _obj) const{
|
||||
audio::int32_32_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
audio::int32_32_t& audio::int32_32_t::operator++() {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int32_32_t audio::int32_32_t::operator++(int _unused) {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
audio::int32_32_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
|
||||
audio::int32_32_t& audio::int32_32_t::operator--() {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int32_32_t audio::int32_32_t::operator--(int _unused) {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
audio::int32_32_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::ostream& audio::operator <<(std::ostream& _os, const audio::int32_32_t& _obj) {
|
||||
_os << "[" << etk::to_string(_obj.get()) << ":0.31=";
|
||||
|
@ -3,14 +3,9 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <audio/types.h>
|
||||
|
||||
#ifndef __AUDIO_TYPE_INT32_32_T_H__
|
||||
#define __AUDIO_TYPE_INT32_32_T_H__
|
||||
|
||||
#include <audio/debug.h>
|
||||
|
||||
namespace audio {
|
||||
/**
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
@ -22,8 +17,9 @@ namespace audio {
|
||||
int32_t m_data;
|
||||
public:
|
||||
int32_32_t() {}
|
||||
int32_32_t(int32_t _value) {
|
||||
m_data = _value;
|
||||
int32_32_t(int32_t _value) :
|
||||
m_data(_value) {
|
||||
// nothing to do
|
||||
}
|
||||
// transformation operator:
|
||||
int32_32_t(const audio::int8_8_t& _val);
|
||||
@ -40,152 +36,81 @@ namespace audio {
|
||||
// set operator
|
||||
int32_32_t(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int32_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
int32_t get() const {
|
||||
return m_data;
|
||||
}
|
||||
float getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
double getDouble() const {
|
||||
return double(m_data)/double(INT16_MAX);
|
||||
}
|
||||
void set(int32_t _value);
|
||||
int32_t get() const;
|
||||
float getFloat() const;
|
||||
double getDouble() const;
|
||||
/* ****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const int32_32_t& operator= (const int32_32_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int32_32_t& operator= (const int32_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const int32_32_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
bool operator== (const int32_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const int32_32_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
bool operator!= (const int32_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator< (const audio::int32_32_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
bool operator< (const audio::int32_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator<= (const audio::int32_32_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
bool operator<= (const audio::int32_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator> (const audio::int32_32_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
bool operator> (const audio::int32_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator>= (const audio::int32_32_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
bool operator>= (const audio::int32_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const int32_32_t& operator+= (const int32_32_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int32_32_t& operator+= (const int32_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
int32_32_t operator+ (const int32_32_t& _obj) const {
|
||||
int32_32_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int32_32_t operator+ (const int32_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const int32_32_t& operator-= (const int32_32_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int32_32_t& operator-= (const int32_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
int32_32_t operator- (const int32_32_t& _obj) const {
|
||||
int32_32_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int32_32_t operator- (const int32_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* *= operator
|
||||
*****************************************************/
|
||||
const int32_32_t& operator*= (const int32_32_t& _obj) {
|
||||
int64_t tmp = int64_t(m_data) * int64_t(_obj.m_data);
|
||||
m_data = int32_t(tmp >> 31);
|
||||
return *this;
|
||||
}
|
||||
const int32_32_t& operator*= (const int32_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* * operator
|
||||
*****************************************************/
|
||||
int32_32_t operator* (const int32_32_t& _obj) const {
|
||||
int32_32_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int32_32_t operator* (const int32_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* /= operator
|
||||
*****************************************************/
|
||||
const int32_32_t& operator/= (const int32_32_t& _obj) {
|
||||
int64_t tmp = (int64_t(m_data) << 31) / int64_t(_obj.m_data);
|
||||
m_data = int32_t(tmp);
|
||||
return *this;
|
||||
}
|
||||
const int32_32_t& operator/= (const int32_32_t& _obj);
|
||||
/* ****************************************************
|
||||
* / operator
|
||||
*****************************************************/
|
||||
int32_32_t operator/ (const int32_32_t& _obj) const{
|
||||
int32_32_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int32_32_t operator/ (const int32_32_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* ++ operator
|
||||
*****************************************************/
|
||||
int32_32_t& operator++() {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
int32_32_t operator++(int _unused) {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
int32_32_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
int32_32_t& operator++();
|
||||
int32_32_t operator++(int _unused);
|
||||
/* ****************************************************
|
||||
* -- operator
|
||||
*****************************************************/
|
||||
int32_32_t& operator--() {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
int32_32_t operator--(int _unused) {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
int32_32_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
int32_32_t& operator--();
|
||||
int32_32_t operator--(int _unused);
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::int32_32_t& _obj);
|
||||
}
|
||||
|
||||
#include <audio/debugRemove.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -7,28 +7,6 @@
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int32_64_t.h>
|
||||
|
||||
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int16_32_t.h>
|
||||
|
||||
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int16_32_t.h>
|
||||
|
||||
|
||||
|
||||
audio::int32_64_t::int32_64_t(const audio::int8_8_t& _val) {
|
||||
m_data = int64_t(_val.get()) << 25;
|
||||
}
|
||||
@ -90,6 +68,118 @@ void audio::int32_64_t::set(int64_t _value, int32_t _flotingPointPosition) {
|
||||
m_data = std::avg(int64_t(INT64_MIN), val, int64_t(INT64_MAX));
|
||||
}
|
||||
|
||||
void audio::int32_64_t::set(int64_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
|
||||
int64_t audio::int32_64_t::get() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
float audio::int32_64_t::getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
|
||||
double audio::int32_64_t::getDouble() const {
|
||||
return double(m_data)/double(INT32_MAX)*0.5;
|
||||
}
|
||||
|
||||
const audio::int32_64_t& audio::int32_64_t::operator= (const audio::int32_64_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool audio::int32_64_t::operator== (const audio::int32_64_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
|
||||
bool audio::int32_64_t::operator!= (const audio::int32_64_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
|
||||
bool audio::int32_64_t::operator< (const audio::int32_64_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int32_64_t::operator<= (const audio::int32_64_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int32_64_t::operator> (const audio::int32_64_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int32_64_t::operator>= (const audio::int32_64_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
|
||||
const audio::int32_64_t& audio::int32_64_t::operator+= (const audio::int32_64_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int32_64_t audio::int32_64_t::operator+ (const audio::int32_64_t& _obj) const {
|
||||
audio::int32_64_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int32_64_t& audio::int32_64_t::operator-= (const audio::int32_64_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int32_64_t audio::int32_64_t::operator- (const audio::int32_64_t& _obj) const {
|
||||
audio::int32_64_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int32_64_t& audio::int32_64_t::operator*= (const audio::int32_64_t& _obj) {
|
||||
int64_t tmp = m_data * _obj.m_data;
|
||||
m_data = int64_t(tmp >> 32);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int32_64_t audio::int32_64_t::operator* (const audio::int32_64_t& _obj) const {
|
||||
audio::int32_64_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int32_64_t& audio::int32_64_t::operator/= (const audio::int32_64_t& _obj) {
|
||||
int64_t tmp = (int64_t(m_data) << 16) / int64_t(_obj.m_data);
|
||||
m_data = int64_t(tmp)<<16;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int32_64_t audio::int32_64_t::operator/ (const audio::int32_64_t& _obj) const{
|
||||
audio::int32_64_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
audio::int32_64_t& audio::int32_64_t::operator++() {
|
||||
m_data += (1LL<<32);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int32_64_t audio::int32_64_t::operator++(int _unused) {
|
||||
audio::int32_64_t result(m_data);
|
||||
m_data += (1LL<<32);
|
||||
return result;
|
||||
}
|
||||
|
||||
audio::int32_64_t& audio::int32_64_t::operator--() {
|
||||
m_data -= (1LL<<32);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int32_64_t audio::int32_64_t::operator--(int _unused) {
|
||||
audio::int32_64_t result(m_data);
|
||||
m_data -= (1LL<<32);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::ostream& audio::operator <<(std::ostream& _os, const audio::int32_64_t& _obj) {
|
||||
_os << "[" << etk::to_string(_obj.get()) << ":31.32=";
|
||||
|
@ -3,20 +3,18 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <audio/types.h>
|
||||
|
||||
#ifndef __AUDIO_TYPE_INT32_64_T_H__
|
||||
#define __AUDIO_TYPE_INT32_64_T_H__
|
||||
|
||||
namespace audio {
|
||||
class int32_64_t {
|
||||
private:
|
||||
int64_t m_data;
|
||||
public:
|
||||
int32_64_t() {}
|
||||
int32_64_t(int64_t _value) {
|
||||
m_data = _value;
|
||||
int32_64_t(int64_t _value) :
|
||||
m_data(_value) {
|
||||
// nothing to do
|
||||
}
|
||||
// transformation operator:
|
||||
int32_64_t(const audio::int8_8_t& _val);
|
||||
@ -33,150 +31,81 @@ namespace audio {
|
||||
// set operator
|
||||
int32_64_t(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int64_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
int64_t get() const {
|
||||
return m_data;
|
||||
}
|
||||
float getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
double getDouble() const {
|
||||
return double(m_data)/double(INT32_MAX)*0.5;
|
||||
}
|
||||
void set(int64_t _value);
|
||||
int64_t get() const;
|
||||
float getFloat() const;
|
||||
double getDouble() const;
|
||||
/* ****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const int32_64_t& operator= (const int32_64_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int32_64_t& operator= (const int32_64_t& _obj);
|
||||
/* ****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const int32_64_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
bool operator== (const int32_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const int32_64_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
bool operator!= (const int32_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator< (const audio::int32_64_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
bool operator< (const audio::int32_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator<= (const audio::int32_64_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
bool operator<= (const audio::int32_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator> (const audio::int32_64_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
bool operator> (const audio::int32_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator>= (const audio::int32_64_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
bool operator>= (const audio::int32_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const int32_64_t& operator+= (const int32_64_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int32_64_t& operator+= (const int32_64_t& _obj);
|
||||
/* ****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
int32_64_t operator+ (const int32_64_t& _obj) const {
|
||||
int32_64_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int32_64_t operator+ (const int32_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const int32_64_t& operator-= (const int32_64_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int32_64_t& operator-= (const int32_64_t& _obj);
|
||||
/* ****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
int32_64_t operator- (const int32_64_t& _obj) const {
|
||||
int32_64_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int32_64_t operator- (const int32_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* *= operator
|
||||
*****************************************************/
|
||||
const int32_64_t& operator*= (const int32_64_t& _obj) {
|
||||
int64_t tmp = m_data * _obj.m_data;
|
||||
m_data = int64_t(tmp >> 32);
|
||||
return *this;
|
||||
}
|
||||
const int32_64_t& operator*= (const int32_64_t& _obj);
|
||||
/* ****************************************************
|
||||
* * operator
|
||||
*****************************************************/
|
||||
int32_64_t operator* (const int32_64_t& _obj) const {
|
||||
int32_64_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int32_64_t operator* (const int32_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* /= operator
|
||||
*****************************************************/
|
||||
const int32_64_t& operator/= (const int32_64_t& _obj) {
|
||||
int64_t tmp = (int64_t(m_data) << 16) / int64_t(_obj.m_data);
|
||||
m_data = int64_t(tmp)<<16;
|
||||
return *this;
|
||||
}
|
||||
const int32_64_t& operator/= (const int32_64_t& _obj);
|
||||
/* ****************************************************
|
||||
* / operator
|
||||
*****************************************************/
|
||||
int32_64_t operator/ (const int32_64_t& _obj) const{
|
||||
int32_64_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int32_64_t operator/ (const int32_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* ++ operator
|
||||
*****************************************************/
|
||||
int32_64_t& operator++() {
|
||||
m_data += (1LL<<32);
|
||||
return *this;
|
||||
}
|
||||
int32_64_t operator++(int _unused) {
|
||||
int32_64_t result(m_data);
|
||||
m_data += (1LL<<32);
|
||||
return result;
|
||||
}
|
||||
int32_64_t& operator++();
|
||||
int32_64_t operator++(int _unused);
|
||||
/* ****************************************************
|
||||
* -- operator
|
||||
*****************************************************/
|
||||
int32_64_t& operator--() {
|
||||
m_data -= (1LL<<32);
|
||||
return *this;
|
||||
}
|
||||
int32_64_t operator--(int _unused) {
|
||||
int32_64_t result(m_data);
|
||||
m_data -= (1LL<<32);
|
||||
return result;
|
||||
}
|
||||
int32_64_t& operator--();
|
||||
int32_64_t operator--(int _unused);
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::int32_64_t& _obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -7,28 +7,6 @@
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int64_64_t.h>
|
||||
|
||||
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int16_32_t.h>
|
||||
|
||||
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int16_32_t.h>
|
||||
|
||||
|
||||
|
||||
audio::int64_64_t::int64_64_t(const audio::int8_8_t& _val) {
|
||||
m_data = int64_t(_val.get()) << 56;
|
||||
}
|
||||
@ -103,6 +81,137 @@ void audio::int64_64_t::set(int64_t _value, int32_t _flotingPointPosition) {
|
||||
m_data = std::avg(int64_t(INT64_MIN), val, int64_t(INT64_MAX));
|
||||
}
|
||||
|
||||
void audio::int64_64_t::set(int64_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
|
||||
int64_t audio::int64_64_t::get() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
float audio::int64_64_t::getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
|
||||
double audio::int64_64_t::getDouble() const {
|
||||
return double(m_data)/double(INT64_MAX);
|
||||
}
|
||||
|
||||
const audio::int64_64_t& audio::int64_64_t::operator= (const audio::int64_64_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool audio::int64_64_t::operator== (const audio::int64_64_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
|
||||
bool audio::int64_64_t::operator!= (const audio::int64_64_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
|
||||
bool audio::int64_64_t::operator< (const audio::int64_64_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int64_64_t::operator<= (const audio::int64_64_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int64_64_t::operator> (const audio::int64_64_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int64_64_t::operator>= (const audio::int64_64_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
|
||||
const audio::int64_64_t& audio::int64_64_t::operator+= (const audio::int64_64_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int64_64_t audio::int64_64_t::operator+ (const audio::int64_64_t& _obj) const {
|
||||
audio::int64_64_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int64_64_t& audio::int64_64_t::operator-= (const audio::int64_64_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int64_64_t audio::int64_64_t::operator- (const audio::int64_64_t& _obj) const {
|
||||
audio::int64_64_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int64_64_t& audio::int64_64_t::operator*= (const audio::int64_64_t& _obj) {
|
||||
if ( m_data > INT32_MAX
|
||||
|| m_data < INT32_MIN) {
|
||||
if ( _obj.m_data > INT32_MAX
|
||||
|| _obj.m_data < INT32_MIN) {
|
||||
int64_t tmp = (m_data >> 31) * (_obj.m_data >> 31);
|
||||
m_data = tmp >> 1;
|
||||
} else {
|
||||
int64_t tmp = (m_data >> 31) * (_obj.m_data);
|
||||
m_data = tmp >> 32;
|
||||
}
|
||||
} else {
|
||||
if ( _obj.m_data > INT32_MAX
|
||||
|| _obj.m_data < INT32_MIN) {
|
||||
int64_t tmp = (m_data) * (_obj.m_data >> 32);
|
||||
m_data = tmp >> 31;
|
||||
} else {
|
||||
int64_t tmp = (m_data >> 24) * (_obj.m_data >> 24);
|
||||
m_data = tmp >> 16;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int64_64_t audio::int64_64_t::operator* (const audio::int64_64_t& _obj) const {
|
||||
audio::int64_64_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int64_64_t& audio::int64_64_t::operator/= (const audio::int64_64_t& _obj) {
|
||||
// TODO: Does not work
|
||||
int64_t tmp = (m_data) / (_obj.m_data);
|
||||
m_data = tmp << 63;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int64_64_t audio::int64_64_t::operator/ (const audio::int64_64_t& _obj) const{
|
||||
audio::int64_64_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
audio::int64_64_t& audio::int64_64_t::operator++() {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int64_64_t audio::int64_64_t::operator++(int _unused) {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
audio::int64_64_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
|
||||
audio::int64_64_t& audio::int64_64_t::operator--() {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int64_64_t audio::int64_64_t::operator--(int _unused) {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
audio::int64_64_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::ostream& audio::operator <<(std::ostream& _os, const audio::int64_64_t& _obj) {
|
||||
_os << "[" << etk::to_string(_obj.get()) << ":0.63=";
|
||||
|
@ -3,22 +3,18 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <audio/types.h>
|
||||
|
||||
#ifndef __AUDIO_TYPE_INT64_64_T_H__
|
||||
#define __AUDIO_TYPE_INT64_64_T_H__
|
||||
|
||||
#include <audio/debug.h>
|
||||
|
||||
namespace audio {
|
||||
class int64_64_t {
|
||||
private:
|
||||
int64_t m_data;
|
||||
public:
|
||||
int64_64_t() {}
|
||||
int64_64_t(int64_t _value) {
|
||||
m_data = _value;
|
||||
int64_64_t(int64_t _value) :
|
||||
m_data(_value) {
|
||||
// nothing to do
|
||||
}
|
||||
// transformation operator:
|
||||
int64_64_t(const audio::int8_8_t& _val);
|
||||
@ -35,171 +31,81 @@ namespace audio {
|
||||
// set operator
|
||||
int64_64_t(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int64_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
int64_t get() const {
|
||||
return m_data;
|
||||
}
|
||||
float getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
double getDouble() const {
|
||||
return double(m_data)/double(INT64_MAX);
|
||||
}
|
||||
void set(int64_t _value);
|
||||
int64_t get() const;
|
||||
float getFloat() const;
|
||||
double getDouble() const;
|
||||
/* ****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const int64_64_t& operator= (const int64_64_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int64_64_t& operator= (const int64_64_t& _obj);
|
||||
/* ****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const int64_64_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
bool operator== (const int64_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const int64_64_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
bool operator!= (const int64_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator< (const audio::int64_64_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
bool operator< (const audio::int64_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator<= (const audio::int64_64_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
bool operator<= (const audio::int64_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator> (const audio::int64_64_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
bool operator> (const audio::int64_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator>= (const audio::int64_64_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
bool operator>= (const audio::int64_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const int64_64_t& operator+= (const int64_64_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int64_64_t& operator+= (const int64_64_t& _obj);
|
||||
/* ****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
int64_64_t operator+ (const int64_64_t& _obj) const {
|
||||
int64_64_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int64_64_t operator+ (const int64_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const int64_64_t& operator-= (const int64_64_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int64_64_t& operator-= (const int64_64_t& _obj);
|
||||
/* ****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
int64_64_t operator- (const int64_64_t& _obj) const {
|
||||
int64_64_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int64_64_t operator- (const int64_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* *= operator
|
||||
*****************************************************/
|
||||
const int64_64_t& operator*= (const int64_64_t& _obj) {
|
||||
if ( m_data > INT32_MAX
|
||||
|| m_data < INT32_MIN) {
|
||||
if ( _obj.m_data > INT32_MAX
|
||||
|| _obj.m_data < INT32_MIN) {
|
||||
int64_t tmp = (m_data >> 31) * (_obj.m_data >> 31);
|
||||
m_data = tmp >> 1;
|
||||
} else {
|
||||
int64_t tmp = (m_data >> 31) * (_obj.m_data);
|
||||
m_data = tmp >> 32;
|
||||
}
|
||||
} else {
|
||||
if ( _obj.m_data > INT32_MAX
|
||||
|| _obj.m_data < INT32_MIN) {
|
||||
int64_t tmp = (m_data) * (_obj.m_data >> 32);
|
||||
m_data = tmp >> 31;
|
||||
} else {
|
||||
int64_t tmp = (m_data >> 24) * (_obj.m_data >> 24);
|
||||
m_data = tmp >> 16;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
const int64_64_t& operator*= (const int64_64_t& _obj);
|
||||
/* ****************************************************
|
||||
* * operator
|
||||
*****************************************************/
|
||||
int64_64_t operator* (const int64_64_t& _obj) const {
|
||||
int64_64_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int64_64_t operator* (const int64_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* /= operator
|
||||
*****************************************************/
|
||||
const int64_64_t& operator/= (const int64_64_t& _obj) {
|
||||
// TODO: Does not work
|
||||
int64_t tmp = (m_data) / (_obj.m_data);
|
||||
m_data = tmp << 63;
|
||||
return *this;
|
||||
}
|
||||
const int64_64_t& operator/= (const int64_64_t& _obj);
|
||||
/* ****************************************************
|
||||
* / operator
|
||||
*****************************************************/
|
||||
int64_64_t operator/ (const int64_64_t& _obj) const{
|
||||
int64_64_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int64_64_t operator/ (const int64_64_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* ++ operator
|
||||
*****************************************************/
|
||||
int64_64_t& operator++() {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
int64_64_t operator++(int _unused) {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
int64_64_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
int64_64_t& operator++();
|
||||
int64_64_t operator++(int _unused);
|
||||
/* ****************************************************
|
||||
* -- operator
|
||||
*****************************************************/
|
||||
int64_64_t& operator--() {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
int64_64_t operator--(int _unused) {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
int64_64_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
int64_64_t& operator--();
|
||||
int64_64_t operator--(int _unused);
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::int64_64_t& _obj);
|
||||
}
|
||||
|
||||
#include <audio/debugRemove.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,27 +8,6 @@
|
||||
#include <audio/int8_16_t.h>
|
||||
|
||||
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int16_32_t.h>
|
||||
|
||||
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int16_32_t.h>
|
||||
|
||||
|
||||
|
||||
audio::int8_16_t::int8_16_t(const audio::int8_8_t& _val) {
|
||||
m_data = int16_t(_val.get())<<1;
|
||||
}
|
||||
@ -98,6 +77,118 @@ void audio::int8_16_t::set(int64_t _value, int32_t _flotingPointPosition) {
|
||||
m_data = std::avg(int64_t(INT16_MIN), val, int64_t(INT16_MAX));
|
||||
}
|
||||
|
||||
void audio::int8_16_t::set(int16_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
|
||||
int16_t audio::int8_16_t::get() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
float audio::int8_16_t::getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
|
||||
double audio::int8_16_t::getDouble() const {
|
||||
return double(m_data)/double(INT8_MAX)*0.5;
|
||||
}
|
||||
|
||||
const audio::int8_16_t& audio::int8_16_t::operator= (const audio::int8_16_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool audio::int8_16_t::operator== (const audio::int8_16_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
|
||||
bool audio::int8_16_t::operator!= (const audio::int8_16_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
|
||||
bool audio::int8_16_t::operator< (const audio::int8_16_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int8_16_t::operator<= (const audio::int8_16_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int8_16_t::operator> (const audio::int8_16_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int8_16_t::operator>= (const audio::int8_16_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
|
||||
const audio::int8_16_t& audio::int8_16_t::operator+= (const audio::int8_16_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int8_16_t audio::int8_16_t::operator+ (const audio::int8_16_t& _obj) const {
|
||||
audio::int8_16_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int8_16_t& audio::int8_16_t::operator-= (const audio::int8_16_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int8_16_t audio::int8_16_t::operator- (const audio::int8_16_t& _obj) const {
|
||||
audio::int8_16_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int8_16_t& audio::int8_16_t::operator*= (const audio::int8_16_t& _obj) {
|
||||
int16_t tmp = int16_t(m_data) * int16_t(_obj.m_data);
|
||||
m_data = int8_t(tmp >> 8);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int8_16_t audio::int8_16_t::operator* (const audio::int8_16_t& _obj) const {
|
||||
audio::int8_16_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int8_16_t& audio::int8_16_t::operator/= (const audio::int8_16_t& _obj) {
|
||||
int32_t tmp = (int32_t(m_data) << 8) / int32_t(_obj.m_data);
|
||||
m_data = int16_t(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int8_16_t audio::int8_16_t::operator/ (const audio::int8_16_t& _obj) const{
|
||||
audio::int8_16_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
audio::int8_16_t& audio::int8_16_t::operator++() {
|
||||
m_data += (1<<8);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int8_16_t audio::int8_16_t::operator++(int _unused) {
|
||||
audio::int8_16_t result(m_data);
|
||||
m_data += (1<<8);
|
||||
return result;
|
||||
}
|
||||
|
||||
audio::int8_16_t& audio::int8_16_t::operator--() {
|
||||
m_data -= (1<<8);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int8_16_t audio::int8_16_t::operator--(int _unused) {
|
||||
audio::int8_16_t result(m_data);
|
||||
m_data -= (1<<8);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::ostream& audio::operator <<(std::ostream& _os, const audio::int8_16_t& _obj) {
|
||||
_os << "[" << etk::to_string(_obj.get()) << ":7.8=";
|
||||
|
@ -3,12 +3,9 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <audio/types.h>
|
||||
|
||||
#ifndef __AUDIO_TYPE_INT8_16_T_H__
|
||||
#define __AUDIO_TYPE_INT8_16_T_H__
|
||||
|
||||
namespace audio {
|
||||
/**
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
@ -22,8 +19,9 @@ namespace audio {
|
||||
int16_t m_data;
|
||||
public:
|
||||
int8_16_t() {}
|
||||
int8_16_t(int16_t _value) {
|
||||
m_data = _value;
|
||||
int8_16_t(int16_t _value) :
|
||||
m_data(_value) {
|
||||
// nothing to do
|
||||
}
|
||||
// transformation operator:
|
||||
int8_16_t(const audio::int8_8_t& _val);
|
||||
@ -40,150 +38,81 @@ namespace audio {
|
||||
// set operator
|
||||
int8_16_t(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int16_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
int16_t get() const {
|
||||
return m_data;
|
||||
}
|
||||
float getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
double getDouble() const {
|
||||
return double(m_data)/double(INT8_MAX)*0.5;
|
||||
}
|
||||
void set(int16_t _value);
|
||||
int16_t get() const;
|
||||
float getFloat() const;
|
||||
double getDouble() const;
|
||||
/* ****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const int8_16_t& operator= (const int8_16_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int8_16_t& operator= (const int8_16_t& _obj);
|
||||
/* ****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const int8_16_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
bool operator== (const int8_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const int8_16_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
bool operator!= (const int8_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator< (const audio::int8_16_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
bool operator< (const audio::int8_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator<= (const audio::int8_16_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
bool operator<= (const audio::int8_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator> (const audio::int8_16_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
bool operator> (const audio::int8_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator>= (const audio::int8_16_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
bool operator>= (const audio::int8_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const int8_16_t& operator+= (const int8_16_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int8_16_t& operator+= (const int8_16_t& _obj);
|
||||
/* ****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
int8_16_t operator+ (const int8_16_t& _obj) const {
|
||||
int8_16_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int8_16_t operator+ (const int8_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const int8_16_t& operator-= (const int8_16_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int8_16_t& operator-= (const int8_16_t& _obj);
|
||||
/* ****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
int8_16_t operator- (const int8_16_t& _obj) const {
|
||||
int8_16_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int8_16_t operator- (const int8_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* *= operator
|
||||
*****************************************************/
|
||||
const int8_16_t& operator*= (const int8_16_t& _obj) {
|
||||
int16_t tmp = int16_t(m_data) * int16_t(_obj.m_data);
|
||||
m_data = int8_t(tmp >> 8);
|
||||
return *this;
|
||||
}
|
||||
const int8_16_t& operator*= (const int8_16_t& _obj);
|
||||
/* ****************************************************
|
||||
* * operator
|
||||
*****************************************************/
|
||||
int8_16_t operator* (const int8_16_t& _obj) const {
|
||||
int8_16_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int8_16_t operator* (const int8_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* /= operator
|
||||
*****************************************************/
|
||||
const int8_16_t& operator/= (const int8_16_t& _obj) {
|
||||
int32_t tmp = (int32_t(m_data) << 8) / int32_t(_obj.m_data);
|
||||
m_data = int16_t(tmp);
|
||||
return *this;
|
||||
}
|
||||
const int8_16_t& operator/= (const int8_16_t& _obj);
|
||||
/* ****************************************************
|
||||
* / operator
|
||||
*****************************************************/
|
||||
int8_16_t operator/ (const int8_16_t& _obj) const{
|
||||
int8_16_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int8_16_t operator/ (const int8_16_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* ++ operator
|
||||
*****************************************************/
|
||||
int8_16_t& operator++() {
|
||||
m_data += (1<<8);
|
||||
return *this;
|
||||
}
|
||||
int8_16_t operator++(int _unused) {
|
||||
int8_16_t result(m_data);
|
||||
m_data += (1<<8);
|
||||
return result;
|
||||
}
|
||||
int8_16_t& operator++();
|
||||
int8_16_t operator++(int _unused);
|
||||
/* ****************************************************
|
||||
* -- operator
|
||||
*****************************************************/
|
||||
int8_16_t& operator--() {
|
||||
m_data -= (1<<8);
|
||||
return *this;
|
||||
}
|
||||
int8_16_t operator--(int _unused) {
|
||||
int8_16_t result(m_data);
|
||||
m_data -= (1<<8);
|
||||
return result;
|
||||
}
|
||||
int8_16_t& operator--();
|
||||
int8_16_t operator--(int _unused);
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::int8_16_t& _obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,27 +8,6 @@
|
||||
#include <audio/int8_8_t.h>
|
||||
|
||||
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int16_32_t.h>
|
||||
|
||||
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <audio/debug.h>
|
||||
#include <audio/int16_32_t.h>
|
||||
|
||||
|
||||
|
||||
audio::int8_8_t::int8_8_t(const audio::int8_8_t& _val) {
|
||||
m_data = _val.m_data;
|
||||
}
|
||||
@ -104,6 +83,119 @@ void audio::int8_8_t::set(int64_t _value, int32_t _flotingPointPosition) {
|
||||
m_data = std::avg(int64_t(INT8_MIN), val, int64_t(INT8_MAX));
|
||||
}
|
||||
|
||||
void audio::int8_8_t::set(int8_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
|
||||
int8_t audio::int8_8_t::get() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
float audio::int8_8_t::getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
|
||||
double audio::int8_8_t::getDouble() const {
|
||||
return double(m_data)/double(INT8_MAX);
|
||||
}
|
||||
|
||||
const audio::int8_8_t& audio::int8_8_t::operator= (const audio::int8_8_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool audio::int8_8_t::operator== (const audio::int8_8_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
|
||||
bool audio::int8_8_t::operator!= (const audio::int8_8_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
|
||||
bool audio::int8_8_t::operator< (const audio::int8_8_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int8_8_t::operator<= (const audio::int8_8_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int8_8_t::operator> (const audio::int8_8_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
|
||||
bool audio::int8_8_t::operator>= (const audio::int8_8_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
|
||||
const audio::int8_8_t& audio::int8_8_t::operator+= (const audio::int8_8_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int8_8_t audio::int8_8_t::operator+ (const audio::int8_8_t& _obj) const {
|
||||
audio::int8_8_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int8_8_t& audio::int8_8_t::operator-= (const audio::int8_8_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int8_8_t audio::int8_8_t::operator- (const audio::int8_8_t& _obj) const {
|
||||
audio::int8_8_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int8_8_t& audio::int8_8_t::operator*= (const audio::int8_8_t& _obj) {
|
||||
int16_t tmp = int16_t(m_data) * int16_t(_obj.m_data) + (1LL<<5);
|
||||
m_data = int8_t(tmp >> 7);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int8_8_t audio::int8_8_t::operator* (const audio::int8_8_t& _obj) const {
|
||||
audio::int8_8_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
const audio::int8_8_t& audio::int8_8_t::operator/= (const audio::int8_8_t& _obj) {
|
||||
int16_t tmp = (int16_t(m_data) << 7) / int16_t(_obj.m_data);
|
||||
m_data = int8_t(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int8_8_t audio::int8_8_t::operator/ (const audio::int8_8_t& _obj) const{
|
||||
audio::int8_8_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
|
||||
audio::int8_8_t& audio::int8_8_t::operator++() {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int8_8_t audio::int8_8_t::operator++(int _unused) {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
int8_8_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
|
||||
audio::int8_8_t& audio::int8_8_t::operator--() {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
|
||||
audio::int8_8_t audio::int8_8_t::operator--(int _unused) {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
int8_8_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& audio::operator <<(std::ostream& _os, const audio::int8_8_t& _obj) {
|
||||
_os << "[" << etk::to_string(_obj.get()) << ":0.7=";
|
||||
|
129
audio/int8_8_t.h
129
audio/int8_8_t.h
@ -3,14 +3,9 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <audio/types.h>
|
||||
|
||||
#ifndef __AUDIO_TYPE_INT8_8_T_H__
|
||||
#define __AUDIO_TYPE_INT8_8_T_H__
|
||||
|
||||
#include <audio/debug.h>
|
||||
|
||||
namespace audio {
|
||||
/**
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
@ -22,8 +17,9 @@ namespace audio {
|
||||
int8_t m_data;
|
||||
public:
|
||||
int8_8_t() {}
|
||||
int8_8_t(int8_t _value) {
|
||||
m_data = _value;
|
||||
int8_8_t(int8_t _value) :
|
||||
m_data(_value) {
|
||||
// nothing to do
|
||||
}
|
||||
// transformation operator:
|
||||
int8_8_t(const audio::int8_8_t& _val);
|
||||
@ -40,152 +36,81 @@ namespace audio {
|
||||
// set operator
|
||||
int8_8_t(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int64_t _value, int32_t _flotingPointPosition);
|
||||
void set(int8_t _value) {
|
||||
m_data = _value;
|
||||
}
|
||||
int8_t get() const {
|
||||
return m_data;
|
||||
}
|
||||
float getFloat() const {
|
||||
return getDouble();
|
||||
}
|
||||
double getDouble() const {
|
||||
return double(m_data)/double(INT8_MAX);
|
||||
}
|
||||
void set(int8_t _value);
|
||||
int8_t get() const;
|
||||
float getFloat() const;
|
||||
double getDouble() const;
|
||||
/* ****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const int8_8_t& operator= (const int8_8_t& _obj ) {
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int8_8_t& operator= (const int8_8_t& _obj);
|
||||
/* ****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const int8_8_t& _obj) const {
|
||||
return _obj.m_data == m_data;
|
||||
}
|
||||
bool operator== (const int8_8_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const int8_8_t& _obj) const {
|
||||
return _obj.m_data != m_data;
|
||||
}
|
||||
bool operator!= (const int8_8_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator< (const audio::int8_8_t& _obj) const {
|
||||
return m_data < _obj.m_data;
|
||||
}
|
||||
bool operator< (const audio::int8_8_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator<= (const audio::int8_8_t& _obj) const {
|
||||
return m_data <= _obj.m_data;
|
||||
}
|
||||
bool operator<= (const audio::int8_8_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator> (const audio::int8_8_t& _obj) const {
|
||||
return m_data > _obj.m_data;
|
||||
}
|
||||
bool operator> (const audio::int8_8_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* < operator
|
||||
*****************************************************/
|
||||
bool operator>= (const audio::int8_8_t& _obj) const {
|
||||
return m_data >= _obj.m_data;
|
||||
}
|
||||
bool operator>= (const audio::int8_8_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const int8_8_t& operator+= (const int8_8_t& _obj) {
|
||||
m_data += _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int8_8_t& operator+= (const int8_8_t& _obj);
|
||||
/* ****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
int8_8_t operator+ (const int8_8_t& _obj) const {
|
||||
int8_8_t tmpp(m_data);
|
||||
tmpp.m_data += _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int8_8_t operator+ (const int8_8_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const int8_8_t& operator-= (const int8_8_t& _obj) {
|
||||
m_data -= _obj.m_data;
|
||||
return *this;
|
||||
}
|
||||
const int8_8_t& operator-= (const int8_8_t& _obj);
|
||||
/* ****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
int8_8_t operator- (const int8_8_t& _obj) const {
|
||||
int8_8_t tmpp(m_data);
|
||||
tmpp.m_data -= _obj.m_data;
|
||||
return tmpp;
|
||||
}
|
||||
int8_8_t operator- (const int8_8_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* *= operator
|
||||
*****************************************************/
|
||||
const int8_8_t& operator*= (const int8_8_t& _obj) {
|
||||
int16_t tmp = int16_t(m_data) * int16_t(_obj.m_data) + (1LL<<5);
|
||||
m_data = int8_t(tmp >> 7);
|
||||
return *this;
|
||||
}
|
||||
const int8_8_t& operator*= (const int8_8_t& _obj);
|
||||
/* ****************************************************
|
||||
* * operator
|
||||
*****************************************************/
|
||||
int8_8_t operator* (const int8_8_t& _obj) const {
|
||||
int8_8_t tmpp(m_data);
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int8_8_t operator* (const int8_8_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* /= operator
|
||||
*****************************************************/
|
||||
const int8_8_t& operator/= (const int8_8_t& _obj) {
|
||||
int16_t tmp = (int16_t(m_data) << 7) / int16_t(_obj.m_data);
|
||||
m_data = int8_t(tmp);
|
||||
return *this;
|
||||
}
|
||||
const int8_8_t& operator/= (const int8_8_t& _obj);
|
||||
/* ****************************************************
|
||||
* / operator
|
||||
*****************************************************/
|
||||
int8_8_t operator/ (const int8_8_t& _obj) const{
|
||||
int8_8_t tmpp(m_data);
|
||||
tmpp /= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
int8_8_t operator/ (const int8_8_t& _obj) const;
|
||||
/* ****************************************************
|
||||
* ++ operator
|
||||
*****************************************************/
|
||||
int8_8_t& operator++() {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
int8_8_t operator++(int _unused) {
|
||||
AUDIO_CRITICAL("INCREMENT ++ a type that can not be > 0");
|
||||
int8_8_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
int8_8_t& operator++();
|
||||
int8_8_t operator++(int _unused);
|
||||
/* ****************************************************
|
||||
* -- operator
|
||||
*****************************************************/
|
||||
int8_8_t& operator--() {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
return *this;
|
||||
}
|
||||
int8_8_t operator--(int _unused) {
|
||||
AUDIO_CRITICAL("DECREMENT -- a type that can not be > 0");
|
||||
int8_8_t result(m_data);
|
||||
return result;
|
||||
}
|
||||
int8_8_t& operator--();
|
||||
int8_8_t operator--(int _unused);
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::int8_8_t& _obj);
|
||||
}
|
||||
|
||||
#include <audio/debugRemove.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifndef __AUDIO_TYPES_H__
|
||||
#define __AUDIO_TYPES_H__
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace audio {
|
||||
class int8_8_t;
|
||||
@ -41,6 +41,3 @@ namespace audio {
|
||||
#include <audio/int64_64_t.h>
|
||||
#include <audio/float_t.h>
|
||||
#include <audio/double_t.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -21,7 +21,7 @@ def get_maintainer():
|
||||
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||
|
||||
def get_version():
|
||||
return [0,1]
|
||||
return [0,2]
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
@ -45,8 +45,6 @@ def create(target, module_name):
|
||||
])
|
||||
my_module.add_header_file([
|
||||
'audio/types.h',
|
||||
'audio/debug.h',
|
||||
'audio/debugRemove.h',
|
||||
'audio/channel.h',
|
||||
'audio/format.h',
|
||||
'audio/Time.h',
|
||||
|
Loading…
x
Reference in New Issue
Block a user