Reorganized Into Folders

This commit is contained in:
Darell Chua Yun Da
2021-12-10 10:01:30 +08:00
parent 88f77fed35
commit f856cdcd2b
41 changed files with 53 additions and 4 deletions

BIN
src/NotWorking/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,17 @@
function x = Daniel_Doan_convolution(f,h)
%input: two 1d arrays representing two sound signals in the time domain
%output: the convolution of the two waves, which is the inverse FT of
%FT(f)*FT(h)
%author: Daniel Doan
%padding to ensure the entire convolution is calculated
pad = length(f) + length(h) - 1;
%take FT of f
F = fft(f, pad);
%take FT of h
H = fft(h, pad);
%multiply the two FTs
X = F .* H;
%take inverse FT of the product
x = ifft(X);
end

34
src/NotWorking/add_sine.m Normal file
View File

@@ -0,0 +1,34 @@
function x = add_sine(amplitude, fundamental, harmonics, fs, duration)
% ADD_SINE: Additive sine wave synthesis
%CONTRIBUTORS:
%Benjamin Liou: Original author
% DOCUMENTATION:
% harmonics should ideally be a 1D matrix of:
% overtones: positive integers
% undertones: 1/ positive integers
% example: [1/2, 1, 2, 3]
% NOTE: pitch of the fundamental frequency will still be perceived even
% when the fundamental itself is missing. ex. [4,5,6]
% NOTE: it seems like when MATLAB's built in sound() takes in values,
% magnitudes over 1 get distorted.
% initialize local variables from input arguments
n = fs * duration; % number of samples (length of matrix)
% initialize a one dimensional zero matrix to be populated
x = zeros(1, n);
% populate matrix by adding sine waves
for harmonic = harmonics
x = x + generate_sine(1, fundamental * harmonic, 0, fs, duration);
end
% scale to amplitude
scalar = max(abs(x));
x = x / scalar * amplitude;
end

29
src/NotWorking/fade_in.m Normal file
View File

@@ -0,0 +1,29 @@
function output = fade_in(input, time)
% Creates a fade-in sound effect that lasts a given
% time parameter of the input sound signal
% By Yalu Ouyang
% input: a 1D array that represents the sound signal in the time domain
% time: how long the fade in effect should last
% Shouldn't be longer than the input signal (in which case the function
% treats it as the duration of the signal)
% Returns modified signal in the time domain (output).
len = length(input);
% if time parameter longer than signal, treat time as
% the duration of original signal
if time > len
time = len
end
% set multiplier as 1D array
% fade in effect: from no volume to full volume of signal
multiplier = (1 : time) / time;
% the resulting fade-in output
output = input .* multiplier;
end
% This is useful for making videos, specifically the intro part

32
src/NotWorking/fade_out.m Normal file
View File

@@ -0,0 +1,32 @@
function output = fade_out(input, time)
% Creates a fade-out sound effect that lasts a given
% time parameter of the input sound signal
% By Yalu Ouyang
% input: a 1D array that represents the sound signal in the time domain
% time: how long the fade out effect should last
% Shouldn't be longer than the input signal
% (in which case the function treats it as the duration of the signal)
% Returns modified signal in the time domain (output).
len = length(input);
% if time parameter longer than signal, treat time as
% the duration of original signal
if time > len
time = len
end
% set multiplier as 1D array
multiplier = (1 : time) / time;
% fade out effect: from full volume of signal to no volume
multiplier = flip(multiplier)
% the resulting fade-in output
output = input .* multiplier;
end
% This is useful for creating videos, specifically the outro part