Cut the one channel data in chunks and analyzes them separately. Making the chunksize a power of two works fastest.
(data, freq, bits, chunksize=512)
| 158 | |
| 159 | |
| 160 | def analyze_chunks(data, freq, bits, chunksize=512): |
| 161 | """Cut the one channel data in chunks and analyzes them separately. |
| 162 | |
| 163 | Making the chunksize a power of two works fastest. |
| 164 | """ |
| 165 | res = [] |
| 166 | while data != []: |
| 167 | f = find_frequencies(data[:chunksize], freq, bits) |
| 168 | res.append(sorted(find_notes(f), key=operator.itemgetter(1))[-1][0]) |
| 169 | data = data[chunksize:] |
| 170 | return res |
| 171 | |
| 172 | |
| 173 | def find_melody(file="440_480_clean.wav", chunksize=512): |
no test coverage detected