diff --git a/audio_to_float/scripts/spectrogram.py b/audio_to_float/scripts/spectrogram.py index 72fc7c73..fbee64c1 100755 --- a/audio_to_float/scripts/spectrogram.py +++ b/audio_to_float/scripts/spectrogram.py @@ -32,7 +32,9 @@ def update(self, event): if len(self.buffer) < self.buffer_len: return samples = np.asarray(self.buffer) - f, t, Sxx = signal.spectrogram(samples, self.sample_rate) + # TODO(lucasw) this is hugely inefficient if it is re-calculating + # for samples that were processed in previous update. + f, t, Sxx = signal.spectrogram(samples, self.sample_rate, nperseg=512) # TODO(lucasw) is there a standard spectrogram conversion? Sxx = np.log(1.0 + Sxx * 2**16) mins = np.min(Sxx) diff --git a/float_to_audio/scripts/gen_float.py b/float_to_audio/scripts/gen_float.py index 9572541c..fba2e578 100755 --- a/float_to_audio/scripts/gen_float.py +++ b/float_to_audio/scripts/gen_float.py @@ -12,6 +12,7 @@ # In order to support this a fifo buffer will store all the samples to be # played back, and grow it as needed to support the longest sample received. +import random import rospy from sensor_msgs.msg import ChannelFloat32 @@ -56,6 +57,7 @@ def update(self, event): val += sc * (fr * 4.0 - 1.0) else: val += sc * (1.0 - ((fr - 0.5) * 4.0)) + val += random.random() * 0.2 self.msg.values[i] = val self.counter += 1