Skip to content

Commit

Permalink
MIDI - re-implement midi reset button in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
samaaron committed Jun 11, 2020
1 parent f1cf603 commit a655103
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
6 changes: 6 additions & 0 deletions app/server/erlang/pi_server_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ loop(State) ->
MIDIServer = maps:get(midi_server, State),
MIDIServer ! {flush},
?MODULE:loop(State);
{cmd, ["/midi_reset"]=Cmd} ->
debug_cmd(Cmd),
MIDIServer = maps:get(midi_server, State),
MIDIServer ! {reset},
?MODULE:loop(State);

{cmd, ["/flush", Tag]=Cmd} ->
debug_cmd(Cmd),
{Tracker, NewState} = tracker_pid(Tag, State),
Expand Down
7 changes: 7 additions & 0 deletions app/server/erlang/pi_server_midi.erl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ loop(State) ->
sp_midi:midi_flush(),
cue_debug("Flushing MIDI", maps:get(cue_server, State)),
?MODULE:loop(State);
{reset} ->
sp_midi:midi_deinit(),
sp_midi:midi_init(),
cue_debug("Resetting MIDI", maps:get(cue_server, State)),
NewState = State#{midi_ins := [],
midi_outs := []},
?MODULE:loop(NewState);
{midi_in, Bin} ->
try osc:decode(Bin) of
{cmd, [Path | Args]} ->
Expand Down
18 changes: 0 additions & 18 deletions app/server/ruby/lib/sonicpi/lang/midi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1594,24 +1594,6 @@ def __midi_message(m)
def __midi_rest_message(m)
__delayed_message m unless __thread_locals.get(:sonic_pi_suppress_midi_logging)
end

def __midi_system_reset(silent=false)
__info "Resetting MIDI subsystems..." unless silent
__schedule_delayed_blocks_and_messages!
@mod_sound_studio.init_or_reset_midi(silent)
end

def __midi_system_start(silent=false)
__info "Starting MIDI subsystems..." unless silent
__schedule_delayed_blocks_and_messages!
@mod_sound_studio.start_midi(silent)
end

def __midi_system_stop(silent=false)
__info "Stopping MIDI subsystems..." unless silent
__schedule_delayed_blocks_and_messages!
@mod_sound_studio.stop_midi(silent)
end
end
end
end
17 changes: 17 additions & 0 deletions app/server/ruby/lib/sonicpi/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,23 @@ def __stop_jobs
GC.compact if RUBY_VERSION >= "2.7.0"
end

def __midi_system_reset(silent=false)
__info "Resetting MIDI subsystems..." unless silent
__schedule_delayed_blocks_and_messages!
@osc_client.send("/midi_reset")
end

def __midi_system_start(silent=false)
__info "Starting MIDI subsystems..." unless silent
__schedule_delayed_blocks_and_messages!
# @mod_sound_studio.start_midi(silent)
end

def __midi_system_stop(silent=false)
__info "Stopping MIDI subsystems..." unless silent
__schedule_delayed_blocks_and_messages!
# @mod_sound_studio.stop_midi(silent)
end
def __update_midi_ins(ins)
# @midi_out_ports = args
desc = ins.join("\n")
Expand Down

0 comments on commit a655103

Please sign in to comment.