Skip to content

Commit

Permalink
disable unnecessary magphase in plot_presets
Browse files Browse the repository at this point in the history
melspectrogram does not produce complex values
revert 9eb902d
  • Loading branch information
Vincent Lostanlen committed Jun 28, 2018
1 parent 65368f0 commit 61eb016
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions docs/examples/plot_presets.py
Expand Up @@ -61,30 +61,23 @@
filename = 'audio/Karissa_Hobbs_-_09_-_Lets_Go_Fishin.mp3'
y, sr = librosa.load(filename, duration=5, offset=35)

# Generate a complex-valued mel spectrogram:
# Generate a mel spectrogram:
M = librosa.feature.melspectrogram(y=y)


# Extract magnitudes and phases from complex time-frequency bins in M:
M_mag, M_phase = librosa.magphase(M)


# Of course, you can still override the new default manually, e.g.:
M_hop512 = librosa.feature.melspectrogram(y=y, hop_length=512)
M_hop512_mag = librosa.magphase(M)[0]


# And plot the results
plt.figure(figsize=(6, 6))
ax = plt.subplot(3, 1, 1)

librosa.display.specshow(librosa.amplitude_to_db(M_mag, ref=np.max),
librosa.display.specshow(librosa.amplitude_to_db(M, ref=np.max),
y_axis='mel', x_axis='time')

plt.title('44100/1024/4096')

plt.subplot(3, 1, 2, sharex=ax, sharey=ax)
librosa.display.specshow(librosa.amplitude_to_db(M_hop512_mag, ref=np.max),
librosa.display.specshow(librosa.amplitude_to_db(M_hop512, ref=np.max),
hop_length=512,
y_axis='mel', x_axis='time')
plt.title('44100/512/4096')
Expand All @@ -95,10 +88,9 @@

y2, sr2 = librosa.load(filename, duration=5, offset=35)
M_11k = librosa.feature.melspectrogram(y=y2, sr=sr2)
M_11k_mag = librosa.magphase(M_11k)[0]

plt.subplot(3, 1, 3, sharex=ax, sharey=ax)
librosa.display.specshow(librosa.amplitude_to_db(M_11k_mag, ref=np.max),
librosa.display.specshow(librosa.amplitude_to_db(M_11k, ref=np.max),
y_axis='mel', x_axis='time')

plt.title('11025/1024/4096')
Expand Down

0 comments on commit 61eb016

Please sign in to comment.