Skip to content

Commit c0eba1a

Browse files
committed
SuperSonic - update with new MIDI functionality
This means sp_midi is now deprecated
1 parent 4ff479d commit c0eba1a

18 files changed

Lines changed: 312 additions & 797 deletions

app/external/supersonic

Submodule supersonic updated 83 files

app/gui/widgets/metricspanel.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,14 @@ void MetricsPanel::drainEgressRing(bool nrt)
641641
const QString cMuted = m_theme ? m_theme->color("CommentForeground").name() : kindColor(K_Muted).name();
642642
walkRing(rv, cur, m_scratch,
643643
[&](uint32_t seq, uint32_t src, const uint8_t* payload, uint32_t n) {
644-
oscpkt::PacketReader pr(payload, n);
644+
// NRT-out frames carry a leading [route:u32] word (OUT too once
645+
// unified). OSC addresses start with '/', a route word doesn't, so
646+
// skip 4 bytes when the first byte isn't '/'.
647+
const uint8_t* osc = payload;
648+
uint32_t oscN = n;
649+
if (n >= 4 && payload[0] != '/') { osc += 4; oscN -= 4; }
650+
651+
oscpkt::PacketReader pr(osc, oscN);
645652
oscpkt::Message* msg = pr.isOk() ? pr.popMessage() : nullptr;
646653
if (msg && msg->addressPattern() == "/supersonic/debug") {
647654
oscpkt::Message::ArgReader ar = msg->arg();
@@ -658,7 +665,7 @@ void MetricsPanel::drainEgressRing(bool nrt)
658665
}
659666
}
660667
if (m_oscInView)
661-
m_oscInView->append(formatOscHtml(payload, n, seq, src, /*outgoing=*/false));
668+
m_oscInView->append(formatOscHtml(osc, oscN, seq, src, /*outgoing=*/false));
662669
});
663670
}
664671

app/server/beam/tau/CMakeLists.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,5 @@ include(ExternalProject)
1717

1818
set(CMAKE_OSX_DEPLOYMENT_TARGET '10.15')
1919

20-
# sp_midi
21-
ExternalProject_Add(sp_midi
22-
PREFIX sp_midi-prefix
23-
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../external/sp_midi
24-
INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/priv
25-
CMAKE_ARGS
26-
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/priv
27-
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
28-
-DUSE_SYSTEM_RTMIDI=${USE_SYSTEM_LIBS}
29-
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release
30-
)
20+
# MIDI moved to SuperSonic (Rust/midir; see app/server/ruby midi_api.rb): the
21+
# sp_midi NIF has been removed and there are no external NIFs left to build here.

app/server/beam/tau/config/runtime.exs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ config :logger, :tau_file_log,
5555

5656
if config_env() != :test do
5757
config :tau,
58-
midi_on: extract_env.("TAU_MIDI_ON", :bool, false),
59-
midi_enabled: extract_env.("TAU_MIDI_ENABLED", :bool, false),
6058
cues_on: extract_env.("TAU_CUES_ON", :bool, false),
6159
osc_in_udp_loopback_restricted:
6260
extract_env.("TAU_OSC_IN_UDP_LOOPBACK_RESTRICTED", :bool, true),
@@ -68,8 +66,6 @@ if config_env() != :test do
6866
daemon_host: {127, 0, 0, 1}
6967
else
7068
config :tau,
71-
midi_on: extract_env.("TAU_MIDI_ON", :bool, false),
72-
midi_enabled: extract_env.("TAU_MIDI_ENABLED", :bool, false),
7369
cues_on: extract_env.("TAU_CUES_ON", :bool, true),
7470
osc_in_udp_loopback_restricted:
7571
extract_env.("TAU_OSC_IN_UDP_LOOPBACK_RESTRICTED", :bool, true),

app/server/beam/tau/lib/tau/application.ex

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,7 @@ defmodule Tau.Application do
1010
def start(_type, _args) do
1111
Logger.info("All systems booting....")
1212

13-
midi_enabled = Application.get_env(:tau, :midi_enabled, false)
14-
15-
if midi_enabled do
16-
Logger.info("Initialising MIDI native interface")
17-
:sp_midi.init()
18-
else
19-
Logger.info("Starting without MIDI native interface")
20-
end
13+
# MIDI moved to SuperSonic (Rust/midir); the sp_midi NIF has been removed.
2114

