I am attempting to update the Bokeh spectrogram example to serve as a visualizer for some signal processing work, where my data source is a large dataset of .wav files.
My problem: when I change the data source of the spectrogram to something other than the data streamed from pyaudio (wrapped in the app directory as audio.py), the spectrogram (created using the custom WaterfallRenderer) no longer updates as part of the update() function, which is called as a periodic callback. HOWEVER, the spectrogram DOES update if I move the frequency slider, that is, if I move the slider back and forth,
I can get the spectrogram/waterfall to scroll. If I leave audio.py as the data source for all the other plots (signal_plot, spectrum_plot, eq), those still update in real-time. Just not the spectrogram (waterfall). The test behavior I am trying to achieve is for the static spectrum to cause static bands on the scrolling spectrogram, as if pyaudio picked up these steady tones, but the scrolling only occurs when the frequency slider is moved.
I note that app_hooks.py, starts audio.update_audio_data() as a thread, but am not sure why that would prevent a static spectrum from updating the plot.
The problem is simple to reproduce. I have slightly modified main.py so that waterfall_renderer.latest takes its data from a static spectrum (ndarray), identical to one which it would receive from audio.py. Please share any thoughts, many thanks!
My implementation:
add to imports (main.py):
from .spectrogram_data import static_spectrum
line 78/79 becomes:
waterfall_renderer.latest = static_spectrum.tolist()
# waterfall_renderer.latest = spectrum.tolist() # previous version, using spectrum from audio.data['values']
finally, the contents of spectrogram_data.py, though it could be any 512 element ndarray for this test:
import numpy as np
static_spectrum = np.asarray([0.25845337, 0.25598122, 0.34292651, 0.23404662, 0.29240546, 0.26256236,
0.262309, 0.28073791, 0.28838212, 0.30717492, 0.30219797, 0.32221864,
0.32933016, 0.34895406, 0.36164073, 0.38236228, 0.40141973, 0.43524974,
0.467844, 0.51579171, 0.57366946, 0.64814502, 0.7791036, 0.89534827,
1.17349182, 1.57026521, 2.46067445, 7.71447409, 8.11260236, 2.57502298,
1.53096035, 1.07958376, 0.83188277, 0.66290329, 0.57288032, 0.49171422,
0.43211778, 0.37656272, 0.34119653, 0.29892811, 0.27852872, 0.25873506,
0.24215651, 0.21975472, 0.21925573, 0.19207885, 0.18710984, 0.17605622,
0.16771836, 0.15902481, 0.14510053, 0.14161619, 0.13584085, 0.12906095,
0.13009376, 0.08940503, 0.11459808, 0.11046002, 0.10746498, 0.10145201,
0.10059768, 0.09919343, 0.09452233, 0.0908366, 0.08884924, 0.08590659,
0.08308414, 0.08348386, 0.07822601, 0.07882354, 0.07315738, 0.07134991,
0.07389128, 0.06944061, 0.06611991, 0.06459004, 0.0657912, 0.06565643,
0.06208887, 0.06292808, 0.05954502, 0.05790267, 0.05852629, 0.05532739,
0.05502241, 0.05679357, 0.0537295, 0.05392256, 0.05159943, 0.05039817,
0.04873646, 0.04816757, 0.04944953, 0.04723717, 0.04761347, 0.04592364,
0.04557323, 0.04571959, 0.04384196, 0.04341244, 0.04385928, 0.04311181,
0.04279701, 0.04174006, 0.03958805, 0.04313195, 0.0388005, 0.03862513,
0.03786198, 0.03816022, 0.03888646, 0.0366035, 0.03672044, 0.0383389,
0.03679689, 0.03557466, 0.03453071, 0.03454272, 0.03432328, 0.03511742,
0.03374305, 0.03260487, 0.03197614, 0.03227917, 0.0329708, 0.03309581,
0.03183017, 0.03161367, 0.03181377, 0.03181946, 0.03109826, 0.03021364,
0.030081, 0.03040023, 0.03007094, 0.02949279, 0.02959446, 0.03011041,
0.02764042, 0.02914424, 0.02845511, 0.02792121, 0.02747209, 0.02736553,
0.02743512, 0.02727956, 0.02649442, 0.02665774, 0.02728399, 0.02585457,
0.02589911, 0.02599783, 0.02502176, 0.02527945, 0.02565219, 0.02509806,
0.0247709, 0.02494709, 0.0249859, 0.0244494, 0.02454126, 0.02386427,
0.02333159, 0.02403915, 0.02348012, 0.02356087, 0.02342524, 0.02310547,
0.02415073, 0.02184466, 0.02246595, 0.02239819, 0.02197215, 0.02233091,
0.02249723, 0.02248014, 0.02218472, 0.02157591, 0.02162577, 0.02117378,
0.02136729, 0.02171639, 0.02096931, 0.01969341, 0.02070981, 0.02004743,
0.0206363, 0.02050299, 0.020194, 0.02038392, 0.0201852, 0.02004248,
0.0200186, 0.01993137, 0.01903939, 0.01949554, 0.01930734, 0.01924958,
0.01947401, 0.02053492, 0.01957043, 0.01927907, 0.01942628, 0.01869617,
0.0188329, 0.01939561, 0.0184543, 0.01851687, 0.01772594, 0.01828451,
0.01879375, 0.01773291, 0.01827834, 0.01827569, 0.01755797, 0.01841582,
0.01766791, 0.01801331, 0.01743003, 0.01733253, 0.0173988, 0.01819401,
0.01704187, 0.01700117, 0.01720127, 0.01682367, 0.01744663, 0.01717698,
0.01730243, 0.01697083, 0.0168225, 0.01731541, 0.01706191, 0.01669824,
0.01576905, 0.01624461, 0.01641013, 0.0166367, 0.01650356, 0.01599025,
0.01651044, 0.01579569, 0.01607195, 0.01602233, 0.01614911, 0.01559572,
0.01564862, 0.01543978, 0.01646524, 0.01553141, 0.01520715, 0.01554853,
0.01551608, 0.01532779, 0.01551872, 0.01499758, 0.0149814, 0.01585003,
0.01536676, 0.01540786, 0.01531895, 0.01482433, 0.01467617, 0.01449173,
0.0146238, 0.01466892, 0.01441124, 0.01529404, 0.01466716, 0.01487321,
0.01455608, 0.01482599, 0.0142621, 0.01443539, 0.01471169, 0.01445597,
0.01500394, 0.01452773, 0.01421005, 0.01403155, 0.01433689, 0.01447981,
0.0136863, 0.01411152, 0.01407492, 0.01368678, 0.01431273, 0.01443524,
0.01344565, 0.01389828, 0.01326043, 0.01397924, 0.01351904, 0.01392635,
0.01398273, 0.01311207, 0.01360715, 0.01320505, 0.01356054, 0.01374027,
0.01324708, 0.01263116, 0.01273368, 0.01398737, 0.0133537, 0.01345948,
0.01364871, 0.01317422, 0.01392325, 0.01294438, 0.01352554, 0.01336277,
0.0130425, 0.01289704, 0.01247974, 0.01344706, 0.01300743, 0.01289353,
0.01288021, 0.01313591, 0.01306938, 0.01264827, 0.01278697, 0.01232407,
0.01244716, 0.01230125, 0.01311039, 0.01260805, 0.01258482, 0.01271871,
0.01258934, 0.01306891, 0.01319345, 0.01278979, 0.01243381, 0.01261547,
0.01289319, 0.01364069, 0.01219497, 0.01286494, 0.01238357, 0.01214218,
0.01184895, 0.01289411, 0.01212871, 0.01229017, 0.01249078, 0.01250687,
0.01237203, 0.01215669, 0.01195132, 0.01179772, 0.01181154, 0.01214489,
0.01184446, 0.01229009, 0.01201387, 0.01152382, 0.01213564, 0.01194576,
0.01228042, 0.01171698, 0.01204241, 0.01143873, 0.01139178, 0.01184008,
0.01165618, 0.01159321, 0.01193134, 0.01166516, 0.01147032, 0.01162961,
0.01153453, 0.01175687, 0.01181389, 0.01149525, 0.01113883, 0.01185316,
0.01141207, 0.0110858, 0.01165113, 0.01164684, 0.01123414, 0.01134889,
0.01084929, 0.01181073, 0.01122689, 0.01158992, 0.01138661, 0.01163957,
0.01154581, 0.01193108, 0.01199758, 0.0114669, 0.01193981, 0.0117633,
0.01140083, 0.01132383, 0.01138549, 0.01164405, 0.01135976, 0.01162874,
0.01127941, 0.0109866, 0.01153854, 0.01129533, 0.01158169, 0.01126415,
0.01118368, 0.01141798, 0.01102783, 0.01153233, 0.01085265, 0.01157239,
0.01132767, 0.01137476, 0.01094452, 0.0110344, 0.01110805, 0.01164081,
0.01093009, 0.01125297, 0.01058984, 0.01209392, 0.01072231, 0.0102136,
0.01072259, 0.01050441, 0.01161675, 0.01098816, 0.01067852, 0.01051522,
0.01082745, 0.01065499, 0.01093838, 0.01067198, 0.01133385, 0.01083469,
0.01076164, 0.01114013, 0.01117931, 0.01093253, 0.01073461, 0.01087713,
0.01096013, 0.01139841, 0.00993657, 0.01133282, 0.01050587, 0.01068472,
0.01029954, 0.0109072, 0.01069072, 0.01073851, 0.01131649, 0.0109771,
0.01134446, 0.01113353, 0.01076073, 0.01065248, 0.01022598, 0.01113214,
0.01082053, 0.01123836, 0.01095627, 0.01139221, 0.01127387, 0.01127172,
0.01046206, 0.01078176, 0.01077093, 0.01111244, 0.01010251, 0.01006648,
0.01122872, 0.01047253, 0.01125478, 0.01004169, 0.01057424, 0.01050988,
0.01042047, 0.01069688, 0.01000791, 0.01055775, 0.0103613, 0.01101853,
0.01100944, 0.01067106, 0.01085091, 0.01080405, 0.01083829, 0.01059029,
0.01037555, 0.01102004, 0.01039428, 0.01081101, 0.0107839, 0.01109158,
0.01043489, 0.01081073, 0.01066337, 0.01088162, 0.01102907, 0.0107331,
0.01014691, 0.00995868, 0.01116797, 0.01024631, 0.01107536, 0.01071542,
0.01091996, 0.01031275])