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
Last revision Both sides next revision
vpde_lecture35 [2020/04/23 08:26]
trinh
vpde_lecture35 [2020/04/23 08:34]
trinh
Line 39: Line 39:
 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 58:
 %  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>