-
Notifications
You must be signed in to change notification settings - Fork 2
/
Create_Sound_from_tone_complex___.html
118 lines (117 loc) · 4.9 KB
/
Create_Sound_from_tone_complex___.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<html><head><meta name="robots" content="index,follow">
<title>Create Sound from tone complex...</title></head><body bgcolor="#FFFFFF">
<table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Palatino,Times" size=6 color="#999900"><b>
Create Sound from tone complex...
</b></font></table></table>
<p>
A command in the <a href="New_menu.html">New menu</a> to create a <a href="Sound.html">Sound</a> as the sum of a number of sine waves with equidistant frequencies.</p>
<h3>
Settings</h3>
<dl>
<dt>
<b>Name</b>
<dd>
the name of the resulting Sound object.
<dt>
<b>Start time (s)</b>
<dt>
<b>End time (s)</b>
<dd>
the time domain of the resulting Sound.
<dt>
<b>Sampling frequency (Hz)</b>
<dd>
the sampling frequency of the resulting Sound.
<dt>
<b>Phase</b>
<dd>
determines whether the result is a sum of <i>sines</i> or a sum of <i>cosines</i>, i.e., whether the zero crossings or the maxima of the components are synchronized. This choice has little perceptual consequences.
<dt>
<b>Frequency step (Hz)</b>
<dd>
the distance between the components. In first approximation, this is the perceived fundamental frequency.
<dt>
<b>First frequency (Hz)</b>
<dd>
the lowest frequency component. If you supply a value of 0, <b>First frequency</b> is taken equal to <b>Frequency step</b>.
<dt>
<b>Ceiling (Hz)</b>
<dd>
the frequency above which no components are used. If you supply a value of 0 or a value above the Sound's <a href="Nyquist_frequency.html">Nyquist frequency</a>, <i>ceiling</i> is taken equal to the Nyquist frequency.
<dt>
<b>Number of components</b>
<dd>
determines how many sinusoids are used. If you supply a value of 0 or a very high value, the maximum number of components is used, limited by <b>Ceiling</b>.
</dl>
<h3>
Example 1: a pulse train</h3>
<p>
A series of pulses at regular intervals, sampled after low-pass filtering at the Nyquist frequency, can be regarded as a sum of cosine waves. For instance, a 100-Hz pulse train, sampled at 22050 Hz, can be created with:</p>
<code>
Create Sound from tone complex... train 0 1 22050 Cosine 100 0 0 0<br></code>
<p>
Supplying the value 0 for <i>firstFrequency</i> yields an unshifted harmonic complex.</p>
<h3>
Example 2: a shifted harmonic complex</h3>
<p>
Some experiments on human pitch perception (<i>residue pitch</i>) use a number of sinusoidal components with harmonically related frequencies that are all shifted by a constant amount.</p>
<p>
For instance, to get a sum of sine waves with frequencies 105 Hz, 205 Hz, and 305 Hz, you would use:</p>
<code>
Create Sound from tone complex... train 0.3 1 22050 Sine 100 105 0 3<br></code>
<p>
or</p>
<code>
Create Sound from tone complex... train 0.3 1 22050 Sine 100 105 350 0<br></code>
<p>
whichever you prefer.</p>
<p>
Some of these experiments are described in <a href="Plomp__1967_.html">Plomp (1967)</a> and <a href="Patterson___Wightman__1976_.html">Patterson & Wightman (1976)</a>.</p>
<h3>
Algorithm</h3>
<p>
For the `sine' phase, the resulting Sound is given by the following formula:</p>
<p>
<i>x</i>(<i>t</i>) = ∑<sub><i>i</i>=1..<i>numberOfComponents</sub></i> sin (2<i></i>π·(<i>firstFrequency</i> + (<i>i</i>–1)·<i>frequencyStep</i>)·<i>t</i>)</p>
<h3>
More flexibility?</h3>
<p>
Suppose you wanted to vary the relative strengths of the frequency components. You could achieve this by creating a Sound with the command discussed here, take its Fourier transform, run a formula on the resulting Spectrum, and take the inverse Fourier transform.</p>
<p>
A more general approach is described shortly.</p>
<p>
Suppose you need a sum of sine waves with frequencies 105, 205, 305, ..., 1905 Hz, and with relative amplitudes 1, 1/2, 1/3, ..., 1/19. You could build a script that computes the various components, and add them to each other as you go along. Instead of calling 19 scripts, however, you can achieve this with the following more general script:</p>
<code>
form Add waves with decreasing amplitudes<br></code>
<code>
natural Number_of_components 19<br></code>
<code>
endform<br></code>
<code>
# Create a Matrix with frequency and amplitude information in each row:<br></code>
<code>
Create simple Matrix... freqAndGain number_of_components 2 0<br></code>
<code>
Formula... if col = 1 then row * 100 + 5 else 1 / row fi<br></code>
<code>
# Create a large Matrix with all the component sine waves:<br></code>
<code>
Create Matrix... components 0 1 10000 1e-4 0.5e-4 1 number_of_components number_of_components 1 1 0<br></code>
<code>
Formula... Matrix_freqAndGain [2] * sin (2 * pi * Matrix_freqAndGain [1] * x)<br></code>
<code>
# Integrate:<br></code>
<code>
Formula... self + self [row - 1, col]<br></code>
<code>
# Publish last row:<br></code>
<code>
To Sound (slice)... number_of_components<br></code>
<code>
Scale amplitudes... 0.99<br></code>
<hr>
<address>
<p>© ppgb, February 2, 2006</p>
</address>
</body>
</html>