Top Level Namespace

Defined Under Namespace

Modules: PM Classes: Array, Integer

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/patchmaster/irb/irb.rb', line 53

def method_missing(sym, *args)
  pm = PM::PatchMaster.instance
  if dsl.respond_to?(sym)
    patch.stop
    dsl.send(sym, *args)
    if sym == :input || sym == :inp
      pm.inputs.last.start
    end
    patch.start
  elsif pm.respond_to?(sym)
    pm.send(sym, *args)
  else
    super
  end
end

Instance Method Details

#clearObject

Stop and delete all connections.



37
38
39
40
41
# File 'lib/patchmaster/irb/irb.rb', line 37

def clear
  patch.stop
  patch.connections = []
  patch.start
end

#dslObject



27
28
29
# File 'lib/patchmaster/irb/irb.rb', line 27

def dsl
  PM::IRB.instance.dsl
end

#panic!Object

The “panic” command is handled by the PM::DSL instance. This version (panic!) tells that panic to send all all-notes-off messages.



49
50
51
# File 'lib/patchmaster/irb/irb.rb', line 49

def panic!
  PM::PatchMaster.instance.panic(true)
end

#patchObject

Return the current (only) patch.



32
33
34
# File 'lib/patchmaster/irb/irb.rb', line 32

def patch
  dsl.instance_variable_get(:@patch)
end

#pmObject

Helper methods



9
10
11
# File 'lib/patchmaster/web/sinatra_app.rb', line 9

def pm
  @pm ||= PM::SinatraApp.instance.pm
end

#pm_helpObject



43
44
45
# File 'lib/patchmaster/irb/irb.rb', line 43

def pm_help
  puts IO.read(File.join(File.dirname(__FILE__), 'irb_help.txt'))
end

#return_status(opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/patchmaster/web/sinatra_app.rb', line 13

def return_status(opts={})
  pm = pm()
  status = {
    :lists => pm.song_lists.map(&:name),
    :list => pm.song_list.name,
    :songs => pm.song_list.songs.map(&:name),
    :triggers => pm.inputs.collect do |instrument|
      instrument.triggers.collect { |trigger| ":#{instrument.sym} #{trigger.to_s}" }
    end.flatten
  }
  if pm.song
    status[:song] = {
      :name => pm.song.name,
      :patches => pm.song.patches.map(&:name)
    }
    if pm.patch
      status[:patch] = {
        :name => pm.patch.name,
        :connections => pm.patch.connections.collect do |conn|
          {
            :input => conn.input.name,
            :input_chan => conn.input_chan ? conn.input_chan + 1 : 'all',
            :output => conn.output.name,
            :output_chan => conn.output_chan + 1,
            :pc => conn.pc_prog.to_s,
            :zone => conn.zone ? [conn.note_num_to_name(conn.zone.begin),
                                  conn.note_num_to_name(conn.zone.end)] : '',
            :xpose => conn.xpose.to_s,
            :filter => conn.filter.to_s
          }
        end
      }
    end
  end
  json status.merge(opts)
end