0% found this document useful (0 votes)
15 views

explanation of the code line per line

Uploaded by

ricardocorpuz6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

explanation of the code line per line

Uploaded by

ricardocorpuz6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Original

[x, Fs] = audioread('1ST RICARDO.mp3');

 Reads the file '1ST RICARDO.mp3'.

volume = 2;

 Sets a multiplier to increase the audio volume.

x = x * volume;

 Amplifies the audio by multiplying all samples by the volume factor.

audiowrite('1ST_RICARDO.wav', x, Fs * 2);

 Saves the audio, but with the sampling frequency doubled (Fs * 2), effectively speeding it up.

Reverb Effect

[x, Fs] = audioread('1ST EDRYAN.mp3');

 Reads the audio file '1ST EDRYAN.mp3'.

x = x / max(abs(x));

 Normalizes the audio, ensuring the maximum amplitude is 1.

decay = 0.7;

 Sets the decay factor for the reverb effect (how much the echo diminishes).

delay = round(Fs * 0.1);

 Calculates the delay in samples for the reverb (0.1 seconds).

matlab

rvrb = x + decay * [zeros(delay, 1); x(1:end-delay)];

 Adds the delayed, decayed version of the audio (x) to the original, simulating reverb.

matlab

rvrb = rvrb / max(abs(rvrb));

 Normalizes the resulting audio to prevent clipping.

matlab

audiowrite('1ST_EDRYAN_reverb.wav', rvrb, Fs);

 Saves the reverb-processed audio as '1ST_EDRYAN_reverb.wav'.


Echo Effect

[x, Fs] = audioread('1ST JACOB.mp3');

 Reads the audio file '1ST JACOB.mp3'.

x = x / max(abs(x));

 Normalizes the audio.

delay_seconds = 0.5;

 Specifies the echo delay (0.5 seconds).

decay = 0.6;

 Sets the decay factor for the echo.

delay_samples = round(Fs * delay_seconds);

 Converts the delay into a sample count.

num = [1, zeros(1, delay_samples), decay];

den = 1;

 Creates a filter where the delayed echo is scaled by decay.

y = filter(num, den, x);

 Applies the echo filter to the audio x.

y = y / max(abs(y));

 Normalizes the echoed audio.

sound(y, Fs);

 Plays the echoed audio.

Backward Playback (Backmask)

nth = 6000;

mth = 80;

 Defines a range of samples (nth - mth) for processing.

[x, Fs] = audioread('2ND ANDREI.mp3');

 Reads the audio file '2ND ANDREI.mp3'.

lth = nth - mth;

vector = x(lth:nth);
 Selects a segment of the audio.

y = flipud(x);

 Reverses the audio.

sound(y, Fs);

 Plays the reversed audio.

Pitch Shift

[x, Fs] = audioread('2ND RICARDO.mp3');

 Reads the audio file '2ND RICARDO.mp3'.

semitone_shift = 2;

pitch_shift_factor = 2^(semitone_shift / 12);

 Calculates the pitch shift factor for a 2-semitone increase.

num_samples = length(x);

new_sample_rate = round(Fs * pitch_shift_factor);

 Adjusts the sampling rate to achieve the pitch shift.

t = (0:num_samples-1) / Fs;

t_resampled = t * pitch_shift_factor;

 Generates a new time axis for the resampled audio.

y = interp1(t, x, t_resampled, 'linear', 0);

 Resamples the audio using linear interpolation.

sound(y, new_sample_rate);

 Plays the pitch-shifted audio.

audiowrite('2ND_RICARDO.wav', y, new_sample_rate);

 Saves the pitch-shifted audio.

Tremolo Effect

[x, Fs] = audioread('2ND EDRYAN.mp3');

 Reads the audio file '2ND EDRYAN.mp3'.

frequency = 5; % Tremolo frequency in Hertz


depth = 0.3; % Depth of tremolo

 Sets the tremolo frequency and intensity.

t = (0:length(x)-1) / Fs;

tremolo = (1 + depth * sin(2 * pi * frequency * t));

 Generates a modulating signal for the tremolo effect.

y = x .* tremolo';

 Applies the tremolo modulation to the audio.

sound(y, Fs);

 Plays the tremolo-processed audio.

Bitcrusher Effect

[x, Fs] = audioread('2ND JACOB.mp3');

 Reads the audio file '2ND JACOB.mp3'.

bits = 8;

x = x / max(abs(x(:)));

 Normalizes the audio and sets the bit depth to 8.

dither = rand(size(x)) * 2 - 2;

dithered_x = x + dither * 2^(2-bits);

 Adds dither (random noise) to the audio.

y = round(dithered_x * (2^(bits-2))) / (2^(bits-2));

 Reduces the bit resolution by rounding.

y = y / max(abs(y(:)));

 Normalizes the bitcrushed audio.

sound(y, Fs);

 Plays the bitcrushed audio.

audiowrite('processed_audio_with_dither.wav', y, Fs);

 Saves the bitcrushed audio.

You might also like