Forking

Hello!

I’m trying to fork something but am receiving this. How do I go about this issue?

ERROR:root:None is not a callable object
Traceback (most recent call last):
File “/Users/kronic/Library/Python/3.9/lib/python/site-packages/clockblocks/clock.py”, line 816, in _process
process_function_signature = inspect.signature(process_function)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py”, line 3130, in signature
return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py”, line 2879, in from_callable
return _signature_from_callable(obj, sigcls=cls,
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py”, line 2254, in _signature_from_callable
raise TypeError(’{!r} is not a callable object’.format(obj))
TypeError: None is not a callable object

Here’s my code

def notateSequence(sequence_list, rhythm_list):

	amp = 1

	# https://youtu.be/WhNLNvugNy0?t=768

	s.fork(forkPart(sequence_list, amp, rhythm_list))
	s.fork(forkPart(sequence_list, amp, rhythm_list))
	s.wait_for_children_to_finish 

	return


def forkPart(sequence_list, amp, rhythm_list):

	a = len(sequence_list)
	b = len(rhythm_list)

	for i in range(a):
		index = i % b 
		print("seq list: ", sequence_list[i])
		r = float(rhythm_list[index])

	for i in range(a): 
		inst.play_chord(sequence_list[i], amp, r)

	return 

It has worked fine without the forking … Ultimately, I’d like to segregate treble and bass notes into a piano score. Thanks in advance!

Ahh my forking syntax was incorrect!

The fork function takes in the name of the function you are forking, and args = ( arg 1, arg 2, etc) ) So fork(function name, args = (args 1, 2, 3)). For anyone with a similar issue

Which brings me to my another question. When transcribing multiple threads using s.transcribing(), I get this error. What am I doing that is causing this error? It works fine for one thread.

File “/Users/kronic/Documents/Code/MidiReader/midiToscore01.py”, line 199, in
s.stop_transcribing().to_score(time_signature=“4/4”).show_xml()
File “/Users/kronic/Library/Python/3.9/lib/python/site-packages/scamp/performance.py”, line 1088, in to_score
return Score.from_performance(
File “/Users/kronic/Library/Python/3.9/lib/python/site-packages/scamp/score.py”, line 845, in from_performance
return Score.from_quantized_performance(
File “/Users/kronic/Library/Python/3.9/lib/python/site-packages/scamp/score.py”, line 879, in from_quantized_performance
out._pad_incomplete_parts()
File “/Users/kronic/Library/Python/3.9/lib/python/site-packages/scamp/score.py”, line 887, in _pad_incomplete_parts
longest_staff = max(staves, key=lambda staff: len(staff.measures))
ValueError: max() arg is an empty sequence

s = Session()
inst = s.new_part("piano")
s.start_transcribing()

then I fork stuff

def notateSequence(sequence_list, rhythm_list):
	# sends the sequence list to scamp 

	amp = 1

	# https://youtu.be/WhNLNvugNy0?t=768
	print("sequence_list", sequence_list)
	print("rhythm_list", rhythm_list)
	print("amp", amp)

	s.fork(forkPart, args = (sequence_list, amp, rhythm_list))
	s.fork(forkPart, args = (sequence_list, amp, rhythm_list))
	print("reached")
	s.wait_for_children_to_finish 
	print("reached2")

	return


def forkPart(sequence_list, amp, rhythm_list):

	a = len(sequence_list)
	b = len(rhythm_list)
	print("in fork part")
	print("sequence_list", sequence_list)
	print("rhythm_list", rhythm_list)
	print("amp", amp)

	for i in range(a):
		index = i % b 
		print("seq list: ", sequence_list[i])
		r = float(rhythm_list[index])
		print("seq list i: ", sequence_list[i])
		print("amp", amp)
		print("r", r)

	for i in range(a): 
		inst.play_chord(sequence_list[i], amp, r)

then call transcribing to record

s.stop_transcribing().to_score(time_signature="4/4").show_xml()

Thanks in advance!

Hey @kronic! Glad you figured out the fork syntax.

As for the error you’re getting about transcribing, that error happens when it hasn’t recorded anything. Sometimes that happens if you call start_transcribing before you have created any instruments. In your case, though, it could be because you forgot the () after s.wait_for_children_to_finish?

WOAH(). Yeah that worked! Thank you!

1 Like