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