C# Audio - How to time stretch (different tempo, same pitch)
Asked Answered
G

4

14

I'm trying to make a winform app in C# (VS2008) that can load an mp3 (other formats would be nice, but mp3 at a minimum) and be able to adjust the playback speed (tempo) without affecting pitch. I really don't need any other audio effects. I tried using DirectShow but that doesn't seem to offer time stretch capabilities. I was able to incorporate irrklang but that does not seem to have the time stretch capability either. So now I've moved on to SoundTouch. That certainly has the capabilities but I'm very unclear on how to implement in C#.

After a few days of this, about all I've accomplished is using DLLImport on the SoundTouch DLL and am able to successfully retrieve a version number. At this point, I'm not even sure if I can do what I'm trying to do with SoundTouch. Can anyone offer some guidance either on how to implement SoundTouch or a different library with the capabilities that I'm looking for? Thank you.

Gotthard answered 23/2, 2010 at 18:49 Comment(0)
L
9

If anyone is still interested, I have written .Net wrapper class for SoundTouch library. http://code.google.com/p/soundtouchnet/

Leannaleanne answered 16/11, 2010 at 23:34 Comment(0)
A
6

The answer is that SoundTouch can do what you want to do.

Take a look at the example program SoundStretch. It gives examples of using the SoundTouch library to change the tempo(without changing the pitch) as well as changing the pitch (without changing tempo) and playback rate(change both pitch and tempo). I would look through the source code and use what you need.

The only problem that I see is that you are using an mp3 format and this uses a WAV format so you will need to convert the file first. I really don't think that you'll find a program that does what you want directly on any sort of compressed file because of the nature of the method used to do this sort of thing. It uses a phase vocoder if you want to look into the whole process a bit more.

Aleenaleetha answered 23/2, 2010 at 19:35 Comment(4)
Was writing a comment basically saying the same thing. You beat me to it ;)Pernell
That happens to me all the time.Aleenaleetha
Ok, well at least I know I'm going down the right avenue. My problem now is that the examples that I see (and I certainly may be missing something important) are all in C++. Using DLLImport, I can get this to work in C#: SOUNDTOUCHDLL_API const char *__stdcall soundtouch_getVersionString(); For my purposes, I would need to be able to call: SOUNDTOUCHDLL_API HANDLE __stdcall soundtouch_createInstance(); And SOUNDTOUCHDLL_API void __stdcall soundtouch_setTempoChange(HANDLE h, float newTempo); And that is where I'm completely stuck now.Gotthard
@heath: Don't write your new problem into a comment. Edit this question and add your ongoing investigation (or problems) at the end or open up a new question. Otherwise nobody will see that you stuck on the next place.Delfeena
H
4

Another way of using SoundTouch in C# is to use the BASS sound library (http://un4seen.com) with the BASS.NET wrapper and the BASS_FX plugin. BASS_FX uses SoundTouch to do TimeStretching.

Humid answered 20/2, 2011 at 21:26 Comment(0)
I
-1

Here is one possible approach to invoke from C#. You need to write a COM wrapper in C++ to wrap around the SoundTouch DLL. Once you have the COM wrapper ready, you can import it into your .NET (C#) project and invoke the underlying SoundTouch DLL through the COM Wrapper. Hope this helps.

Inference answered 8/3, 2010 at 8:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.