Added MP3 and OGG support

This commit is contained in:
Skyler Lehmkuhl 2013-01-20 16:49:21 -05:00
parent 023e4ca5bd
commit 1d08fd9587
3 changed files with 60 additions and 50 deletions

View File

@ -4,6 +4,6 @@ Section: graphics
Priority: optional
Architecture: all
Installed-size: 27000
Depends: bash, python, python-imaging, imagemagick, libzzip-0-13, sox, python-numpy
Depends: bash, python, python-imaging, imagemagick, libzzip-0-13, sox, python-numpy, mplayer
Maintainer: skycooler@gmail.com
Description: Lightningbeam is an open-source animated content creation tool.

View File

@ -685,7 +685,7 @@ def save_file_as(widget=None):
pass
def import_to_stage(widget=None):
try:
thefile = svlgui.file_dialog("open",None,["jpg","png","bmp","wav"]).path
thefile = svlgui.file_dialog("open",None,["jpg","png","bmp","wav","mp3","ogg"]).path
except AttributeError:
# User cancelled
return
@ -716,7 +716,12 @@ def import_to_stage(widget=None):
root.descendItem().add(im)
break
else:
if thefile.endswith("wav"):
for i in ("wav", "mp3", "ogg"):
if thefile.endswith(i):
if i in ("mp3", "ogg"):
theorigfile = thefile
thefile = svlgui.SECURETEMPDIR+"/"+thefile.split('/')[-1]+'.wav'
os.system('mplayer -srate 48000 -vo null -vc null -ao pcm:fast:file="'+thefile+'" "'+theorigfile+'"')
if svlgui.PLATFORM=="osx":
if not os.path.exists('sox/sox'):
try:
@ -762,8 +767,12 @@ def import_to_stage(widget=None):
data = NP.fromstring(subprocess.check_output(cmd),'<i%d'%(out_byps))
data = data.reshape(len(data)/num_channels, num_channels)
info = subprocess.check_output([SOX_EXEC,'--i',thefile])
sound = svlgui.Sound(data, name=thefile.split('/')[-1], path=thefile, info=info)
if i=="mp3":
sound = svlgui.Sound(data, name=thefile.split('/')[-1], path=theorigfile, info=info, type=i)
else:
sound = svlgui.Sound(data, name=thefile.split('/')[-1], path=thefile, info=info, type=i)
root.descendItem().add(sound)
break
MainWindow.stage.draw()
def import_to_library(widget=None):

View File

@ -1977,7 +1977,7 @@ class Text (object):
class Sound:
"""Class for storing sounds in."""
def __init__(self, data, name, path, info):
def __init__(self, data, name, path, info, type):
global Library
Library.append(self)
self.data = data
@ -1989,6 +1989,7 @@ class Sound:
self.yscale = 0
self.path = path
self.iname = None
self.type = type
reading_comments_flag = False
other = ''
for l in info.splitlines():