Skip to content

Instantly share code, notes, and snippets.

@ocelotsloth
Created October 4, 2016 01:17
Show Gist options
  • Save ocelotsloth/c9aa2efbfa34491a33c4c8d505c27ff7 to your computer and use it in GitHub Desktop.
Save ocelotsloth/c9aa2efbfa34491a33c4c8d505c27ff7 to your computer and use it in GitHub Desktop.
Sample pitch class in python
# Class to define a pitch
# returns string represetnation
class Pitch:
pitches = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
def __init__(self, intUserPitch):
self.pitch = intUserPitch
def __repr__(self):
return "Pitch(" + str(self.pitch) + ")"
def __str__(self):
return self.pitches[self.pitch]
def getPitch(self):
return self.pitch
def setPitch(self, intUserPitch):
self.pitch = intUserPitch
def getPitches(self):
return self.pitches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment