Advertisement
STANAANDREY

ring modulator

Oct 8th, 2023
1,365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.72 KB | None | 0 0
  1. ringModulation('input.wav', 'output.wav', 100);
  2.  
  3. function ringModulation(inputFilePath, outputFilePath, modulatorFrequency)
  4.     [inputWave, sampleRate] = audioread(inputFilePath);
  5.    
  6.     t = (0:length(inputWave) - 1) / sampleRate;
  7.     modulator = sin(2 * pi * modulatorFrequency * t)';
  8.    
  9.     outputWave = inputWave .* modulator;
  10.    
  11.     audiowrite(outputFilePath, outputWave, sampleRate);
  12.    
  13.     figure;
  14.     subplot(3, 1, 1);
  15.     plot(t(1:1000), inputWave(1:1000));
  16.     title('Input Wave');
  17.    
  18.     subplot(3, 1, 2);
  19.     plot(t(1:1000), outputWave(1:1000));
  20.     title('Output Wave (Ring Modulated)');
  21.    
  22.     subplot(3, 1, 3);
  23.     plot(t(1:1000), modulator(1:1000));
  24.     title('Modulator Signal');
  25. end
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement