Difference between revisions of "Ripple Sounds"
Jump to navigation
Jump to search
Line 29: | Line 29: | ||
% Mirror the frequency modulation components for ifft compatibility | % Mirror the frequency modulation components for ifft compatibility | ||
− | + | mirrored_mod_sin_freq = [modulation_sin_freq, fliplr(modulation_sin_freq)]; | |
− | + | mirrored_mod_cos_freq = [modulation_cos_freq, fliplr(modulation_cos_freq)]; | |
% Apply time modulation to pink noise in the time domain | % Apply time modulation to pink noise in the time domain | ||
Line 36: | Line 36: | ||
modulated_noise_cos_time = modulation_cos_time .* pink_noise_time; | modulated_noise_cos_time = modulation_cos_time .* pink_noise_time; | ||
− | % Perform fft to | + | % Perform fft to convert the signals to the frequency domain |
modulated_noise_sin_freq = fft(modulated_noise_sin_time); | modulated_noise_sin_freq = fft(modulated_noise_sin_time); | ||
modulated_noise_cos_freq = fft(modulated_noise_cos_time); | modulated_noise_cos_freq = fft(modulated_noise_cos_time); | ||
Line 45: | Line 45: | ||
% Perform ifft to get rippled noise in the time domain | % Perform ifft to get rippled noise in the time domain | ||
− | sin_rippled_noise_time = ifft( | + | sin_rippled_noise_time = ifft(rippled_noise_sin_freq , 'symmetric'); |
− | cos_rippled_noise_time = ifft( | + | cos_rippled_noise_time = ifft(rippled_noise_cos_freq , 'symmetric'); |
% Determine the ripple type (ascending vs. descending) | % Determine the ripple type (ascending vs. descending) | ||
Line 57: | Line 57: | ||
% Calculate the final rippled stimulus | % Calculate the final rippled stimulus | ||
− | + | rippled_stimulus_time = pink_noise_time + modulation_depth * combined_rippled_noise_time; | |
</pre> | </pre> | ||
Revision as of 10:36, 16 August 2024
Introduction
%todo
FFT-iFFT method
Below is an example of an implementation in matlab. It is based on a broadband signal consisting of pink noise. The input parameters are
- t = time domain array
- octaves = frequency domain array
- ripples_per_sec = the ripple velocity
- phi = a phase that can be added to the time modulation
- ripples_per_octave = the ripple density
- ripple_type = determines if the ripple is ascending or descending
- modulation_depth = half the amplitude of the modulation
The variables in the time domain are denoted by '_time' at the end and variables in the frequency domain by '_freq'.
% Generate array with pink noise pink_noise_time = pinknoise(length(t)); % Create modulation functions for time domain (velocity modulation) modulation_sin_time = sin(2 * pi * ripples_per_sec * t + phi); modulation_cos_time = cos(2 * pi * ripples_per_sec * t + phi); % Create modulation functions for frequency domain (density modulation) modulation_sin_freq = sin(2 * pi * ripples_per_octave * octaves); modulation_cos_freq = cos(2 * pi * ripples_per_octave * octaves); % Mirror the frequency modulation components for ifft compatibility mirrored_mod_sin_freq = [modulation_sin_freq, fliplr(modulation_sin_freq)]; mirrored_mod_cos_freq = [modulation_cos_freq, fliplr(modulation_cos_freq)]; % Apply time modulation to pink noise in the time domain modulated_noise_sin_time = modulation_sin_time .* pink_noise_time; modulated_noise_cos_time = modulation_cos_time .* pink_noise_time; % Perform fft to convert the signals to the frequency domain modulated_noise_sin_freq = fft(modulated_noise_sin_time); modulated_noise_cos_freq = fft(modulated_noise_cos_time); % Apply frequency modulation in the frequency domain rippled_noise_sin_freq = mirrored_mod_sin_freq .* modulated_noise_sin_freq; rippled_noise_cos_freq = mirrored_mod_cos_freq .* modulated_noise_cos_freq; % Perform ifft to get rippled noise in the time domain sin_rippled_noise_time = ifft(rippled_noise_sin_freq , 'symmetric'); cos_rippled_noise_time = ifft(rippled_noise_cos_freq , 'symmetric'); % Determine the ripple type (ascending vs. descending) switch ripple_type case 'ascending' combined_rippled_noise_time = sin_rippled_noise_time + cos_rippled_noise_time; case 'descending' combined_rippled_noise_time = sin_rippled_noise_time - cos_rippled_noise_time; end % Calculate the final rippled stimulus rippled_stimulus_time = pink_noise_time + modulation_depth * combined_rippled_noise_time;
N.B. when the density is zero 'rippled_noise' by itself has an envelope of a rectified sine wave (which has double the velocity). Only after adding the original noise the envelope is the correct one.
Band filter method
%todo