2 # Copyright (C) 2006,2007 John Anderson
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 require "rexml/document"
19 file = File.new( ARGV[0] )
20 doc = REXML::Document.new file
22 # fetch the node containing the controls
23 controls = XPath.first( doc, 'Session/ControlProtocols/Protocol[@name="Generic MIDI"]/controls' )
27 # A Control is a button or slider. It has an internal ID
28 # an incoming MIDI message, and an outgoing midi message
33 # Strips have solo,rec,mute,pan,fader
34 # Strips have midi input
35 # Strips have midi output
36 # Strips have an XML representation, or something like that
38 def initialize( node )
39 @solo = node.elements['solo']
40 @mute = node.elements['mute']
41 @rec = node.elements['recenable']
42 @fader = node.elements['IO/gaincontrol']
43 @panner = node.elements['IO/Panner/StreamPanner/panner']
47 # This knows how to extract a set of controls from a Route
49 doc.elements.each( 'Session/Routes/Route' ) do |node|
50 strip = Strip.new( node )
52 controls.add_element( 'mute',
53 'id' => mute.attribute('id').value,
55 'channel' => channel.to_s,
56 'additional' => "0x41"