% NIDRAM — educational sonification example. Synthetic data, not a molecule.
% Run from this folder in MATLAB. No specialist toolbox is required.
% Mapping: f_audio = 110 * sqrt(wavenumber_cm1 / 500).
% This does not preserve physical molecular frequencies or imply healing.
T = readtable('synthetic-modes.csv');
Fs = 44100; duration = 12; t = (0:1/Fs:duration-1/Fs)';
f = 110 * sqrt(T.wavenumber_cm1 / 500);
weights = T.relative_intensity / sum(T.relative_intensity);
y = zeros(size(t));
for k = 1:height(T)
    y = y + weights(k) * sin(2*pi*f(k)*t);
end
envelope = min(1,t/2) .* min(1,(duration-t)/3);
y = y .* envelope;
y = 0.15 * y / max(max(abs(y)),eps);
audiowrite('nidram-synthetic-sonification.wav',[y y],Fs);
disp('Wrote synthetic demonstration; not an IR/Raman measurement.');
