| 1 |
# Copyright (c) 2010-2011 Toshi Nagata. All rights reserved. |
| 2 |
# |
| 3 |
# This program is free software; you can redistribute it and/or modify |
| 4 |
# it under the terms of the GNU General Public License as published by |
| 5 |
# the Free Software Foundation version 2 of the License. |
| 6 |
# |
| 7 |
# This program is distributed in the hope that it will be useful, |
| 8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 |
# GNU General Public License for more details. |
| 11 |
|
| 12 |
class Sequence |
| 13 |
|
| 14 |
def change_control_number_ext |
| 15 |
hash = Dialog.run { |
| 16 |
layout(1, |
| 17 |
layout(2, |
| 18 |
item(:text, :title=>"Old control number"), |
| 19 |
item(:textfield, :width=>40, :range=>[0, 127], :tag=>"old"), |
| 20 |
item(:text, :title=>"New control number"), |
| 21 |
item(:textfield, :width=>40, :range=>[0, 127], :tag=>"new")), |
| 22 |
item(:checkbox, :title=>"Change only editable tracks", :tag=>"editable_only"), |
| 23 |
item(:checkbox, :title=>"Change only selected events", :tag=>"selection_only")) |
| 24 |
} |
| 25 |
if hash["status"] == 0 |
| 26 |
old = hash["old"] |
| 27 |
new = hash["new"] |
| 28 |
editable_only = hash["editable_only"] |
| 29 |
selection_only = hash["selection_only"] |
| 30 |
# puts "old = #{old}, new = #{new}, editable_only = #{editable_only}" |
| 31 |
each_track { |tr| |
| 32 |
next if editable_only && !tr.editable? |
| 33 |
tr.send(selection_only ? :each_selected : :each) { |p| |
| 34 |
if p.kind == :control && p.code == old |
| 35 |
p.code = new |
| 36 |
end |
| 37 |
} |
| 38 |
} |
| 39 |
end |
| 40 |
end |
| 41 |
|
| 42 |
end |
| 43 |
|
| 44 |
# register_menu("Change control number...", :change_control_number_ext) |