Created
October 4, 2016 01:17
-
-
Save ocelotsloth/c9aa2efbfa34491a33c4c8d505c27ff7 to your computer and use it in GitHub Desktop.
Sample pitch class in python
This file contains 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
# 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