Skip to content

Commit

Permalink
Fixing the plot spectrum function for mono wave files
Browse files Browse the repository at this point in the history
  • Loading branch information
mgm8 committed May 19, 2024
1 parent 94b9b00 commit 9209292
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions spacelab_decoder/spacelabdecoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,19 +283,28 @@ def on_button_plot_clicked(self, button):
error_dialog.destroy()
else:
# Read the wav file (mono)
sampling_frequency, signal_data = wavfile.read(self.filechooser_audio_file.get_filename())
sampling_frequency, data = wavfile.read(self.filechooser_audio_file.get_filename())

samples = list()

# Convert stereo to mono by reading only the first channel
if data.ndim > 1:
for i in range(len(data)):
samples.append(data[i][0])
else:
samples = data

# Plot the signal read from wav file
plt.figure(num='Spectrogram');
plt.subplot(211)
plt.title(self.filechooser_audio_file.get_filename())

plt.plot(signal_data, linewidth=0.75)
plt.plot(samples, linewidth=0.75)
plt.xlabel('Sample')
plt.ylabel('Amplitude')

plt.subplot(212)
plt.specgram(signal_data, Fs=sampling_frequency)
plt.specgram(samples, Fs=sampling_frequency)
plt.xlabel('Time [sec]')
plt.ylabel('Frequency [Hz]')

Expand Down
2 changes: 1 addition & 1 deletion spacelab_decoder/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
__copyright__ = "Copyright The SpaceLab-Decoder Contributors"
__credits__ = ["Gabriel Mariano Marcelino - PU5GMA"]
__license__ = "GPLv3"
__version__ = "0.3.23"
__version__ = "0.3.24"
__maintainer__ = "Gabriel Mariano Marcelino - PU5GMA"
__email__ = "[email protected]"
__status__ = "Development"

0 comments on commit 9209292

Please sign in to comment.