• ### Sample rate issues while using [Soundfiler]

Hi people, I've been making a little sampler following the instructions of Kreidler's book. It took me a while but I managed to understand how it really works, pretty neat. Nevertheless I noticed a problem with soundfiler. I'm loading my samples via {openpanel]. Sadly, altough the patchs' logic is right, the samples I load into it are playing with higher pitch. While debugging, I noticed that [soundfiler] outputs via its right outlet a really low sample rate (it varies, for an A440 sine 2 seconds long, it outputs a sample rate of 4000), so it makes sense that the samples are playing at a higher pitch. Why does this happen? I'm kinda sad that this happens. Thanks in advance!

The example is 3.4.2.3, here's the links to the book's page:
http://www.pd-tutorial.com/english/ch03s04.html

• Posts 6 | Views 601
• @ChicoVaca The problem as you say is the number of samples per second for your sample. Pd will be playing them at 44100 or 48000 samples per second (which you have set for your sound card in the Pd media settings).
So 4000 samples will be played in about 1/10th of a second.

The solution is about a third of the way down the page that you linked to, and a little bit of maths can calculate the value (automatically in your patch using the sample rate from [soundfiler] and the setting for Pd) that you will need for [line~] to play the sample correctly using [tabread4~]

David.

• @whale-av said:

Pd will be playing them at 44100 or 48000 samples per second (which you have set for your sound card in the Pd media settings).
So 4000 samples will be played in about 1/10th of a second.

Hi David, thanks for your answer. I don't know if I understood you, but I meant that the sample rate that [soundfiler] outputs (via a list in its right outlet) it's 4000 per second (so the two second file is actualy 8000 samples long) and not 44100. So, from what I understand, it's not reading the actual sample rate, that's what I'm not understanding. My sample rate is set to 44100Hz in preferences.
The other thing is, soundfiler doesn't always read the same sample rate, from what i've tested, it varies from file to file.... so I can't make definitive calculations for all samples... I'm at loss.

• @ChicoVaca said:

So, from what I understand, it's not reading the actual sample rate, that's what I'm not understanding. My sample rate is set to 44100Hz in preferences.

[soundfiler] is supposed to output the sample rate of the audio file, not the sample rate of the audio hardware.

There is no guarantee that every sound file will match the audio system. Nor is there any guarantee that every sound file's sample rate will match that of every other file (so "soundfiler doesn't always read the same sample rate" is reasonable and expected behavior when audio files exist at different sample rates -- you should not expect to do one set of calculations that will work for every file, unless you have ensured that all files have the same sample rate).

I created some abstractions to handle this, because I find Pd's native interface to be tiresome, but it's very late where I live, maybe an example tomorrow (or search the forum for hjh-abs).

hjh

• @ChicoVaca Yes.... as I said above, it can be solved with very little maths, and you need the sample rate of the file to do so.
Luckily [soundfiler] also reports the total samples on the left outlet so it is simple division and the Pd sample rate can be ignored.
This is what you need to do to use that value and play back at the correct speed....... this.zip
It will always play at the right speed regardless of the sample rate of the file, and regardless of the sample rate set for Pd.
You should add a "crown" or "Hanning" array to stop any clicks as the array starts and stops playing the sample..... see the floss tutorial that you linked to in your OP.
David.

Credit to @lacuna for [array-guard]

• Thanks to the both of you! I'll look further into this.

Posts 6 | Views 601
Internal error.

Oops! Looks like something went wrong!