def __init__(self, names, intervals, bemols=0, sharps=0): """ intervals -- A list of SolfegeInterval containing the interval between a note and the tonic intervals -- list of intervals between two successive notes of the scale. If an interval is an int, it is a chromatic intervals related to the diatonic interval 1. Otherwise its a pair chromatic, diatonic) bemol,sharp -- the number of such to use when the scale starts on C""" super().__init__(names) diatonicSum=0 chromaticSum=0 intervals_correct=[] for interval in intervals: if isinstance(interval,tuple): diatonic,chromatic = interval elif isinstance(interval,int): diatonic=1 chromatic=interval if isinstance(diatonic,int): diatonic = DiatonicInterval(diatonic) if isinstance(chromatic,int): chromatic = ChromaticInterval(chromatic) diatonicSum+=diatonic.getNumber() chromaticSum+=chromatic.getNumber() interval= SolfegeInterval(chromatic=chromaticSum,diatonic=diatonicSum) intervals_correct.append(interval) if diatonicSum!=7: print("Warning: scale %s has a diatonic sum of %d"%(names[0],diatonicSum), file=sys.stderr) elif chromaticSum!=12: print("Warning: scale %s has a chromatic sum of %d"%(names[0],chromaticSum), file=sys.stderr) self.intervals=intervals_correct self.bemols=bemols self.sharps=sharps
def anki(self): """return the tuple (pos1,pos3,pos5,posn) pos1 is the string of length 6, whose x represents a string not played, . a string played, but not for note tonic, and 1 represents a string played for the tonic. pos3, pos5 are similar for third and fifth. posn is used for 6th or 7th """ text = "" for (number, setOfInterval) in [ ("1", {ChromaticInterval(0)}), ("3", {ChromaticInterval(3), ChromaticInterval(4)}), ("5", {ChromaticInterval(6), ChromaticInterval(7)}), ("n", { ChromaticInterval(9), ChromaticInterval(10), ChromaticInterval(11) }) ]: text += "," for i in self.chord: interval = self.chord[i].getInterval() if interval is None: text += "x" else: if interval in setOfInterval: text += number else: text += "." return text
def containsWrongNote(self): """Whether it contains an interval which should not be present in a standard reversed chord""" if "wrong note" not in self.dic: r = False if ChromaticInterval(1) in self.setOfInterval: debug("Contains half tone") r = True if ChromaticInterval(2) in self.setOfInterval: debug("Contains tone") r = True if ChromaticInterval(5) in self.setOfInterval: debug("contains fourth") r = True self.dic["wrong note"] = r debug("Does it contains a wrong note: %s" % r) return self.dic["wrong note"]
def __init__(self, string, fret, **kwargs): assert (isinstance(string, int)) assert (isinstance(fret, int) or fret is None) self.string = string self.fret = fret if fret is not None: super().__init__(toCopy=distance_string[self.string] + ChromaticInterval(self.fret), **kwargs) else: super().__init__(none=True, **kwargs)
def is7thMaj(self): if "has7thMaj" not in self.dic: r = ChromaticInterval(11) in self.setOfInterval self.dic["has7thMaj"] = r debug("Does it has a 7thMaj:%s" % r) return self.dic["has7thMaj"]
def is6th(self): if "has6th" not in self.dic: r = ChromaticInterval(9) in self.setOfInterval self.dic["has6th"] = r debug("Does it has a 6th:%s" % r) return self.dic["has6th"]
def isFifthJust(self): if "isFifthJust" not in self.dic: r = ChromaticInterval(7) in self.setOfInterval self.dic["isFifthJust"] = r debug("is it fifth just:%s" % r) return self.dic["isFifthJust"]
def isFifthAugmented(self): if "isFifthAugmented" not in self.dic: r = ChromaticInterval(8) in self.setOfInterval self.dic["isFifthAugmented"] = r debug("is it fifth diminished:%s" % r) return self.dic["isFifthAugmented"]
def isMajor(self): if "isMajor" not in self.dic: r = ChromaticInterval(4) in self.setOfInterval self.dic["isMajor"] = r debug("is it major:%s" % r) return self.dic["isMajor"]
def containsTonic(self): if "containsTonic" not in self.dic: r = ChromaticInterval(0) in self.setOfInterval self.dic["containsTonic"] = r debug("Does it contains tonic:%s" % r) return self.dic["containsTonic"]