|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TSOUNDSAMPLE_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define TSOUNDSAMPLE_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tsound.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TSOUND_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// forward declarations
|
|
Toshihiro Shimizu |
890ddd |
class TMono8SignedSample;
|
|
Toshihiro Shimizu |
890ddd |
class TMono8UnsignedSample;
|
|
Toshihiro Shimizu |
890ddd |
class TStereo8SignedSample;
|
|
Toshihiro Shimizu |
890ddd |
class TStereo8UnsignedSample;
|
|
Toshihiro Shimizu |
890ddd |
class TMono16Sample;
|
|
Toshihiro Shimizu |
890ddd |
class TStereo16Sample;
|
|
Toshihiro Shimizu |
890ddd |
class TMono24Sample;
|
|
Toshihiro Shimizu |
890ddd |
class TStereo24Sample;
|
|
justburner |
9369f1 |
class TMono32FloatSample;
|
|
justburner |
9369f1 |
class TStereo32FloatSample;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TMono8SignedSample {
|
|
Shinya Kitaoka |
120a6e |
SCHAR value;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef SCHAR ChannelValueType;
|
|
Shinya Kitaoka |
120a6e |
typedef TMono8SignedSample ChannelSampleType;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TMono8SignedSample(SCHAR v = 0) : value(v) {}
|
|
Shinya Kitaoka |
120a6e |
~TMono8SignedSample(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static bool isSampleSigned() { return true; }
|
|
Shinya Kitaoka |
120a6e |
static int getBitPerSample() { return 8; }
|
|
justburner |
9369f1 |
static int getSampleType() { return TSound::INT; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline SCHAR getValue(TSound::Channel /*chan*/) const { return value; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline void setValue(TSound::Channel /*chan*/, SCHAR v) { value = v; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline double getPressure(TSound::Channel chan) const {
|
|
Shinya Kitaoka |
120a6e |
return (getValue(chan));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8SignedSample &operator+=(const TMono8SignedSample &s) {
|
|
Shinya Kitaoka |
120a6e |
int ival = value + s.value;
|
|
Shinya Kitaoka |
120a6e |
value = tcrop(ival, (int)-128, (int)127);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8SignedSample &operator*=(double a) {
|
|
Shinya Kitaoka |
120a6e |
int ival = (int)(value * a);
|
|
Shinya Kitaoka |
120a6e |
value = tcrop(ival, (int)-128, (int)127);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8SignedSample operator*(double a) { return (*this) *= a; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static TMono8SignedSample mix(const TMono8SignedSample &s1, double a1,
|
|
Shinya Kitaoka |
120a6e |
const TMono8SignedSample &s2, double a2) {
|
|
Shinya Kitaoka |
120a6e |
return TMono8SignedSample(
|
|
Shinya Kitaoka |
120a6e |
tcrop((int)(s1.value * a1 + s2.value * a2), -128, 127));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8SignedSample from(const TMono8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8SignedSample from(const TMono8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8SignedSample from(const TStereo8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8SignedSample from(const TStereo8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8SignedSample from(const TMono16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8SignedSample from(const TStereo16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8SignedSample from(const TMono24Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8SignedSample from(const TStereo24Sample &sample);
|
|
justburner |
9369f1 |
static inline TMono8SignedSample from(const TMono32FloatSample &sample);
|
|
justburner |
9369f1 |
static inline TMono8SignedSample from(const TStereo32FloatSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8SignedSample operator+(const TMono8SignedSample &s1,
|
|
Shinya Kitaoka |
120a6e |
const TMono8SignedSample &s2) {
|
|
Shinya Kitaoka |
120a6e |
TMono8SignedSample s = s1;
|
|
Shinya Kitaoka |
120a6e |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TMono8UnsignedSample {
|
|
Shinya Kitaoka |
120a6e |
UCHAR value;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef UCHAR ChannelValueType;
|
|
Shinya Kitaoka |
120a6e |
typedef TMono8UnsignedSample ChannelSampleType;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TMono8UnsignedSample(UCHAR v = 127) : value(v) {}
|
|
Shinya Kitaoka |
120a6e |
~TMono8UnsignedSample(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static bool isSampleSigned() { return false; }
|
|
Shinya Kitaoka |
120a6e |
static int getBitPerSample() { return 8; }
|
|
justburner |
9369f1 |
static int getSampleType() { return TSound::UINT; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline UCHAR getValue(TSound::Channel /*chan*/) const { return value; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline void setValue(TSound::Channel /*chan*/, UCHAR v) { value = v; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline double getPressure(TSound::Channel chan) const {
|
|
Shinya Kitaoka |
120a6e |
return (getValue(chan) - 128);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8UnsignedSample &operator+=(const TMono8UnsignedSample &s) {
|
|
Shinya Kitaoka |
120a6e |
value = tcrop((int)(value - 128 + s.value), 0, 255);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8UnsignedSample &operator*=(double a) {
|
|
Shinya Kitaoka |
120a6e |
value = tcrop((int)((value - 128) * a + 128), 0, 255);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8UnsignedSample operator*(double a) {
|
|
Shinya Kitaoka |
120a6e |
int ival = tcrop((int)((value - 128) * a + 128), 0, 255);
|
|
Shinya Kitaoka |
120a6e |
return TMono8UnsignedSample(ival);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static TMono8UnsignedSample mix(const TMono8UnsignedSample &s1, double a1,
|
|
Shinya Kitaoka |
120a6e |
const TMono8UnsignedSample &s2, double a2) {
|
|
Shinya Kitaoka |
120a6e |
return TMono8UnsignedSample(tcrop(
|
|
Shinya Kitaoka |
120a6e |
(int)((s1.value - 128) * a1 + (s2.value - 128) * a2 + 128), 0, 255));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8UnsignedSample from(const TMono8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8UnsignedSample from(const TMono8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8UnsignedSample from(const TStereo8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8UnsignedSample from(const TStereo8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8UnsignedSample from(const TMono16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8UnsignedSample from(const TStereo16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8UnsignedSample from(const TMono24Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono8UnsignedSample from(const TStereo24Sample &sample);
|
|
justburner |
9369f1 |
static inline TMono8UnsignedSample from(const TMono32FloatSample &sample);
|
|
justburner |
9369f1 |
static inline TMono8UnsignedSample from(const TStereo32FloatSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8UnsignedSample operator+(const TMono8UnsignedSample &s1,
|
|
Shinya Kitaoka |
120a6e |
const TMono8UnsignedSample &s2) {
|
|
Shinya Kitaoka |
120a6e |
TMono8UnsignedSample s = s1;
|
|
Shinya Kitaoka |
120a6e |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TStereo8SignedSample {
|
|
Shinya Kitaoka |
120a6e |
SCHAR channel[2]; // l'ordine dei canali e' left,right
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef SCHAR ChannelValueType;
|
|
Shinya Kitaoka |
120a6e |
typedef TMono8SignedSample ChannelSampleType;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStereo8SignedSample(short v) {
|
|
Shinya Kitaoka |
120a6e |
channel[0] = v >> 8;
|
|
Shinya Kitaoka |
120a6e |
channel[1] = v & 0xFF;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStereo8SignedSample(SCHAR lchan = 0, SCHAR rchan = 0) {
|
|
Shinya Kitaoka |
120a6e |
channel[0] = lchan;
|
|
Shinya Kitaoka |
120a6e |
channel[1] = rchan;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
~TStereo8SignedSample(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static bool isSampleSigned() { return true; }
|
|
Shinya Kitaoka |
120a6e |
static int getBitPerSample() { return 8; }
|
|
justburner |
9369f1 |
static int getSampleType() { return TSound::INT; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline SCHAR getValue(TSound::Channel chan) const {
|
|
Shinya Kitaoka |
120a6e |
assert(chan <= 1);
|
|
Shinya Kitaoka |
120a6e |
return channel[chan];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline void setValue(TSound::Channel chan, SCHAR v) {
|
|
Shinya Kitaoka |
120a6e |
assert(chan <= 1);
|
|
Shinya Kitaoka |
120a6e |
channel[chan] = v;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline double getPressure(TSound::Channel chan) const {
|
|
Shinya Kitaoka |
120a6e |
return (getValue(chan));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8SignedSample &operator+=(const TStereo8SignedSample &s) {
|
|
Shinya Kitaoka |
120a6e |
int iLeftVal = channel[0] + s.channel[0];
|
|
Shinya Kitaoka |
120a6e |
int iRightVal = channel[1] + s.channel[1];
|
|
Shinya Kitaoka |
120a6e |
channel[0] = tcrop(iLeftVal, (int)-128, (int)127);
|
|
Shinya Kitaoka |
120a6e |
channel[1] = tcrop(iRightVal, (int)-128, (int)127);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8SignedSample &operator*=(double a) {
|
|
Shinya Kitaoka |
120a6e |
int iLeftVal = (int)(a * channel[0]);
|
|
Shinya Kitaoka |
120a6e |
int iRightVal = (int)(a * channel[1]);
|
|
Shinya Kitaoka |
120a6e |
channel[0] = tcrop(iLeftVal, (int)-128, (int)127);
|
|
Shinya Kitaoka |
120a6e |
channel[1] = tcrop(iRightVal, (int)-128, (int)127);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8SignedSample operator*(double a) {
|
|
Shinya Kitaoka |
120a6e |
return TStereo8SignedSample(*this) *= a;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static TStereo8SignedSample mix(const TStereo8SignedSample &s1, double a1,
|
|
Shinya Kitaoka |
120a6e |
const TStereo8SignedSample &s2, double a2) {
|
|
Shinya Kitaoka |
120a6e |
return TStereo8SignedSample(
|
|
Shinya Kitaoka |
120a6e |
tcrop((int)(s1.channel[0] * a1 + s2.channel[0] * a2), -128, 127),
|
|
Shinya Kitaoka |
120a6e |
tcrop((int)(s1.channel[1] * a1 + s2.channel[1] * a2), -128, 127));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8SignedSample from(const TMono8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8SignedSample from(const TMono8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8SignedSample from(const TStereo8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8SignedSample from(const TStereo8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8SignedSample from(const TMono16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8SignedSample from(const TStereo16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8SignedSample from(const TMono24Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8SignedSample from(const TStereo24Sample &sample);
|
|
justburner |
9369f1 |
static inline TStereo8SignedSample from(const TMono32FloatSample &sample);
|
|
justburner |
9369f1 |
static inline TStereo8SignedSample from(const TStereo32FloatSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8SignedSample operator+(const TStereo8SignedSample &s1,
|
|
Shinya Kitaoka |
120a6e |
const TStereo8SignedSample &s2) {
|
|
Shinya Kitaoka |
120a6e |
TStereo8SignedSample s = s1;
|
|
Shinya Kitaoka |
120a6e |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TStereo8UnsignedSample {
|
|
Shinya Kitaoka |
120a6e |
UCHAR channel[2]; // l'ordine dei canali e' left,right
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef UCHAR ChannelValueType;
|
|
Shinya Kitaoka |
120a6e |
typedef TMono8UnsignedSample ChannelSampleType;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStereo8UnsignedSample(short v) {
|
|
Shinya Kitaoka |
120a6e |
channel[0] = v >> 8;
|
|
Shinya Kitaoka |
120a6e |
channel[1] = v & 0xFF;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStereo8UnsignedSample(UCHAR lchan = 127, UCHAR rchan = 127) {
|
|
Shinya Kitaoka |
120a6e |
channel[0] = lchan;
|
|
Shinya Kitaoka |
120a6e |
channel[1] = rchan;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
~TStereo8UnsignedSample(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static bool isSampleSigned() { return false; }
|
|
Shinya Kitaoka |
120a6e |
static int getBitPerSample() { return 8; }
|
|
justburner |
9369f1 |
static int getSampleType() { return TSound::UINT; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline UCHAR getValue(TSound::Channel chan) const {
|
|
Shinya Kitaoka |
120a6e |
assert(chan <= 1);
|
|
Shinya Kitaoka |
120a6e |
return channel[chan];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline void setValue(TSound::Channel chan, UCHAR v) {
|
|
Shinya Kitaoka |
120a6e |
assert(chan <= 1);
|
|
Shinya Kitaoka |
120a6e |
channel[chan] = v;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline double getPressure(TSound::Channel chan) const {
|
|
Shinya Kitaoka |
120a6e |
return (((int)getValue(chan)) - 128);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8UnsignedSample &operator+=(const TStereo8UnsignedSample &s) {
|
|
Shinya Kitaoka |
120a6e |
int iLeftVal = channel[0] + s.channel[0] - 128;
|
|
Shinya Kitaoka |
120a6e |
int iRightVal = channel[1] + s.channel[1] - 128;
|
|
Shinya Kitaoka |
120a6e |
channel[0] = tcrop(iLeftVal, 0, 255);
|
|
Shinya Kitaoka |
120a6e |
channel[1] = tcrop(iRightVal, 0, 255);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8UnsignedSample &operator*=(double a) {
|
|
Shinya Kitaoka |
120a6e |
int iLeftVal = (int)(a * (channel[0] - 128));
|
|
Shinya Kitaoka |
120a6e |
int iRightVal = (int)(a * (channel[1] - 128));
|
|
Shinya Kitaoka |
120a6e |
channel[0] = tcrop(iLeftVal + 128, 0, 255);
|
|
Shinya Kitaoka |
120a6e |
channel[1] = tcrop(iRightVal + 128, 0, 255);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8UnsignedSample operator*(double a) {
|
|
Shinya Kitaoka |
120a6e |
return TStereo8UnsignedSample(*this) *= a;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static TStereo8UnsignedSample mix(const TStereo8UnsignedSample &s1, double a1,
|
|
Shinya Kitaoka |
120a6e |
const TStereo8UnsignedSample &s2,
|
|
Shinya Kitaoka |
120a6e |
double a2) {
|
|
Shinya Kitaoka |
120a6e |
return TStereo8UnsignedSample(tcrop((int)((s1.channel[0] - 128) * a1 +
|
|
Shinya Kitaoka |
120a6e |
(s2.channel[0] - 128) * a2 + 128),
|
|
Shinya Kitaoka |
120a6e |
0, 255),
|
|
Shinya Kitaoka |
120a6e |
tcrop((int)((s1.channel[1] - 128) * a1 +
|
|
Shinya Kitaoka |
120a6e |
(s2.channel[1] - 128) * a2 + 128),
|
|
Shinya Kitaoka |
120a6e |
0, 255));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8UnsignedSample from(const TMono8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8UnsignedSample from(const TMono8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8UnsignedSample from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8UnsignedSample from(const TStereo8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8UnsignedSample from(const TMono16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8UnsignedSample from(const TStereo16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8UnsignedSample from(const TMono24Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo8UnsignedSample from(const TStereo24Sample &sample);
|
|
justburner |
9369f1 |
static inline TStereo8UnsignedSample from(const TMono32FloatSample &sample);
|
|
justburner |
9369f1 |
static inline TStereo8UnsignedSample from(const TStereo32FloatSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8UnsignedSample operator+(const TStereo8UnsignedSample &s1,
|
|
Shinya Kitaoka |
120a6e |
const TStereo8UnsignedSample &s2) {
|
|
Shinya Kitaoka |
120a6e |
TStereo8UnsignedSample s = s1;
|
|
Shinya Kitaoka |
120a6e |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TMono16Sample {
|
|
Shinya Kitaoka |
120a6e |
short value;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef short ChannelValueType;
|
|
Shinya Kitaoka |
120a6e |
typedef TMono16Sample ChannelSampleType;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TMono16Sample(short v = 0) : value(v) {}
|
|
Shinya Kitaoka |
120a6e |
~TMono16Sample(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static bool isSampleSigned() { return true; }
|
|
Shinya Kitaoka |
120a6e |
static int getBitPerSample() { return 16; }
|
|
justburner |
9369f1 |
static int getSampleType() { return TSound::INT; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline short getValue(TSound::Channel) const { return value; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline void setValue(TSound::Channel /*chan*/, short v) { value = v; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline double getPressure(TSound::Channel chan) const {
|
|
Shinya Kitaoka |
120a6e |
return (getValue(chan));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TMono16Sample &operator+=(const TMono16Sample &s) {
|
|
Shinya Kitaoka |
120a6e |
int iVal = value + s.value;
|
|
Shinya Kitaoka |
120a6e |
value = tcrop(iVal, -32768, 32767);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TMono16Sample &operator*=(double a) {
|
|
Shinya Kitaoka |
120a6e |
int iVal = (int)(value * a);
|
|
Shinya Kitaoka |
120a6e |
value = tcrop(iVal, -32768, 32767);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TMono16Sample operator*(double a) { return TMono16Sample(*this) *= a; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static TMono16Sample mix(const TMono16Sample &s1, double a1,
|
|
Shinya Kitaoka |
120a6e |
const TMono16Sample &s2, double a2) {
|
|
Shinya Kitaoka |
120a6e |
return TMono16Sample(
|
|
Shinya Kitaoka |
120a6e |
tcrop((int)(s1.value * a1 + s2.value * a2), -32768, 32767));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static inline TMono16Sample from(const TMono8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono16Sample from(const TMono8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono16Sample from(const TStereo8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono16Sample from(const TStereo8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono16Sample from(const TMono16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono16Sample from(const TStereo16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono16Sample from(const TMono24Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono16Sample from(const TStereo24Sample &sample);
|
|
justburner |
9369f1 |
static inline TMono16Sample from(const TMono32FloatSample &sample);
|
|
justburner |
9369f1 |
static inline TMono16Sample from(const TStereo32FloatSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono16Sample operator+(const TMono16Sample &s1,
|
|
Shinya Kitaoka |
120a6e |
const TMono16Sample &s2) {
|
|
Shinya Kitaoka |
120a6e |
TMono16Sample s = s1;
|
|
Shinya Kitaoka |
120a6e |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TStereo16Sample {
|
|
Shinya Kitaoka |
120a6e |
short channel[2]; // l'ordine dei canali e' left,right
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef short ChannelValueType;
|
|
Shinya Kitaoka |
120a6e |
typedef TMono16Sample ChannelSampleType;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStereo16Sample(TINT32 v) {
|
|
Shinya Kitaoka |
120a6e |
channel[0] = (short)(v << 16);
|
|
Shinya Kitaoka |
120a6e |
channel[1] = (short)(v & 0xFFFF);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStereo16Sample(short lchan = 0, short rchan = 0) {
|
|
Shinya Kitaoka |
120a6e |
channel[0] = lchan;
|
|
Shinya Kitaoka |
120a6e |
channel[1] = rchan;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
~TStereo16Sample(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static bool isSampleSigned() { return true; }
|
|
Shinya Kitaoka |
120a6e |
static int getBitPerSample() { return 16; }
|
|
justburner |
9369f1 |
static int getSampleType() { return TSound::INT; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline short getValue(TSound::Channel chan) const {
|
|
Shinya Kitaoka |
120a6e |
assert(chan <= 1);
|
|
Shinya Kitaoka |
120a6e |
return channel[chan];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline void setValue(TSound::Channel chan, short v) {
|
|
Shinya Kitaoka |
120a6e |
assert(chan <= 1);
|
|
Shinya Kitaoka |
120a6e |
channel[chan] = v;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline double getPressure(TSound::Channel chan) const {
|
|
Shinya Kitaoka |
120a6e |
return (getValue(chan));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo16Sample &operator+=(const TStereo16Sample &s) {
|
|
Shinya Kitaoka |
120a6e |
int iLeftVal = channel[0] + s.channel[0];
|
|
Shinya Kitaoka |
120a6e |
int iRightVal = channel[1] + s.channel[1];
|
|
Shinya Kitaoka |
120a6e |
channel[0] = tcrop(iLeftVal, -32768, 32767);
|
|
Shinya Kitaoka |
120a6e |
channel[1] = tcrop(iRightVal, -32768, 32767);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo16Sample &operator*=(double a) {
|
|
Shinya Kitaoka |
120a6e |
int iLeftVal = (int)(a * channel[0]);
|
|
Shinya Kitaoka |
120a6e |
int iRightVal = (int)(a * channel[1]);
|
|
Shinya Kitaoka |
120a6e |
channel[0] = tcrop(iLeftVal, -32768, 32767);
|
|
Shinya Kitaoka |
120a6e |
channel[1] = tcrop(iRightVal, -32768, 32767);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo16Sample operator*(double a) {
|
|
Shinya Kitaoka |
120a6e |
return TStereo16Sample(*this) *= a;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static TStereo16Sample mix(const TStereo16Sample &s1, double a1,
|
|
Shinya Kitaoka |
120a6e |
const TStereo16Sample &s2, double a2) {
|
|
Shinya Kitaoka |
120a6e |
return TStereo16Sample(
|
|
Shinya Kitaoka |
120a6e |
tcrop((int)(s1.channel[0] * a1 + s2.channel[0] * a2), -32768, 32767),
|
|
Shinya Kitaoka |
120a6e |
tcrop((int)(s1.channel[1] * a1 + s2.channel[1] * a2), -32768, 32767));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo16Sample from(const TMono8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo16Sample from(const TMono8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo16Sample from(const TStereo8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo16Sample from(const TStereo8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo16Sample from(const TMono16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo16Sample from(const TStereo16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo16Sample from(const TMono24Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo16Sample from(const TStereo24Sample &sample);
|
|
justburner |
9369f1 |
static inline TStereo16Sample from(const TMono32FloatSample &sample);
|
|
justburner |
9369f1 |
static inline TStereo16Sample from(const TStereo32FloatSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo16Sample operator+(const TStereo16Sample &s1,
|
|
Shinya Kitaoka |
120a6e |
const TStereo16Sample &s2) {
|
|
Shinya Kitaoka |
120a6e |
TStereo16Sample s = s1;
|
|
Shinya Kitaoka |
120a6e |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TMono24Sample {
|
|
justburner |
9369f1 |
UCHAR byte[3]; // LSB first
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef TINT32 ChannelValueType;
|
|
Shinya Kitaoka |
120a6e |
typedef TMono24Sample ChannelSampleType;
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
9369f1 |
TMono24Sample(TINT32 v = 0) { setValue(0, v); }
|
|
Shinya Kitaoka |
120a6e |
~TMono24Sample(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static bool isSampleSigned() { return true; }
|
|
Shinya Kitaoka |
120a6e |
static int getBitPerSample() { return 24; }
|
|
justburner |
9369f1 |
static int getSampleType() { return TSound::INT; }
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
9369f1 |
inline TINT32 getValue(TSound::Channel) const {
|
|
justburner |
9369f1 |
return byte[0] | (byte[1] << 8) | (byte[2] << 16) |
|
|
justburner |
9369f1 |
(byte[2] & 0x80 ? ~0xFFFFFF : 0);
|
|
justburner |
9369f1 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline void setValue(TSound::Channel /*chan*/, TINT32 v) {
|
|
justburner |
9369f1 |
int iVal = tcrop<tint32>(v, -8388608, 8388607);</tint32>
|
|
justburner |
9369f1 |
byte[0] = iVal;
|
|
justburner |
9369f1 |
byte[1] = iVal >> 8;
|
|
justburner |
9369f1 |
byte[2] = iVal >> 16;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline double getPressure(TSound::Channel chan) const {
|
|
Shinya Kitaoka |
120a6e |
return (getValue(chan));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TMono24Sample &operator+=(const TMono24Sample &s) {
|
|
justburner |
9369f1 |
setValue(0, getValue(0) + s.getValue(0));
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TMono24Sample &operator*=(double a) {
|
|
justburner |
9369f1 |
setValue(0, getValue(0) * a);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TMono24Sample operator*(double a) { return TMono24Sample(*this) *= a; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static TMono24Sample mix(const TMono24Sample &s1, double a1,
|
|
Shinya Kitaoka |
120a6e |
const TMono24Sample &s2, double a2) {
|
|
justburner |
9369f1 |
int iVal = s1.getValue(0) * a1 + s2.getValue(0) * a2;
|
|
justburner |
9369f1 |
return TMono24Sample(iVal);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static inline TMono24Sample from(const TMono8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono24Sample from(const TMono8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono24Sample from(const TStereo8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono24Sample from(const TStereo8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono24Sample from(const TMono16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono24Sample from(const TStereo16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono24Sample from(const TMono24Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TMono24Sample from(const TStereo24Sample &sample);
|
|
justburner |
9369f1 |
static inline TMono24Sample from(const TMono32FloatSample &sample);
|
|
justburner |
9369f1 |
static inline TMono24Sample from(const TStereo32FloatSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono24Sample operator+(const TMono24Sample &s1,
|
|
Shinya Kitaoka |
120a6e |
const TMono24Sample &s2) {
|
|
Shinya Kitaoka |
120a6e |
TMono24Sample s = s1;
|
|
Shinya Kitaoka |
120a6e |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TStereo24Sample {
|
|
justburner |
9369f1 |
typedef struct {
|
|
justburner |
9369f1 |
UCHAR byte[3]; // LSB first
|
|
justburner |
9369f1 |
} TSample;
|
|
justburner |
9369f1 |
TSample channel[2]; // l'ordine dei canali e' left,right
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef TINT32 ChannelValueType;
|
|
Shinya Kitaoka |
120a6e |
typedef TMono24Sample ChannelSampleType;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStereo24Sample(TINT32 lchan = 0, TINT32 rchan = 0) {
|
|
justburner |
9369f1 |
setValue(0, lchan);
|
|
justburner |
9369f1 |
setValue(1, rchan);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
~TStereo24Sample(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static bool isSampleSigned() { return true; }
|
|
Shinya Kitaoka |
120a6e |
static int getBitPerSample() { return 24; }
|
|
justburner |
9369f1 |
static int getSampleType() { return TSound::INT; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TINT32 getValue(TSound::Channel chan) const {
|
|
Shinya Kitaoka |
120a6e |
assert(chan <= 1);
|
|
justburner |
9369f1 |
const TSample &s = channel[chan];
|
|
justburner |
9369f1 |
return s.byte[0] | (s.byte[1] << 8) | (s.byte[2] << 16) |
|
|
justburner |
9369f1 |
(s.byte[2] & 0x80 ? ~0xFFFFFF : 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline void setValue(TSound::Channel chan, TINT32 v) {
|
|
Shinya Kitaoka |
120a6e |
assert(chan <= 1);
|
|
justburner |
9369f1 |
int iVal = tcrop<tint32>(v, -8388608, 8388607);</tint32>
|
|
justburner |
9369f1 |
TSample &s = channel[chan];
|
|
justburner |
9369f1 |
s.byte[0] = iVal;
|
|
justburner |
9369f1 |
s.byte[1] = iVal >> 8;
|
|
justburner |
9369f1 |
s.byte[2] = iVal >> 16;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline double getPressure(TSound::Channel chan) const {
|
|
Shinya Kitaoka |
120a6e |
return (getValue(chan));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample &operator+=(const TStereo24Sample &s) {
|
|
justburner |
9369f1 |
setValue(0, getValue(0) + s.getValue(0));
|
|
justburner |
9369f1 |
setValue(1, getValue(1) + s.getValue(1));
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample &operator*=(double a) {
|
|
justburner |
9369f1 |
setValue(0, getValue(0) * a);
|
|
justburner |
9369f1 |
setValue(1, getValue(1) * a);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample operator*(double a) {
|
|
Shinya Kitaoka |
120a6e |
return TStereo24Sample(*this) *= a;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static TStereo24Sample mix(const TStereo24Sample &s1, double a1,
|
|
Shinya Kitaoka |
120a6e |
const TStereo24Sample &s2, double a2) {
|
|
justburner |
9369f1 |
int iValL = s1.getValue(0) * a1 + s2.getValue(0) * a2;
|
|
justburner |
9369f1 |
int iValR = s1.getValue(1) * a1 + s2.getValue(1) * a2;
|
|
justburner |
9369f1 |
return TStereo24Sample(iValL, iValR);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo24Sample from(const TMono8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo24Sample from(const TMono8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo24Sample from(const TStereo8SignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo24Sample from(const TStereo8UnsignedSample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo24Sample from(const TMono16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo24Sample from(const TStereo16Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo24Sample from(const TMono24Sample &sample);
|
|
Shinya Kitaoka |
120a6e |
static inline TStereo24Sample from(const TStereo24Sample &sample);
|
|
justburner |
9369f1 |
static inline TStereo24Sample from(const TMono32FloatSample &sample);
|
|
justburner |
9369f1 |
static inline TStereo24Sample from(const TStereo32FloatSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample operator+(const TStereo24Sample &s1,
|
|
Shinya Kitaoka |
120a6e |
const TStereo24Sample &s2) {
|
|
Shinya Kitaoka |
120a6e |
TStereo24Sample s = s1;
|
|
Shinya Kitaoka |
120a6e |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
9369f1 |
//=========================================================
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
class DVAPI TMono32FloatSample {
|
|
justburner |
9369f1 |
float value;
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
public:
|
|
justburner |
9369f1 |
typedef float ChannelValueType;
|
|
justburner |
9369f1 |
typedef TMono32FloatSample ChannelSampleType;
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
TMono32FloatSample(float v = 0.0f) : value(v) {}
|
|
justburner |
9369f1 |
~TMono32FloatSample(){};
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
static bool isSampleSigned() { return true; }
|
|
justburner |
9369f1 |
static int getBitPerSample() { return 32; }
|
|
justburner |
9369f1 |
static int getSampleType() { return TSound::FLOAT; }
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline float getValue(TSound::Channel) const { return value; }
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline void setValue(TSound::Channel /*chan*/, float v) {
|
|
justburner |
9369f1 |
value = v;
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline double getPressure(TSound::Channel chan) const {
|
|
justburner |
9369f1 |
return (getValue(chan));
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono32FloatSample &operator+=(const TMono32FloatSample &s) {
|
|
justburner |
9369f1 |
value += s.value;
|
|
justburner |
9369f1 |
return *this;
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono32FloatSample &operator*=(double a) {
|
|
justburner |
9369f1 |
value *= a;
|
|
justburner |
9369f1 |
return *this;
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono32FloatSample operator*(double a) { return TMono32FloatSample(*this) *= a; }
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
static TMono32FloatSample mix(const TMono32FloatSample &s1, double a1,
|
|
justburner |
9369f1 |
const TMono32FloatSample &s2, double a2) {
|
|
justburner |
9369f1 |
return TMono32FloatSample(s1.value * a1 + s2.value * a2);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
static inline TMono32FloatSample from(const TMono8UnsignedSample &sample);
|
|
justburner |
9369f1 |
static inline TMono32FloatSample from(const TMono8SignedSample &sample);
|
|
justburner |
9369f1 |
static inline TMono32FloatSample from(const TStereo8SignedSample &sample);
|
|
justburner |
9369f1 |
static inline TMono32FloatSample from(const TStereo8UnsignedSample &sample);
|
|
justburner |
9369f1 |
static inline TMono32FloatSample from(const TMono16Sample &sample);
|
|
justburner |
9369f1 |
static inline TMono32FloatSample from(const TStereo16Sample &sample);
|
|
justburner |
9369f1 |
static inline TMono32FloatSample from(const TMono24Sample &sample);
|
|
justburner |
9369f1 |
static inline TMono32FloatSample from(const TStereo24Sample &sample);
|
|
justburner |
9369f1 |
static inline TMono32FloatSample from(const TMono32FloatSample &sample);
|
|
justburner |
9369f1 |
static inline TMono32FloatSample from(const TStereo32FloatSample &sample);
|
|
justburner |
9369f1 |
};
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono32FloatSample operator+(const TMono32FloatSample &s1,
|
|
justburner |
9369f1 |
const TMono32FloatSample &s2) {
|
|
justburner |
9369f1 |
TMono32FloatSample s = s1;
|
|
justburner |
9369f1 |
return s += s2;
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//=========================================================
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
class DVAPI TStereo32FloatSample {
|
|
justburner |
9369f1 |
float channel[2]; // l'ordine dei canali e' left,right
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
public:
|
|
justburner |
9369f1 |
typedef float ChannelValueType;
|
|
justburner |
9369f1 |
typedef TMono32FloatSample ChannelSampleType;
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
TStereo32FloatSample(float lchan = 0.0f, float rchan = 0.0f) {
|
|
justburner |
9369f1 |
channel[0] = lchan;
|
|
justburner |
9369f1 |
channel[1] = rchan;
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
~TStereo32FloatSample(){};
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
static bool isSampleSigned() { return true; }
|
|
justburner |
9369f1 |
static int getBitPerSample() { return 32; }
|
|
justburner |
9369f1 |
static int getSampleType() { return TSound::FLOAT; }
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline float getValue(TSound::Channel chan) const {
|
|
justburner |
9369f1 |
assert(chan <= 1);
|
|
justburner |
9369f1 |
return channel[chan];
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline void setValue(TSound::Channel chan, float v) {
|
|
justburner |
9369f1 |
assert(chan <= 1);
|
|
justburner |
9369f1 |
channel[chan] = v;
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline double getPressure(TSound::Channel chan) const {
|
|
justburner |
9369f1 |
return (getValue(chan));
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo32FloatSample &operator+=(const TStereo32FloatSample &s) {
|
|
justburner |
9369f1 |
channel[0] += s.channel[0];
|
|
justburner |
9369f1 |
channel[1] += s.channel[1];
|
|
justburner |
9369f1 |
return *this;
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo32FloatSample &operator*=(double a) {
|
|
justburner |
9369f1 |
channel[0] *= a;
|
|
justburner |
9369f1 |
channel[1] *= a;
|
|
justburner |
9369f1 |
return *this;
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo32FloatSample operator*(double a) {
|
|
justburner |
9369f1 |
return TStereo32FloatSample(*this) *= a;
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
static TStereo32FloatSample mix(const TStereo32FloatSample &s1, double a1,
|
|
justburner |
9369f1 |
const TStereo32FloatSample &s2, double a2) {
|
|
justburner |
9369f1 |
return TStereo32FloatSample(s1.channel[0] * a1 + s2.channel[0] * a2,
|
|
justburner |
9369f1 |
s1.channel[1] * a1 + s2.channel[1] * a2);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
static inline TStereo32FloatSample from(const TMono8UnsignedSample &sample);
|
|
justburner |
9369f1 |
static inline TStereo32FloatSample from(const TMono8SignedSample &sample);
|
|
justburner |
9369f1 |
static inline TStereo32FloatSample from(const TStereo8SignedSample &sample);
|
|
justburner |
9369f1 |
static inline TStereo32FloatSample from(const TStereo8UnsignedSample &sample);
|
|
justburner |
9369f1 |
static inline TStereo32FloatSample from(const TMono16Sample &sample);
|
|
justburner |
9369f1 |
static inline TStereo32FloatSample from(const TStereo16Sample &sample);
|
|
justburner |
9369f1 |
static inline TStereo32FloatSample from(const TMono24Sample &sample);
|
|
justburner |
9369f1 |
static inline TStereo32FloatSample from(const TStereo24Sample &sample);
|
|
justburner |
9369f1 |
static inline TStereo32FloatSample from(const TMono32FloatSample &sample);
|
|
justburner |
9369f1 |
static inline TStereo32FloatSample from(const TStereo32FloatSample &sample);
|
|
justburner |
9369f1 |
};
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo32FloatSample operator+(const TStereo32FloatSample &s1,
|
|
justburner |
9369f1 |
const TStereo32FloatSample &s2) {
|
|
justburner |
9369f1 |
TStereo32FloatSample s = s1;
|
|
justburner |
9369f1 |
return s += s2;
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8SignedSample TMono8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono8SignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8SignedSample TMono8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono8UnsignedSample &sample) {
|
|
justburner |
9369f1 |
return TMono8SignedSample(sample.getValue(TSound::MONO) - 128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8SignedSample TMono8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo8SignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return TMono8SignedSample(
|
|
Shinya Kitaoka |
120a6e |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8SignedSample TMono8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo8UnsignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return TMono8SignedSample(
|
|
Shinya Kitaoka |
120a6e |
((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 1) -
|
|
Shinya Kitaoka |
120a6e |
128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8SignedSample TMono8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono16Sample &sample) {
|
|
justburner |
9369f1 |
int val = (sample.getValue(TSound::MONO) >> 8);
|
|
Shinya Kitaoka |
120a6e |
return TMono8SignedSample(val);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8SignedSample TMono8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo16Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return TMono8SignedSample(
|
|
Shinya Kitaoka |
120a6e |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 9);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8SignedSample TMono8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono24Sample &sample) {
|
|
justburner |
9369f1 |
int val = (sample.getValue(TSound::MONO) >> 16);
|
|
Shinya Kitaoka |
120a6e |
return TMono8SignedSample(val);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8SignedSample TMono8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo24Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int val =
|
|
Shinya Kitaoka |
120a6e |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 17;
|
|
Shinya Kitaoka |
120a6e |
return TMono8SignedSample(val);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono8SignedSample TMono8SignedSample::from(
|
|
justburner |
9369f1 |
const TMono32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fval = sample.getValue(TSound::MONO) * 128.0;
|
|
justburner |
9369f1 |
return TMono8SignedSample(tcrop((int)fval, -128, 127));
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono8SignedSample TMono8SignedSample::from(
|
|
justburner |
9369f1 |
const TStereo32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fval =
|
|
justburner |
9369f1 |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) * 64.0;
|
|
justburner |
9369f1 |
return TMono8SignedSample(tcrop((int)fval, -128, 127));
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8UnsignedSample TMono8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono8SignedSample &sample) {
|
|
justburner |
9369f1 |
return TMono8UnsignedSample(sample.getValue(TSound::MONO) + 128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8UnsignedSample TMono8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono8UnsignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8UnsignedSample TMono8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo8SignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int iVal = sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT);
|
|
Shinya Kitaoka |
120a6e |
return TMono8UnsignedSample((iVal >> 1) + 128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8UnsignedSample TMono8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo8UnsignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return TMono8UnsignedSample(
|
|
Shinya Kitaoka |
120a6e |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8UnsignedSample TMono8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono16Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return TMono8UnsignedSample((sample.getValue(TSound::MONO) >> 8) + 128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8UnsignedSample TMono8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo16Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return TMono8UnsignedSample(
|
|
Shinya Kitaoka |
120a6e |
((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 9) +
|
|
Shinya Kitaoka |
120a6e |
128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8UnsignedSample TMono8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono24Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return TMono8UnsignedSample(
|
|
Shinya Kitaoka |
120a6e |
(unsigned char)(sample.getValue(TSound::MONO) >> 16) + 128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8UnsignedSample TMono8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo24Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return TMono8UnsignedSample(
|
|
Shinya Kitaoka |
120a6e |
(unsigned char)((sample.getValue(TSound::LEFT) +
|
|
Shinya Kitaoka |
120a6e |
sample.getValue(TSound::RIGHT)) >>
|
|
Shinya Kitaoka |
120a6e |
17) +
|
|
Shinya Kitaoka |
120a6e |
128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono8UnsignedSample TMono8UnsignedSample::from(
|
|
justburner |
9369f1 |
const TMono32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fval = sample.getValue(TSound::MONO) * 128.0;
|
|
justburner |
9369f1 |
return TMono8UnsignedSample(tcrop((int)fval + 128, 0, 255));
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono8UnsignedSample TMono8UnsignedSample::from(
|
|
justburner |
9369f1 |
const TStereo32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fval =
|
|
justburner |
9369f1 |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) * 64.0;
|
|
justburner |
9369f1 |
return TMono8UnsignedSample(tcrop((int)fval + 128, 0, 255));
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8SignedSample TStereo8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono8UnsignedSample &sample) {
|
|
justburner |
9369f1 |
int srcval = sample.getValue(TSound::MONO) - 128;
|
|
Shinya Kitaoka |
120a6e |
return TStereo8SignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8SignedSample TStereo8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono8SignedSample &sample) {
|
|
justburner |
9369f1 |
int srcval = sample.getValue(TSound::MONO);
|
|
Shinya Kitaoka |
120a6e |
return TStereo8SignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8SignedSample TStereo8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo8SignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8SignedSample TStereo8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo8UnsignedSample &sample) {
|
|
justburner |
9369f1 |
int srcvalL = sample.getValue(TSound::LEFT) - 128;
|
|
justburner |
9369f1 |
int srcvalR = sample.getValue(TSound::RIGHT) - 128;
|
|
justburner |
9369f1 |
return TStereo8SignedSample(srcvalL, srcvalR);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8SignedSample TStereo8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono16Sample &sample) {
|
|
justburner |
9369f1 |
int srcval = sample.getValue(TSound::MONO) >> 8;
|
|
Shinya Kitaoka |
120a6e |
return TStereo8SignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8SignedSample TStereo8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo16Sample &sample) {
|
|
justburner |
9369f1 |
int srcvalL = sample.getValue(TSound::LEFT) >> 8;
|
|
justburner |
9369f1 |
int srcvalR = sample.getValue(TSound::RIGHT) >> 8;
|
|
justburner |
9369f1 |
return TStereo8SignedSample(srcvalL, srcvalR);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8SignedSample TStereo8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono24Sample &sample) {
|
|
justburner |
9369f1 |
int srcval = sample.getValue(TSound::MONO) >> 16;
|
|
Shinya Kitaoka |
120a6e |
return TStereo8SignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8SignedSample TStereo8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo24Sample &sample) {
|
|
justburner |
9369f1 |
int srcvalL = sample.getValue(TSound::LEFT) >> 16;
|
|
justburner |
9369f1 |
int srcvalR = sample.getValue(TSound::RIGHT) >> 16;
|
|
justburner |
9369f1 |
return TStereo8SignedSample(srcvalL, srcvalR);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo8SignedSample TStereo8SignedSample::from(
|
|
justburner |
9369f1 |
const TMono32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fval = sample.getValue(TSound::MONO) * 128.0;
|
|
justburner |
9369f1 |
int srcval = tcrop((int)fval, -128, 127);
|
|
Shinya Kitaoka |
120a6e |
return TStereo8SignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo8SignedSample TStereo8SignedSample::from(
|
|
justburner |
9369f1 |
const TStereo32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fvalL = sample.getValue(TSound::LEFT) * 128.0;
|
|
justburner |
9369f1 |
float fvalR = sample.getValue(TSound::RIGHT) * 128.0;
|
|
justburner |
9369f1 |
return TStereo8SignedSample(tcrop((int)fvalL, -128, 127),
|
|
justburner |
9369f1 |
tcrop((int)fvalR, -128, 127));
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono8UnsignedSample &sample) {
|
|
justburner |
9369f1 |
int srcval = sample.getValue(TSound::MONO);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return TStereo8UnsignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono8SignedSample &sample) {
|
|
justburner |
9369f1 |
int srcval = sample.getValue(TSound::MONO) + 128;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return TStereo8UnsignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo8UnsignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo8SignedSample &sample) {
|
|
justburner |
9369f1 |
int srcvalL = sample.getValue(TSound::LEFT) + 128;
|
|
justburner |
9369f1 |
int srcvalR = sample.getValue(TSound::RIGHT) + 128;
|
|
justburner |
9369f1 |
return TStereo8UnsignedSample(srcvalL, srcvalR);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono16Sample &sample) {
|
|
justburner |
9369f1 |
int srcval = (sample.getValue(TSound::MONO) >> 8) + 128;
|
|
Shinya Kitaoka |
120a6e |
return TStereo8UnsignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo16Sample &sample) {
|
|
justburner |
9369f1 |
int srcvalL = (sample.getValue(TSound::LEFT) >> 8) + 128;
|
|
justburner |
9369f1 |
int srcvalR = (sample.getValue(TSound::RIGHT) >> 8) + 128;
|
|
justburner |
9369f1 |
return TStereo8UnsignedSample(srcvalL, srcvalR);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono24Sample &sample) {
|
|
justburner |
9369f1 |
int srcval = (sample.getValue(TSound::MONO) >> 16) + 128;
|
|
Shinya Kitaoka |
120a6e |
return TStereo8UnsignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo24Sample &sample) {
|
|
justburner |
9369f1 |
int srcvalL = (sample.getValue(TSound::LEFT) >> 16) + 128;
|
|
justburner |
9369f1 |
int srcvalR = (sample.getValue(TSound::RIGHT) >> 16) + 128;
|
|
justburner |
9369f1 |
return TStereo8UnsignedSample(srcvalL, srcvalR);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(
|
|
justburner |
9369f1 |
const TMono32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fval = sample.getValue(TSound::MONO) * 128.0;
|
|
justburner |
9369f1 |
int srcval = tcrop((int)fval + 128, 0, 255);
|
|
Shinya Kitaoka |
120a6e |
return TStereo8UnsignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(
|
|
justburner |
9369f1 |
const TStereo32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fvalL = sample.getValue(TSound::LEFT) * 128.0;
|
|
justburner |
9369f1 |
float fvalR = sample.getValue(TSound::RIGHT) * 128.0;
|
|
justburner |
9369f1 |
return TStereo8UnsignedSample(tcrop((int)fvalL + 128, 0, 255),
|
|
justburner |
9369f1 |
tcrop((int)fvalR + 128, 0, 255));
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono16Sample TMono16Sample::from(const TMono8UnsignedSample &sample) {
|
|
justburner |
9369f1 |
return TMono16Sample((sample.getValue(TSound::MONO) - 128) << 8);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono16Sample TMono16Sample::from(const TMono8SignedSample &sample) {
|
|
justburner |
9369f1 |
return TMono16Sample(sample.getValue(TSound::MONO) << 8);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono16Sample TMono16Sample::from(const TStereo8SignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return TMono16Sample(
|
|
Shinya Kitaoka |
120a6e |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) << 7);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono16Sample TMono16Sample::from(const TStereo8UnsignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return TMono16Sample(
|
|
Shinya Kitaoka |
120a6e |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT) - 256)
|
|
Shinya Kitaoka |
120a6e |
<< 7);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono16Sample TMono16Sample::from(const TMono16Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono16Sample TMono16Sample::from(const TStereo16Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return TMono16Sample(
|
|
Shinya Kitaoka |
120a6e |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono16Sample TMono16Sample::from(const TMono24Sample &sample) {
|
|
justburner |
9369f1 |
int srcval = (sample.getValue(TSound::MONO) >> 8);
|
|
Shinya Kitaoka |
120a6e |
return TMono16Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono16Sample TMono16Sample::from(const TStereo24Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval =
|
|
Shinya Kitaoka |
120a6e |
((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 9);
|
|
Shinya Kitaoka |
120a6e |
return TMono16Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono16Sample TMono16Sample::from(const TMono32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fval = sample.getValue(TSound::MONO) * 32768.0;
|
|
justburner |
9369f1 |
return TMono16Sample(tcrop((int)fval, -32768, 32767));
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono16Sample TMono16Sample::from(const TStereo32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fval =
|
|
justburner |
9369f1 |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) *
|
|
justburner |
9369f1 |
16384.0;
|
|
justburner |
9369f1 |
return TMono16Sample(tcrop((int)fval, -32768, 32767));
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo16Sample TStereo16Sample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono8UnsignedSample &sample) {
|
|
justburner |
9369f1 |
int srcval = (sample.getValue(TSound::MONO) - 128) << 8;
|
|
Shinya Kitaoka |
120a6e |
return TStereo16Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo16Sample TStereo16Sample::from(const TMono8SignedSample &sample) {
|
|
justburner |
9369f1 |
int srcval = sample.getValue(TSound::MONO) << 8;
|
|
Shinya Kitaoka |
120a6e |
return TStereo16Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo16Sample TStereo16Sample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo8SignedSample &sample) {
|
|
justburner |
9369f1 |
int srcvalL = sample.getValue(TSound::LEFT) << 8;
|
|
justburner |
9369f1 |
int srcvalR = sample.getValue(TSound::RIGHT) << 8;
|
|
justburner |
9369f1 |
return TStereo16Sample(srcvalL, srcvalR);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo16Sample TStereo16Sample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo8UnsignedSample &sample) {
|
|
justburner |
9369f1 |
int srcvalL = (sample.getValue(TSound::LEFT) - 128) << 8;
|
|
justburner |
9369f1 |
int srcvalR = (sample.getValue(TSound::RIGHT) - 128) << 8;
|
|
justburner |
9369f1 |
return TStereo16Sample(srcvalL, srcvalR);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo16Sample TStereo16Sample::from(const TMono16Sample &sample) {
|
|
justburner |
9369f1 |
int srcval = sample.getValue(TSound::MONO);
|
|
Shinya Kitaoka |
120a6e |
return TStereo16Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo16Sample TStereo16Sample::from(const TStereo16Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo16Sample TStereo16Sample::from(const TMono24Sample &sample) {
|
|
justburner |
9369f1 |
int srcval = (sample.getValue(TSound::MONO) >> 8);
|
|
Shinya Kitaoka |
120a6e |
return TStereo16Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo16Sample TStereo16Sample::from(const TStereo24Sample &sample) {
|
|
justburner |
9369f1 |
int srcvalL = sample.getValue(TSound::LEFT) >> 8;
|
|
justburner |
9369f1 |
int srcvalR = sample.getValue(TSound::RIGHT) >> 8;
|
|
justburner |
9369f1 |
return TStereo16Sample(srcvalL, srcvalR);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo16Sample TStereo16Sample::from(const TMono32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fval = sample.getValue(TSound::MONO) * 32768.0;
|
|
justburner |
9369f1 |
int srcval = tcrop((int)fval, -32768, 32767);
|
|
Shinya Kitaoka |
120a6e |
return TStereo16Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo16Sample TStereo16Sample::from(const TStereo32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fvalL = sample.getValue(TSound::LEFT) * 32768.0;
|
|
justburner |
9369f1 |
float fvalR = sample.getValue(TSound::RIGHT) * 32768.0;
|
|
justburner |
9369f1 |
return TStereo16Sample(tcrop((int)fvalL, -32768, 32767),
|
|
justburner |
9369f1 |
tcrop((int)fvalR, -32768, 32767));
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono24Sample TMono24Sample::from(const TMono8UnsignedSample &sample) {
|
|
justburner |
9369f1 |
int srcval = (sample.getValue(TSound::MONO) - 128) << 16;
|
|
Shinya Kitaoka |
120a6e |
return TMono24Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono24Sample TMono24Sample::from(const TMono8SignedSample &sample) {
|
|
justburner |
9369f1 |
int srcval = sample.getValue(TSound::MONO) << 16;
|
|
Shinya Kitaoka |
120a6e |
return TMono24Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono24Sample TMono24Sample::from(const TStereo8SignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = (sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT))
|
|
Shinya Kitaoka |
120a6e |
<< 15;
|
|
Shinya Kitaoka |
120a6e |
return TMono24Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono24Sample TMono24Sample::from(const TStereo8UnsignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval =
|
|
Shinya Kitaoka |
120a6e |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT) - 256)
|
|
Shinya Kitaoka |
120a6e |
<< 15;
|
|
Shinya Kitaoka |
120a6e |
return TMono24Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono24Sample TMono24Sample::from(const TMono16Sample &sample) {
|
|
justburner |
9369f1 |
int srcval = sample.getValue(TSound::MONO) << 8;
|
|
Shinya Kitaoka |
120a6e |
return TMono24Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono24Sample TMono24Sample::from(const TStereo16Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = (sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT))
|
|
Shinya Kitaoka |
120a6e |
<< 7;
|
|
Shinya Kitaoka |
120a6e |
return TMono24Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono24Sample TMono24Sample::from(const TMono24Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono24Sample TMono24Sample::from(const TStereo24Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval =
|
|
Shinya Kitaoka |
120a6e |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 1;
|
|
Shinya Kitaoka |
120a6e |
return TMono24Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono24Sample TMono24Sample::from(const TMono32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fval = sample.getValue(TSound::MONO) * 8388608.0;
|
|
justburner |
9369f1 |
return TMono24Sample(tcrop((int)fval, -8388608, 8388607));
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono24Sample TMono24Sample::from(const TStereo32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fval =
|
|
justburner |
9369f1 |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) *
|
|
justburner |
9369f1 |
4194304.0;
|
|
justburner |
9369f1 |
return TMono24Sample(tcrop((int)fval, -8388608, 8388607));
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample TStereo24Sample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono8UnsignedSample &sample) {
|
|
justburner |
9369f1 |
int srcval = (sample.getValue(TSound::MONO) - 128) << 16;
|
|
Shinya Kitaoka |
120a6e |
return TStereo24Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample TStereo24Sample::from(const TMono8SignedSample &sample) {
|
|
justburner |
9369f1 |
int srcval = sample.getValue(TSound::MONO) << 16;
|
|
Shinya Kitaoka |
120a6e |
return TStereo24Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample TStereo24Sample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo8SignedSample &sample) {
|
|
justburner |
9369f1 |
int srcvalL = sample.getValue(TSound::LEFT) << 16;
|
|
justburner |
9369f1 |
int srcvalR = sample.getValue(TSound::RIGHT) << 16;
|
|
justburner |
9369f1 |
return TStereo24Sample(srcvalL, srcvalR);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample TStereo24Sample::from(
|
|
Shinya Kitaoka |
120a6e |
const TStereo8UnsignedSample &sample) {
|
|
justburner |
9369f1 |
int srcvalL = (sample.getValue(TSound::LEFT) - 128) << 16;
|
|
justburner |
9369f1 |
int srcvalR = (sample.getValue(TSound::RIGHT) - 128) << 16;
|
|
justburner |
9369f1 |
return TStereo24Sample(srcvalL, srcvalR);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample TStereo24Sample::from(const TMono16Sample &sample) {
|
|
justburner |
9369f1 |
int srcval = sample.getValue(TSound::MONO) << 8;
|
|
Shinya Kitaoka |
120a6e |
return TStereo24Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample TStereo24Sample::from(const TStereo16Sample &sample) {
|
|
justburner |
9369f1 |
int srcvalL = sample.getValue(TSound::LEFT) << 8;
|
|
justburner |
9369f1 |
int srcvalR = sample.getValue(TSound::RIGHT) << 8;
|
|
justburner |
9369f1 |
return TStereo24Sample(srcvalL, srcvalR);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample TStereo24Sample::from(const TMono24Sample &sample) {
|
|
justburner |
9369f1 |
int srcval = sample.getValue(TSound::MONO);
|
|
Shinya Kitaoka |
120a6e |
return TStereo24Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample TStereo24Sample::from(const TStereo24Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo24Sample TStereo24Sample::from(const TMono32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fval = sample.getValue(TSound::MONO) * 8388608.0;
|
|
justburner |
9369f1 |
int srcval = tcrop((int)fval, -8388608, 8388607);
|
|
justburner |
9369f1 |
return TStereo24Sample(srcval, srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo24Sample TStereo24Sample::from(const TStereo32FloatSample &sample) {
|
|
justburner |
9369f1 |
float fvalL = sample.getValue(TSound::LEFT) * 8388608.0;
|
|
justburner |
9369f1 |
float fvalR = sample.getValue(TSound::RIGHT) * 8388608.0;
|
|
justburner |
9369f1 |
return TStereo24Sample(tcrop((int)fvalL, -8388608, 8388607),
|
|
justburner |
9369f1 |
tcrop((int)fvalR, -8388608, 8388607));
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//==============================================================================
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono32FloatSample TMono32FloatSample::from(const TMono8UnsignedSample &sample) {
|
|
justburner |
9369f1 |
float srcval = (sample.getValue(TSound::MONO) - 128) / 128.0;
|
|
justburner |
9369f1 |
return TMono32FloatSample(srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono32FloatSample TMono32FloatSample::from(const TMono8SignedSample &sample) {
|
|
justburner |
9369f1 |
float srcval = sample.getValue(TSound::MONO) / 128.0;
|
|
justburner |
9369f1 |
return TMono32FloatSample(srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono32FloatSample TMono32FloatSample::from(const TStereo8SignedSample &sample) {
|
|
justburner |
9369f1 |
float srcval =
|
|
justburner |
9369f1 |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) / 256.0;
|
|
justburner |
9369f1 |
return TMono32FloatSample(srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono32FloatSample TMono32FloatSample::from(const TStereo8UnsignedSample &sample) {
|
|
justburner |
9369f1 |
float srcval =
|
|
justburner |
9369f1 |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT) - 256) /
|
|
justburner |
9369f1 |
256.0;
|
|
justburner |
9369f1 |
return TMono32FloatSample(srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono32FloatSample TMono32FloatSample::from(const TMono16Sample &sample) {
|
|
justburner |
9369f1 |
float srcval = sample.getValue(TSound::MONO) / 32768.0;
|
|
justburner |
9369f1 |
return TMono32FloatSample(srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono32FloatSample TMono32FloatSample::from(const TStereo16Sample &sample) {
|
|
justburner |
9369f1 |
float srcval =
|
|
justburner |
9369f1 |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) /
|
|
justburner |
9369f1 |
65536.0;
|
|
justburner |
9369f1 |
return TMono32FloatSample(srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono32FloatSample TMono32FloatSample::from(const TMono24Sample &sample) {
|
|
justburner |
9369f1 |
float srcval = sample.getValue(TSound::MONO) / 8388608.0;
|
|
justburner |
9369f1 |
return TMono32FloatSample(srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono32FloatSample TMono32FloatSample::from(const TStereo24Sample &sample) {
|
|
justburner |
9369f1 |
float srcval =
|
|
justburner |
9369f1 |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) /
|
|
justburner |
9369f1 |
16777216.0;
|
|
justburner |
9369f1 |
return TMono32FloatSample(srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono32FloatSample TMono32FloatSample::from(const TMono32FloatSample &sample) {
|
|
justburner |
9369f1 |
return sample;
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TMono32FloatSample TMono32FloatSample::from(const TStereo32FloatSample &sample) {
|
|
justburner |
9369f1 |
float srcval =
|
|
justburner |
9369f1 |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) / 2.0;
|
|
justburner |
9369f1 |
return TMono32FloatSample(srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//==============================================================================
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo32FloatSample TStereo32FloatSample::from(
|
|
justburner |
9369f1 |
const TMono8UnsignedSample &sample) {
|
|
justburner |
9369f1 |
float srcval = (sample.getValue(TSound::MONO) - 128) / 128.0;
|
|
justburner |
9369f1 |
return TStereo32FloatSample(srcval, srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo32FloatSample TStereo32FloatSample::from(const TMono8SignedSample &sample) {
|
|
justburner |
9369f1 |
float srcval = sample.getValue(TSound::MONO) / 128.0;
|
|
justburner |
9369f1 |
return TStereo32FloatSample(srcval, srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo32FloatSample TStereo32FloatSample::from(
|
|
justburner |
9369f1 |
const TStereo8SignedSample &sample) {
|
|
justburner |
9369f1 |
float srcvalL = sample.getValue(TSound::LEFT) / 128.0;
|
|
justburner |
9369f1 |
float srcvalR = sample.getValue(TSound::RIGHT) / 128.0;
|
|
justburner |
9369f1 |
return TStereo32FloatSample(srcvalL, srcvalR);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo32FloatSample TStereo32FloatSample::from(
|
|
justburner |
9369f1 |
const TStereo8UnsignedSample &sample) {
|
|
justburner |
9369f1 |
float srcvalL = (sample.getValue(TSound::LEFT) - 128) / 128.0;
|
|
justburner |
9369f1 |
float srcvalR = (sample.getValue(TSound::RIGHT) - 128) / 128.0;
|
|
justburner |
9369f1 |
return TStereo32FloatSample(srcvalL, srcvalR);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo32FloatSample TStereo32FloatSample::from(const TMono16Sample &sample) {
|
|
justburner |
9369f1 |
float srcval = sample.getValue(TSound::MONO) / 32768.0;
|
|
justburner |
9369f1 |
return TStereo32FloatSample(srcval, srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo32FloatSample TStereo32FloatSample::from(const TStereo16Sample &sample) {
|
|
justburner |
9369f1 |
float srcvalL = sample.getValue(TSound::LEFT) / 32768.0;
|
|
justburner |
9369f1 |
float srcvalR = sample.getValue(TSound::RIGHT) / 32768.0;
|
|
justburner |
9369f1 |
return TStereo32FloatSample(srcvalL, srcvalR);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo32FloatSample TStereo32FloatSample::from(const TMono24Sample &sample) {
|
|
justburner |
9369f1 |
float srcval = sample.getValue(TSound::MONO) / 8388608.0;
|
|
justburner |
9369f1 |
return TStereo32FloatSample(srcval, srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo32FloatSample TStereo32FloatSample::from(const TStereo24Sample &sample) {
|
|
justburner |
9369f1 |
float srcvalL = sample.getValue(TSound::LEFT) / 8388608.0;
|
|
justburner |
9369f1 |
float srcvalR = sample.getValue(TSound::RIGHT) / 8388608.0;
|
|
justburner |
9369f1 |
return TStereo32FloatSample(srcvalL, srcvalR);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo32FloatSample TStereo32FloatSample::from(const TMono32FloatSample &sample) {
|
|
justburner |
9369f1 |
float srcval = sample.getValue(TSound::MONO);
|
|
justburner |
9369f1 |
return TStereo32FloatSample(srcval, srcval);
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
//------------------------------------------------------------------------------
|
|
justburner |
9369f1 |
|
|
justburner |
9369f1 |
inline TStereo32FloatSample TStereo32FloatSample::from(const TStereo32FloatSample &sample) {
|
|
justburner |
9369f1 |
return sample;
|
|
justburner |
9369f1 |
}
|
|
justburner |
9369f1 |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|