PageRenderTime 102ms CodeModel.GetById 60ms app.highlight 3ms RepoModel.GetById 37ms app.codeStats 0ms

/examples/one/one.py

http://echo-nest-remix.googlecode.com/
Python | 38 lines | 28 code | 1 blank | 9 comment | 0 complexity | 2daa3f91f4a8892dacdfd518af39c600 MD5 | raw file
 1#!/usr/bin/env python
 2# encoding: utf=8
 3"""
 4one.py
 5
 6Digest only the first beat of every bar.
 7
 8By Ben Lacker, 2009-02-18.
 9"""
10import echonest.audio as audio
11from echonest.selection import have_pitch_max,have_pitches_max
12
13usage = """
14Usage: 
15    python one.py <input_filename> <output_filename>
16
17Example:
18    python one.py EverythingIsOnTheOne.mp3 EverythingIsReallyOnTheOne.mp3
19"""
20
21def main(input_filename, output_filename):
22    audiofile = audio.LocalAudioFile(input_filename)
23    bars = audiofile.analysis.bars
24    collect = audio.AudioQuantumList()
25    for bar in bars:
26        collect.append(bar.children()[0])
27    out = audio.getpieces(audiofile, collect)
28    out.encode(output_filename)
29
30if __name__ == '__main__':
31    import sys
32    try:
33        input_filename = sys.argv[1]
34        output_filename = sys.argv[2]
35    except:
36        print usage
37        sys.exit(-1)
38    main(input_filename, output_filename)