Exemple #1
0
    def markScale(self, scaleName, keyName):
        """Mark the scale in the given key.

        scaleName -- a key found in INTERVALS
        keyName -- see: checkNoteName()

        Does not call update(). Raise Exception if either scaleName or keyName
        is unknown. Return None.
        """
        try:
            keyName = self.checkNoteName(keyName)
        except:
            raise Exception('Unknown key name: {}'.format(repr(keyName)))
        intervals = INTERVALS.get(scaleName, None)
        if intervals is None:
            raise Exception('Unknown scale name: {}'.format(repr(scaleName)))
        self.markedNotes = []
        idx = NOTES.index(keyName)
        shiftedNotes = listRot(NOTES, -idx)
        notes = [shiftedNotes[0]]
        i = 0
        for ii in intervals[:-1]:
            i = i + ii
            notes.append(shiftedNotes[i])
        self.markedNotes = []
        for name in notes:
            noteName = self.checkNoteName(name)
            for string, stringNotes in enumerate(self.allNotes):
                for fret, note in enumerate(stringNotes):
                    if note == noteName:
                        self.markedNotes.append((string, fret,
                                                 note == keyName))
Exemple #2
0
    def _createNotes(self):
        """Create a MxN array of all note names on the neck.

        M is self.nStrings
        N is self.nFrets (+1 for the open string).

        Return None.
        """
        # index 0 is the bottom (lightest) string
        self.allNotes = [[] for n in range(self.nStrings)]
        t = self.tuning[-1::-1]
        for string in range(self.nStrings):
            i = NOTES.index(t[string])
            notes = NOTES[i:] + NOTES[:i]
            for f, note in enumerate(cycle(notes)):
                if f > self.nFrets:
                    break
                self.allNotes[string].append(note)