view light9/wavelength.py @ 1359:39aa22c3bf0f

show cp Ignore-this: 73df1c1f51b704717c2e19b6c675b414
author Drew Perttula <drewp@bigasterisk.com>
date Sun, 05 Jun 2016 09:21:52 +0000
parents a6f4a5b2647c
children f066d6e874db
line wrap: on
line source

#!/usr/bin/python

from __future__ import division, nested_scopes
import sys, wave

def wavelength(filename):
    filename = filename.replace('.ogg', '.wav')
    wavefile = wave.open(filename, 'rb')

    framerate = wavefile.getframerate() # frames / second
    nframes = wavefile.getnframes() # number of frames
    song_length = nframes / framerate

    return song_length

if __name__ == "__main__":
    for songfile in sys.argv[1:]:
        print songfile, wavelength(songfile)