I have pd running at 48k (what my iOS device runs at) and I'm trying to play a wav file that is 44.1k. When doing so, the pitch is shifted up. Is there a conversion I need to make in order to ensure that the file plays at the correct pitch/rate? Right now I'm essentially following the phase vocoder example (since I might do time stretching), but the pitch isn't the original pith.
-
How to maintain pitch, when playing an audio file with a 44.1k samplerate when PD samplerate is 48k
-
@ablue It is possible to up / downsample internally in Pd using [block~]..... but only in multiples of 2.... so not useful here.
In extended you could simply change the samplerate for Pd for each track played.......... https://forum.pdpatchrepo.info/topic/10302/openpanel-and-readsf-play-audio-file-detuned-and-slowed-down
and of course that can still be done for vanilla if all the externals are available (compiled) for your os. Try "find externals" "deken" in Pd to see if you can get them. Very unlikely for iOS I think.The patch I posted there simply gets info about the file to be played and changes the Pd samplerate before playing it. It cannot deal with playing two tracks at different rates at the same time. Sound generation within Pd... [osc~] etc would be unaffected though...... which is all good.
Changing the samplerate of Pd might not change the soundcard rate in iOS (unsure). The os might do the up / downsampling itself.If you cannot use the externals from extended then I think you will have to add the samplerate info to all your tracks..... in their names........ like this...... "my-track 48.wav" and extract the 48 or 44 value to do the same.
You can still send the [audio-dialog( message to Pd in Vanilla....... so that part of this patch will still work........ set_audio_parameters.pd
There is a complete list of the values that need to be set by the message in there as well, and by clicking the [audio-properties( message at bottom right you can get your current parameters........ then change the sample-rate.... then send the new message back to Pd.Or you could load tracks into a table and calculate the new values for the table as they are loaded..... horrible..... and you would still need to know the track samplerate.
Probably easier to just re-sample all the audio for your project first, at 48K, using another program.
David. -
@whale-av said:
In extended you could simply change the samplerate for Pd for each track played.......... https://forum.pdpatchrepo.info/topic/10302/openpanel-and-readsf-play-audio-file-detuned-and-slowed-down
Thanks! I appreciate the thought out reply. I'll take a look and see what I can do. In my case, PD's rate is set by the OS and I can't guarantee the rate of the wav files so some type of conversion will be necessary.
Thanks again.
-
@ablue Someone might be able to help if you give a little more info.
E.g. the version of Pd you are running on your ios device..... and the ios versionMaybe there is some way for another app to stream the audio into Pd through a loopback to the Pd audio input so that resampling occurs in that other app? That would be slow though (real time) for writing to a table.
You still will have the problem that you cannot know (in Pd) the samplrate of the file, but this from the Pd doc folder might fit in your scheme....... Pd/doc/3.audio.examples/G09.pitchshift.pd
...... click message for conversion added (it is NOW the right way around)........ and fixed wrong directory for example audio...
pitch.zip
David.