Ismir2012SoftwareSessionPlan » History » Version 10
Luis Figueira, 2012-10-03 02: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 | 8 | Luis Figueira | *** *Slide*: how to detect tempo? |
58 | 8 | Luis Figueira | *** *Slide*: how our estimator will work |
59 | 7 | Luis Figueira | * Write the onset detection function and autocorrelation function calls in tempo_estimator.py |
60 | 6 | Luis Figueira | <pre></pre> |
61 | 1 | Luis Figueira | * Commit |
62 | 7 | Luis Figueira | * Python Shell: |
63 | 7 | Luis Figueira | ** import the audiofile module |
64 | 7 | Luis Figueira | ** load the audiofile |
65 | 7 | Luis Figueira | <pre> |
66 | 7 | Luis Figueira | import audiofile as af |
67 | 7 | Luis Figueira | |
68 | 7 | Luis Figueira | (samples, samplerate) = af.read_all_read_all_mono_samples_from_file('test files/beatbox.wav') |
69 | 7 | Luis Figueira | </pre> |
70 | 7 | Luis Figueira | |
71 | 7 | Luis Figueira | ** split the file into non overlapping blocks and calculate the RMS of each |
72 | 1 | Luis Figueira | ** Hot to calculate the RMS? |
73 | 8 | Luis Figueira | ** Create signal_processing.py and test_signal_processing.py |
74 | 8 | Luis Figueira | *** *Slide*: how our estimator will work |
75 | 8 | Luis Figueira | ** ipython: write rms function |
76 | 7 | Luis Figueira | <pre> |
77 | 7 | Luis Figueira | import numpy as np |
78 | 1 | Luis Figueira | |
79 | 7 | Luis Figueira | def rms(array): |
80 | 8 | Luis Figueira | return np.sqrt(np.mean(samples**2)) |
81 | 1 | Luis Figueira | |
82 | 1 | Luis Figueira | </pre> |
83 | 8 | Luis Figueira | ** write RMS tests |
84 | 8 | Luis Figueira | ** paste RMS function to signal_processing.py |
85 | 8 | Luis Figueira | ** nosetests signal_processing.py |
86 | 9 | Luis Figueira | * in ipython again |
87 | 9 | Luis Figueira | ** how many frames (non overlapping) does the signal have? |
88 | 9 | Luis Figueira | <pre>np.ceil(samples/512)</pre> |
89 | 10 | Luis Figueira | *** don't forget to mention tghat ceil returns a float |
90 | 9 | Luis Figueira | ** what are the contents of the first frame? |
91 | 9 | Luis Figueira | <pre>samples[0:512]</pre> |
92 | 9 | Luis Figueira | ** what are the contents of the second frame? |
93 | 9 | Luis Figueira | <pre>samples[512:1024]</pre> |
94 | 9 | Luis Figueira | ** Generalising.... |
95 | 9 | Luis Figueira | * signal_processing.py |
96 | 9 | Luis Figueira | ** def get_frame_count(n_samples, increment) |
97 | 9 | Luis Figueira | ** def get_frame(samples, increment, n) |
98 | 9 | Luis Figueira | ** write tests for both functions |
99 | 10 | Luis Figueira | ** ipython: protoype both functions, write them, test them |
100 | 10 | Luis Figueira | * implement detection function on tempo_estimator.py |
101 | 10 | Luis Figueira | * implement tests |
102 | 10 | Luis Figueira | * Autocorrelation+ testing |
103 | 10 | Luis Figueira | * plot waveform and detection function |
104 | 10 | Luis Figueira | ** time scales are wrong |
105 | 10 | Luis Figueira | * create plots.py just as a simple plotting script |