| 41 |
|
|
| 42 |
def change_timebase |
def change_timebase |
| 43 |
timebase = self.timebase |
timebase = self.timebase |
| 44 |
hash = Dialog.run { |
hash = Dialog.run("Change Timebase") { |
| 45 |
layout(1, |
layout(1, |
| 46 |
layout(2, |
layout(2, |
| 47 |
item(:text, :title=>"Current timebase = #{timebase}"), |
item(:text, :title=>"Current timebase = #{timebase}"), |
| 49 |
item(:text, :title=>"New timebase"), |
item(:text, :title=>"New timebase"), |
| 50 |
item(:textfield, :width=>40, :range=>[24, 960], :tag=>"new"))) |
item(:textfield, :width=>40, :range=>[24, 960], :tag=>"new"))) |
| 51 |
} |
} |
| 52 |
p hash |
# p hash |
| 53 |
if hash[:status] == 0 |
if hash[:status] == 0 |
| 54 |
new = hash["new"].to_f |
new = hash["new"].to_f |
| 55 |
mult = new / timebase |
mult = new / timebase |
| 63 |
end |
end |
| 64 |
end |
end |
| 65 |
|
|
| 66 |
def randomize |
def randomize_ticks |
| 67 |
wd = 10.0 |
wd = (get_global_settings("randomize_tick_width") || "10").to_f |
| 68 |
each_track { |tr| |
if !self.has_selection |
| 69 |
s = tr.selection |
message_box("No events are selected.", "Error", :ok); |
| 70 |
t = [] |
return |
| 71 |
s.each { |p| |
end |
| 72 |
t1 = self.tick_to_time(p.tick) |
hash = Dialog.run("Randomize Ticks") { |
| 73 |
t2 = t1 + (rand() - 0.5) * wd / 1000.0 |
layout(1, |
| 74 |
t.push(Integer(self.time_to_tick(t2))) |
layout(1, |
| 75 |
} |
item(:text, :title=>"Randomize width (in milliseconds, 10-1000)"), |
| 76 |
s.modify_tick(t) |
item(:textfield, :width=>40, :value=>wd.to_s, :range=>[10, 1000], :tag=>"width"))) |
| 77 |
} |
} |
| 78 |
|
if hash[:status] == 0 |
| 79 |
|
wd = hash["width"].to_f |
| 80 |
|
set_global_settings("randomize_tick_width", wd.to_s) |
| 81 |
|
each_track { |tr| |
| 82 |
|
s = tr.selection |
| 83 |
|
t = [] |
| 84 |
|
s.each { |p| |
| 85 |
|
t1 = self.tick_to_time(p.tick) |
| 86 |
|
t2 = t1 + (rand() - 0.5) * wd / 1000.0 |
| 87 |
|
t.push(Integer(self.time_to_tick(t2))) |
| 88 |
|
} |
| 89 |
|
s.modify_tick(t) |
| 90 |
|
} |
| 91 |
|
end |
| 92 |
end |
end |
| 93 |
|
|
| 94 |
end |
end |
| 95 |
|
|
| 96 |
register_menu("Change timebase...", :change_timebase) |
register_menu("Change timebase...", :change_timebase) |
| 97 |
|
register_menu("Randomize ticks...", :randomize_ticks, 1) |
| 98 |
# register_menu("Change control number...", :change_control_number_ext) |
# register_menu("Change control number...", :change_control_number_ext) |