Including Distortion with Audio Signal
조회 수: 35 (최근 30일)
이전 댓글 표시
I am new to MATLAB and am attempting to distort an mp3 file. I found code for distortion but I don't know how to implement the function with my signal. How do i pass the signal into the distortion? Distortion code I am using is below but I'm open to change it if need be.
function [y] = fuzz(x, Fs)
% Distortion based on an exponential function
% x - input
% gain - amount of distortion,
% mix - mix of original and distorted sound
%1=only distorted
gain = 11;
mix = 0.1;
q=x./abs(x);
y=q.*(1-exp(gain*(q.*x)));
y=mix*y+(1-mix)*x;
end
댓글 수: 0
답변 (1개)
Mathieu NOE
2021년 3월 29일
hello
this is an example how to use your function within a main code
but I guess the implementation for the distortion is not correct , the result was making my ears bleed...
had to reduce "gain" factor but even then I got only "scratches"
clearvars;
close all;
infile='DirectGuitar.wav';
outfile='out_dist.wav';
% read the sample waveform
[x,Fs] = audioread(infile);
% normalize x to +/- 1 amplitude
x = x ./ (max(abs(x)));
[y] = fuzz(x, Fs);
% write output
% normalize y to +/- 1 amplitude
y = y ./ (max(abs(y)));
audiowrite(outfile, y, Fs);
figure(1)
hold on
plot(x,'r');
plot(y,'b');
title('Distorded and original Signal');
sound(y,Fs);
function [y] = fuzz(x, Fs)
% Distortion based on an exponential function
% x - input
% gain - amount of distortion,
% mix - mix of original and distorted sound
%1=only distorted
gain = 11/5;
mix = 0.1;
q=x./abs(x);
y=q.*(1-exp(gain*(q.*x)));
y=mix*y+(1-mix)*x;
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio Processing Algorithm Design에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!