Hallo, Enrique Erne hat gesagt: // Enrique Erne wrote:
try something like this:
[soundfiler] | [/ 44100] | [pow -1] | [phasor~]
Another possibility is to use [vline~] instead of [phasor~] as in C05.sampler.oneshot.pd and then restart the sample-player, when the sample has finished.
I "borrowed" this algorithm for my clone of the [play-samp~] abstraction of RTC-lib (attached), which is a sample player, that can both play a sample just once as well as loop it.
C05.sampler.oneshot.pd should be quite clear, the only thing that may be a bit hard to understand at first is the funny looking message: "; phase 1, 4.41e+08 1e+07;" But actually it has an easy explanation: 4.41e+08 is the sample [vline~] should approach in 1e+07 msec. This will make vline~ go at the same speed as it would go if it would need to reach sample number 44100 in 1 second, that is if it was playing at "CD-audio-speed". The speed is:
4.41e+08 smps / 1e+07msec = 44100 smps / 1000 msec = 44100 smps / 1 sec = 44.1 kHz = CD
Miller just decided to let it go to some really huge sample number during a very long time (1e+07msec) so that no calculations about the length of the sample are needed in oneshot-mode.
Of course if you want to loop, you *need to* do these calculations to restart the loop when the sample has played completly. This is easy to achieve by just converting the size of the array in samples to the duration it would have, if it was played with the sample's samplerate.
Again assuming this is 44.1kHz, you get the duration in msecs by dividing the number of samples by 44.1.
Attached play-samp~.pd uses Zexy's [arraysize] to get the length of the sample to play, but you could also just use soundfiler's output instead. The sample is first played as "oneshot" sample, but additionally a [delay] object is set up to play the sample again (and again) after the duration calculated like above. (Additionally transposition is implemented by just scaling the vline~-input accordingly.)
Frank Barknecht _ ______footils.org_ __goto10.org__