def play_c_scale_builtin(): # so you don't have to build your scales manually scale_C2 = psonic.scale(psonic.C2, psonic.MAJOR) scale_C3 = psonic.scale(psonic.C3, psonic.MAJOR) scale_C4 = psonic.scale(psonic.C4, psonic.MAJOR) print('C2 Scale:', scale_C2) print('C3 Scale:', scale_C3) print('C4 Scale:', scale_C4) # listening demo: psonic.use_synth(psonic.PIANO) play(scale_C3[0]) sleep(0.5) play(scale_C3[1]) sleep(0.5) play(scale_C3[2]) sleep(0.5) play(scale_C3[3]) sleep(0.5) play(scale_C3[4]) sleep(0.5) play(scale_C3[5]) sleep(0.5) play(scale_C3[6]) sleep(0.5) play(scale_C3[7])
def three_quarter_notes_descending_arp(): notes = sp.scale(root_note=sp.C5, scale_mode=sp.MINOR_PENTATONIC, num_octaves=1) for i in range(3): sp.use_synth(sp.SINE) sp.play(notes[-(i + 1)], release=0.1, amp=0.5) Metronome().beat_sleep(wait_len=0.25)
def riff_3(tempo: float = 60): speed = 60 / tempo psonic.use_synth(psonic.PROPHET) sc = psonic.scale(psonic.E2, psonic.MINOR) s = random.choice([0.125 * speed, 0.25 * speed, 0.5 * speed]) for i in range(8): r = random.choice([0.125, 0.25, 1, 2]) n = random.choice(sc) co = random.randint(30, 100) psonic.play(n, release=r, cutoff=co) psonic.sleep(s)
import psonic c_arpeggio = psonic.scale(psonic.C2, psonic.MAJOR, num_octaves=4) print(c_arpeggio) psonic.use_synth(psonic.PIANO) previous_note = 1000000 start = len(c_arpeggio) - 1 end = -1 # -1 b/c range function does not include the endpoint for i in range(start, end, -1): print(i) # for debugging note = c_arpeggio[i] if note == previous_note: continue psonic.play(note) psonic.sleep(0.2) previous_note = note