Skip to content
This repository has been archived by the owner on Jun 17, 2019. It is now read-only.

Commit

Permalink
turned things into classes
Browse files Browse the repository at this point in the history
  • Loading branch information
hughrawlinson committed May 21, 2012
1 parent f31e87c commit 27f1cab
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
@@ -0,0 +1,10 @@

MacGui/SNDCNV/SNDCNV/SNDCNV-Prefix.pch

MacGui/SNDCNV/SNDCNV.xcodeproj/project.pbxproj

MacGui/SNDCNV/SNDCNV.xcodeproj/project.pbxproj

MacGui/SNDCNV/SNDCNV.xcodeproj/project.pbxproj

.DS_Store
53 changes: 53 additions & 0 deletions GUI/SNDCNV_GUI.py
@@ -0,0 +1,53 @@
import SNDCNVclassified
from Tkinter import *
import tkFileDialog
import tkMessageBox
import sys

class SNDCNV_GUI:

inputFile = ""
outputFile = ""
sndcnv = SNDCNVclassified

def null():
pass

def __init__(self, master):
frame = Frame(height=90, width=140)
frame.pack_propagate(0)
frame.pack()

inputFile = ""
outputFile = ""

SNDCNVLabel = Label(text="|| SNDCNV ||")
SNDCNVLabel.pack()

goButton = Button(frame, text="Set Input File", command=self.inputFileCallback(1))
goButton.pack()

goButton = Button(frame, text="Set Output File", command=self.inputFileCallback(2))
goButton.pack()

goButton = Button(frame, text="Go", command=null)
goButton.pack()

def inputFileCallback(self,e):
a = tkFileDialog
if(e==1):
fileName = a.askopenfilename()[1]
if(len(fileName <= 2)):
self.sndcnv.outputFile(fileName)
else:
print("File Not Valid")
elif(e==2):
fileName = a.askopenfilename()[1]
if(len(fileName <= 2)):
self.sndcnv.outputFile(fileName)
else:
print("File Not Valid")

root = Tk()
sndcnv = SNDCNV_GUI(root)
root.mainloop()
57 changes: 57 additions & 0 deletions GUI/SNDCNVclassified.py
@@ -0,0 +1,57 @@
import wave, aifc, sys, sndhdr

def __init__():
inputFileLocation = ""
outputFileLocation = ""

def inputFile(a):
inputFileLocation = a

def outputFile(a):
outputFileLocation = a

def convert():
samplePerCycle = 1
"""Converts between wav and aiff files"""
if sndhdr.what(inputFileLocation)[0] == 'wav':
#from Wav to Aiff.
input = wave.open(inputFileLocation, 'r')
output = aifc.open(outputFileLocation, 'w')

elif sndhdr.what(inputFileLocation)[0] == 'aiff':
#from Aiff to Wav
input = aifc.open(inputFileLocation, 'r')
output = wave.open(outputFileLocation, 'w')

nframes = input.getnframes()

output.setnchannels(input.getnchannels())
output.setframerate(input.getframerate())
output.setsampwidth(input.getsampwidth())

i = 1
dataset = []

for i in range(0, nframes, samplePerCycle):
input.setpos(i)
dataval = input.readframes(samplePerCycle)
dataset.append(dataval)

#===========================================
#Implement output(nframes) == input(nframes)
#===========================================
#if (nframes % samplePerCycle < samplePerCycle):
# if (nframes % samplePerCycle != 0):
# samplePerCycle = nframes % samplePerCycle

valuestr = ''.join(dataset)
output.writeframes(valuestr)

input.close()
output.close()

if __name__ == "__main__":
import sys
inputFile = sys.argv[1]
outputFile = sys.argv[2]
convert(inputFile,outputFile)
Binary file added GUI/SNDCNVclassified.pyc
Binary file not shown.
Binary file added archive/alpha 0.0.1/progressbar/__init__.pyc
Binary file not shown.
Binary file added archive/alpha 0.0.1/progressbar/compat.pyc
Binary file not shown.

0 comments on commit 27f1cab

Please sign in to comment.