Skip to content

Commit fbfe903

Browse files
add txalaparta to CLI
1 parent fb7a356 commit fbfe903

4 files changed

Lines changed: 33 additions & 14 deletions

File tree

src/notochord/__main__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def help():
1212
homunculus: run the Notochord homunculus TUI
1313
harmonizer: run the Notochord harmonizer TUI
1414
improviser: run the Notochord improviser TUI
15+
txalaparta: run the txalaparta app
1516
files: show the location of Notochord models and config files on disk
1617
""")
1718

@@ -30,6 +31,9 @@ def _main():
3031
if sys.argv[1] == 'improviser':
3132
sys.argv = sys.argv[1:]
3233
run(improviser)
34+
if sys.argv[1] == 'txalaparta':
35+
sys.argv = sys.argv[1:]
36+
run(txalaparta)
3337
if sys.argv[1] == 'files':
3438
d = Notochord.user_data_dir()
3539
print(d)

src/notochord/app/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .server import main as server
22
from .harmonizer import main as harmonizer
33
from .improviser import main as improviser
4-
from .homunculus import main as homunculus
4+
from .homunculus import main as homunculus
5+
from .txalaparta import main as txalaparta
Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
from rich.panel import Panel
1818
from rich.pretty import Pretty
1919
from 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

6262
def 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()

src/notochord/model.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,19 +1207,26 @@ def from_checkpoint(cls, path):
12071207
path: file path to Notochord model
12081208
"""
12091209
if path=="notochord-latest.ckpt":
1210+
url = 'https://github.com/Intelligent-Instruments-Lab/iil-python-tools/releases/download/notochord-v0.4.0/notochord_lakh_50G_deep.pt'
1211+
elif path=="txala-latest.ckpt":
1212+
url = 'https://github.com/Intelligent-Instruments-Lab/notochord/releases/download/notochord-v0.5.4/noto-txala-011-0020.ckpt'
1213+
else:
1214+
url = None
1215+
1216+
if url is not None:
12101217
d = Notochord.user_data_dir()
12111218
path = d / path
12121219
# maybe download
12131220
if not path.is_file():
12141221
while True:
12151222
answer = input("Do you want to download a notochord model? (y/n)")
12161223
if answer.lower() in ["y","yes"]:
1217-
download_url('https://github.com/Intelligent-Instruments-Lab/iil-python-tools/releases/download/notochord-v0.4.0/notochord_lakh_50G_deep.pt', path)
1224+
download_url(url, path)
12181225
print(f'saved to {path}')
12191226
break
12201227
if answer.lower() in ["n","no"]:
12211228
break
1222-
# path =
1229+
# path =
12231230
checkpoint = torch.load(path, map_location=torch.device('cpu'))
12241231
model = cls(**checkpoint['kw']['model'])
12251232
model.load_state_dict(checkpoint['model_state'], strict=False)

0 commit comments

Comments
 (0)