0

I'm attempting to make a music visualizer in Python. For math on the audio signal I'm using a modified version of the FFT called the Constant Q Transform (CQT). My issue is finding a way to plot the result of the CQT in real time AND play back the music in real time.

Currently I'm taking 1024 samples of the music, transforming them, plotting them with matplotlib, then sending the samples to an audiostream to be played. The delay is the plotting with matplotlib. My goal is to do something like this or this. It appears in the second video the transform is generated beforehand then played back.

How would you recommend generating such a visualization? Is it possible to compute the transform, visualize it, and play back the audio in real time with no/minimal stuttering?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
  • You need to synchronize the feeds ... so how long it take to CQT + render the 1024 samples? and what is the sample rate? I think the rendering is the slowest so you need to optimize it (not using slow api) and find number of samples where the `duration(render+CQT) <= samples/samplerate` after that you can both render and play the sound ... on windows use WAVEOUT instead of DirecX as the latter is slow (too high and unreliable latency and not working callbacks unless they repaired it) – Spektre Dec 29 '18 at 10:39
  • I am afraid Python might pose a speed problem ... If you need speed use C++ ... On windows it is doable with C++/WAVEIN/WAVEOUT/GDI see [plotting real time Data on (qwt )Oscillocope](https://stackoverflow.com/a/21658139/2521214) Which is `stereo signal generator -> WAVEOUT -> WAVEIN -> Osciloscope + FFT/FCT Spectral analyser` – Spektre Dec 29 '18 at 10:47
  • Have you looked into [pyqtgraph](http://www.pyqtgraph.org/)? – fstop_22 Jan 02 '19 at 13:31

0 Answers0