You just changed the source code, you will need to recompile it to take effect - The libaudio.so file has to be recompiled. Leverage this Makefile: PYNQ/Makefile at master · Xilinx/PYNQ · GitHub
Thanks,
but there is still an issue with audio playback, which is my origin reason for changing the sampling rate.
If you listen to the audio playback you will notice a difference in pitch. The pitch of the playback will sound higher than the origin soundfile, if you compare it with playback on PC.
So i want to share all steps for reproduction of this phenomenon.
The jupyter notebook code you have entered looks like you only loaded the old sample, but I am not sure if you have recorded that sample also using the 48KHz sample rate. The reason why you have seen higher pitch might be: you played a 44KHz recorded sample using 48KHz sample rate.
i have just mentioned the testfile as reference in my code. I’ve tested this several files as well. If i compare the playback of this test file on pynq with playback on PC via network there will be the same pitch difference noticable. If you playback 44.1khz soundfile on PYNQ you will notice a much higher difference in pitch. So there must be something which we have not considered. Maybe you can test it by yourself and give me feedback.
Thanks for your reply. I’m already familiar with the most common effects of audio codecs and formats.
I can change the sampling rate easily with windows audio driver or my external audio interface for comparison. I will explain it in detail:
An 48 kHz audio file on my pc with equivalent driver settings sounds normal. On PYNQ-Z2 the same file sounds a little bit higher pitched than on my pc.
An 44.1 kHz audio on my pc with equivalent driver settings also sounds normal. On PYNQ-Z2 the same file sounds much higher pitched and faster playback than on my pc.
So one could guess that the playback of audio is getting faster when using audio files with lower sample rates. My guess if you change the audio codec to another sampling rate - PYNQ’s overlay is however still calculating with the predefined 48 kHz. Normally when you convert between 44.1 to 48 kHz you have to interpolate the redundant or missing samples. So there could be something else i have to consider.
I will attach you all my material for reconstruction:
I have not noticed the difference for the 48KHz samples. For 44.1KHz I can tell the difference - so maybe let’s just focus on 44.1KHz samples.
First, I need to confirm a few things. For your 44.1KHz sample recorded on z2, did you play it back using z2, or using PC? Does it sound different on z2 / PC?
I checked your configurations in C program and they look good to me.
So you are recording 44.1KHz sample from PC, and play it back on z2 audio output? You have two sources of audio input (PC, or Z2 audio-in), and two ways to play it back (PC, or Z2 audio-out). My question was “which one of the 4 combinations were you showing in your question?”
I wanted the compare the audio playback on PC with the audio playback on PYNQ Z2:
The first version is the original soundfile from PC storage which is recorded with PC audio interface and the soundfile of the second version was stored on PYNQ storage and played out with PYNQ Z2 line out into my PC audio interface line in and recorded with the same audio settings for comparison.
PN: You will notice the pitch difference of the two 48 kHz samples in the first 1-2 seconds. Observe how the tone of the piano sound and hiats is a little bit higher at the PYNQ version.
Sorry, I still cannot tell the difference for the two 48KHz samples…
For the 44.1KHz samples, can you try this thing: record your wav file using pynq-z2, and then play back that wav file in your PC. If the wav file is ok on your PC side, then at least we know the wav file has been recorded correctly.
Similarly, you can try to record the wav file from PC, and play it back on z2 to see if the playback side is working fine.
Also I think you need to look into the wav package that we use in audio.py. There might be some surprises that the sample rates are adjusted automatically by the package.
I’ve been debugging a similar issue – trying to reconfigure the audio codec on the PYNQ-Z2 to play at 44.1kHz. I found that writing to the appropriate I2C registers (as described above) didn’t seem to work.
Hey Jeff,
thanks for your contribution on this issue. Did u manage to adjust the samplerate of the audio codec from 48 to 44.1kHz by changing the clockrates in user_logic.vhd?