Changeset - fff8762db48a
[Not reviewed]
default
0 1 1
drewp@bigasterisk.com - 20 years ago 2005-06-14 02:52:37
drewp@bigasterisk.com
finished incomplete patch- asco now measures the length of songs (only for .wav)
2 files changed with 21 insertions and 9 deletions:
0 comments (0 inline, 0 general)
bin/ascoltami
Show inline comments
 
@@ -29,7 +29,7 @@ from twisted.internet.error import Canno
 
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 @@ class Player:
 
        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 @@ class Player:
 
        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):
light9/wavelength.py
Show inline comments
 
new file 100644
 
#!/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)
0 comments (0 inline, 0 general)