Thanks to Neil, I have happy time using scamp to have fun with music. But I found another issue: All of the notes_lengths are set the same. If I prefer to change note_length for different notes, what should I do?
from scamp import *
s = Session()
s.tempo = 65
user input instrument and its information format dict
all_parts_info = [
[[45, 52, 59, 57, 60], [0.9, 0.6, 0.8, 0.5, 0.8], [0.5, 1, 0.5, 1, 0.5]],
# I change the note_length here But it does not work logically
[[49, 52, 59, 57, 62], [0.9, 0.6, 0.8, 0.5, 0.8], [0.5, 1, 0.5, 1, 0.5]]
]
instrument_names = [‘guitar’, ‘piano’]
instruments = []
for inst in instrument_names:
x = s.new_part(inst)
instruments.append(x)
print(‘instruments:’, instruments)
def my(instrument, part_info):
pitches = part_info[0]
volumes = part_info[1]
note_length = part_info[2]
iter_list = list(zip(pitches, volumes))
for p, v in iter_list:
instrument.play_note(p, v, note_length)
for instrument, this_part_info in zip(instruments, all_parts_info):
s.fork(my, (instrument, this_part_info))
s.wait_for_children_to_finish()