Hi,
I’m new to scamp and excited to get it working. I’m trying to use a function that handles playing melody, volume and duration to create a simple two-part unison melody similar to the tutorial video on forking. Unfortunately, I am getting a lengthy error (“Exception in thread Thread-203” is start of error message) when I run the code below. However, the example 09_multi_part.py file from Github does work (scamp/09_multi_part.py at master · MarcTheSpark/scamp · GitHub). Any help understanding why this doesn’t work and what best practices are for creating multipart melodies with function and lists of pitches would be appreciated.
from scamp import *
s = Session()
s.tempo = 90
piano = s.new_part("piano")
clarinet = s.new_part("clarinet")
mel = [60, 63, 65, 66, 67, 70, 72, 70, 67, 66, 65, 63, 60]
vol = [0.5, 0.5, 0.5, 0.5,1.0, 1.0, 1.0, 1.0, 0.75, 0.75, 0.75, 0.75, 0.25]
dur = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0]
def play_melody(instr, pitch_list: list, vol_list: list, dur_list: list) -> None:
for pitch, volume, duration in zip(pitch_list, vol_list, dur_list):
instr.play_note(pitch, volume, duration)
piano_part = play_melody(piano, mel, vol, dur)
clarinet_part = play_melody(clarinet, mel, vol, dur)
fork(piano_part)
fork(clarinet_part)
s.wait_for_children_to_finish()