Slow motion

Started by Jachin,

Jachin

Hi all,
I just came across nBass and I am wondering if it has the features i need. I am using vb.net and i need to know if you can slow playback down. Is this possible? Like in WMP9 on XP. If this could be done via BASS then I'd love to know how.

If someone knows how please let me know asap.

Thanks:)

Zakhar

Hi!
What you're looking after is basically called 'Time Stretch'.It's the same method used in applications like SonicFoundary ACID which can loop any wave file at any speed.It's a little bit difficult to do it cause you could slower or fasten a wave file but at them same time its PITCH will change. There are lots of Math and theorical stuff involved in such projects,and sound quality is always the factor,and that's the difference betwwen different looping programs.

but one easy way could be theorically like this:

Create a channle with BASS and using 'ChannelSetAttributes' set frequency to whatever you like.doing so will speed up or down the channel playback.but when you alter the frequency PITCH also will change so you have to shift it back or forward to correct the tune.

you have to write a custom DSP to create a PITCH SHIFTER and correct the wave tunning.it should be a REAL TIME pitch shifer so it won't alter the SPEED again. since i guess there's no builtin Pitch shifter in DirectX 8.0,you have to write it yourslef.

but the most hard part comes here: you have to do some math to find the amount of PITCH SHIFTING needed for a particular SPEED. i mean you have to find a formula that can calculate needed amount of pitch shift by a given Frequency [which is set to channle ith 'channelSetAttributes'].got me?

so, 'channelSetAttributes' changes speed of wave file but also its pitch,and you correct the pitch with a REAL TIME custom DSP Callback.

the chalenge is to write a DSP routine in a way that it doesn't warble and lush up the sound so much. surely even the most simple routine could handle +20\-20 BPMs but then it starts to fall apart and shound shitty!

[sorry for many spell and gramar mistakes!  :) ]

Zakhar

PS. I forgot to say that Pitch shifting is one of the most CPU eating processes,and since VB is naturaly a bit slow,you may won't get perfect results.i tried it and it wasn't so interesting. i though trying it with Delphi to get the better result,but guess VC is the perfect tool for this matter.

(: JOBnik! :)

Hi ;D

You could use latest BASS_FX.DLL version to have Tempo, i.e: Time Stretch, and Pitch Scaling :)

Have fun!

8) JOBnik! 8)

Jachin

What is this BASS_FX.DLL?

The quality of what i am doing doesn't have to be that great. I am simply slowing down a voice recording. You know when you tape a speaker and they get really enthusiastic and speak too fast for you to take any of it in. In my program atm i use windows media player to slow it down just slightly. Trouble is, that only works on XP.

Unfortunately I only know vb.net so i guess that sort of limits things. Anyway if someone could explain the BASS_FX.DLL that would be great.

(: JOBnik! :)

Hi ;D

I guess if you only need the same effect as in WMP9 (Sample rate changer) then you don't have to use BASS_FX.DLL, but only a function called:

dim freq as long
BASS_ChannelSetAttributes(handle, freq, -1,-101)

freq = a new frequency/samplerate
e.g: freq = 44100 => the optimal speed
     freq = 44100 * 1.3 = 57330 => Speed up by 30% :)

* If you wanna check/test BASS_FX then grab it from here:
http://www.un4seen.com/files/bass_fx12beta.zip

and see what it can do ;)

Have fun!

8) JOBnik! 8)

Jachin

Call me stupid but
BASS_ChannelSetAttributes(handle, freq, -1,-101)

gives me an error when i add it to the nBASS 1.8 stream sample.

What am i doing wrong?

Ian @ un4seen

With nBASS, you'ld do this...
stream.SetAttributes(freq, -1, -101);

Jachin

Ok i did stream.SetAttributes(freq, -1, -101);

but visual studio says "E:\nBASS-1.8\StreamTest\Form1.cs(455): 'nBASS.AdvancedChannel' does not contain a definition for 'SetAttributes'
"

Ian @ un4seen

I've not used nBASS myself, so it was something of a guess from looking at the nBASS source :)

Looking at the StreamTest source though, you'll find this...
                 ChannelAttributes chanatt = stream.Attributes;
                  chanatt.panning = ((TrackBar)sender).Value;
                  stream.Attributes = chanatt;
I guess there's probably a simpler way to do it (ie. only 1 line of code), but anyway, try replacing the "chanatt.panning = ..." line with "chanatt.freq = ...".

Jachin

Hey that worked really good, the audio file is definately slower but as you say, the pitch is terrible.

What is the best way to do some pitch correction?