|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TSOUND_T__INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define TSOUND_T__INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tsoundsample.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 |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
d1f6c4 |
class DVAPI TSoundTrackT final : public TSoundTrack {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef T SampleType;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TSoundTrackT(TUINT32 sampleRate, int channelCount, TINT32 sampleCount)
|
|
Shinya Kitaoka |
120a6e |
: TSoundTrack(sampleRate, T::getBitPerSample(), channelCount, sizeof(T),
|
|
Shinya Kitaoka |
120a6e |
sampleCount, T::isSampleSigned()) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TSoundTrackT(TUINT32 sampleRate, int channelCount, TINT32 sampleCount,
|
|
Shinya Kitaoka |
120a6e |
T *buffer, TSoundTrackT<t> *parent)</t>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
: TSoundTrack(sampleRate, T::getBitPerSample(), channelCount, sizeof(T),
|
|
Shinya Kitaoka |
120a6e |
sampleCount, reinterpret_cast<uchar *="">(buffer), parent) {}</uchar>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
~TSoundTrackT(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
bool isSampleSigned() const override { return T::isSampleSigned(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! Returns the const samples array
|
|
Shinya Kitaoka |
120a6e |
const T *samples() const { return reinterpret_cast<t *="">(m_buffer); }</t>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! Returns the samples array
|
|
Shinya Kitaoka |
120a6e |
T *samples() { return reinterpret_cast<t *="">(m_buffer); }</t>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! Returns a soundtrack whom is a clone of the object
|
|
Shinya Kitaoka |
473e70 |
TSoundTrackP clone() const override {
|
|
Shinya Kitaoka |
120a6e |
TSoundTrackP dst = TSoundTrack::create(getFormat(), m_sampleCount);
|
|
Shinya Kitaoka |
120a6e |
TSoundTrackP src(const_cast<tsoundtrack *="">((const TSoundTrack *)this));</tsoundtrack>
|
|
Shinya Kitaoka |
120a6e |
dst->copy(src, (TINT32)0);
|
|
Shinya Kitaoka |
120a6e |
return dst;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! Extract the subtrack in the samples range [s0,s1] given in samples
|
|
Shinya Kitaoka |
473e70 |
TSoundTrackP extract(TINT32 s0, TINT32 s1) override {
|
|
Shinya Kitaoka |
120a6e |
if (!m_buffer || s0 > s1) return TSoundTrackP();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// addRef();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TINT32 ss0, ss1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ss0 = tcrop<tint32>(s0, (TINT32)0, getSampleCount() - 1);</tint32>
|
|
Shinya Kitaoka |
120a6e |
ss1 = tcrop<tint32>(s1, (TINT32)0, getSampleCount() - 1);</tint32>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return TSoundTrackP(new TSoundTrackT<t>(</t>
|
|
Shinya Kitaoka |
120a6e |
getSampleRate(), getChannelCount(), ss1 - ss0 + 1,
|
|
Shinya Kitaoka |
120a6e |
(T *)(m_buffer + (long)(ss0 * getSampleSize())), this));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns a soundtrack whom is a clone of the object for the spicified channel
|
|
Shinya Kitaoka |
120a6e |
A clone means that it's an object who lives indipendently from the other
|
|
Shinya Kitaoka |
120a6e |
from which it's created.It hasn't reference to the object.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
473e70 |
TSoundTrackP clone(TSound::Channel chan) const override {
|
|
Shinya Kitaoka |
120a6e |
if (getChannelCount() == 1)
|
|
Shinya Kitaoka |
120a6e |
return clone();
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
typedef typename T::ChannelSampleType TCST;
|
|
Shinya Kitaoka |
120a6e |
TSoundTrackT<tcst> *dst =</tcst>
|
|
Shinya Kitaoka |
120a6e |
new TSoundTrackT<tcst>(m_sampleRate, 1, getSampleCount());</tcst>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
const T *sample = samples();
|
|
Shinya Kitaoka |
120a6e |
const T *endSample = sample + getSampleCount();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TCST *dstSample = dst->samples();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
while (sample < endSample) {
|
|
Shinya Kitaoka |
120a6e |
*dstSample++ = sample->getValue(chan);
|
|
Shinya Kitaoka |
120a6e |
sample++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return dst;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! Copies from sample dst_s0 of object the samples of the soundtrack src
|
|
Shinya Kitaoka |
473e70 |
void copy(const TSoundTrackP &src, TINT32 dst_s0) override {
|
|
Shinya Kitaoka |
120a6e |
TSoundTrackT<t> *srcT = dynamic_cast<tsoundtrackt<t> *>(src.getPointer());</tsoundtrackt<t></t>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!srcT)
|
|
Shinya Kitaoka |
120a6e |
throw(
|
|
Shinya Kitaoka |
120a6e |
TException("Unable to copy from a track whose format is different"));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
T *srcSample = srcT->samples();
|
|
Shinya Kitaoka |
120a6e |
T *srcEndSample = srcT->samples() + srcT->getSampleCount();
|
|
Shinya Kitaoka |
120a6e |
T *dstEndSample = samples() + getSampleCount();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TINT32 ss0 = tcrop<tint32>(dst_s0, (TINT32)0, getSampleCount() - (TINT32)1);</tint32>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
T *dstSample = samples() + ss0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
while (srcSample < srcEndSample && dstSample < dstEndSample)
|
|
Shinya Kitaoka |
120a6e |
*dstSample++ = *srcSample++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
5b7b9f |
//----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
5b7b9f |
//! Applies a trasformation (echo, reverb, ect) to the object and returns the
|
|
shun-iwasawa |
5b7b9f |
//! transformed soundtrack
|
|
MichaĆ Janiszewski |
d37dbb |
TSoundTrackP apply(TSoundTransform *transform) override;
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//! Returns the pressure of the sample s about the channel chan
|
|
Shinya Kitaoka |
473e70 |
double getPressure(TINT32 s, TSound::Channel chan) const override {
|
|
Shinya Kitaoka |
120a6e |
assert(s >= 0 && s < getSampleCount());
|
|
Shinya Kitaoka |
120a6e |
assert(m_buffer);
|
|
Shinya Kitaoka |
120a6e |
const T *sample = samples() + s;
|
|
Shinya Kitaoka |
120a6e |
assert(sample);
|
|
Shinya Kitaoka |
120a6e |
return sample->getPressure(chan);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//! Returns the soundtrack pressure max and min values in the given sample
|
|
Shinya Kitaoka |
120a6e |
//! range and channel
|
|
Shinya Kitaoka |
120a6e |
void getMinMaxPressure(TINT32 s0, TINT32 s1, TSound::Channel chan,
|
|
Shinya Kitaoka |
473e70 |
double &min, double &max) const override {
|
|
Shinya Kitaoka |
120a6e |
TINT32 sampleCount = getSampleCount();
|
|
Shinya Kitaoka |
120a6e |
if (sampleCount <= 0) {
|
|
Shinya Kitaoka |
120a6e |
min = 0;
|
|
Shinya Kitaoka |
120a6e |
max = -1;
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(s1 >= s0);
|
|
Shinya Kitaoka |
120a6e |
TINT32 ss0, ss1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ss0 = tcrop<tint32>(s0, (TINT32)0, sampleCount - (TINT32)1);</tint32>
|
|
Shinya Kitaoka |
120a6e |
ss1 = tcrop<tint32>(s1, (TINT32)0, sampleCount - (TINT32)1);</tint32>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(ss1 >= ss0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (s0 == s1) {
|
|
Shinya Kitaoka |
120a6e |
min = max = getPressure(s0, chan);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const T *sample = samples() + ss0;
|
|
Shinya Kitaoka |
120a6e |
assert(sample);
|
|
Shinya Kitaoka |
120a6e |
min = max = sample->getPressure(chan);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const T *endSample = sample + (ss1 - ss0 + 1);
|
|
Shinya Kitaoka |
120a6e |
++sample;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
while (sample < endSample) {
|
|
Shinya Kitaoka |
120a6e |
double value = sample->getPressure(chan);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (max < value) max = value;
|
|
Shinya Kitaoka |
120a6e |
if (min > value) min = value;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
++sample;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//! Returns the soundtrack pressure max value in the given sample range and
|
|
Shinya Kitaoka |
120a6e |
//! channel
|
|
Shinya Kitaoka |
38fd86 |
double getMaxPressure(TINT32 s0, TINT32 s1,
|
|
Shinya Kitaoka |
38fd86 |
TSound::Channel chan) const override {
|
|
Shinya Kitaoka |
120a6e |
TINT32 sampleCount = getSampleCount();
|
|
Shinya Kitaoka |
120a6e |
if (sampleCount <= 0) {
|
|
Shinya Kitaoka |
120a6e |
return -1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(s1 >= s0);
|
|
Shinya Kitaoka |
120a6e |
TINT32 ss0, ss1;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ss0 = tcrop<tint32>(s0, (TINT32)0, sampleCount - (TINT32)1);</tint32>
|
|
Shinya Kitaoka |
120a6e |
ss1 = tcrop<tint32>(s1, (TINT32)0, sampleCount - (TINT32)1);</tint32>
|
|
Shinya Kitaoka |
120a6e |
assert(ss1 >= ss0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (s0 == s1) return (getPressure(s0, chan));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const T *sample = samples() + ss0;
|
|
Shinya Kitaoka |
120a6e |
assert(sample);
|
|
Shinya Kitaoka |
120a6e |
double maxPressure = sample->getPressure(chan);
|
|
Shinya Kitaoka |
120a6e |
const T *endSample = sample + (ss1 - ss0 + 1);
|
|
Shinya Kitaoka |
120a6e |
++sample;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
while (sample < endSample) {
|
|
Shinya Kitaoka |
120a6e |
if (maxPressure < sample->getPressure(chan))
|
|
Shinya Kitaoka |
120a6e |
maxPressure = sample->getPressure(chan);
|
|
Shinya Kitaoka |
120a6e |
++sample;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return ((double)maxPressure);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//! Returns the soundtrack pressure min value in the given sample range and
|
|
Shinya Kitaoka |
120a6e |
//! channel
|
|
Shinya Kitaoka |
38fd86 |
double getMinPressure(TINT32 s0, TINT32 s1,
|
|
Shinya Kitaoka |
38fd86 |
TSound::Channel chan) const override {
|
|
Shinya Kitaoka |
120a6e |
TINT32 sampleCount = getSampleCount();
|
|
Shinya Kitaoka |
120a6e |
if (sampleCount <= 0) {
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(s1 >= s0);
|
|
Shinya Kitaoka |
120a6e |
TINT32 ss0, ss1;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ss0 = tcrop<tint32>(s0, (TINT32)0, (TINT32)(getSampleCount() - (TINT32)1));</tint32>
|
|
Shinya Kitaoka |
120a6e |
ss1 = tcrop<tint32>(s1, (TINT32)0, (TINT32)(getSampleCount() - (TINT32)1));</tint32>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(ss1 >= ss0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (s0 == s1) return (getPressure(s0, chan));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const T *sample = samples() + ss0;
|
|
Shinya Kitaoka |
120a6e |
assert(sample);
|
|
Shinya Kitaoka |
120a6e |
double minPressure = sample->getPressure(chan);
|
|
Shinya Kitaoka |
120a6e |
const T *endSample = sample + (ss1 - ss0 + 1);
|
|
Shinya Kitaoka |
120a6e |
++sample;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
while (sample < endSample) {
|
|
Shinya Kitaoka |
120a6e |
if (minPressure > sample->getPressure(chan))
|
|
Shinya Kitaoka |
120a6e |
minPressure = sample->getPressure(chan);
|
|
Shinya Kitaoka |
120a6e |
++sample;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return ((double)minPressure);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Copies the samples in the given sample range and channel
|
|
Shinya Kitaoka |
120a6e |
inside the dstChan channel from sample dst_s0
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
void copyChannel(const TSoundTrackT<t> &src, TINT32 src_s0, TINT32 src_s1,</t>
|
|
Shinya Kitaoka |
120a6e |
TSound::Channel srcChan, TINT32 dst_s0,
|
|
Shinya Kitaoka |
120a6e |
TSound::Channel dstChan) {
|
|
Shinya Kitaoka |
120a6e |
TINT32 ss0, ss1;
|
|
Shinya Kitaoka |
120a6e |
// se i valori sono nel range ed uguali => voglio copiare il
|
|
Shinya Kitaoka |
120a6e |
// canale di un solo campione
|
|
Shinya Kitaoka |
120a6e |
if (src_s1 == src_s0 && src_s1 >= 0 && src_s1 < src.getSampleCount())
|
|
Shinya Kitaoka |
120a6e |
ss0 = ss1 = src_s1;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
assert(src_s1 >= src_s0);
|
|
Shinya Kitaoka |
120a6e |
ss0 = tcrop(src_s0, (TINT32)0, (TINT32)(src.getSampleCount() - 1));
|
|
Shinya Kitaoka |
120a6e |
ss1 = tcrop(src_s1, (TINT32)0, (TINT32)(src.getSampleCount() - 1));
|
|
Shinya Kitaoka |
120a6e |
assert(ss1 >= ss0);
|
|
Shinya Kitaoka |
120a6e |
// esco perche' non ha senso copiare indiscriminatamente il primo
|
|
Shinya Kitaoka |
120a6e |
// o l'ultimo campione della sorgente
|
|
Shinya Kitaoka |
120a6e |
if (ss1 == ss0) return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(dst_s0 >= 0L && dst_s0 < getSampleCount());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const T *srcSample = src.samples() + ss0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const T *srcEndSample =
|
|
Shinya Kitaoka |
120a6e |
srcSample +
|
|
Shinya Kitaoka |
120a6e |
std::min((TINT32)(ss1 - ss0 + 1), (TINT32)(getSampleCount() - dst_s0));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
T *dstSample = samples() + dst_s0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (; srcSample < srcEndSample; srcSample++, dstSample++)
|
|
Shinya Kitaoka |
120a6e |
dstSample->setValue(srcChan, srcSample->getValue(dstChan));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//! Makes blank the samples in the given sample range
|
|
Shinya Kitaoka |
473e70 |
void blank(TINT32 s0, TINT32 s1) override {
|
|
Shinya Kitaoka |
120a6e |
TINT32 ss0, ss1;
|
|
Shinya Kitaoka |
120a6e |
// se i valori sono nel range ed uguali => voglio pulire
|
|
Shinya Kitaoka |
120a6e |
// un solo campione
|
|
Shinya Kitaoka |
120a6e |
if (s1 == s0 && s1 >= 0 && s1 < getSampleCount())
|
|
Shinya Kitaoka |
120a6e |
ss0 = ss1 = s1;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
assert(s1 >= s0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ss0 = tcrop<tint32>(s0, (TINT32)0, (TINT32)(getSampleCount() - 1));</tint32>
|
|
Shinya Kitaoka |
120a6e |
ss1 = tcrop<tint32>(s1, (TINT32)0, (TINT32)(getSampleCount() - 1));</tint32>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(ss1 >= ss0);
|
|
Shinya Kitaoka |
120a6e |
// esco perche' non ha senso pulire indiscriminatamente
|
|
Shinya Kitaoka |
120a6e |
// il primo o l'ultimo campione
|
|
Shinya Kitaoka |
120a6e |
if (ss1 == ss0) return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
T *sample = samples() + ss0;
|
|
Shinya Kitaoka |
120a6e |
assert(sample);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
T blankSample;
|
|
Shinya Kitaoka |
120a6e |
const T *endSample = sample + (ss1 - ss0 + 1);
|
|
Shinya Kitaoka |
120a6e |
while (sample < endSample) *sample++ = blankSample;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//! Makes blank the samples in the given sample range and channel
|
|
Shinya Kitaoka |
120a6e |
void blankChannel(TINT32 s0, TINT32 s1, TSound::Channel chan) {
|
|
Shinya Kitaoka |
120a6e |
if (s0 > s1) return;
|
|
Shinya Kitaoka |
120a6e |
// ....
|
|
Shinya Kitaoka |
120a6e |
assert(false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSoundTrackT<tmono8signedsample>;</tmono8signedsample>
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSoundTrackT<tmono8unsignedsample>;</tmono8unsignedsample>
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSoundTrackT<tstereo8signedsample>;</tstereo8signedsample>
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSoundTrackT<tstereo8unsignedsample>;</tstereo8unsignedsample>
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSoundTrackT<tmono16sample>;</tmono16sample>
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSoundTrackT<tstereo16sample>;</tstereo16sample>
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSoundTrackT<tmono24sample>;</tmono24sample>
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSoundTrackT<tstereo24sample>;</tstereo24sample>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
typedef TSoundTrackT<tmono8signedsample> TSoundTrackMono8Signed;</tmono8signedsample>
|
|
Toshihiro Shimizu |
890ddd |
typedef TSoundTrackT<tmono8unsignedsample> TSoundTrackMono8Unsigned;</tmono8unsignedsample>
|
|
Toshihiro Shimizu |
890ddd |
typedef TSoundTrackT<tstereo8signedsample> TSoundTrackStereo8Signed;</tstereo8signedsample>
|
|
Toshihiro Shimizu |
890ddd |
typedef TSoundTrackT<tstereo8unsignedsample> TSoundTrackStereo8Unsigned;</tstereo8unsignedsample>
|
|
Toshihiro Shimizu |
890ddd |
typedef TSoundTrackT<tmono16sample> TSoundTrackMono16;</tmono16sample>
|
|
Toshihiro Shimizu |
890ddd |
typedef TSoundTrackT<tstereo16sample> TSoundTrackStereo16;</tstereo16sample>
|
|
Toshihiro Shimizu |
890ddd |
typedef TSoundTrackT<tmono24sample> TSoundTrackMono24;</tmono24sample>
|
|
Toshihiro Shimizu |
890ddd |
typedef TSoundTrackT<tstereo24sample> TSoundTrackStereo24;</tstereo24sample>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class TSoundTransform {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TSoundTransform() {}
|
|
Shinya Kitaoka |
120a6e |
virtual ~TSoundTransform() {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
virtual TSoundTrackP compute(const TSoundTrackMono8Signed &) { return 0; };
|
|
Shinya Kitaoka |
120a6e |
virtual TSoundTrackP compute(const TSoundTrackMono8Unsigned &) { return 0; };
|
|
Shinya Kitaoka |
120a6e |
virtual TSoundTrackP compute(const TSoundTrackStereo8Signed &) { return 0; };
|
|
Shinya Kitaoka |
120a6e |
virtual TSoundTrackP compute(const TSoundTrackStereo8Unsigned &) {
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
virtual TSoundTrackP compute(const TSoundTrackMono16 &) { return 0; };
|
|
Shinya Kitaoka |
120a6e |
virtual TSoundTrackP compute(const TSoundTrackStereo16 &) { return 0; };
|
|
Shinya Kitaoka |
120a6e |
virtual TSoundTrackP compute(const TSoundTrackMono24 &) { return 0; };
|
|
Shinya Kitaoka |
120a6e |
virtual TSoundTrackP compute(const TSoundTrackStereo24 &) { return 0; };
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
|
e280ae |
|
|
|
e280ae |
#if !defined(_MSC_VER) || defined(TSOUND_EXPORTS)
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
|
e280ae |
TSoundTrackP TSoundTrackT<t>::apply(TSoundTransform *transform) {</t>
|
|
Shinya Kitaoka |
120a6e |
assert(transform);
|
|
Shinya Kitaoka |
120a6e |
return transform->compute(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
|
e280ae |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|