From: <man...@us...> - 2013-08-07 05:53:34
|
Revision: 2591 http://sourceforge.net/p/modplug/code/2591 Author: manxorist Date: 2013-08-07 05:53:27 +0000 (Wed, 07 Aug 2013) Log Message: ----------- [Ref] Move AudioReadTarget into its own file. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Added Paths: ----------- trunk/OpenMPT/soundlib/AudioReadTarget.h Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-08-07 05:53:27 UTC (rev 2591) @@ -422,6 +422,7 @@ <ClInclude Include="..\common\versionNumber.h" /> <ClInclude Include="..\include\pugixml\src\pugiconfig.hpp" /> <ClInclude Include="..\include\pugixml\src\pugixml.hpp" /> + <ClInclude Include="..\soundlib\AudioReadTarget.h" /> <ClInclude Include="..\soundlib\ChunkReader.h" /> <ClInclude Include="..\soundlib\Dither.h" /> <ClInclude Include="..\soundlib\Dlsbank.h" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2013-08-07 05:53:27 UTC (rev 2591) @@ -236,6 +236,9 @@ <ClInclude Include="..\soundlib\Dither.h"> <Filter>Header Files\soundlib</Filter> </ClInclude> + <ClInclude Include="..\soundlib\AudioReadTarget.h"> + <Filter>Header Files\soundlib</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp"> Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-08-07 05:53:27 UTC (rev 2591) @@ -23,8 +23,7 @@ #include <cstring> #include "soundlib/Sndfile.h" -#include "soundlib/Dither.h" -#include "soundlib/SampleFormatConverters.h" +#include "soundlib/AudioReadTarget.h" #include "soundlib/FileReader.h" namespace openmpt { Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-08-07 05:53:27 UTC (rev 2591) @@ -12,7 +12,7 @@ #include "mptrack.h" #include "MainFrm.h" #include "../sounddev/SoundDevice.h" -#include "../soundlib/SampleFormatConverters.h" +#include "../soundlib/AudioReadTarget.h" #include "moddoc.h" #include "childfrm.h" #include "Dlsbank.h" Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-08-07 05:53:27 UTC (rev 2591) @@ -21,7 +21,7 @@ #include "../common/version.h" #include "ACMConvert.h" #include "../soundlib/Dither.h" -#include "../soundlib/SampleFormatConverters.h" +#include "../soundlib/AudioReadTarget.h" #include <fstream> Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-08-07 05:53:27 UTC (rev 2591) @@ -821,6 +821,10 @@ > </File> <File + RelativePath="..\soundlib\AudioReadTarget.h" + > + </File> + <File RelativePath=".\AutoSaver.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-08-07 05:53:27 UTC (rev 2591) @@ -482,6 +482,7 @@ <ClInclude Include="..\sounddsp\DSP.h" /> <ClInclude Include="..\sounddsp\EQ.h" /> <ClInclude Include="..\sounddsp\Reverb.h" /> + <ClInclude Include="..\soundlib\AudioReadTarget.h" /> <ClInclude Include="..\soundlib\ChunkReader.h" /> <ClInclude Include="..\soundlib\Dither.h" /> <ClInclude Include="..\soundlib\Dlsbank.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-08-07 05:53:27 UTC (rev 2591) @@ -888,6 +888,9 @@ <ClInclude Include="..\soundlib\Dither.h"> <Filter>Header Files\soundlib</Filter> </ClInclude> + <ClInclude Include="..\soundlib\AudioReadTarget.h"> + <Filter>Header Files\soundlib</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Added: trunk/OpenMPT/soundlib/AudioReadTarget.h =================================================================== --- trunk/OpenMPT/soundlib/AudioReadTarget.h (rev 0) +++ trunk/OpenMPT/soundlib/AudioReadTarget.h 2013-08-07 05:53:27 UTC (rev 2591) @@ -0,0 +1,109 @@ +/* + * AudioReadTarget.h + * ----------------- + * Purpose: Callback class implementations for audio data read via CSoundFile::Read. + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "Sndfile.h" +#include "Dither.h" +#include "SampleFormatConverters.h" + + +template<typename Tsample> +class AudioReadTargetBuffer + : public IAudioReadTarget +{ +private: + std::size_t countRendered; + Dither &dither; +protected: + Tsample *outputBuffer; + Tsample * const *outputBuffers; +public: + AudioReadTargetBuffer(Dither &dither_, Tsample *buffer, Tsample * const *buffers) + : countRendered(0) + , dither(dither_) + , outputBuffer(buffer) + , outputBuffers(buffers) + { + ASSERT(SampleFormat(SampleFormatTraits<Tsample>::sampleFormat).IsValid()); + } + virtual ~AudioReadTargetBuffer() { } + std::size_t GetRenderedCount() const { return countRendered; } +public: + virtual void DataCallback(int *MixSoundBuffer, std::size_t channels, std::size_t countChunk) + { + // Convert to output sample format and optionally perform dithering and clipping if needed + + const SampleFormat sampleFormat = SampleFormatTraits<Tsample>::sampleFormat; + + if(sampleFormat.IsInt()) + { + dither.Process(MixSoundBuffer, countChunk, channels, sampleFormat.GetBitsPerSample()); + } + + if(outputBuffer) + { + ConvertInterleavedFixedPointToInterleaved<MIXING_FRACTIONAL_BITS>(outputBuffer + (channels * countRendered), MixSoundBuffer, channels, countChunk); + } + if(outputBuffers) + { + Tsample *buffers[4] = { nullptr, nullptr, nullptr, nullptr }; + for(std::size_t channel = 0; channel < channels; ++channel) + { + buffers[channel] = outputBuffers[channel] + countRendered; + } + ConvertInterleavedFixedPointToNonInterleaved<MIXING_FRACTIONAL_BITS>(buffers, MixSoundBuffer, channels, countChunk); + } + + countRendered += countChunk; + } +}; + + +#ifndef MODPLUG_TRACKER + +template<typename Tsample> +class AudioReadTargetGainBuffer + : public AudioReadTargetBuffer<Tsample> +{ +private: + typedef AudioReadTargetBuffer<Tsample> Tbase; +private: + const float gainFactor; +public: + AudioReadTargetGainBuffer(Dither &dither, Tsample *buffer, Tsample * const *buffers, float gainFactor_) + : Tbase(dither, buffer, buffers) + , gainFactor(gainFactor_) + { + return; + } + virtual ~AudioReadTargetGainBuffer() { } +public: + virtual void DataCallback(int *MixSoundBuffer, std::size_t channels, std::size_t countChunk) + { + const SampleFormat sampleFormat = SampleFormatTraits<Tsample>::sampleFormat; + const std::size_t countRendered = Tbase::GetRenderedCount(); + + if(sampleFormat.IsInt()) + { + // Apply final output gain for non floating point output + ApplyGain(MixSoundBuffer, channels, countChunk, Util::Round<int32>(gainFactor * (1<<16))); + } + + Tbase::DataCallback(MixSoundBuffer, channels, countChunk); + + if(sampleFormat.IsFloat()) + { + // Apply final output gain for floating point output after conversion so we do not suffer underflow or clipping + ApplyGain(reinterpret_cast<float*>(Tbase::outputBuffer), reinterpret_cast<float*const*>(Tbase::outputBuffers), countRendered, channels, countChunk, gainFactor); + } + + } +}; + +#endif // !MODPLUG_TRACKER Property changes on: trunk/OpenMPT/soundlib/AudioReadTarget.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-08-07 05:53:27 UTC (rev 2591) @@ -39,8 +39,6 @@ #include "../sounddsp/AGC.h" #include "../sounddsp/DSP.h" #include "../sounddsp/EQ.h" -#include "Dither.h" -#include "SampleFormatConverters.h" class FileReader; @@ -207,102 +205,6 @@ }; -template<typename Tsample> -class AudioReadTargetBuffer - : public IAudioReadTarget -{ -private: - std::size_t countRendered; - Dither &dither; -protected: - Tsample *outputBuffer; - Tsample * const *outputBuffers; -public: - AudioReadTargetBuffer(Dither &dither_, Tsample *buffer, Tsample * const *buffers) - : countRendered(0) - , dither(dither_) - , outputBuffer(buffer) - , outputBuffers(buffers) - { - ASSERT(SampleFormat(SampleFormatTraits<Tsample>::sampleFormat).IsValid()); - } - virtual ~AudioReadTargetBuffer() { } - std::size_t GetRenderedCount() const { return countRendered; } -public: - virtual void DataCallback(int *MixSoundBuffer, std::size_t channels, std::size_t countChunk) - { - // Convert to output sample format and optionally perform dithering and clipping if needed - - const SampleFormat sampleFormat = SampleFormatTraits<Tsample>::sampleFormat; - - if(sampleFormat.IsInt()) - { - dither.Process(MixSoundBuffer, countChunk, channels, sampleFormat.GetBitsPerSample()); - } - - if(outputBuffer) - { - ConvertInterleavedFixedPointToInterleaved<MIXING_FRACTIONAL_BITS>(outputBuffer + (channels * countRendered), MixSoundBuffer, channels, countChunk); - } - if(outputBuffers) - { - Tsample *buffers[4] = { nullptr, nullptr, nullptr, nullptr }; - for(std::size_t channel = 0; channel < channels; ++channel) - { - buffers[channel] = outputBuffers[channel] + countRendered; - } - ConvertInterleavedFixedPointToNonInterleaved<MIXING_FRACTIONAL_BITS>(buffers, MixSoundBuffer, channels, countChunk); - } - - countRendered += countChunk; - } -}; - - -#ifndef MODPLUG_TRACKER - -template<typename Tsample> -class AudioReadTargetGainBuffer - : public AudioReadTargetBuffer<Tsample> -{ -private: - typedef AudioReadTargetBuffer<Tsample> Tbase; -private: - const float gainFactor; -public: - AudioReadTargetGainBuffer(Dither &dither, Tsample *buffer, Tsample * const *buffers, float gainFactor_) - : Tbase(dither, buffer, buffers) - , gainFactor(gainFactor_) - { - return; - } - virtual ~AudioReadTargetGainBuffer() { } -public: - virtual void DataCallback(int *MixSoundBuffer, std::size_t channels, std::size_t countChunk) - { - const SampleFormat sampleFormat = SampleFormatTraits<Tsample>::sampleFormat; - const std::size_t countRendered = Tbase::GetRenderedCount(); - - if(sampleFormat.IsInt()) - { - // Apply final output gain for non floating point output - ApplyGain(MixSoundBuffer, channels, countChunk, Util::Round<int32>(gainFactor * (1<<16))); - } - - Tbase::DataCallback(MixSoundBuffer, channels, countChunk); - - if(sampleFormat.IsFloat()) - { - // Apply final output gain for floating point output after conversion so we do not suffer underflow or clipping - ApplyGain(reinterpret_cast<float*>(Tbase::outputBuffer), reinterpret_cast<float*const*>(Tbase::outputBuffers), countRendered, channels, countChunk, gainFactor); - } - - } -}; - -#endif // !MODPLUG_TRACKER - - #if MPT_COMPILER_MSVC #pragma warning(disable:4324) //structure was padded due to __declspec(align()) #endif Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-08-06 18:45:59 UTC (rev 2590) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-08-07 05:53:27 UTC (rev 2591) @@ -15,8 +15,6 @@ #include "MIDIEvents.h" #include "tuning.h" #include "Tables.h" -#include "Dither.h" -#include "SampleFormatConverters.h" #ifdef MODPLUG_TRACKER #include "../mptrack/TrackerSettings.h" #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |