(4 intermediate revisions by 2 users not shown) | |||
Line 7: | Line 7: | ||
<center><font size= 4>21 Savage in MATLAB</font size> | <center><font size= 4>21 Savage in MATLAB</font size> | ||
− | A [http://www.projectrhea.org/learning/slectures.php slecture] by [[ECE]] student Jeff Rodrigues | + | A [http://www.projectrhea.org/learning/slectures.php slecture] by [[ECE]] student Jeff Rodrigues |
Partly based on the [[https://www.projectrhea.org/rhea/index.php/2019_Spring_ECE_301_Boutin|ECE301 Spring 2019]] lecture material of Boutin. | Partly based on the [[https://www.projectrhea.org/rhea/index.php/2019_Spring_ECE_301_Boutin|ECE301 Spring 2019]] lecture material of Boutin. | ||
Line 13: | Line 13: | ||
---- | ---- | ||
---- | ---- | ||
− | == | + | ==Introduction== |
− | + | 21 Savage is a prolific and talented artist. His debut studio album, "Issa Album", came with the lead single "Bank Account", which reached 12th on the Billboard Hot 100. This song is a suitable choice to reproduce in MATLAB, as it has a simple yet catchy tune. | |
− | + | ||
---- | ---- | ||
− | == | + | ==How it's Done== |
− | + | Playing the main track of "Bank Account" in MATLAB requires four notes: E, F#, A♭, and A. The frequencies of these notes in Hz are 329.63, 369.99, 415.3, and 440, respectively. These frequencies are designated in MATLAB along with a time step. Then, the note frequencies are ordered in a vector 'notes' according to the song, which is then used to input each frequency into a sine wave. The 'reshape' and 'soundsc' functions are used to process and then play the signal. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
---- | ---- | ||
− | == | + | ==The Code== |
− | + | clear all | |
− | + | Fs = 8000; | |
+ | delta = 1/Fs; | ||
+ | |||
+ | t = 0:delta:0.4; | ||
+ | |||
+ | %Frequencies of the notes | ||
+ | |||
+ | E = 329.63; | ||
+ | |||
+ | A_flat = 415.3; | ||
+ | |||
+ | F_sharp = 369.99; | ||
+ | |||
+ | A = 440; | ||
+ | |||
+ | notes = [E; A_flat; F_sharp; A_flat; E; A_flat; F_sharp; A_flat; E; A_flat; F_sharp; A_flat; A; A_flat; E; A_flat; E; A_flat; F_sharp; A_flat; E; A_flat; F_sharp; A_flat; E; A_flat; F_sharp; A_flat; A; A_flat; E; A_flat]; | ||
+ | |||
+ | x = sin(2*pi*notes*t); | ||
+ | |||
+ | song = reshape(x',32*length(t),1); | ||
+ | |||
+ | soundsc(song,1/delta) | ||
---- | ---- | ||
− | == | + | ==The result== |
− | + | Listen to the result [[Media:21SavageECE301S19.ogg|here ]]. | |
+ | |||
+ | |||
---- | ---- | ||
− | == | + | ==References== |
− | * | + | *https://www.youtube.com/watch?v=7N-kgbVjRuc - the song |
− | * | + | *http://pages.mtu.edu/~suits/notefreqs.html - frequencies of notes |
---- | ---- | ||
---- | ---- |
Latest revision as of 14:38, 26 April 2019
A slecture by ECE student Jeff Rodrigues
Partly based on the [Spring 2019] lecture material of Boutin.
Contents
Introduction
21 Savage is a prolific and talented artist. His debut studio album, "Issa Album", came with the lead single "Bank Account", which reached 12th on the Billboard Hot 100. This song is a suitable choice to reproduce in MATLAB, as it has a simple yet catchy tune.
How it's Done
Playing the main track of "Bank Account" in MATLAB requires four notes: E, F#, A♭, and A. The frequencies of these notes in Hz are 329.63, 369.99, 415.3, and 440, respectively. These frequencies are designated in MATLAB along with a time step. Then, the note frequencies are ordered in a vector 'notes' according to the song, which is then used to input each frequency into a sine wave. The 'reshape' and 'soundsc' functions are used to process and then play the signal.
The Code
clear all
Fs = 8000;
delta = 1/Fs;
t = 0:delta:0.4;
%Frequencies of the notes
E = 329.63;
A_flat = 415.3;
F_sharp = 369.99;
A = 440;
notes = [E; A_flat; F_sharp; A_flat; E; A_flat; F_sharp; A_flat; E; A_flat; F_sharp; A_flat; A; A_flat; E; A_flat; E; A_flat; F_sharp; A_flat; E; A_flat; F_sharp; A_flat; E; A_flat; F_sharp; A_flat; A; A_flat; E; A_flat];
x = sin(2*pi*notes*t);
song = reshape(x',32*length(t),1);
soundsc(song,1/delta)
The result
Listen to the result here .
References
- https://www.youtube.com/watch?v=7N-kgbVjRuc - the song
- http://pages.mtu.edu/~suits/notefreqs.html - frequencies of notes
Questions and comments
If you have any questions, comments, etc. please post them here.
[to 2019 Spring ECE 301 Boutin]