diff --git a/report/wavetable_trumpet.wav b/report/Trumpet_wavetable.wav similarity index 100% rename from report/wavetable_trumpet.wav rename to report/Trumpet_wavetable.wav diff --git a/report/trumpet_comparison.png b/report/trumpet_comparison.png new file mode 100644 index 0000000..a71b421 Binary files /dev/null and b/report/trumpet_comparison.png differ diff --git a/report_archive/trumpet_comparison.png b/report_archive/trumpet_comparison.png new file mode 100644 index 0000000..0b41cab Binary files /dev/null and b/report_archive/trumpet_comparison.png differ diff --git a/report_archive/trumpet_sample_spectrogram.png b/report_archive/trumpet_sample_spectrogram.png new file mode 100644 index 0000000..68f5ff6 Binary files /dev/null and b/report_archive/trumpet_sample_spectrogram.png differ diff --git a/report_archive/trumpet_wavetable_spectrogram.png b/report_archive/trumpet_wavetable_spectrogram.png new file mode 100644 index 0000000..14bccbd Binary files /dev/null and b/report_archive/trumpet_wavetable_spectrogram.png differ diff --git a/resampler/analysis.py b/resampler/analysis.py new file mode 100644 index 0000000..d8f67bc --- /dev/null +++ b/resampler/analysis.py @@ -0,0 +1,47 @@ +import librosa +import librosa.display +import matplotlib.pyplot as plt +import numpy as np + +def compute_spectrogram(audio_path): + # Load audio file + y, sr = librosa.load(audio_path) + # Compute spectrogram + D = librosa.amplitude_to_db(np.abs(librosa.stft(y)), ref=np.max) + return D, sr + +# Compute spectrograms for both files +D1, sr1 = compute_spectrogram('samples/Trumpet.wav') +D2, sr2 = compute_spectrogram('report/Trumpet_wavetable.wav') + +# Create figure with 2x2 grid +plt.figure(figsize=(15, 10)) + +# Plot original spectrogram (magma) +plt.subplot(2, 2, 1) +librosa.display.specshow(D1, sr=sr1, x_axis='time', y_axis='log', cmap='magma') +plt.colorbar(format='%+2.0f dB') +plt.title('Original Trumpet Sample (Bflat3)') + +# Plot wavetable spectrogram (viridis) +plt.subplot(2, 2, 2) +librosa.display.specshow(D2, sr=sr2, x_axis='time', y_axis='log', cmap='viridis') +plt.colorbar(format='%+2.0f dB') +plt.title('Wavetable Recreation of Trumpet (Bflat3)') + +# Plot combined spectrogram (spanning bottom row) +plt.subplot(2, 1, 2) +# Plot original first with higher alpha +librosa.display.specshow(D1, sr=sr1, x_axis='time', y_axis='log', cmap='magma', alpha=0.7) +# Plot wavetable second with lower alpha +librosa.display.specshow(D2, sr=sr2, x_axis='time', y_axis='log', cmap='viridis', alpha=0.3) +plt.colorbar(format='%+2.0f dB') +plt.title('Combined View (Original in Magma, Wavetable in Viridis)') + +plt.tight_layout() + +# Save the figure +plt.savefig('report/trumpet_comparison.png') + +# Show the figure +plt.show() \ No newline at end of file