Open EnricoGiordano1992 opened 3 years ago
@EnricoGiordano1992 not actively maintaining this repo for recent versions for Vivado (was tested on 2018.1 and 2018.3) and PYNQ, but I don't mind helping! From what I can see, the error message says the audio IP already exists in the IPI. If I remember correctly, I did not add any check for that IP - either way the two options you have are: a) Restart Vivado and run it again (reclone and rerun the script) b) Comment this line https://github.com/wady101/PYNQ_Z2-Audio/blob/fc9571886935a4def5870e071591d8407fa5546a/sources/base.tcl#L3206 as the error states that it can somehow find adau1761_0 which should not be the case.
Let me know the outcome :+1:
Ok good, if you agree, I can share the code for the latest support for PYNQ and tools! the problem is solved, but...now I have another problem. During the last make, I have this error:
arm-linux-gnueabihf-gcc -fPIC -I ../inc/ -I ../bsp/ps7_cortexa9_0/include/ -c -g3 -gstabs adau1762.cpp ../src/i2cps.c ../src/uio.c
arm-linux-gnueabihf-gcc: error: ../src/i2cps.c: No such file or directory
arm-linux-gnueabihf-gcc: error: ../src/uio.c: No such file or directory
Makefile:16: recipe for target 'all' failed
I see that in the makefile there are some includes that is not presents in repository (../inc and ../bsp/ps7_cortexa9_0/include), do you have any suggestions?
Thanks a lot!
@EnricoGiordano1992 Those are from the Xilinx ARM BSP libraries:
https://ohwr.org/project/evo/tree/69f5408fd24bcdba0710e4ef07a0e3ba6de7c609/boot/microzed/BSP/ps7_cortexa9_0/include https://github.com/PeterOgden/PYNQ/blob/7c31c77569077e6bfb9a386cf594609c44a92434/pynq/lib/_pynq/_audio/i2cps.c https://github.com/PeterOgden/PYNQ/blob/7c31c77569077e6bfb9a386cf594609c44a92434/pynq/lib/_pynq/_audio/uio.c https://github.com/PeterOgden/PYNQ/blob/7c31c77569077e6bfb9a386cf594609c44a92434/pynq/lib/_pynq/_audio/uio.h https://github.com/PeterOgden/PYNQ/blob/7c31c77569077e6bfb9a386cf594609c44a92434/pynq/lib/_pynq/_audio/i2cps.h
I will have to update this repo with the above mentioned files. But with these, it should work alright (hopefully!). Probably remove that inc/
, I don't remember where that is from
Ok, I have done little progress...in attachment the code PYNQ_Z2-Audio.zip
(on setup.sh, just set board_ip variable with your board ip)
Now I have a problem on jupyter notebook at this part:
Do you have any suggestions? Sorry for take your time but I think that this project is very usefull for the community :-)
@EnricoGiordano1992 no it's alright - keep firing those questions away! It is always fun to look at your old written code ;)
I guess comment that line out, (Line 42 in audio.py
). I think that I used that for testing the whole flow
Ok, I have prepared the full patch in this archive:
PYNQ_Z2-Audio.zip
Thanks for suggestions!
According to your example on Jupyter Notebook, how can I get a continuous stream in a numpy array in order to elaborate the datas? I want to implement a filter on the mic data and I can't understand on your example how elaborate the input data (I see that you can record a n-seconds audio and play it, but I don't understand how I can record without cuts the mic and meanwhile elaborate the numpy array).
@EnricoGiordano1992 Thanks for the patch, I'll put it in a separate branch! I am also okay if you want to submit it as a merge request :) The purpose behind this example was to create a streaming audio IP - for the microphone side too! Hence, that is why you might not be able to modify the buffer as a whole. Other than diving into the code yourself, I suggest - in Line 455, https://github.com/wady101/PYNQ_Z2-Audio/blob/4aa7c092a56808d336b9e9240161323955e40c36/audio.py#L455 Try adding your own C++ function call there For a Python change you might have to wait a while, I do plan to look at it this weekend - is there any specific kind of filter you are looking at?
Ok, maybe at the next step I will implement the filter :) Now I have another problem: when I record the audio (line in or mic, I have the same behaviour), the np.array output has a strange numbers inside...when I play the array with playinit function I have no problem, but converting the numpy array to wav file I have a completely distorted audio. I have plotted the array and I have this graph:
and I save the wav file in this way:
I have implemented the record function in this way:
from audio import *
from pynq import Overlay
import numpy as np
import pynq.lib.dma
from pynq import Xlnk
import psutil
import asyncio
import time
from threading import Thread
base=Overlay("./sources/AXIS_audio.bit")
Audiobj=base.adau1761_0
Audiobj.select_line_in()
#Audiobj.select_microphone()
Audiobj.recordinit(60)
xlnk = Xlnk()
dma_send = base.axi_dma_0
seconds = 1
coeff = 1
buffer_size = int((seconds * 2 * 48000) / coeff)
arr_total = np.array(list())
cma_ar = xlnk.cma_array(shape = buffer_size, dtype = "uint32")
def get_stream(threadName, seconds, iterations):
global arr_total
iterations *= coeff
arr_total = np.array(list())
while iterations > 0:
base.segment_stream_0.write(0, buffer_size)
dma_send.recvchannel.transfer(cma_ar)
dma_send.recvchannel.wait()
arr_total = np.concatenate((arr_total, cma_ar), axis=None)
print(threadName + ": " + str(arr_total.shape))
iterations -= 1
what is wrong in my code? Do you have any example about saving the numpy array output to a file? Thanks a lot!
Ok, I think that the problem is that I have a PDM audio signal and not a PCM audio signal...do you have any suggestion for PDM -> PCM conversion? Thanks!
Hi wady101 do you have any update?
@EnricoGiordano1992 , apologies for the late reply. I am not sure if you have found the solution - but you would have to implement a LPF in Python right after you get the numpy array from the audio codec. https://en.wikipedia.org/wiki/Pulse-density_modulation#Digital-to-analog_conversion You might have to use Scipy for this: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.butter.html An analog filter would be required to covert the output from the ADC back to the analog signal you are looking for. Is this what you were asking?
Hi @wady101 , thanks for the support! Unfortunately I didn't find any solutions... I tried to use a butterworth filter without success. Below the screenshot
I suppose that the problems are fs, lowcut and highcut parameters, because I obtain only noise. Do you have any working code or do you know what are the correct parameters? Thanks in advance!
Sadly no, @EnricoGiordano1992 .
But having a look at this - did you play around with fs
? Probably notch it up to 10k? Also did you take out the FFT and see the difference (before and after filter)?
Also go for a higher order
- we aren't really looking at execution speed (for now):P
To clarify - do you want to hear the sound after the filter you applied or do you want to see visually?
One more thing which is the best test for this - is to play a sine wave on your phone and record it on the board.
Hi wady101 I cannot build the project using the setup script. I am using PYNQ 2.5 (from tag) and Vivado 2019.1 . This is the error:
This is the full log: