diff --git a/stepmania/src/Makefile.am b/stepmania/src/Makefile.am
index 7bb01fb26d..d2e68c73e3 100644
--- a/stepmania/src/Makefile.am
+++ b/stepmania/src/Makefile.am
@@ -38,7 +38,7 @@ RageLog.cpp RageLog.h RageMath.cpp RageMath.h RageSound.cpp RageSound.h \
RageSoundManager.cpp RageSoundManager.h RageSoundReader.h RageSoundReader_SDL_Sound.cpp RageSoundReader_SDL_Sound.h \
RageTexture.cpp RageTexture.h RageTextureManager.cpp RageTextureManager.h RageThreads.cpp RageThreads.h \
RageTimer.cpp RageTimer.h RageTypes.h RageUtil.cpp RageUtil.h RageSoundReader_Preload.cpp RageSoundReader_Preload.h \
-RageSoundResampler.cpp RageSoundResampler.h
+RageSoundResampler.cpp RageSoundResampler.h RageSoundReader_Resample.cpp RageSoundReader_Resample.h
DataStructures = \
CodeDetector.cpp CodeDetector.h Course.cpp Course.h Font.cpp Font.h FontCharAliases.cpp FontCharAliases.h \
diff --git a/stepmania/src/RageSoundReader_Resample.cpp b/stepmania/src/RageSoundReader_Resample.cpp
new file mode 100644
index 0000000000..5d5e2aa342
--- /dev/null
+++ b/stepmania/src/RageSoundReader_Resample.cpp
@@ -0,0 +1,98 @@
+#include "global.h"
+#include "RageSoundReader_Resample.h"
+
+RageSoundReader_Resample::RageSoundReader_Resample()
+{
+ source = NULL;
+ samplerate = -1;
+}
+
+void RageSoundReader_Resample::Open(SoundReader *source_)
+{
+ source = source_;
+ ASSERT(source);
+
+ samplerate = source->GetSampleRate();
+ resamp.SetInputSampleRate(samplerate);
+}
+
+
+RageSoundReader_Resample::~RageSoundReader_Resample()
+{
+ delete source;
+}
+
+void RageSoundReader_Resample::SetSampleRate(int hz)
+{
+ samplerate = hz;
+ resamp.SetOutputSampleRate(samplerate);
+}
+
+int RageSoundReader_Resample::GetLength() const
+{
+ resamp.reset();
+ return source->GetLength();
+}
+
+int RageSoundReader_Resample::GetLength_Fast() const
+{
+ resamp.reset();
+ return source->GetLength_Fast();
+}
+
+int RageSoundReader_Resample::SetPosition_Accurate(int ms)
+{
+ resamp.reset();
+ return source->SetPosition_Accurate(ms);
+}
+
+int RageSoundReader_Resample::SetPosition_Fast(int ms)
+{
+ resamp.reset();
+ return source->SetPosition_Fast(ms);
+}
+static const int BUFSIZE = 1024*16;
+
+int RageSoundReader_Resample::Read(char *buf, unsigned len)
+{
+ int bytes_read = 0;
+ while(len)
+ {
+ int size = resamp.read(buf, len);
+
+ if(size == -1)
+ break;
+
+ buf += size;
+ len -= size;
+ bytes_read += size;
+
+ if(size == 0)
+ {
+ static char buf[BUFSIZE];
+
+ int cnt = source->Read(buf, sizeof(buf));
+
+ if(cnt == -1)
+ {
+ SetError(source->GetError());
+ return -1;
+ }
+ if(cnt == 0)
+ resamp.eof();
+ else
+ resamp.write(buf, cnt);
+ }
+ }
+
+ return bytes_read;
+}
+
+SoundReader *RageSoundReader_Resample::Copy() const
+{
+ SoundReader *new_source = source->Copy();
+ RageSoundReader_Resample *ret = new RageSoundReader_Resample;
+ ret->Open(new_source);
+ ret->SetSampleRate(samplerate);
+ return ret;
+}
diff --git a/stepmania/src/RageSoundReader_Resample.h b/stepmania/src/RageSoundReader_Resample.h
new file mode 100644
index 0000000000..7dd345d770
--- /dev/null
+++ b/stepmania/src/RageSoundReader_Resample.h
@@ -0,0 +1,34 @@
+#ifndef RAGE_SOUND_READER_RESAMPLE
+#define RAGE_SOUND_READER_RESAMPLE
+
+#include "RageSoundReader.h"
+#include "RageSoundResampler.h"
+
+/* This class changes the sampling rate of a sound. */
+class RageSoundReader_Resample: public SoundReader
+{
+ int samplerate;
+
+ SoundReader *source;
+
+ mutable RageSoundResampler resamp;
+
+public:
+ /* We own source. */
+ void Open(SoundReader *source);
+ int GetLength() const;
+ int GetLength_Fast() const;
+ int SetPosition_Accurate(int ms);
+ int SetPosition_Fast(int ms);
+ int Read(char *buf, unsigned len);
+ RageSoundReader_Resample();
+ virtual ~RageSoundReader_Resample();
+ SoundReader *Copy() const;
+
+ /* Change the actual sample rate of a sound. */
+ void SetSampleRate(int hz);
+
+ int GetSampleRate() const { return samplerate; }
+};
+
+#endif
diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp
index bd706cc821..df2eba339c 100644
--- a/stepmania/src/StepMania.dsp
+++ b/stepmania/src/StepMania.dsp
@@ -60,7 +60,7 @@ IntDir=.\../Release6
TargetDir=\temp\stepmania
TargetName=StepMania
SOURCE="$(InputPath)"
-PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
+PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool
@@ -95,7 +95,7 @@ IntDir=.\../Debug6
TargetDir=\temp\stepmania
TargetName=StepMania-debug
SOURCE="$(InputPath)"
-PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
+PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool
@@ -239,6 +239,14 @@ SOURCE=.\RageSoundReader_Preload.h
# End Source File
# Begin Source File
+SOURCE=.\RageSoundReader_Resample.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\RageSoundReader_Resample.h
+# End Source File
+# Begin Source File
+
SOURCE=.\RageSoundReader_SDL_Sound.cpp
# End Source File
# Begin Source File
diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj
index 1e9d428d52..16f5004d85 100644
--- a/stepmania/src/StepMania.vcproj
+++ b/stepmania/src/StepMania.vcproj
@@ -1480,6 +1480,12 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
+
+
+
+