How to play a soundfile with the movement from a simple slider?
Hi,
Long time not been here. I am not good enough in MSP so i need help for making this:
[slider] — [scale .. .. .. ..] — [waveform~] — [dac~]
(this is a simple diagram to explain)
The slider controls the playhead position in a soundfile/sample.
A soundfile is loaded in [buffer~] and played with [waveform~].
But the soundfile is only playing when the slider moves and at the position and speed of the movement from the slider. So that it is possible to play a soundfile by hand without clicks or noise jammings.
Thanks for ideas, example patches, externals that help me develop this.
Grzz
Read the help file of play~. All you need to do is scale the range of your slider to the length of your sound file, convert to audio rate and apply some smoothing (line~, curve~, rampsmooth~, slide~, onepole~.......).
You can't play a sound file with waveform~, but you could use it to display the contents of the buffer, and use its [line $1 ] message or a transparent multislider to display the playhead position.
Or, you could do the whole thing with groove~ for better audio quality with slightly more patching.
Thanks.
But that i have already tried out and the problem is to get rid off the clicks and noise jammings. Also with line~ it is not smooth enough.
What i want to reach is when the slider goes for example from left to right and right to left with a certain speed and lenght, then the playhead of the soundfile/sample follows at the same position, speed and lenght in a smooth way.
I will try again but hopefully better with groove~.
More tips and tricks? :)
Have you tried just increasing the ramp time for line~? Also, another thing to try could be to calculate the acceleration of the slider and use that to set the ramp time of line~; so that when the slider is moving quickly, the ramp time is fast, and when it is moving slowly, the ramp time is longer. That should keep it sounding smooth even when scrubbing quite slowly.
Simple way of getting acceleration is to find the difference between the previous output value and the current. [t f f ] >> [bucket ] >> [abs 0. ] are good for this.
I'm also thinking that the resolution of your slider will have a big effect on how good this can sound. Even with smoothing, if the source has low resolution you won't be able to scrub slowly without hearing the "jumps" between values. Also with play~ if you plan to be scrubbing really slowly you'll hear the interpolation artifacts, in which case groove~ will be more appropriate.
this is the simplest example of using a slider to read through [buffer~] with [groove~]
index~
mmmm only use index~ if you want any movement of the slider to simply scrub through your file at a playback speed of exactly 1. Anything else and you'll get major artifacts.
The OP wanted playback to follow the speed of the slider, hence index~ is probably the worst choice! :P Play~ is the most convenient, groove~ is the best option all-around.
Thanksthanksthanks.
Still an amazing active forum.
Unfortunate i have not much time anymore to participate more.
@Tim Lloyd
Nice that you come up with this. Getting the acceleration from data in realtime, here the slider, is something i need a lot off times. And when i need it i always try to use/test a different approach. So, i will test these approach of yours.
I think it is interesting to start a new topic about "getting the acceleration from data". Will do that later.
@brendan mccloskey
Thanks for the example patch but it gives to much artifacts.
This is what I was suggesting with play~. I had a quick go at patching it together for groove~ and found it a bit of a pain tbh :P It might be worth doing only if you're picky about audio quality.
The acceleration thing isn't my idea btw......like most things I know it was suggested by another forum-ite a while ago in response to a similar question.
Ok, thanks, i test your patch tomorrow evening and let you know.
Thanks. These is a very good base to build-on further the patch that i need.
When i have free time i will try also with groove~ and post my experiences.
And the new topic about "getting the acceleration from data" is not necessary anymore because of the [p speed&scale] patch. Kind regards.
well tim, with some training it should be possible to move the mouse exactly like that.
oommm....
Quick extension of the questions above. The patch that Tim posted looks like the perfect start for a problem I'm trying to solve. But I need to be able to toggle between scrub and just plain loop.
Is there a simple way to plug something in that would automate the play and then allow the user to take over that control and scrub the audio back and forth using the patch above from the point where the audio was playing.
Think record scratching.