CMSIS-DSP: Improvements to some Python nodes of SDF.

pull/19/head
Christophe Favergeon 4 years ago
parent 02d4e88031
commit 9bdaa9d9ea

@ -18,6 +18,7 @@ q15Type = CType(Q15)
### each time (half number of MFCCs)
src=WavSource("src",NBCHANNELS*AUDIO_INTERRUPT_LENGTH)
src.addLiteralArg("test_stereo.wav")
src.addLiteralArg(True)
toMono=StereoToMono("toMono",q15Type,AUDIO_INTERRUPT_LENGTH)

@ -56,12 +56,12 @@ def scheduler(mfccConfig,dispbuf):
#
# Create node objects
#
audioWin = SlidingBuffer(1024,256,fifo1,fifo2);
mfcc = MFCC(1024,13,fifo2,fifo3,mfccConfig);
mfccWin = SlidingBuffer(754,377,fifo3,fifo4);
sink = NumpySink(754,fifo4,dispbuf);
src = WavSource(384,fifo0,"test_stereo.wav");
toMono = StereoToMono(384,192,fifo0,fifo1);
audioWin = SlidingBuffer(1024,256,fifo1,fifo2)
mfcc = MFCC(1024,13,fifo2,fifo3,mfccConfig)
mfccWin = SlidingBuffer(754,377,fifo3,fifo4)
sink = NumpySink(754,fifo4,dispbuf)
src = WavSource(384,fifo0,"test_stereo.wav",True)
toMono = StereoToMono(384,192,fifo0,fifo1)
while((sdfError==0) and (debugCounter > 0)):
nbSchedule = nbSchedule + 1

@ -33,9 +33,10 @@ import wave
# Pad with zero when end of file is reached
class WavSource(GenericSource):
"Read a stereo wav with 16 bits encoding"
def __init__(self,outputSize,fifoout,name):
def __init__(self,outputSize,fifoout,name,stereo=True):
GenericSource.__init__(self,outputSize,fifoout)
self._file=wave.open(name, 'rb')
self._stereo=stereo
#print(self._file.getnchannels())
#print(self._file.getnframes())
@ -43,8 +44,11 @@ class WavSource(GenericSource):
def run(self):
a=self.getWriteBuffer()
# Stereo file so chunk must be divided by 2
frame=np.frombuffer(self._file.readframes(self._outputSize//2),dtype=np.int16)
if self._stereo:
# Stereo file so chunk must be divided by 2
frame=np.frombuffer(self._file.readframes(self._outputSize//2),dtype=np.int16)
else:
frame=np.frombuffer(self._file.readframes(self._outputSize),dtype=np.int16)
if frame.size > 0:
a[:frame.size] = frame
a[frame.size:] = 0

@ -60,7 +60,7 @@ def {{config.schedName}}({{optionalargs()}}):
#
{% for node in nodes %}
{% if node.hasState %}
{{node.nodeName}} = {{node.typeName}}({{node.pythonIoTemplate()}},{{node.args}});
{{node.nodeName}} = {{node.typeName}}({{node.pythonIoTemplate()}},{{node.args}})
{% endif %}
{% endfor %}

Loading…
Cancel
Save