Class: SonicPi

Inherits:
Object
  • Object
show all
Defined in:
lib/sonic_pi.rb

Constant Summary collapse

RUN_COMMAND =
"/run-code"
STOP_COMMAND =
"/stop-all-jobs"
SERVER =
'localhost'
PORT =
4557

Instance Method Summary collapse

Instance Method Details

#run(command) ⇒ Object



11
12
13
# File 'lib/sonic_pi.rb', line 11

def run(command)
  client.send(run_command(command))
end

#stopObject



15
16
17
# File 'lib/sonic_pi.rb', line 15

def stop
  client.send(stop_command)
end

#test_connection!Object



19
20
21
22
23
24
25
26
# File 'lib/sonic_pi.rb', line 19

def test_connection!
  begin
    OSC::Server.new(PORT)
    abort("ERROR: Sonic Pi is not listening on #{PORT} - is it running?")
  rescue
    # everything is good
  end
end