Trinh @ Bath

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
vpde_lecture35 [2020/04/23 08:26]
trinh
vpde_lecture35 [2020/04/27 17:40] (current)
trinh
Line 1: Line 1:
 ====== Lecture 35: Maths of music II ====== ====== Lecture 35: Maths of music II ======
 +
 +<html>
 +<iframe width="560" height="315" src="https://www.youtube.com/embed/L0HSQ9sJB_I" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
 +</html>
  
 I don't want to dwell on the details of how the fft command works but it is enough to talk about analogies. Suppose we give you an $N$ vector $f_n$ with elements $n = 0, 1, 2, \ldots N-1$ that represents the signal we want to process. I don't want to dwell on the details of how the fft command works but it is enough to talk about analogies. Suppose we give you an $N$ vector $f_n$ with elements $n = 0, 1, 2, \ldots N-1$ that represents the signal we want to process.
Line 39: Line 43:
 The rest is about more fun stuff.  The rest is about more fun stuff. 
  
-===== Real sounds from instruments ===== +===== Pitch modification =====
- +
-===== Tuning music and beats =====+
  
 <Code:Matlab linenums:1 | Pitch> <Code:Matlab linenums:1 | Pitch>
Line 60: Line 62:
 %  sampling frequency. This is a cheap way of modifying pitch. %  sampling frequency. This is a cheap way of modifying pitch.
 sound(fA, 659.3/440*Fs) sound(fA, 659.3/440*Fs)
 +</Code>
 +
 +===== Tuning an instrument =====
 +
 +<Code:Matlab linenums:1 | Tuning>
 +% Example of tuning
 +Fs = 2^13; T = 8;
 +t = 0:1/Fs:T;
 +
 +% This is how tuning works. Play a 440Hz note with an off-tune 442Hz note
 +% signal
 +f = sin(2*pi*440*t) + sin(2*pi*442*t);
 +sound(f, Fs)
 +
 +%%
 +
 +% This is easy to show mathematically. When you add two sine waves together
 +% that differ very slightly in frequency, it gives a beating pattern
 +plot(t, f)
 </Code> </Code>