Mercurial > code > home > repos > light9
changeset 243:fff8762db48a
finished incomplete patch- asco now measures the length of songs (only for .wav)
author | drewp@bigasterisk.com |
---|---|
date | Tue, 14 Jun 2005 02:52:37 +0000 |
parents | 561b4202461d |
children | 1f7edb2e4724 |
files | bin/ascoltami light9/wavelength.py |
diffstat | 2 files changed, 21 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/ascoltami Mon Jun 13 03:18:04 2005 +0000 +++ b/bin/ascoltami Tue Jun 14 02:52:37 2005 +0000 @@ -29,7 +29,7 @@ from twisted.web import xmlrpc, server import run_local -from light9 import networking, showconfig +from light9 import networking, showconfig, wavelength from pympd import Mpd @@ -138,7 +138,9 @@ reactor.callLater(.05, self.pollStatus) def set_total_time(self, song_path): - raise NotImplementedError("get lengther.py from semprini") + # currently only good for .wav + p = os.path.join(showconfig.musicDir(), song_path) + self.total_time.set(wavelength.wavelength(p)) def play(self, song_path): @@ -150,13 +152,6 @@ self.filename_var.set(song_path) self.set_total_time(song_path) -## # jump to song 1 to get its total_time -## self.mpd.seek(seconds=0, song=1) -## self.mpd.pause() -## self.mpd.status().addCallback(self.play2) - -## def play2(self, stat): -## self.total_time.set(stat.time_total) self.mpd.seek(seconds=0, song=0) def check_autopause(self):
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/light9/wavelength.py Tue Jun 14 02:52:37 2005 +0000 @@ -0,0 +1,17 @@ +#!/usr/bin/python + +from __future__ import division, nested_scopes +import sys, wave + +def wavelength(filename): + 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)