@@ -1199,36 +1199,34 @@ end
11991199---
12001200
12011201function sync_clock_to_loop (source ,style )
1202- local duration = 0
1202+ local dur = 0
12031203 local pattern_id ;
12041204 if style == " audio" then
1205- duration = source .end_point - source .start_point
1205+ dur = source .end_point - source .start_point
12061206 elseif style == " pattern" then
12071207 pattern_id = string.match (source .name ," %d+" )
12081208 if params :string (" sync_clock_to_pattern_" .. pattern_id ) == " yes" then
12091209 for i = source .start_point ,source .end_point do
1210- duration = duration + source .time [i ]
1210+ dur = dur + source .time [i ]
12111211 end
12121212 end
12131213 end
1214- local quarter = duration / 4
1215- local derived_bpm = 60 / quarter
1216- while derived_bpm < 70 do
1217- derived_bpm = derived_bpm * 2
1218- if derived_bpm > 160 then break end
1219- end
1220- while derived_bpm > 160 do
1221- derived_bpm = derived_bpm / 2
1222- if derived_bpm <= 70 then break end
1223- end
1224- if duration ~= 0 then
1214+ if dur > 0 then
1215+ local quarter = dur / 4
1216+ local derived_bpm = 60 / quarter
1217+ while derived_bpm < 70 do
1218+ derived_bpm = derived_bpm * 2
1219+ if derived_bpm > 160 then break end
1220+ end
1221+ while derived_bpm > 160 do
1222+ derived_bpm = derived_bpm / 2
1223+ if derived_bpm <= 70 then break end
1224+ end
12251225 if params :get (" clock_midi_out" ) ~= 1 then
12261226 params :set (" clock_tempo" ,util .round (derived_bpm ))
12271227 else
12281228 params :set (" clock_tempo" ,util .round (derived_bpm ,0.01 ))
12291229 end
1230- else
1231- print (" won't be doing it!" )
12321230 end
12331231end
12341232
0 commit comments