Advertisement
STANAANDREY

tremolo

Oct 8th, 2023
1,253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.01 KB | None | 0 0
  1. inputFilePath = 'input.wav';
  2. outputFilePath = 'output_with_tremolo.wav';
  3. modulatorAmplitude = 0.95; % Adjust the modulation depth as needed
  4. modulatorFrequency = 400;   % Adjust the modulation frequency as needed
  5.  
  6. addTremolo(inputFilePath, outputFilePath, modulatorAmplitude, modulatorFrequency);
  7.  
  8.  
  9. function addTremolo(inputFilePath, outputFilePath, modulatorAmplitude, modulatorFrequency)
  10.     [inputWave, fs] = audioread(inputFilePath);
  11.    
  12.     t = (0:length(inputWave) - 1) / fs;
  13.     modulatorSignal = 1 + modulatorAmplitude * sin(2 * pi * modulatorFrequency * t);
  14.    
  15.     outputWave = inputWave .* modulatorSignal';
  16.    
  17.     audiowrite(outputFilePath, outputWave, fs);
  18.    
  19.     figure;
  20.  
  21.     subplot(3, 1, 1);
  22.     plot(t(1:1000), inputWave(1:1000));
  23.     title('Input Wave');
  24.    
  25.     subplot(3, 1, 2);
  26.     plot(t(1:1000), outputWave(1:1000));
  27.     title('Output Wave (with Tremolo)');
  28.    
  29.     subplot(3, 1, 3);
  30.     plot(t(1:1000), modulatorSignal(1:1000));
  31.     title('Modulator Signal');
  32.    
  33. end
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement