/examples/one/one.py
http://echo-nest-remix.googlecode.com/ · Python · 38 lines · 26 code · 3 blank · 9 comment · 3 complexity · 2daa3f91f4a8892dacdfd518af39c600 MD5 · raw file
- #!/usr/bin/env python
- # encoding: utf=8
- """
- one.py
- Digest only the first beat of every bar.
- By Ben Lacker, 2009-02-18.
- """
- import echonest.audio as audio
- from echonest.selection import have_pitch_max,have_pitches_max
- usage = """
- Usage:
- python one.py <input_filename> <output_filename>
- Example:
- python one.py EverythingIsOnTheOne.mp3 EverythingIsReallyOnTheOne.mp3
- """
- def main(input_filename, output_filename):
- audiofile = audio.LocalAudioFile(input_filename)
- bars = audiofile.analysis.bars
- collect = audio.AudioQuantumList()
- for bar in bars:
- collect.append(bar.children()[0])
- out = audio.getpieces(audiofile, collect)
- out.encode(output_filename)
- if __name__ == '__main__':
- import sys
- try:
- input_filename = sys.argv[1]
- output_filename = sys.argv[2]
- except:
- print usage
- sys.exit(-1)
- main(input_filename, output_filename)