diff --git a/docs/examples/plot_presets.py b/docs/examples/plot_presets.py index bd59dd8e9e..e1c9583da2 100644 --- a/docs/examples/plot_presets.py +++ b/docs/examples/plot_presets.py @@ -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') @@ -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')