WARNING:root:Clock MASTER.... probably processing is too heavy

Description:

Hi all
The code run but I think some of the parts may be slightly out of sync…and once Thorny just closed. My PC specs are ok I think, Windows 11; 64GB DDR5 Ram; Processor is i7-10700K CPU @ 3.8GHz 8 cores 16 logical processors
I am only running Thorny and I did another version of the code where I save all the computations for the envelope in a list so nothing is computed as I go through the for loop…Any suggestions will be appreciated …thanks in advance

Error printout:

WARNING:root:Clock MASTER (beat=2.833333333333333) is running noticeably behind real time (0.06216 s) on a wait call of 0 s; probably processing is too heavy.

(Place the error printout here)

The full code that resulted in the error:

(Place code here)
staccato,staccatissimo,marcato,tenuto,accent ="staccato", "staccatissimo", "marcato" , "tenuto", "accent"

```def playInstrument(inst, interval, whenNotToPlay, listMelody,listRhythm ):
    articulations = [staccato,staccatissimo,marcato,accent] #[staccato,staccatissimo,marcato,tenuto,accent] 
    for pitch, rhythm in zip(listMelody,listRhythm ):
        if counter%whenNotToPlay==0 and counter >0:wait(rhythm)
        else:
            levels, curves = [],[]
            for i in range(0,randint(2,6)):
                levels.append(round((random()+0.1),2))  #round to 2 decimal places
                curves.append(randint(-5,5))
            avTime = rhythm/(len(levels)) #(len(levels)-1)
            dur = [avTime]*(len(levels)-1)
            fp_cres = Envelope.from_levels_and_durations(levels, dur, curves)
            if random() <=0.75: articulation = articulations[2]
            else : articulation = choice(articulations)
            inst.play_note(pitch+interval , fp_cres,rhythm, articulation)
    #wait(
cello_whenNotToPlay,oboe_whenNotToPlay, piano_whenNotToPlay, brass_whenNotToPlay = randint(2,6),randint(2,6) ,randint(2,6) ,randint(2,6)        
cello_interval,oboe_interval,piano_interval,brass_interval = 0,31,16,-12
                #playInstrument(cello, cello_interval, cello_whenNotToPlay, listMelody,listRhythm )
fork(playInstrument, args = [cello, cello_interval, cello_whenNotToPlay, listMelody,listRhythm ])
fork(playInstrument, args = [oboe,  oboe_interval,  oboe_whenNotToPlay,  listMelody,listRhythm ])
fork(playInstrument, args = [piano, piano_interval, piano_whenNotToPlay, listMelody,listRhythm ])
fork(playInstrument, args = [brass, brass_interval, brass_whenNotToPlay, listMelody,listRhythm ])
s.wait_for_children_to_finish()

#**************************************************************************************************************
#i tried this version to store values calculated for the envelope(levels, durations, curves ) into a list so that as the play_note loops through the melody list there will not be much calculations i thought.... but with the same problem
# def playInstrument(inst, interval, whenNotToPlay, listMelody,listRhythm ):
#     articulations = [staccato,staccatissimo,marcato,accent] #[staccato,staccatissimo,marcato,tenuto,accent]
#     list_fp_cres, list_articulation = [],[] #[[]],[[]],[]
#     for pitch, rhythm in zip(listMelody,listRhythm ):
#         if counter%whenNotToPlay==0 and counter >0:wait(rhythm)
#         else:
#             levels, curves = [],[]
#             for i in range(0,randint(2,6)):
#                 levels.append(round((uniform(0.05, 0.7)),2))  #round to 2 decimal places
#                 curves.append(randint(-5,5))
#             avTime = rhythm/(len(levels)) #(len(levels)-1)
#             dur = [avTime]*(len(levels)-1)
#             fp_cres = Envelope.from_levels_and_durations(levels, dur, curves)
#             if random() <=0.75: articulation = articulations[2]
#             else : articulation = choice(articulations)
#             list_fp_cres.append(fp_cres)
#             list_articulation.append(articulation)
#     for pitch, rhythm, fp, art in zip(listMelody,listRhythm, list_fp_cres,list_articulation): inst.play_note(pitch+interval , fp,rhythm, art)
#     
# cello_whenNotToPlay,oboe_whenNotToPlay, piano_whenNotToPlay, brass_whenNotToPlay = randint(2,6),randint(2,6) ,randint(2,6) ,randint(2,6)        
# cello_interval,oboe_interval,piano_interval,brass_interval = 0,31,16,-12
#                 #playInstrument(cello, cello_interval, cello_whenNotToPlay, listMelody,listRhythm )
# fork(playInstrument, args = [cello, cello_interval, cello_whenNotToPlay, listMelody,listRhythm ])
# fork(playInstrument, args = [oboe,  oboe_interval,  oboe_whenNotToPlay,  listMelody,listRhythm ])
# fork(playInstrument, args = [piano, piano_interval, piano_whenNotToPlay, listMelody,listRhythm ])
# fork(playInstrument, args = [brass, brass_interval, brass_whenNotToPlay, listMelody,listRhythm ])
# s.wait_for_children_to_finish()

Thanks for posting this question. I also want to ask for advice on this issue. I run my music code in VS code IDE. For all the times I run, that warning msg is printed out (WARNING:root:Clock MASTER beat=…) but the code is working perfectly. If I want to repeat a piece several times, the sounds at the first iteration are always a bit out of synced, but from the second iteration, they all are good.
My temporary solution is putting wait(1) at top of the loop, so the sounds at the first iteration are perfect. I believe there is something with the configuration for the clockmaster on each computer.

1 Like

Hi! I think the code you posted is missing some of the setup, which I need to be able to test it.

1 Like

Hi
here is the code

from scamp import *
from random import *
from math import *

listRhythm= [0.17, 0.5, 0.17, 0.17, 0.5, 0.17, 1.5, 0.17, 0.33, 1.67, 1.67, 0.5, 0.5, 2.17, 3.17, 5.33, 2.0, 2.83, 1.0, 6.67, 2.17]
listMelody=[65,   64,  65,   64,   62,  64,   65,  64,   65,   64,   65,   60,  62,  57,   58,   60,   62,  64,   65,  67,   69]
staccato,staccatissimo,marcato,tenuto,accent ="staccato", "staccatissimo", "marcato" , "tenuto", "accent"

s = Session(tempo =60)  # or canleave blank and add later ...
cello =s.new_part("Cello")
oboe = s.new_part("Oboe")
piano = s.new_part("Piano Merlin ")
electricPiano = s.new_part("E.Piano 1")
brass = s.new_part("brass")
bass = s.new_part("Fingered Bass")
TenorSax = s.new_part("Tenor Sax")
organ = s.new_part("Organ 1")

def playInstrument(inst, interval, whenNotToPlay, listMelody,listRhythm ):
    articulations = [staccato,staccatissimo,marcato,accent] #[staccato,staccatissimo,marcato,tenuto,accent]
    counter =0
    for pitch, rhythm in zip(listMelody,listRhythm ):
        if counter%whenNotToPlay==0 and counter >0:wait(rhythm)
        else:
            levels, curves = [],[]
            for i in range(0,randint(2,6)):
                levels.append(round((random()+0.1),2))  #round to 2 decimal places
                curves.append(randint(-5,5))
            avTime = rhythm/(len(levels)) #(len(levels)-1)
            dur = [avTime]*(len(levels)-1)
            fp_cres = Envelope.from_levels_and_durations(levels, dur, curves)
            if random() <=0.75: articulation = articulations[2]
            else : articulation = choice(articulations)
            inst.play_note(pitch+interval , fp_cres,rhythm, articulation)
        counter +=1
cello_whenNotToPlay,oboe_whenNotToPlay, piano_whenNotToPlay, brass_whenNotToPlay = randint(2,6),randint(2,6) ,randint(2,6) ,randint(2,6)        
cello_interval,oboe_interval,piano_interval,brass_interval = 0,31,16,-12
                #playInstrument(cello, cello_interval, cello_whenNotToPlay, listMelody,listRhythm )
fork(playInstrument, args = [cello, cello_interval, cello_whenNotToPlay, listMelody,listRhythm ])
fork(playInstrument, args = [oboe,  oboe_interval,  oboe_whenNotToPlay,  listMelody,listRhythm ])
fork(playInstrument, args = [piano, piano_interval, piano_whenNotToPlay, listMelody,listRhythm ])
fork(playInstrument, args = [brass, brass_interval, brass_whenNotToPlay, listMelody,listRhythm ])
s.wait_for_children_to_finish()

Hi Marc
Hope you are well
I posted the full code as requested because the initial code was not complete so i just thought to remind you incase you had not seen the full code

I couldn’t replicate the problem on my machine.

But you might try adding:

s.synchronization_policy = 0.7

after you create the session. This allows the clock to catch up more. by shaving off time from wait calls.

1 Like

thanks i will try it

hi Marc- I tried the s.synchronization_policy=0.7 after I created the session but i get an error whioch is below
File “C:\Users\User\AppData\Roaming\Python\Python310\site-packages\clockblocks\clock.py”, line 336, in synchronization_policy
raise ValueError('Invalid synchronization policy “{}”. Must be one of (“all relatives”, “all descendants”, ’
ValueError: Invalid synchronization policy “0.7”. Must be one of (“all relatives”, “all descendants”, “no synchronization”, “inherit”).

Sorry! I meant s.timing_policy = 0.7

1 Like