Ripple Sounds: Difference between revisions

From biophysics
Jump to navigation Jump to search
Line 4: Line 4:
Below is an example of an implementation in matlab. It is based on a broadband signal consisting of pink noise.  
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);
    
    
  % Create modulation for time domain
    % Create modulation for time domain
     sin_modulation_t = sin(2 * pi * ripples_per_sec * t + phi);
     sin_modulation_t = sin(2 * pi * ripples_per_sec * t + phi);
     cos_modulation_t = cos(2 * pi * ripples_per_sec * t + phi);         
     cos_modulation_t = cos(2 * pi * ripples_per_sec * t + phi);         
Line 27: Line 27:
     cos_modulated =  ifft(cos_modulation_f .* fft_cos_mod_t, 'symmetric');   
     cos_modulated =  ifft(cos_modulation_f .* fft_cos_mod_t, 'symmetric');   


  % determine the ripple type (ascending vs. Descending)
    % determine the ripple type (ascending vs. Descending)
     switch rippleType
     switch rippleType
         case ascending
         case ascending
Line 36: Line 36:


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


</pre>
</pre>

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