2215
children = [
2316
:tau_server_sup

app/server/beam/tau/src/sp_midi/sp_midi.erl

Lines changed: 0 additions & 47 deletions
This file was deleted.

app/server/beam/tau/src/sp_midi/sp_midi_test.erl

Lines changed: 0 additions & 68 deletions
This file was deleted.

app/server/beam/tau/src/tau_server/tau_server_api.erl

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
-module(tau_server_api).
1616

17-
-export([start_link/2]).
17+
-export([start_link/1]).
1818

1919
%% internal
20-
-export([init/3, loop/1]).
20+
-export([init/2, loop/1]).
2121

2222
%% sys module callbacks
2323
-export([system_continue/3, system_terminate/4, system_code_change/4,
@@ -66,12 +66,12 @@
6666

6767

6868
%% supervisor compliant start function
69-
start_link(CueServer, MIDIServer) ->
69+
start_link(CueServer) ->
7070
%% synchronous start of the child process
71-
proc_lib:start_link(?MODULE, init, [self(), CueServer, MIDIServer]).
71+
proc_lib:start_link(?MODULE, init, [self(), CueServer]).
7272

7373

74-
init(Parent, CueServer, MIDIServer) ->
74+
init(Parent, CueServer) ->
7575
register(?SERVER, self()),
7676
APIPort = application:get_env(?APPLICATION, api_port, undefined),
7777
DaemonToken = application:get_env(?APPLICATION, daemon_token, undefined),
@@ -104,7 +104,6 @@ init(Parent, CueServer, MIDIServer) ->
104104
daemon_host => DaemonHost,
105105
api_socket => APISocket,
106106
cue_server => CueServer,
107-
midi_server => MIDIServer,
108107
tag_map => #{}
109108
},
110109
send_to_cue({tau_ready}, State),
@@ -155,18 +154,6 @@ loop(State) ->
155154
ok = gen_udp:send(APISocket, DaemonHost, DaemonPort, PidBin),
156155
?MODULE:loop(State);
157156

158-
{cmd, ["/midi", OSC]=Cmd} ->
159-
debug_cmd(Cmd),
160-
MIDIServer = maps:get(midi_server, State),
161-
MIDIServer ! {send_midi, OSC},
162-
?MODULE:loop(State);
163-
164-
{cmd, ["/midi-flush"]=Cmd} ->
165-
debug_cmd(Cmd),
166-
MIDIServer = maps:get(midi_server, State),
167-
MIDIServer ! {flush},
168-
?MODULE:loop(State);
169-
170157
{cmd, ["/flush", Tag]=Cmd} ->
171158
debug_cmd(Cmd),
172159
{Tracker, NewState} = tracker_pid(Tag, State),
@@ -183,11 +170,6 @@ loop(State) ->
183170
send_to_cue({cues_on, Flag}, State),
184171
?MODULE:loop(State);
185172

186-
{cmd, ["/stop-start-midi-cues", Flag]=Cmd} ->
187-
debug_cmd(Cmd),
188-
send_to_cue({midi_on, Flag}, State),
189-
?MODULE:loop(State);
190-
191173
{cmd, Cmd} ->
192174
logger:error("Unknown OSC command:: ~p", [Cmd]),
193175
?MODULE:loop(State);
@@ -218,10 +200,6 @@ do_bundle(Time, Args, State) ->
218200
schedule_cmd(Time, "default", State, {send_osc, Host, Port, OSC});
219201
["/send-after-tagged", Tag, Host, Port, OSC] ->
220202
schedule_cmd(Time, Tag, State, {send_osc, Host, Port, OSC});
221-
["/midi-at", MIDI] ->
222-
schedule_midi(Time, "default", State, {send_midi, MIDI});
223-
["/midi-at-tagged", Tag, MIDI] ->
224-
schedule_midi(Time, Tag, State, {send_midi, MIDI});
225203
Other ->
226204
logger:error("Unexpected bundle content:~p", Other),
227205
State
@@ -247,10 +225,6 @@ schedule_internal_call(Time, Tag, State, Server, Msg) ->
247225
NewState.
248226

249227

250-
schedule_midi(Time, Tag, State, Msg) ->
251-
MIDIServer = maps:get(midi_server, State),
252-
schedule_internal_call(Time, Tag, State, MIDIServer, Msg).
253-
254228
schedule_cmd(Time, Tag, State, Msg) ->
255229
CueServer = maps:get(cue_server, State),
256230
schedule_internal_call(Time, Tag, State, CueServer, Msg).

app/server/beam/tau/src/tau_server/tau_server_cue.erl

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ init(Parent) ->
4040
register(?SERVER, self()),
4141
OSCInUDPLoopbackRestricted = application:get_env(?APPLICATION, osc_in_udp_loopback_restricted, true),
4242
CuesOn = application:get_env(?APPLICATION, cues_on, true),
43-
MIDIOn = application:get_env(?APPLICATION, midi_on, true),
4443
OSCInUDPPort = application:get_env(?APPLICATION, osc_in_udp_port, undefined),
4544
CuePort = application:get_env(?APPLICATION, spider_port, undefined),
4645
CueHost = {127,0,0,1},
@@ -71,7 +70,6 @@ init(Parent) ->
7170
[try erlang:port_info(InSocket) catch _:_ -> undefined end]),
7271
State = #{parent => Parent,
7372
cues_on => CuesOn,
74-
midi_on => MIDIOn,
7573
cue_host => CueHost,
7674
cue_port => CuePort,
7775
osc_in_udp_loopback_restricted => OSCInUDPLoopbackRestricted,
@@ -83,31 +81,10 @@ init(Parent) ->
8381

8482
loop(State) ->
8583
receive
86-
{midi_in, Path, Args} ->
87-
case State of
88-
#{midi_on := true} ->
89-
CueHost = maps:get(cue_host, State),
90-
CuePort = maps:get(cue_port, State),
91-
InSocket = maps:get(in_socket, State),
92-
forward_internal_cue(CueHost, CuePort, InSocket, Path, Args),
93-
?MODULE:loop(State);
94-
#{midi_on := false} ->
95-
logger:debug("MIDI cue forwarding disabled - ignored: ~p", [{Path, Args}]),
96-
?MODULE:loop(State)
97-
end;
98-
9984
{api_reply, UUID, Response} ->
10085
send_api_reply(State, UUID, Response),
10186
?MODULE:loop(State);
10287

103-
{update_midi_ports, Ins, Outs} ->
104-
CueHost = maps:get(cue_host, State),
105-
CuePort = maps:get(cue_port, State),
106-
InSocket = maps:get(in_socket, State),
107-
update_midi_in_ports(CueHost, CuePort, InSocket, Ins),
108-
update_midi_out_ports(CueHost, CuePort, InSocket, Outs),
109-
?MODULE:loop(State);
110-
11188
{udp, InSocket, Ip, Port, Bin} ->
11289
logger:debug("cue server got UDP on ~p:~p", [Ip, Port]),
11390
try osc:decode(Bin) of
@@ -167,14 +144,6 @@ loop(State) ->
167144
logger:info("Disabling cue forwarding "),
168145
?MODULE:loop(State#{cues_on := false});
169146

170-
{midi_on, true} ->
171-
logger:info("Enabling midi cue forwarding "),
172-
?MODULE:loop(State#{midi_on := true});
173-
174-
{midi_on, false} ->
175-
logger:info("Disabling midi cue forwarding "),
176-
?MODULE:loop(State#{midi_on := false});
177-
178147
{send_osc, Host, Port, OSC} ->
179148
send_udp(maps:get(in_socket, State), Host, Port, OSC),
180149
?MODULE:loop(State);
@@ -240,18 +209,6 @@ send_udp(Socket, Host, Port, Bin)
240209
Error -> logger:error("Unable to send UDP - bad socket (~p): ~p", [Error, Host])
241210
end.
242211

243-
update_midi_in_ports(CueHost, CuePort, InSocket, Args) ->
244-
Bin = osc:encode(["/midi-ins", "erlang" | Args]),
245-
send_udp(InSocket, CueHost, CuePort, Bin),
246-
logger:debug("forwarded new MIDI ins to ~p:~p", [CueHost, CuePort]),
247-
ok.
248-
249-
update_midi_out_ports(CueHost, CuePort, InSocket, Args) ->
250-
Bin = osc:encode(["/midi-outs", "erlang" | Args]),
251-
send_udp(InSocket, CueHost, CuePort, Bin),
252-
logger:debug("forwarded new MIDI outs to ~p:~p", [CueHost, CuePort]),
253-
ok.
254-
255212
send_api_reply(State, UUID, Args) ->
256213
CueHost = maps:get(cue_host, State),
257214
CuePort = maps:get(cue_port, State),
@@ -261,12 +218,6 @@ send_api_reply(State, UUID, Args) ->
261218
send_udp(InSocket, CueHost, CuePort, Bin),
262219
ok.
263220

264-
forward_internal_cue(CueHost, CuePort, InSocket, Path, Args) ->
265-
Bin = osc:encode(["/internal-cue", "erlang", Path | Args]),
266-
send_udp(InSocket, CueHost, CuePort, Bin),
267-
logger:debug("forwarded internal OSC cue to ~p:~p", [CueHost, CuePort]),
268-
ok.
269-
270221
forward_cue(CueHost, CuePort, InSocket, Ip, Port, Cmd) ->
271222
Bin = osc:encode(["/external-osc-cue", inet:ntoa(Ip), Port] ++ Cmd),
272223
send_udp(InSocket, CueHost, CuePort, Bin),

0 commit comments

Comments
 (0)