Ripple Sounds

From biophysics
Jump to navigation Jump to search

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:

Term Description
t time domain array
octaves frequency domain array
ripples_per_sec the ripple velocity in the time domain
phi a phase that can be added to the time modulation
ripples_per_octave the ripple density in the frequency domain
ripple_type determines if the ripple is ascending or descending
modulation_depth half the amplitude of the modulation


The variables that are sin modulated start with 'sin_', the cos modulated start with '_cos'. 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)
sin_modulation_time = sin(2 * pi * ripples_per_sec * t + phi);
cos_modulation_time = cos(2 * pi * ripples_per_sec * t + phi);        

% Create modulation functions for frequency domain (density modulation)
sin_modulation_freq = sin(2 * pi * ripples_per_octave * octaves);
cos_modulation_freq = cos(2 * pi * ripples_per_octave * octaves);
    
% Mirror the frequency modulation components for ifft compatibility
sin_modulation_freq = [sin_modulation_freq, fliplr(sin_modulation_freq)];
cos_modulation_freq = [cos_modulation_freq, fliplr(cos_modulation_freq)];

% Apply time modulation to pink noise in the time domain
sin_modulated_noise_time = sin_modulation_time .* pink_noise_time;
cos_modulated_noise_time = cos_modulation_time .* pink_noise_time;

% Perform fft to convert the signals to the frequency domain
sin_modulated_noise_freq = fft(sin_modulated_noise_time);
cos_modulated_noise_freq = fft(cos_modulated_noise_time);
  
% Apply frequency modulation in the frequency domain 
sin_rippled_noise_freq = sin_modulation_freq .* sin_modulated_noise_freq;
cos_rippled_noise_freq = cos_modulation_freq .* cos_modulated_noise_freq;   

% Perform ifft to get rippled noise in the time domain
sin_rippled_noise_time = ifft(sin_rippled_noise_freq, 'symmetric');
cos_rippled_noise_time = ifft(cos_rippled_noise_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 in the time domain          
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

References

% todo