Ripple Sounds: Difference between revisions

From biophysics
Jump to navigation Jump to search
Created page with "==Introduction== %todo ===FFT-iFFT method=== %todo <pre> % create array with pink noise noise = pinknoise(n); % Create modulation for time domain sin_modulation_..."
 
Line 2: Line 2:
%todo
%todo
===FFT-iFFT method===
===FFT-iFFT method===
%todo
Below is an example of an implementation in matlab. It is based on a broadband signal consisting of pink noise.
<pre>
<pre>
% create array with pink noise
  % create array with pink noise
   noise = pinknoise(n);
   noise = pinknoise(n);
    
    
Line 28: Line 28:


   % determine the ripple type (ascending vs. Descending)
   % determine the ripple type (ascending vs. Descending)
     switch obj.rippleType
     switch rippleType
         case ascending
         case ascending
             rippleStimulus = sin_modulated + cos_modulated;
             rippleStimulus = sin_modulated + cos_modulated;

Revision as of 08:22, 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.

   % create array with pink noise
   noise = pinknoise(n);
   
   % Create modulation for time domain
    sin_modulation_t = sin(2 * pi * ripples_per_sec * t + phi);
    cos_modulation_t = cos(2 * pi * ripples_per_sec * t + phi);        

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

    % apply time modulation to noise, perform fft 
    fft_sin_mod_t = fft(sin_modulation_t .* noise);
    fft_cos_mod_t = fft(cos_modulation_t .* noise);
  
    %apply frequency modulation and perform ifft
    sin_modulated =  ifft(sin_modulation_f .* fft_sin_mod_t, 'symmetric');
    cos_modulated =  ifft(cos_modulation_f .* fft_cos_mod_t, 'symmetric');   

   % determine the ripple type (ascending vs. Descending)
    switch rippleType
        case ascending
            rippleStimulus = sin_modulated + cos_modulated;
        case descending
            rippleStimulus = sin_modulated - cos_modulated;
    end 

    % calculate the modulated stimulus          
   rippleStimulus = noise + modulationDepth * rippleStimulus;

Band filter method

%todo

References