Skip to content
This repository was archived by the owner on Nov 23, 2023. It is now read-only.

Commit b390192

Browse files
committed
2 parents 717d8d6 + ed1b5f3 commit b390192

4 files changed

Lines changed: 25 additions & 20 deletions

File tree

examples/iipyper/iipyper-tutorial.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ def test(address, x, y): # route is /test
5656
# the above works with SuperCollider, but not with Max
5757
# the reply port Max sends doesn't seem to work conveniently.
5858
# (you can't make a new udpsend object with that port, it's taken)
59-
# but you can specify a new return port like this:
59+
# but you can specify your own return port like this:
6060
@osc.args(return_port=5432)
6161
def test2(address, x, y): # route is /test2
6262
print(address, x, y)
63-
return '/test', x-y, x+y # will send to port 5432
63+
return '/test', x-y, x+y # will send on port 5432
6464

6565
# named arguments as key, value pairs in OSC
6666
# e.g. an OSC message ["/keyword_example", "arg2", 3]
@@ -70,8 +70,9 @@ def keyword_example(address, arg1=0, arg2=1, arg3=99):
7070
print(address, arg1, arg2, arg3)
7171
# no return value: does not send OSC back
7272

73-
# can also give the route explicitly to the decorator,
74-
# supporting wildcards
73+
# you can also give the OSC address explicitly to the decorator,
74+
# instead of using the function name.
75+
# this supporting wildcards and other aspects of OSC addresses:
7576
@osc.args('/math/*')
7677
def _(address, a, b):
7778
print(address, a, b)

examples/notochord/generate.scd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
(
88
MIDIClient.init;
99
// MIDIClient.destinations
10-
~m1 = MIDIOut.newByName("IAC Driver", "Bus 1");
11-
~m2 = MIDIOut.newByName("IAC Driver", "Bus 2");
12-
~m3 = MIDIOut.newByName("IAC Driver", "Bus 3");
10+
~m1 = MIDIOut.newByName("IAC Driver", "Bus 1").latency_(0);
11+
~m2 = MIDIOut.newByName("IAC Driver", "Bus 2").latency_(0);
12+
~m3 = MIDIOut.newByName("IAC Driver", "Bus 3").latency_(0);
1313
~gui = false;
1414
MIDIIn.connectAll;
1515
b = NetAddr.new("127.0.0.1", 9999);

examples/notochord/harmonize.scd

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
// neural harmonizer
22
// model answers each note from the controller with a simultaneous note
33

4+
// TODO: multi-instrument vs same-instrument mode
5+
// TODO: enque simultaneous events / block waiting for response
6+
// TODO: triads+
7+
// TODO: above/below modes
48
(
59
MIDIClient.init;
610
// MIDIClient.destinations
7-
~m1 = MIDIOut.newByName("IAC Driver", "Bus 1");
8-
~m2 = MIDIOut.newByName("IAC Driver", "Bus 2");
9-
~m3 = MIDIOut.newByName("IAC Driver", "Bus 3");
11+
~m1 = MIDIOut.newByName("IAC Driver", "Bus 1").latency_(0);
12+
~m2 = MIDIOut.newByName("IAC Driver", "Bus 2").latency_(0);
13+
~m3 = MIDIOut.newByName("IAC Driver", "Bus 3").latency_(0);
1014
~gui = false;
1115
MIDIIn.connectAll;
1216
b = NetAddr.new("127.0.0.1", 9999);
1317
~controller = MIDIClient.sources.detect { |e| e.device.containsi("MPKmini2") }.uid;
1418
)
1519

16-
1720
(
18-
// TODO: what is with this input latency
1921
MIDIdef.noteOn(\input_on, {
2022
arg vel, pitch, chan, src;
2123
var perftime = Process.elapsedTime;
@@ -25,7 +27,7 @@ MIDIdef.noteOn(\input_on, {
2527
)
2628

2729
(
28-
// mapp instruments to channels + buses for the Ableton set
30+
// map instruments to channels + buses for the Ableton set
2931
~prog2portchan = { arg prog;
3032
case
3133
{prog==0}{"can't convert start token".postln}
@@ -227,7 +229,7 @@ MIDIdef.noteOff(\input_off, {
227229
// ~synths[pitch] = nil;
228230

229231
// send MIDI
230-
port_chan[\port].noteOff(port_chan[\chan], ~player_inst);
232+
port_chan[\port].noteOff(port_chan[\chan], pitch);
231233

232234
// inform model of player release
233235
~feed_event.(~player_inst, pitch, dt, 0);
@@ -243,7 +245,7 @@ MIDIdef.noteOff(\input_off, {
243245

244246
// post the current note
245247
[\player_off, dt, ~player_inst, pitch, 0].postln;
246-
[\model_off, 0, ~model_inst, pitch, 0].postln;
248+
[\model_off, 0, ~model_inst, harm_pitch, 0].postln;
247249

248250
}, srcID:~controller);
249251

@@ -339,7 +341,7 @@ OSCdef(\return, {
339341
)
340342

341343
(
342-
// play the first note and let the model take over
344+
// reset
343345
t = nil;
344346
~gate = false;
345347
~pitch_temp = nil;//0.9;
@@ -349,8 +351,11 @@ t = nil;
349351
~player_held.clear;
350352
~release_all.(0);
351353
b.sendMsg("/predictor/reset");
352-
~player_inst = 257;//128.rand+1;
353-
~model_inst = 258;//128.rand+1;
354+
~player_inst = 257;
355+
~model_inst = 258;
356+
// ~player_inst = 128.rand+1;
357+
// ~model_inst = 128.rand+1;
358+
// ~model_inst = 129;
354359
{~gate = true}.defer(0.2);
355360
)
356361

notochord/notochord/model.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import math
2-
from xml.etree.ElementInclude import include
32

43
import numpy as np
54

65
import torch
7-
from torch import logit, nn
6+
from torch import nn
87
import torch.nn.functional as F
98
import torch.distributions as D
109

0 commit comments

Comments
 (0)