1717from rich .panel import Panel
1818from rich .pretty import Pretty
1919from textual .reactive import reactive
20- from textual .widgets import Header , Footer , Static , Button , TextLog
20+ from textual .widgets import Header , Footer , Static , Button , Log
2121
2222### def TUI components ###
23- class NotoLog (TextLog ):
23+ class NotoLog (Log ):
2424 value = reactive ('' )
2525 def watch_value (self , time : float ) -> None :
2626 self .write (self .value )
@@ -60,7 +60,7 @@ def compose(self):
6060### end def TUI components###
6161
6262def main (
63- checkpoint = "artifacts/noto- txala-011-0020 .ckpt" , # Notochord checkpoint
63+ checkpoint = "txala-latest .ckpt" , # Notochord checkpoint
6464 player_config :Dict [int ,int ]= None , # map MIDI channel : GM instrument
6565 noto_config :Dict [int ,int ]= None , # map MIDI channel : GM instrument
6666 pitch_set = (41 ,43 ,45 ), # MIDI pitches used
@@ -97,7 +97,8 @@ def main(
9797 use_tui = True , # run textual UI
9898 predict_player = True , # forecasted next events can be for player (preserves model distribution, but can lead to Notochord deciding not to play)
9999 auto_query = True , # query notochord whenever it is unmuted and there is no pending event. generally should be True except for testing purposes.
100- testing = False
100+ testing = False ,
101+ verbose = 0
101102 ):
102103 """
103104 Args:
@@ -252,7 +253,8 @@ def play_event(event, channel, feed=True, send=True, tag=None, memo=None):
252253 state ['run_length' ] = 1
253254
254255 state ['last_side' ] = side
255- print (f'{ state ["run_length" ]= } ' )
256+ if verbose > 0 :
257+ print (f'{ state ["run_length" ]= } ' )
256258
257259 # send out as MIDI
258260 if send :
@@ -309,8 +311,9 @@ def noto_query(delay=0):
309311 # print(counts)
310312 player_count = sum (counts [i ] for i in player_map .insts )
311313 noto_count = sum (counts [i ] for i in noto_map .insts )
312- print (f'player: { player_count } ' )
313- print (f'noto: { noto_count } ' )
314+ if verbose > 0 :
315+ print (f'player: { player_count } ' )
316+ print (f'noto: { noto_count } ' )
314317 total_count = player_count + noto_count
315318
316319 all_insts = noto_map .insts
@@ -320,7 +323,8 @@ def noto_query(delay=0):
320323 steer_time = 1 - controls .get ('steer_rate' , 0.5 )
321324 tqt = (max (0 ,steer_time - 0.5 ), min (1 , steer_time + 0.5 ))
322325
323- print (tqt )
326+ if verbose > 1 :
327+ print (tqt )
324328
325329 # if using nominal time,
326330 # *subtract* estimated feed latency to min_time; (TODO: really should
@@ -346,7 +350,8 @@ def noto_query(delay=0):
346350 if len (insts )== 0 :
347351 insts = all_insts
348352
349- print (f'{ insts = } ' )
353+ if verbose > 1 :
354+ print (f'{ insts = } ' )
350355
351356 # bal_insts = set(counts.index[counts <= counts.min()+n_margin])
352357 # if balance_sample and len(bal_insts)>0:
@@ -371,7 +376,8 @@ def noto_query(delay=0):
371376
372377 max_t = None if max_time is None else max (max_time , min_time + 0.2 )
373378
374- print (min_time , max_t )
379+ if verbose > 1 :
380+ print (min_time , max_t )
375381
376382 pending .event = query_method (
377383 include_pitch = pitch_set ,
@@ -419,7 +425,8 @@ def _(msg):
419425 # print(f"{controls['steer_density']=}")
420426 if msg .control == 3 :
421427 controls ['steer_rate' ] = msg .value / 127
422- print (f"{ controls ['steer_rate' ]= } " )
428+ if verbose > 0 :
429+ print (f"{ controls ['steer_rate' ]= } " )
423430
424431 if msg .control == 4 :
425432 noto_reset ()
0 commit comments