Exemple #1
0
	long GetSampleSize(){
		long bytearraylength = 0;
		// Lets calculate how big the bytearray must be...
		ResetSample(false);
		playing_sample=true;
		while(playing_sample)
			bytearraylength += CalcSampleSize(256);
		return bytearraylength;
	}
//-----------------------------------------------------------------------------
// Purpose: Create an approprite mixer type given the data format
// Input  : *data - data access abstraction
//			format - pcm or adpcm (1 or 2 -- RIFF format)
//			channels - number of audio channels (1 = mono, 2 = stereo)
//			bits - bits per sample
// Output : CAudioMixer * abstract mixer type that maps mixing to appropriate code
//-----------------------------------------------------------------------------
CAudioMixer *CreateWaveMixer( IWaveData *data, int format, int channels, int bits, int initialStreamPosition )
{
	CAudioMixer *pMixer = NULL;

	if ( format == WAVE_FORMAT_PCM )
	{
		if ( channels > 1 )
		{
			if ( bits == 8 )
				pMixer = new CAudioMixerWave8Stereo( data );
			else
				pMixer = new CAudioMixerWave16Stereo( data );
		}
		else
		{
			if ( bits == 8 )
				pMixer = new CAudioMixerWave8Mono( data );
			else
				pMixer = new CAudioMixerWave16Mono( data );
		}
	}
	else if ( format == WAVE_FORMAT_ADPCM )
	{
		return CreateADPCMMixer( data );
	}
#if defined( _X360 )
	else if ( format == WAVE_FORMAT_XMA )
	{
		return CreateXMAMixer( data, initialStreamPosition );
	}
#endif
	else
	{
		// unsupported format or wav file missing!!!
		return NULL;
	}

	if ( pMixer )
	{
		Assert( CalcSampleSize(bits, channels) == pMixer->GetMixSampleSize() );
	}
	else
	{
		Assert( 0 );
	}
	return pMixer;
}
	virtual int GetMixSampleSize() { return CalcSampleSize(16, 2); }
	virtual int GetMixSampleSize() { return CalcSampleSize(8, 1); }
	virtual int GetMixSampleSize() { return CalcSampleSize( 16, NumChannels() ); }