Skip to content

Instantly share code, notes, and snippets.

@wallabra
Created November 9, 2015 20:25
Show Gist options
  • Save wallabra/fdf767a2498e9b0dc992 to your computer and use it in GitHub Desktop.
Save wallabra/fdf767a2498e9b0dc992 to your computer and use it in GitHub Desktop.
# 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