view light9/wavelength.py @ 1950:19c2e6216cf8

support disconnect() on a reconnectingWebSocket to make it stop connecting Ignore-this: db2fa6ff2ccdeadecf1fc7a1d144535c
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 06 Jun 2019 00:07:07 +0000
parents 1aa91a31c0e2
children
line wrap: on
line source

#!/usr/bin/python

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))