def chords(): synth = WaveSynth() with Output(nchannels=1, mixing="sequential", queue_size=1) as out: for rootnote in octave_notes: chord_keys = major_chord_keys(rootnote, 4) print("chord", rootnote, ["{0} {1}".format(note, octave) for note, octave in chord_keys]) freqs = [notes[octave][key] for key, octave in chord_keys] for i in range(1, len(freqs)): assert freqs[i] > freqs[i-1] samples = [synth.sine(freq, 1.5, amplitude=0.333) for freq in freqs] s = samples[0].mix(samples[1]).mix(samples[2]).fadein(0.1).fadeout(0.1) out.play_sample(s) out.wait_all_played()
def pressed(self, note, octave, released=False): if self.arp_filter_gui.input_mode.get().startswith("arp"): if released: if self.arp_after_id: self.after_cancel(self.arp_after_id) # stop the arp cycle self.statusbar["text"] = "ok" self.arp_after_id = 0 return chord_keys = major_chord_keys(note, octave) if self.arp_filter_gui.input_mode.get() == "arpeggio3": chord_keys = list(chord_keys)[:-1] self.statusbar["text"] = "arpeggio: "+" ".join(note for note, octave in chord_keys) self.play_note(chord_keys) else: self.statusbar["text"] = "ok" self.play_note([(note, octave)], released)
def create_chord_osc(clazz, **arguments): if is_audio and self.arp_filter_gui.input_mode.get().startswith("chords"): chord_keys = major_chord_keys(note, octave) if self.arp_filter_gui.input_mode.get() == "chords3": chord_keys = list(chord_keys)[:-1] a4freq = self.a4_choice.get() chord_freqs = [note_freq(n, o, a4freq) for n, o in chord_keys] self.statusbar["text"] = "major chord: "+" ".join(n for n, o in chord_keys) oscillators = [] arguments["amplitude"] /= len(chord_freqs) for f in chord_freqs: arguments["frequency"] = f oscillators.append(clazz(**arguments)) return MixingFilter(*oscillators) else: # no chord (or an LFO instead of audio output oscillator), return one osc for only the given frequency return clazz(**arguments)