Mercurial > code > home > repos > light9
view bin/musicPad @ 953:891f2d75c686
subserver now also serves some premade subterms with the defined chases
Ignore-this: dbf877dc234795252e5c913d7489aa11
author | drewp@bigasterisk.com |
---|---|
date | Fri, 14 Jun 2013 05:30:45 +0000 |
parents | d8202a0a7fd5 |
children | 7772cc48e016 |
line wrap: on
line source
#!bin/python """ rewrite all the songs with silence at the start and end """ import sys, wave, logging, os sys.path.append(".") from light9 import showconfig from light9.namespaces import L9 from light9.ascoltami.playlist import Playlist logging.basicConfig(level=logging.INFO) log = logging.getLogger() introPad = 4 postPad = 9 # 5 + autostop + 4 playlist = Playlist.fromShow(showconfig.getGraph(), showconfig.showUri()) for p in playlist.allSongPaths(): log.info("read %s", p) inputWave = wave.open(p, 'r') outputDir = os.path.join(os.path.dirname(p), "pad") try: os.makedirs(outputDir) except OSError: pass # exists outputPath = os.path.join(outputDir, os.path.basename(p)) outputWave = wave.open(outputPath, 'w') outputWave.setparams(inputWave.getparams()) bytesPerSecond = (inputWave.getnchannels() * inputWave.getsampwidth() * inputWave.getframerate()) outputWave.writeframesraw("\x00" * (bytesPerSecond * introPad)) outputWave.writeframesraw(inputWave.readframes(inputWave.getnframes())) outputWave.writeframesraw("\x00" * (bytesPerSecond * postPad)) outputWave.close() log.info("wrote %s", outputPath)