graph_bench_sync.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Include definitions from the Python package to
  2. # define datatype for the IOs and to have access to the
  3. # Graph class
  4. from cmsisdsp.cg.scheduler import *
  5. from nodes_bench import *
  6. FS=16000
  7. # You can try with 120
  8. AUDIO_INTERRUPT_LENGTH = 192
  9. WINSIZE=256
  10. OVERLAP=128
  11. floatType=CType(F32)
  12. ### Define nodes
  13. src=ArraySource("src",floatType,AUDIO_INTERRUPT_LENGTH)
  14. src.addVariableArg("inputArray")
  15. sliding=SlidingBuffer("audioWin",floatType,WINSIZE,OVERLAP)
  16. overlap=OverlapAdd("audioOverlap",floatType,WINSIZE,OVERLAP)
  17. window=Dsp("mult",floatType,WINSIZE)
  18. toCmplx=ToComplex("toCmplx",floatType,WINSIZE)
  19. toReal=ToReal("toReal",floatType,WINSIZE)
  20. fft=CFFT("cfft",floatType,WINSIZE)
  21. ifft=ICFFT("icfft",floatType,WINSIZE)
  22. hann=Constant("HANN")
  23. sink=ArraySink("sink",floatType,AUDIO_INTERRUPT_LENGTH)
  24. sink.addVariableArg("outputArray")
  25. the_graph = Graph()
  26. the_graph.connect(src.o, sliding.i)
  27. # Windowinthe_graph
  28. the_graph.connect(sliding.o, window.ia)
  29. the_graph.connect(hann,window.ib)
  30. # FFT
  31. the_graph.connect(window.o,toCmplx.i)
  32. the_graph.connect(toCmplx.o,fft.i)
  33. the_graph.connect(fft.o,ifft.i)
  34. the_graph.connect(ifft.o,toReal.i)
  35. # Overlap add
  36. the_graph.connect(toReal.o,overlap.i)
  37. the_graph.connect(overlap.o,sink.i)