def generate_blues_scale(key="C"): """Returns an ordered list of the notes of the blues scale in this key. \ For example: if the key is set to 'C', this function will return \ `['C', 'D#', 'F', 'F#', 'G', 'A#']`. \ This function will raise an !NoteFormatError if the key isn't recognised""" if not (notes.is_valid_note(key)): raise NoteFormatError, "Unrecognised format for key '%s'" % key result = [] fifth_index = notes.fifths.index(key[0]) result.append(intervals.unison(key)) result.append(notes.diminish(intervals.third(key, key))) result.append(intervals.third(key, key)) result.append(intervals.fourth(key, key)) result.append(notes.diminish(intervals.fifth(key, key))) result.append(intervals.fifth(key, key)) result.append(notes.diminish(intervals.seventh(key, key))) # Remove redundant #'s and b's from the result result = map(notes.remove_redundant_accidentals, result) tonic = result.index(notes.remove_redundant_accidentals(key)) result = result[tonic:] + result[:tonic] return result
def seventh(note, key): """Return the seventh chord on note in key. Example: >>> seventh('C', 'C') ['C', 'E', 'G', 'B'] """ return triad(note, key) + [intervals.seventh(note, key)]
def diatonic_thirteenth(note, key): """Return the eleventh chord on note in key (like chords.seventh()). Example: >>> diatonic_thirteenth('E', 'C') ['E', 'G', 'B', 'D', 'F', 'A', 'C'] <-- triad --> 7th <- seventh of 7th -> """ return triad(note, key) + seventh(intervals.seventh(note, key), key)
def get_note_pattern(pattern, key): if pattern[0] == 1 : note = intervals.unison(key) elif pattern[0] == 2 : note = intervals.second(key, key) elif pattern[0] == 3 : note = intervals.third(key, key) elif pattern[0] == 4 : note = intervals.fourth(key, key) elif pattern[0] == 5 : note = intervals.fifth(key, key) elif pattern[0] == 6 : note = intervals.sixth(key, key) elif pattern[0] == 7 : note = intervals.seventh(key, key) if pattern[3] == "bemol": note = notes.diminish(note) elif pattern[3] == "diese" : note = notes.augment(note) return note
else: beats = [random() > 0.5 for x in range(8)] t = 0 for beat in beats: # Play random note if beat and play_solo and loop > solo_start and loop < solo_end: fluidsynth.stop_Note(n) if t % 2 == 0: n = Note(choice(c).name) elif random() > 0.5: if random() < 0.46: n = Note(intervals.second(choice(c).name, key)) elif random() < 0.46: n = Note(intervals.seventh(choice(c).name, key)) else: n = Note(choice(c).name) if t > 0 and t < len(beats) - 1: if beats[t - 1] and not beats[t + 1]: n = Note(choice(c).name) fluidsynth.play_Note(n, solo_channel, randrange(80, 110)) print n # Repeat chord on half of the bar if play_chords and t != 0 and loop > chord_start and loop\ < chord_end: if swing and random() > 0.95: fluidsynth.play_NoteContainer(c, chord_channel3, randrange(20, 75))
noteLengths = [2, 4, 8] lastNote = Note() lastNoteLength = 4 while leadBar.is_full() == False: if random() < 0.8: currentBeat = leadBar.current_beat # add a note # if random() < 0.5 and len(leadBar) > 0: # n = Note(intervals.second(lastNote.name, key)) # print("second of last") if random() < 0.5 and currentBeat != 0.0: n = Note(intervals.second(choice(container).name, key)) # print("second") elif random() < 0.5 and currentBeat != 0.0: n = Note(intervals.seventh(choice(container).name, key)) # print("seventh") else: n = Note(choice(container).name) # print("in chord") lastNote = n lastNoteLength = choice(noteLengths) leadBar.place_notes(n, lastNoteLength) else: # add a rest leadBar.place_rest(choice(noteLengths)) lead.append(leadBar)