|
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;
|
|
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; }
|
|
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);
|
|
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; }
|
|
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);
|
|
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; }
|
|
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);
|
|
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; }
|
|
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);
|
|
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; }
|
|
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);
|
|
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; }
|
|
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);
|
|
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 {
|
|
Shinya Kitaoka |
120a6e |
TINT32 value;
|
|
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 |
TMono24Sample(TINT32 v = 0) : value(tcrop<tint32>(v, -8388608, 8388607)) {}</tint32>
|
|
Shinya Kitaoka |
120a6e |
~TMono24Sample(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
static bool isSampleSigned() { return true; }
|
|
Shinya Kitaoka |
120a6e |
static int getBitPerSample() { return 24; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TINT32 getValue(TSound::Channel) const { return value; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline void setValue(TSound::Channel /*chan*/, TINT32 v) {
|
|
Shinya Kitaoka |
120a6e |
value = tcrop<tint32>(v, -8388608, 8388607);</tint32>
|
|
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) {
|
|
Shinya Kitaoka |
120a6e |
int iVal = value + s.value;
|
|
Shinya Kitaoka |
120a6e |
value = tcrop(iVal, -8388608, 8388607);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TMono24Sample &operator*=(double a) {
|
|
Shinya Kitaoka |
120a6e |
int iVal = (int)(value * a);
|
|
Shinya Kitaoka |
120a6e |
value = tcrop(iVal, -8388608, 8388607);
|
|
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) {
|
|
Shinya Kitaoka |
120a6e |
return TMono24Sample(
|
|
Shinya Kitaoka |
120a6e |
tcrop((int)(s1.value * a1 + s2.value * a2), -8388608, 8388607));
|
|
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);
|
|
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 {
|
|
Shinya Kitaoka |
120a6e |
TINT32 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) {
|
|
Shinya Kitaoka |
120a6e |
channel[0] = tcrop<tint32>(lchan, -8388608, 8388607);</tint32>
|
|
Shinya Kitaoka |
120a6e |
channel[1] = tcrop<tint32>(rchan, -8388608, 8388607);</tint32>
|
|
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; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TINT32 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, TINT32 v) {
|
|
Shinya Kitaoka |
120a6e |
assert(chan <= 1);
|
|
Shinya Kitaoka |
120a6e |
channel[chan] = tcrop<tint32>(v, -8388608, 8388607);</tint32>
|
|
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) {
|
|
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, -8388608, 8388607);
|
|
Shinya Kitaoka |
120a6e |
channel[1] = tcrop(iRightVal, -8388608, 8388607);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample &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, -8388608, 8388607);
|
|
Shinya Kitaoka |
120a6e |
channel[1] = tcrop(iRightVal, -8388608, 8388607);
|
|
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) {
|
|
Shinya Kitaoka |
120a6e |
return TStereo24Sample(tcrop((int)(s1.channel[0] * a1 + s2.channel[0] * a2),
|
|
Shinya Kitaoka |
120a6e |
-8388608, 8388607),
|
|
Shinya Kitaoka |
120a6e |
tcrop((int)(s1.channel[1] * a1 + s2.channel[1] * a2),
|
|
Shinya Kitaoka |
120a6e |
-8388608, 8388607));
|
|
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);
|
|
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 |
|
|
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) {
|
|
Shinya Kitaoka |
120a6e |
return TMono8SignedSample(sample.getValue(TSound::LEFT) - 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) {
|
|
Shinya Kitaoka |
120a6e |
int val = (sample.getValue(TSound::LEFT) >> 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) {
|
|
Shinya Kitaoka |
120a6e |
int val = (sample.getValue(TSound::LEFT) >> 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 |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono8UnsignedSample TMono8UnsignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono8SignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return TMono8UnsignedSample(sample.getValue(TSound::LEFT) + 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 |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo8SignedSample TStereo8SignedSample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono8UnsignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = sample.getValue(TSound::LEFT) - 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = sample.getValue(TSound::LEFT);
|
|
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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval =
|
|
Shinya Kitaoka |
120a6e |
((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 1) -
|
|
Shinya Kitaoka |
120a6e |
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 TMono16Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = sample.getValue(TSound::LEFT) >> 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval =
|
|
Shinya Kitaoka |
120a6e |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 9;
|
|
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 TMono24Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = sample.getValue(TSound::LEFT) >> 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval =
|
|
Shinya Kitaoka |
120a6e |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 17;
|
|
Shinya Kitaoka |
120a6e |
return TStereo8SignedSample(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 TMono8UnsignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = sample.getValue(TSound::LEFT);
|
|
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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = sample.getValue(TSound::LEFT) + 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval =
|
|
Shinya Kitaoka |
120a6e |
((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 1) +
|
|
Shinya Kitaoka |
120a6e |
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 TMono16Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = (sample.getValue(TSound::LEFT) >> 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval =
|
|
Shinya Kitaoka |
120a6e |
((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 9) +
|
|
Shinya Kitaoka |
120a6e |
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 TMono24Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = (sample.getValue(TSound::LEFT) >> 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval =
|
|
Shinya Kitaoka |
120a6e |
((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 17) +
|
|
Shinya Kitaoka |
120a6e |
128;
|
|
Shinya Kitaoka |
120a6e |
return TStereo8UnsignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono16Sample TMono16Sample::from(const TMono8UnsignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return TMono16Sample((sample.getValue(TSound::LEFT) - 128) << 8);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono16Sample TMono16Sample::from(const TMono8SignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
return TMono16Sample(sample.getValue(TSound::LEFT) << 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = (sample.getValue(TSound::LEFT) >> 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 |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo16Sample TStereo16Sample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono8UnsignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = (sample.getValue(TSound::LEFT) - 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = sample.getValue(TSound::LEFT) << 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = (sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT))
|
|
Shinya Kitaoka |
120a6e |
<< 7;
|
|
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 TStereo8UnsignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval =
|
|
Shinya Kitaoka |
120a6e |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT) - 256)
|
|
Shinya Kitaoka |
120a6e |
<< 7;
|
|
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 TMono16Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = sample.getValue(TSound::LEFT);
|
|
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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = (sample.getValue(TSound::LEFT) >> 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval =
|
|
Shinya Kitaoka |
120a6e |
((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 9);
|
|
Shinya Kitaoka |
120a6e |
return TStereo16Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TMono24Sample TMono24Sample::from(const TMono8UnsignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = (sample.getValue(TSound::LEFT) - 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = sample.getValue(TSound::LEFT) << 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = sample.getValue(TSound::LEFT) << 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 |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample TStereo24Sample::from(
|
|
Shinya Kitaoka |
120a6e |
const TMono8UnsignedSample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = (sample.getValue(TSound::LEFT) - 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = sample.getValue(TSound::LEFT) << 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = (sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT))
|
|
Shinya Kitaoka |
120a6e |
<< 15;
|
|
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 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 TStereo24Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TStereo24Sample TStereo24Sample::from(const TMono16Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = sample.getValue(TSound::LEFT) << 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) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = (sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT))
|
|
Shinya Kitaoka |
120a6e |
<< 7;
|
|
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 TMono24Sample &sample) {
|
|
Shinya Kitaoka |
120a6e |
int srcval = sample.getValue(TSound::LEFT);
|
|
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 |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|