Ismir2012SoftwareSessionPlan » History » Version 7

Luis Figueira, 2012-10-03 01:43 PM

1 2 Luis Figueira
h1. Ismir2012: Software Session Plan
2 1 Luis Figueira
3 1 Luis Figueira
4 1 Luis Figueira
h2. Length and plan
5 1 Luis Figueira
6 1 Luis Figueira
* 90 min (75 + 15m interval)
7 1 Luis Figueira
8 1 Luis Figueira
h2. Software Requirements
9 1 Luis Figueira
10 1 Luis Figueira
* Python 
11 1 Luis Figueira
* Numpy
12 1 Luis Figueira
* Matplotlib
13 4 Luis Figueira
* Nose and Nosetests
14 4 Luis Figueira
* ipython (desirable, not mandatory)
15 1 Luis Figueira
16 3 Luis Figueira
h2. Repository
17 3 Luis Figueira
18 3 Luis Figueira
https://code.soundsoftware.ac.uk/hg/python-tutorial-skeleton
19 3 Luis Figueira
20 1 Luis Figueira
h2. Script
21 1 Luis Figueira
22 4 Luis Figueira
* Clone/Check if repository was successfully cloned
23 4 Luis Figueira
* Explore folder and files 
24 4 Luis Figueira
* Launch python shell (ipyhon)
25 4 Luis Figueira
* import audiofile.py and plot samples
26 4 Luis Figueira
* Explain what the test files are and introduction to nose 
27 5 Luis Figueira
* Create estimate_tempo.py (main programme)
28 4 Luis Figueira
<pre>
29 4 Luis Figueira
import tempo_estimator as est
30 4 Luis Figueira
import sys
31 4 Luis Figueira
32 4 Luis Figueira
filename = sys.argv[1]
33 4 Luis Figueira
34 4 Luis Figueira
tempo = est.estimate_tempo_of_file(filename)
35 4 Luis Figueira
</pre> 
36 4 Luis Figueira
* Easy Mercurial: 
37 4 Luis Figueira
** ignore pyc and py~
38 4 Luis Figueira
** commit estimate_tempo.py
39 4 Luis Figueira
** commit .hgignore
40 4 Luis Figueira
* Create estimate_tempo.py
41 1 Luis Figueira
* Create test file test_estimate_tempo.py
42 4 Luis Figueira
<pre>
43 5 Luis Figueira
import estimate_tempo as est
44 4 Luis Figueira
45 4 Luis Figueira
def test_tempo_120bpm():
46 4 Luis Figueira
    tempo = est.estimate_tempo_of_file("test files/120bpm.wav")
47 4 Luis Figueira
48 4 Luis Figueira
    # we consider the test to be passed if error is less than 1/4 of bpm
49 4 Luis Figueira
    error = abs(tempo - 120) < 0.25
50 1 Luis Figueira
    assert 
51 1 Luis Figueira
52 4 Luis Figueira
</pre>
53 5 Luis Figueira
* Commit both files
54 5 Luis Figueira
* Start writing the code of tempo_estimator.py
55 6 Luis Figueira
<pre>
56 6 Luis Figueira
</pre>
57 6 Luis Figueira
* Slide: how to detect tempo?
58 7 Luis Figueira
* Write the onset detection function and autocorrelation function calls in tempo_estimator.py
59 6 Luis Figueira
<pre></pre>
60 1 Luis Figueira
* Commit
61 7 Luis Figueira
* Python Shell: 
62 7 Luis Figueira
** import the audiofile module
63 7 Luis Figueira
** load the audiofile
64 7 Luis Figueira
<pre>
65 7 Luis Figueira
import audiofile as af
66 7 Luis Figueira
67 7 Luis Figueira
(samples, samplerate) = af.read_all_read_all_mono_samples_from_file('test files/beatbox.wav')
68 7 Luis Figueira
</pre>
69 7 Luis Figueira
70 7 Luis Figueira
** split the file into non overlapping blocks and calculate the RMS of each
71 7 Luis Figueira
** Hot to calculate the RMS?
72 7 Luis Figueira
<pre>
73 7 Luis Figueira
import numpy as np 
74 7 Luis Figueira
75 7 Luis Figueira
def rms(array):
76 7 Luis Figueira
    return sqrt(np.mean(samples**2))
77 7 Luis Figueira
78 7 Luis Figueira
</pre>
79 7 Luis Figueira
** test rms function working
80 7 Luis Figueira
** paste it to tempo_estimator.py and build a couple of tests