I'm a PD newbie and I'm trying to figure out how to speed up or slow down a song file similar to speeding up and slowing down a record. I did some searches on the forums but didn't find exactly what I was looking for. I discovered the help file for readsf~ and that enabled me to get a song file playing through PD and from what I can tell the next step is simply adding something to change the sample rate dynamically. I tried block~ but that was giving me artifacts. Is there a simple patch somewhere that I can use for this?
-
Slowing down / speeding up a song
-
> And why is it so roundabout to change the sample rate?
I'm not sure I understand the question
> Is there no way to do that coming out of readsf instead of feeding it into a table first?
Not that I now of. You need to use tabread4~ in order to change the speed of signal, and that requires an array.
> So what are my options in terms of getting around the 91 sec limit?
Using more than one array and changing which array it's playing back at the end of the loop.
-
> And why is it so roundabout to change the sample rate?
I think what I meant was that from what I've read about MAX/MSP modifying the sample rate of an audio file is a little bit easier for a beginner and I was hoping PD would function similarly.>Using more than one array and changing which array it's playing back at the end of the loop.
What would this look like? Could I do it with two arrays, reading back to the audio file and swapping the next set of data into one of them while the other is playing? Or would I want to build out a series of arrays at the initial file load so that I only need to load the sound file once? -
> And why is it so roundabout to change the sample rate?
Now I understand. The best way to change the sample rate of a digital signal without loosing too much quality and being able to do so efficiently in a real-time system is to use 4 point interpolation. That's what tabread4~ does.tabread4~ accepts an input signal which tells it the index to look up in its table. Since it's a signal, it could receive a non integer value (like 3.25) and that's why it does 4 point interpolation. In our example here it would need to figure out what's a 4th of the way between the index 3 and index 4.
Lets assume a table that's 1 second long. In order to play through tabread4~ without modifying its speed we would have to generate a signal which is a straight line that goes from 0 to 44099 in 1 second. If you generate the line in 0.5 seconds it would play it twice as fast and an octave up. You could try this with the line~ object, but for a loop program it is better to use the phasor~ object which generates a saw tooth wave (a straight line that repeats).
Why is it so roundabout? because this way we can do a lot more than just play loops at different speeds. Check out B08 - B14 to see what I mean.
> What would this look like? ...
It would be better to load it once since loading 91 seconds of data per array would cause an IO block generating pauses in your program.In order to hide the implementation detail of how it works you can create an abstraction. I've added here a playloop~ abstraction. Open playloop~-help.pd
You can create as many as you like. I've used $0 in the table name so each instance will get its own array. You can change it to make it work in stereo or to let you set start and end points.
-
Nice! Thanks for the example. It's working wonderfully for me so I'm going to dig into it and see if I can extend it beyond the 91 second limit given your instructions.
-
you can overwrite the maximum limit:
open -maxsize 100000000 yourfile.wav table17
just put some silly big number in where 100000000 is.
-
>>And why is it so roundabout to change the sample rate? Is there no way to do that coming out of readsf instead of feeding it into a table first?<<
i wish this were possible too. it's annoyng in pd that everything needs to be fixed to multiples of a single samplerate.
-
> open -maxsize 100000000 yourfile.wav table17
Did not now that, should prove useful!
But be careful when loading large files since it will cause an IO BLOCK (PD will stutter while loading the file).
> it's annoying in pd that everything needs to be fixed to multiples of a single samplerate
That's not exactly true. If it were than we would only be able to change the speed of signals up by multiples of the the samplerate and we would never be able to slow anything down. The whole point of objects like tabread4~ and tabosc4~ is to allow us to change the samplerate arbitrarily.
It is true about objects like del, metro and line~ but if it weren't then PD would only be useful on the most power computers around.
>i wish this were possible too
An object like readsf~ that buffers and allows for arbitrary samplerate changes sound like an interesting external project. Wonder if anyone is working on it, or has.
-
An object like readsf~ that buffers and allows for arbitrary samplerate changes sound like an interesting external project. Wonder if anyone is working on it, or has.
[readanysf~]
-
ClaudiusMaximus, readanysf sounds like exactly what I've been looking for and hopefully the dependencies don't prove to be a problem. Seems like most of them should be pretty easy to install on my mac.
Hardoff and Satruno, thanks for all the help - I still want to dig into the essentials of pulling in sound files and manipulating them through tables and if I can't get readanysf up and running I know I'll be back here bugging you guys for help on the more traditional methods.