Created
November 9, 2015 20:25
-
-
Save wallabra/fdf767a2498e9b0dc992 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python Audio List Module (PyMus) | |
# | |
# by Gustavo Ramos "Gustavo6046" Rehermann | |
# | |
# ========================= | |
# | |
# Creates and manipulates .pyal files to store | |
# MIDI-style music data. Be warned they are big | |
# filetypes and may occupy some space. | |
currentAudio = [] | |
def addNote(tone, duration, instrument): # adds a note in a way that remembers MIDI | |
currentAudio.append(str(tone) + '$' + str(duration) + '$' + str(instrument)) | |
print 'Added note sucessfully.' | |
def remIndexNote(noteindex): # removes a note in index | |
remnote = currentAudio.pop(noteindex) | |
print 'Removed note sucessfully.' | |
return remnote | |
def eraseCurrentAudio(): # aka "Restart Session" | |
oldca = currentAudio | |
currentAudio = [] | |
return oldca | |
print 'Erased currently working notation.' | |
def printWorkingNotes(): # so you know what you are working on! | |
print 'Currently working audio: \"' + str(currentAudio) + '\"' | |
def saveAudio(filepath): # saving audio... | |
savefilep = open(filepath + '.pyal', 'w+') | |
savefilep.write('!'.join(currentAudio)) | |
savefilep.close() | |
print 'Saved music sucessfully.' | |
def DecodeAudio(encodedaudio): # decoding audio... | |
return encodedaudio.split('!') | |
def loadCodedAudio(filepath): # and loading audio! (kinda) | |
loadfilep = open(filepath, 'r+') | |
return loadfilep.read() | |
def loadAudio(filepath): # loading correctly! | |
return DecodeAudio(loadCodedAudio(filepath)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment