Including Distortion with Audio Signal

조회 수: 35 (최근 30일)
Dominick Metro
Dominick Metro 2019년 4월 2일
답변: Mathieu NOE 2021년 3월 29일
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

답변 (1개)

Mathieu NOE
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

카테고리

Help CenterFile Exchange에서 Audio Processing Algorithm Design에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by