|
Toshihiro Shimizu |
890ddd |
|
|
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 |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TMono8SignedSample
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
SCHAR value;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
typedef SCHAR ChannelValueType;
|
|
Toshihiro Shimizu |
890ddd |
typedef TMono8SignedSample ChannelSampleType;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TMono8SignedSample(SCHAR v = 0) : value(v) {}
|
|
Toshihiro Shimizu |
890ddd |
~TMono8SignedSample(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static bool isSampleSigned() { return true; }
|
|
Toshihiro Shimizu |
890ddd |
static int getBitPerSample() { return 8; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline SCHAR getValue(TSound::Channel /*chan*/) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline void setValue(TSound::Channel /*chan*/, SCHAR v)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
value = v;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline double getPressure(TSound::Channel chan) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (getValue(chan));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8SignedSample &operator+=(const TMono8SignedSample &s)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int ival = value + s.value;
|
|
Toshihiro Shimizu |
890ddd |
value = tcrop(ival, (int)-128, (int)127);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8SignedSample &operator*=(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int ival = (int)(value * a);
|
|
Toshihiro Shimizu |
890ddd |
value = tcrop(ival, (int)-128, (int)127);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8SignedSample operator*(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (*this) *= a;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static TMono8SignedSample mix(
|
|
Toshihiro Shimizu |
890ddd |
const TMono8SignedSample &s1, double a1,
|
|
Toshihiro Shimizu |
890ddd |
const TMono8SignedSample &s2, double a2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono8SignedSample(tcrop((int)(s1.value * a1 + s2.value * a2), -128, 127));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8SignedSample from(const TMono8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8SignedSample from(const TMono8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8SignedSample from(const TStereo8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8SignedSample from(const TStereo8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8SignedSample from(const TMono16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8SignedSample from(const TStereo16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8SignedSample from(const TMono24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8SignedSample from(const TStereo24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8SignedSample operator+(
|
|
Toshihiro Shimizu |
890ddd |
const TMono8SignedSample &s1,
|
|
Toshihiro Shimizu |
890ddd |
const TMono8SignedSample &s2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TMono8SignedSample s = s1;
|
|
Toshihiro Shimizu |
890ddd |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TMono8UnsignedSample
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
UCHAR value;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
typedef UCHAR ChannelValueType;
|
|
Toshihiro Shimizu |
890ddd |
typedef TMono8UnsignedSample ChannelSampleType;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TMono8UnsignedSample(UCHAR v = 127) : value(v) {}
|
|
Toshihiro Shimizu |
890ddd |
~TMono8UnsignedSample(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static bool isSampleSigned() { return false; }
|
|
Toshihiro Shimizu |
890ddd |
static int getBitPerSample() { return 8; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline UCHAR getValue(TSound::Channel /*chan*/) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline void setValue(TSound::Channel /*chan*/, UCHAR v)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
value = v;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline double getPressure(TSound::Channel chan) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (getValue(chan) - 128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8UnsignedSample &operator+=(const TMono8UnsignedSample &s)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
value = tcrop((int)(value - 128 + s.value), 0, 255);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8UnsignedSample &operator*=(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
value = tcrop((int)((value - 128) * a + 128), 0, 255);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8UnsignedSample operator*(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int ival = tcrop((int)((value - 128) * a + 128), 0, 255);
|
|
Toshihiro Shimizu |
890ddd |
return TMono8UnsignedSample(ival);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static TMono8UnsignedSample mix(
|
|
Toshihiro Shimizu |
890ddd |
const TMono8UnsignedSample &s1, double a1,
|
|
Toshihiro Shimizu |
890ddd |
const TMono8UnsignedSample &s2, double a2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono8UnsignedSample(
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)((s1.value - 128) * a1 + (s2.value - 128) * a2 + 128), 0, 255));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8UnsignedSample from(const TMono8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8UnsignedSample from(const TMono8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8UnsignedSample from(const TStereo8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8UnsignedSample from(const TStereo8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8UnsignedSample from(const TMono16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8UnsignedSample from(const TStereo16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8UnsignedSample from(const TMono24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono8UnsignedSample from(const TStereo24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8UnsignedSample operator+(
|
|
Toshihiro Shimizu |
890ddd |
const TMono8UnsignedSample &s1,
|
|
Toshihiro Shimizu |
890ddd |
const TMono8UnsignedSample &s2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TMono8UnsignedSample s = s1;
|
|
Toshihiro Shimizu |
890ddd |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TStereo8SignedSample
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
SCHAR channel[2]; // l'ordine dei canali e' left,right
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
typedef SCHAR ChannelValueType;
|
|
Toshihiro Shimizu |
890ddd |
typedef TMono8SignedSample ChannelSampleType;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TStereo8SignedSample(short v)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = v >> 8;
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = v & 0xFF;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TStereo8SignedSample(SCHAR lchan = 0, SCHAR rchan = 0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = lchan;
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = rchan;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~TStereo8SignedSample(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static bool isSampleSigned() { return true; }
|
|
Toshihiro Shimizu |
890ddd |
static int getBitPerSample() { return 8; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline SCHAR getValue(TSound::Channel chan) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(chan <= 1);
|
|
Toshihiro Shimizu |
890ddd |
return channel[chan];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline void setValue(TSound::Channel chan, SCHAR v)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(chan <= 1);
|
|
Toshihiro Shimizu |
890ddd |
channel[chan] = v;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline double getPressure(TSound::Channel chan) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (getValue(chan));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8SignedSample &operator+=(const TStereo8SignedSample &s)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int iLeftVal = channel[0] + s.channel[0];
|
|
Toshihiro Shimizu |
890ddd |
int iRightVal = channel[1] + s.channel[1];
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = tcrop(iLeftVal, (int)-128, (int)127);
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = tcrop(iRightVal, (int)-128, (int)127);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8SignedSample &operator*=(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int iLeftVal = (int)(a * channel[0]);
|
|
Toshihiro Shimizu |
890ddd |
int iRightVal = (int)(a * channel[1]);
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = tcrop(iLeftVal, (int)-128, (int)127);
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = tcrop(iRightVal, (int)-128, (int)127);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8SignedSample operator*(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8SignedSample(*this) *= a;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static TStereo8SignedSample mix(
|
|
Toshihiro Shimizu |
890ddd |
const TStereo8SignedSample &s1, double a1,
|
|
Toshihiro Shimizu |
890ddd |
const TStereo8SignedSample &s2, double a2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8SignedSample(
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)(s1.channel[0] * a1 + s2.channel[0] * a2), -128, 127),
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)(s1.channel[1] * a1 + s2.channel[1] * a2), -128, 127));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8SignedSample from(const TMono8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8SignedSample from(const TMono8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8SignedSample from(const TStereo8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8SignedSample from(const TStereo8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8SignedSample from(const TMono16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8SignedSample from(const TStereo16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8SignedSample from(const TMono24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8SignedSample from(const TStereo24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8SignedSample operator+(
|
|
Toshihiro Shimizu |
890ddd |
const TStereo8SignedSample &s1,
|
|
Toshihiro Shimizu |
890ddd |
const TStereo8SignedSample &s2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TStereo8SignedSample s = s1;
|
|
Toshihiro Shimizu |
890ddd |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TStereo8UnsignedSample
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
UCHAR channel[2]; // l'ordine dei canali e' left,right
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
typedef UCHAR ChannelValueType;
|
|
Toshihiro Shimizu |
890ddd |
typedef TMono8UnsignedSample ChannelSampleType;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TStereo8UnsignedSample(short v)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = v >> 8;
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = v & 0xFF;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TStereo8UnsignedSample(UCHAR lchan = 127, UCHAR rchan = 127)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = lchan;
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = rchan;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~TStereo8UnsignedSample(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static bool isSampleSigned() { return false; }
|
|
Toshihiro Shimizu |
890ddd |
static int getBitPerSample() { return 8; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline UCHAR getValue(TSound::Channel chan) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(chan <= 1);
|
|
Toshihiro Shimizu |
890ddd |
return channel[chan];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline void setValue(TSound::Channel chan, UCHAR v)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(chan <= 1);
|
|
Toshihiro Shimizu |
890ddd |
channel[chan] = v;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline double getPressure(TSound::Channel chan) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (((int)getValue(chan)) - 128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8UnsignedSample &operator+=(const TStereo8UnsignedSample &s)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int iLeftVal = channel[0] + s.channel[0] - 128;
|
|
Toshihiro Shimizu |
890ddd |
int iRightVal = channel[1] + s.channel[1] - 128;
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = tcrop(iLeftVal, 0, 255);
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = tcrop(iRightVal, 0, 255);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8UnsignedSample &operator*=(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int iLeftVal = (int)(a * (channel[0] - 128));
|
|
Toshihiro Shimizu |
890ddd |
int iRightVal = (int)(a * (channel[1] - 128));
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = tcrop(iLeftVal + 128, 0, 255);
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = tcrop(iRightVal + 128, 0, 255);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8UnsignedSample operator*(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8UnsignedSample(*this) *= a;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static TStereo8UnsignedSample mix(
|
|
Toshihiro Shimizu |
890ddd |
const TStereo8UnsignedSample &s1, double a1,
|
|
Toshihiro Shimizu |
890ddd |
const TStereo8UnsignedSample &s2, double a2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8UnsignedSample(
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)((s1.channel[0] - 128) * a1 + (s2.channel[0] - 128) * a2 + 128), 0, 255),
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)((s1.channel[1] - 128) * a1 + (s2.channel[1] - 128) * a2 + 128), 0, 255));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8UnsignedSample from(const TMono8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8UnsignedSample from(const TMono8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8UnsignedSample from(const TStereo8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8UnsignedSample from(const TStereo8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8UnsignedSample from(const TMono16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8UnsignedSample from(const TStereo16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8UnsignedSample from(const TMono24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo8UnsignedSample from(const TStereo24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8UnsignedSample operator+(
|
|
Toshihiro Shimizu |
890ddd |
const TStereo8UnsignedSample &s1,
|
|
Toshihiro Shimizu |
890ddd |
const TStereo8UnsignedSample &s2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TStereo8UnsignedSample s = s1;
|
|
Toshihiro Shimizu |
890ddd |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TMono16Sample
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
short value;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
typedef short ChannelValueType;
|
|
Toshihiro Shimizu |
890ddd |
typedef TMono16Sample ChannelSampleType;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TMono16Sample(short v = 0) : value(v) {}
|
|
Toshihiro Shimizu |
890ddd |
~TMono16Sample(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static bool isSampleSigned() { return true; }
|
|
Toshihiro Shimizu |
890ddd |
static int getBitPerSample() { return 16; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline short getValue(TSound::Channel) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline void setValue(TSound::Channel /*chan*/, short v)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
value = v;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline double getPressure(TSound::Channel chan) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (getValue(chan));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono16Sample &operator+=(const TMono16Sample &s)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int iVal = value + s.value;
|
|
Toshihiro Shimizu |
890ddd |
value = tcrop(iVal, -32768, 32767);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono16Sample &operator*=(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int iVal = (int)(value * a);
|
|
Toshihiro Shimizu |
890ddd |
value = tcrop(iVal, -32768, 32767);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono16Sample operator*(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono16Sample(*this) *= a;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static TMono16Sample mix(
|
|
Toshihiro Shimizu |
890ddd |
const TMono16Sample &s1, double a1,
|
|
Toshihiro Shimizu |
890ddd |
const TMono16Sample &s2, double a2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono16Sample(tcrop((int)(s1.value * a1 + s2.value * a2), -32768, 32767));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono16Sample from(const TMono8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono16Sample from(const TMono8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono16Sample from(const TStereo8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono16Sample from(const TStereo8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono16Sample from(const TMono16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono16Sample from(const TStereo16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono16Sample from(const TMono24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono16Sample from(const TStereo24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono16Sample operator+(
|
|
Toshihiro Shimizu |
890ddd |
const TMono16Sample &s1,
|
|
Toshihiro Shimizu |
890ddd |
const TMono16Sample &s2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TMono16Sample s = s1;
|
|
Toshihiro Shimizu |
890ddd |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TStereo16Sample
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
short channel[2]; // l'ordine dei canali e' left,right
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
typedef short ChannelValueType;
|
|
Toshihiro Shimizu |
890ddd |
typedef TMono16Sample ChannelSampleType;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TStereo16Sample(TINT32 v)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = (short)(v << 16);
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = (short)(v & 0xFFFF);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TStereo16Sample(short lchan = 0, short rchan = 0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = lchan;
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = rchan;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~TStereo16Sample(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static bool isSampleSigned() { return true; }
|
|
Toshihiro Shimizu |
890ddd |
static int getBitPerSample() { return 16; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline short getValue(TSound::Channel chan) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(chan <= 1);
|
|
Toshihiro Shimizu |
890ddd |
return channel[chan];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline void setValue(TSound::Channel chan, short v)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(chan <= 1);
|
|
Toshihiro Shimizu |
890ddd |
channel[chan] = v;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline double getPressure(TSound::Channel chan) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (getValue(chan));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo16Sample &operator+=(const TStereo16Sample &s)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int iLeftVal = channel[0] + s.channel[0];
|
|
Toshihiro Shimizu |
890ddd |
int iRightVal = channel[1] + s.channel[1];
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = tcrop(iLeftVal, -32768, 32767);
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = tcrop(iRightVal, -32768, 32767);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo16Sample &operator*=(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int iLeftVal = (int)(a * channel[0]);
|
|
Toshihiro Shimizu |
890ddd |
int iRightVal = (int)(a * channel[1]);
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = tcrop(iLeftVal, -32768, 32767);
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = tcrop(iRightVal, -32768, 32767);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo16Sample operator*(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TStereo16Sample(*this) *= a;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static TStereo16Sample mix(
|
|
Toshihiro Shimizu |
890ddd |
const TStereo16Sample &s1, double a1,
|
|
Toshihiro Shimizu |
890ddd |
const TStereo16Sample &s2, double a2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TStereo16Sample(
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)(s1.channel[0] * a1 + s2.channel[0] * a2), -32768, 32767),
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)(s1.channel[1] * a1 + s2.channel[1] * a2), -32768, 32767));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo16Sample from(const TMono8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo16Sample from(const TMono8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo16Sample from(const TStereo8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo16Sample from(const TStereo8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo16Sample from(const TMono16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo16Sample from(const TStereo16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo16Sample from(const TMono24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo16Sample from(const TStereo24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo16Sample operator+(
|
|
Toshihiro Shimizu |
890ddd |
const TStereo16Sample &s1,
|
|
Toshihiro Shimizu |
890ddd |
const TStereo16Sample &s2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TStereo16Sample s = s1;
|
|
Toshihiro Shimizu |
890ddd |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TMono24Sample
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TINT32 value;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
typedef TINT32 ChannelValueType;
|
|
Toshihiro Shimizu |
890ddd |
typedef TMono24Sample ChannelSampleType;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TMono24Sample(TINT32 v = 0) : value(tcrop<tint32>(v, -8388608, 8388607)) {}</tint32>
|
|
Toshihiro Shimizu |
890ddd |
~TMono24Sample(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static bool isSampleSigned() { return true; }
|
|
Toshihiro Shimizu |
890ddd |
static int getBitPerSample() { return 24; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TINT32 getValue(TSound::Channel) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline void setValue(TSound::Channel /*chan*/, TINT32 v)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
value = tcrop<tint32>(v, -8388608, 8388607);</tint32>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline double getPressure(TSound::Channel chan) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (getValue(chan));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono24Sample &operator+=(const TMono24Sample &s)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int iVal = value + s.value;
|
|
Toshihiro Shimizu |
890ddd |
value = tcrop(iVal, -8388608, 8388607);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono24Sample &operator*=(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int iVal = (int)(value * a);
|
|
Toshihiro Shimizu |
890ddd |
value = tcrop(iVal, -8388608, 8388607);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono24Sample operator*(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono24Sample(*this) *= a;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static TMono24Sample mix(
|
|
Toshihiro Shimizu |
890ddd |
const TMono24Sample &s1, double a1,
|
|
Toshihiro Shimizu |
890ddd |
const TMono24Sample &s2, double a2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono24Sample(tcrop((int)(s1.value * a1 + s2.value * a2), -8388608, 8388607));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono24Sample from(const TMono8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono24Sample from(const TMono8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono24Sample from(const TStereo8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono24Sample from(const TStereo8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono24Sample from(const TMono16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono24Sample from(const TStereo16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono24Sample from(const TMono24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TMono24Sample from(const TStereo24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono24Sample operator+(
|
|
Toshihiro Shimizu |
890ddd |
const TMono24Sample &s1,
|
|
Toshihiro Shimizu |
890ddd |
const TMono24Sample &s2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TMono24Sample s = s1;
|
|
Toshihiro Shimizu |
890ddd |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TStereo24Sample
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TINT32 channel[2]; // l'ordine dei canali e' left,right
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
typedef TINT32 ChannelValueType;
|
|
Toshihiro Shimizu |
890ddd |
typedef TMono24Sample ChannelSampleType;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TStereo24Sample(TINT32 lchan = 0, TINT32 rchan = 0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = tcrop<tint32>(lchan, -8388608, 8388607);</tint32>
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = tcrop<tint32>(rchan, -8388608, 8388607);</tint32>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~TStereo24Sample(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static bool isSampleSigned() { return true; }
|
|
Toshihiro Shimizu |
890ddd |
static int getBitPerSample() { return 24; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TINT32 getValue(TSound::Channel chan) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(chan <= 1);
|
|
Toshihiro Shimizu |
890ddd |
return channel[chan];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline void setValue(TSound::Channel chan, TINT32 v)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(chan <= 1);
|
|
Toshihiro Shimizu |
890ddd |
channel[chan] = tcrop<tint32>(v, -8388608, 8388607);</tint32>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline double getPressure(TSound::Channel chan) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (getValue(chan));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo24Sample &operator+=(const TStereo24Sample &s)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int iLeftVal = channel[0] + s.channel[0];
|
|
Toshihiro Shimizu |
890ddd |
int iRightVal = channel[1] + s.channel[1];
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = tcrop(iLeftVal, -8388608, 8388607);
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = tcrop(iRightVal, -8388608, 8388607);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo24Sample &operator*=(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int iLeftVal = (int)(a * channel[0]);
|
|
Toshihiro Shimizu |
890ddd |
int iRightVal = (int)(a * channel[1]);
|
|
Toshihiro Shimizu |
890ddd |
channel[0] = tcrop(iLeftVal, -8388608, 8388607);
|
|
Toshihiro Shimizu |
890ddd |
channel[1] = tcrop(iRightVal, -8388608, 8388607);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo24Sample operator*(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TStereo24Sample(*this) *= a;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static TStereo24Sample mix(
|
|
Toshihiro Shimizu |
890ddd |
const TStereo24Sample &s1, double a1,
|
|
Toshihiro Shimizu |
890ddd |
const TStereo24Sample &s2, double a2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TStereo24Sample(
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)(s1.channel[0] * a1 + s2.channel[0] * a2), -8388608, 8388607),
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)(s1.channel[1] * a1 + s2.channel[1] * a2), -8388608, 8388607));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo24Sample from(const TMono8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo24Sample from(const TMono8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo24Sample from(const TStereo8SignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo24Sample from(const TStereo8UnsignedSample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo24Sample from(const TMono16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo24Sample from(const TStereo16Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo24Sample from(const TMono24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
static inline TStereo24Sample from(const TStereo24Sample &sample);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo24Sample operator+(
|
|
Toshihiro Shimizu |
890ddd |
const TStereo24Sample &s1,
|
|
Toshihiro Shimizu |
890ddd |
const TStereo24Sample &s2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TStereo24Sample s = s1;
|
|
Toshihiro Shimizu |
890ddd |
return s += s2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8SignedSample TMono8SignedSample::from(const TMono8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8SignedSample TMono8SignedSample::from(const TMono8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono8SignedSample(sample.getValue(TSound::LEFT) - 128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8SignedSample TMono8SignedSample::from(const TStereo8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono8SignedSample((sample.getValue(TSound::LEFT) +
|
|
Toshihiro Shimizu |
890ddd |
sample.getValue(TSound::RIGHT)) >>
|
|
Toshihiro Shimizu |
890ddd |
1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8SignedSample TMono8SignedSample::from(const TStereo8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono8SignedSample(((sample.getValue(TSound::LEFT) +
|
|
Toshihiro Shimizu |
890ddd |
sample.getValue(TSound::RIGHT)) >>
|
|
Toshihiro Shimizu |
890ddd |
1) -
|
|
Toshihiro Shimizu |
890ddd |
128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8SignedSample TMono8SignedSample::from(const TMono16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int val = (sample.getValue(TSound::LEFT) >> 8);
|
|
Toshihiro Shimizu |
890ddd |
return TMono8SignedSample(val);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8SignedSample TMono8SignedSample::from(const TStereo16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono8SignedSample((sample.getValue(TSound::LEFT) +
|
|
Toshihiro Shimizu |
890ddd |
sample.getValue(TSound::RIGHT)) >>
|
|
Toshihiro Shimizu |
890ddd |
9);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8SignedSample TMono8SignedSample::from(const TMono24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int val = (sample.getValue(TSound::LEFT) >> 16);
|
|
Toshihiro Shimizu |
890ddd |
return TMono8SignedSample(val);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8SignedSample TMono8SignedSample::from(const TStereo24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int val = (sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 17;
|
|
Toshihiro Shimizu |
890ddd |
return TMono8SignedSample(val);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8UnsignedSample TMono8UnsignedSample::from(const TMono8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono8UnsignedSample(sample.getValue(TSound::LEFT) + 128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8UnsignedSample TMono8UnsignedSample::from(const TMono8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8UnsignedSample TMono8UnsignedSample::from(const TStereo8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int iVal = sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT);
|
|
Toshihiro Shimizu |
890ddd |
return TMono8UnsignedSample((iVal >> 1) + 128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8UnsignedSample TMono8UnsignedSample::from(const TStereo8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono8UnsignedSample((sample.getValue(TSound::LEFT) +
|
|
Toshihiro Shimizu |
890ddd |
sample.getValue(TSound::RIGHT)) >>
|
|
Toshihiro Shimizu |
890ddd |
1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8UnsignedSample TMono8UnsignedSample::from(const TMono16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono8UnsignedSample((sample.getValue(TSound::MONO) >> 8) + 128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8UnsignedSample TMono8UnsignedSample::from(const TStereo16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono8UnsignedSample(((sample.getValue(TSound::LEFT) +
|
|
Toshihiro Shimizu |
890ddd |
sample.getValue(TSound::RIGHT)) >>
|
|
Toshihiro Shimizu |
890ddd |
9) +
|
|
Toshihiro Shimizu |
890ddd |
128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8UnsignedSample TMono8UnsignedSample::from(const TMono24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono8UnsignedSample((unsigned char)(sample.getValue(TSound::MONO) >> 16) + 128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono8UnsignedSample TMono8UnsignedSample::from(const TStereo24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono8UnsignedSample((unsigned char)((sample.getValue(TSound::LEFT) +
|
|
Toshihiro Shimizu |
890ddd |
sample.getValue(TSound::RIGHT)) >>
|
|
Toshihiro Shimizu |
890ddd |
17) +
|
|
Toshihiro Shimizu |
890ddd |
128);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8SignedSample TStereo8SignedSample::from(const TMono8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = sample.getValue(TSound::LEFT) - 128;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8SignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8SignedSample TStereo8SignedSample::from(const TMono8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = sample.getValue(TSound::LEFT);
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8SignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8SignedSample TStereo8SignedSample::from(const TStereo8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8SignedSample TStereo8SignedSample::from(const TStereo8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 1) - 128;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8SignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8SignedSample TStereo8SignedSample::from(const TMono16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = sample.getValue(TSound::LEFT) >> 8;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8SignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8SignedSample TStereo8SignedSample::from(const TStereo16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 9;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8SignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8SignedSample TStereo8SignedSample::from(const TMono24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = sample.getValue(TSound::LEFT) >> 16;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8SignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8SignedSample TStereo8SignedSample::from(const TStereo24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 17;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8SignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(const TMono8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = sample.getValue(TSound::LEFT);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8UnsignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(const TMono8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = sample.getValue(TSound::LEFT) + 128;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8UnsignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(const TStereo8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(const TStereo8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 1) + 128;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8UnsignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(const TMono16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = (sample.getValue(TSound::LEFT) >> 8) + 128;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8UnsignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(const TStereo16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 9) + 128;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8UnsignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(const TMono24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = (sample.getValue(TSound::LEFT) >> 16) + 128;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8UnsignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo8UnsignedSample TStereo8UnsignedSample::from(const TStereo24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 17) + 128;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo8UnsignedSample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono16Sample TMono16Sample::from(const TMono8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono16Sample((sample.getValue(TSound::LEFT) - 128) << 8);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono16Sample TMono16Sample::from(const TMono8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono16Sample(sample.getValue(TSound::LEFT) << 8);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono16Sample TMono16Sample::from(const TStereo8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono16Sample((sample.getValue(TSound::LEFT) +
|
|
Toshihiro Shimizu |
890ddd |
sample.getValue(TSound::RIGHT))
|
|
Toshihiro Shimizu |
890ddd |
<< 7);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono16Sample TMono16Sample::from(const TStereo8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono16Sample((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT) - 256) << 7);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono16Sample TMono16Sample::from(const TMono16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono16Sample TMono16Sample::from(const TStereo16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TMono16Sample((sample.getValue(TSound::LEFT) +
|
|
Toshihiro Shimizu |
890ddd |
sample.getValue(TSound::RIGHT)) >>
|
|
Toshihiro Shimizu |
890ddd |
1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono16Sample TMono16Sample::from(const TMono24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = (sample.getValue(TSound::LEFT) >> 8);
|
|
Toshihiro Shimizu |
890ddd |
return TMono16Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono16Sample TMono16Sample::from(const TStereo24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 9);
|
|
Toshihiro Shimizu |
890ddd |
return TMono16Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo16Sample TStereo16Sample::from(const TMono8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = (sample.getValue(TSound::LEFT) - 128) << 8;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo16Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo16Sample TStereo16Sample::from(const TMono8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = sample.getValue(TSound::LEFT) << 8;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo16Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo16Sample TStereo16Sample::from(const TStereo8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) << 7;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo16Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo16Sample TStereo16Sample::from(const TStereo8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT) - 256) << 7;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo16Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo16Sample TStereo16Sample::from(const TMono16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = sample.getValue(TSound::LEFT);
|
|
Toshihiro Shimizu |
890ddd |
return TStereo16Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo16Sample TStereo16Sample::from(const TStereo16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo16Sample TStereo16Sample::from(const TMono24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = (sample.getValue(TSound::LEFT) >> 8);
|
|
Toshihiro Shimizu |
890ddd |
return TStereo16Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo16Sample TStereo16Sample::from(const TStereo24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
((sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 9);
|
|
Toshihiro Shimizu |
890ddd |
return TStereo16Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono24Sample TMono24Sample::from(const TMono8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = (sample.getValue(TSound::LEFT) - 128) << 16;
|
|
Toshihiro Shimizu |
890ddd |
return TMono24Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono24Sample TMono24Sample::from(const TMono8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = sample.getValue(TSound::LEFT) << 16;
|
|
Toshihiro Shimizu |
890ddd |
return TMono24Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono24Sample TMono24Sample::from(const TStereo8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) << 15;
|
|
Toshihiro Shimizu |
890ddd |
return TMono24Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono24Sample TMono24Sample::from(const TStereo8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT) - 256) << 15;
|
|
Toshihiro Shimizu |
890ddd |
return TMono24Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono24Sample TMono24Sample::from(const TMono16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = sample.getValue(TSound::LEFT) << 8;
|
|
Toshihiro Shimizu |
890ddd |
return TMono24Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono24Sample TMono24Sample::from(const TStereo16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) << 7;
|
|
Toshihiro Shimizu |
890ddd |
return TMono24Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono24Sample TMono24Sample::from(const TMono24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TMono24Sample TMono24Sample::from(const TStereo24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) >> 1;
|
|
Toshihiro Shimizu |
890ddd |
return TMono24Sample(srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo24Sample TStereo24Sample::from(const TMono8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = (sample.getValue(TSound::LEFT) - 128) << 16;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo24Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo24Sample TStereo24Sample::from(const TMono8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = sample.getValue(TSound::LEFT) << 16;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo24Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo24Sample TStereo24Sample::from(const TStereo8SignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) << 15;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo24Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo24Sample TStereo24Sample::from(const TStereo8UnsignedSample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT) - 256) << 15;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo24Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo24Sample TStereo24Sample::from(const TMono16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = sample.getValue(TSound::LEFT) << 8;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo24Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo24Sample TStereo24Sample::from(const TStereo16Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval =
|
|
Toshihiro Shimizu |
890ddd |
(sample.getValue(TSound::LEFT) + sample.getValue(TSound::RIGHT)) << 7;
|
|
Toshihiro Shimizu |
890ddd |
return TStereo24Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo24Sample TStereo24Sample::from(const TMono24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int srcval = sample.getValue(TSound::LEFT);
|
|
Toshihiro Shimizu |
890ddd |
return TStereo24Sample(srcval, srcval);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TStereo24Sample TStereo24Sample::from(const TStereo24Sample &sample)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return sample;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|