Introduction
AIFF Interchange is a simple GUI program that lets the user import one or more AIFF files, and export them to WAVE or FLAC. (Note: Flac conversion is done using default settings)
The program is written in PythonCard.
Current Source Code
(this part is likely to change. When the release date gets closer, the files will be .tgz'ed and uploaded to the project site).
aiffinterchange.rsrc.py
{'application':{'type':'Application',
'name':'Template',
'backgrounds': [
{'type':'Background',
'name':'bgTemplate',
'title':u'Copland AIFF Interchange',
'size':(375, 247),
'menubar': {'type':'MenuBar',
'menus': [
{'type':'Menu',
'name':'menuFile',
'label':'&File',
'items': [
{'type':'MenuItem',
'name':'menuFileExit',
'label':'E&xit',
'command':'exit',
},
]
},
]
},
'components': [
{'type':'StaticText',
'name':'StaticText1',
'position':(15, 196),
'size':(348, -1),
'alignment':u'right',
'text':u'Copland AIFF Interchange',
},
{'type':'Gauge',
'name':'progressBar',
'position':(10, 162),
'size':(353, 32),
'backgroundColor':(225, 217, 209),
'foregroundColor':(0, 0, 0),
'layout':'horizontal',
'max':100,
'value':0,
},
{'type':'Button',
'name':'cmdFlac',
'position':(174, 114),
'label':u'Free Lossless Audio (.flac)',
},
{'type':'Button',
'name':'cmdWav',
'position':(19, 114),
'size':(146, -1),
'label':u'Wave (.wav)',
},
{'type':'StaticBox',
'name':'StaticBox2',
'position':(10, 90),
'size':(353, 68),
'label':u'2. Select format',
},
{'type':'Button',
'name':'cmdBrowse',
'position':(260, 32),
'label':u'Browse...',
},
{'type':'TextField',
'name':'txtInputPath',
'position':(19, 35),
'size':(232, -1),
'editable':False,
},
{'type':'StaticBox',
'name':'StaticBox1',
'position':(10, 10),
'size':(353, 68),
'label':u'1. Select input file(s)',
},
] # end components
} # end background
] # end backgrounds
} }
aiffinterchange.py
#!/usr/bin/python
"""
__version__ = "$Revision: 1.5 $"
__date__ = "$Date: 2004/04/30 16:26:12 $"
"""
from PythonCard import model
import commands
class MyBackground(model.Background):
def on_initialize(self, event):
# if you have any initialization
# including sizer setup, do it here
pass
def on_cmdBrowse_mouseClick(self,event):
self.filesIn = commands.getoutput("zenity --file-selection --title=\"Select one or more AIFFs to convert\" --multiple --separator=:")
if self.filesIn:
self.components.txtInputPath.text = self.filesIn
self.filesInList = self.filesIn.split(":")
def on_cmdWav_mouseClick(self,event):
self.components.progressBar.max = len(self.filesInList)
self.components.cmdWav.enabled = False
self.components.cmdFlac.enabled = False
for infile in self.filesInList:
outfile = infile + ".wav"
commandOutput = commands.getoutput("sox -t aiff \"" + infile + "\" -t wav \"" + outfile + "\"")
self.components.progressBar.value+=1
if (commandOutput.find("ERROR") != -1):
commands.getoutput("zenity --error --title=\"AIFF Interchange\" --text=\"An error occurred:\n" + commandOutput + "\"")
continue
self.components.progressBar.value = 0
self.components.cmdWav.enabled = True
self.components.cmdFlac.enabled = True
commands.getoutput("zenity --info --title=AIFF\ Converter --text=AIFF\ Conversion\ is\ complete.")
def on_cmdFlac_mouseClick(self, event):
self.components.progressBar.max = len(self.filesInList)
self.components.cmdWav.enabled = False
self.components.cmdFlac.enabled = False
for infile in self.filesInList:
commandOutput = commands.getoutput("flac \"" + infile + "\"")
self.components.progressBar.value+=1
if (commandOutput.find("ERROR") != -1):
commands.getoutput("zenity --error --title=\"AIFF Interchange\" --text=\"An error occurred:\n" + commandOutput + "\"")
continue
self.components.progressBar.value = 0
self.components.cmdWav.enabled = True
self.components.cmdFlac.enabled = True
commands.getoutput("zenity --info --title=AIFF\ Converter --text=AIFF\ Conversion\ is\ complete.")
if __name__ == '__main__':
app = model.Application(MyBackground)
app.MainLoop()