forked from ReaTeam/ReaScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtompad_MusicMath.lua
850 lines (723 loc) · 17.3 KB
/
tompad_MusicMath.lua
1
2
3
4
5
6
7
8
9
10
11
12
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
-- @description MusicMath - bpm/pitch to ms/Hz converter
-- @author tompad
-- @version 1.1
-- @changelog
-- Added coverter pitch to Hz
-- Added tooltip "Click to copy to clipboard"
-- Added flashing green when clicking on ms or Hz label
-- @about
-- tompad_MusicMath is a reascript to get ms from bpm and Hz from pitch in a Reaperproject.
--
-- When script window is opened, it takes the current bpm from Reaper and by choosing note buttons it convert bpm to ms.
--
-- By clicking the resulting ms-text the script is copying the ms to the systems clipboard (for pasting in to delay f.ex)
--
-- Any comments on coding, requests, bugs etc is welcome! PM me (tompad) on Reaper Forum (https://forum.cockos.com/member.php?u=19103).
-- Script generated by Lokasenna's GUI Builder
local lib_path = reaper.GetExtState("Lokasenna_GUI", "lib_path_v2")
if not lib_path or lib_path == "" then
reaper.MB("Couldn't load the Lokasenna_GUI library. Please install 'Lokasenna's GUI library v2 for Lua', available on ReaPack, then run the 'Set Lokasenna_GUI v2 library path.lua' script in your Action List.", "Whoops!", 0)
return
end
loadfile(lib_path .. "Core.lua")()
GUI.req("Classes/Class - Label.lua")()
GUI.req("Classes/Class - Options.lua")()
GUI.req("Classes/Class - Button.lua")()
GUI.req("Classes/Class - Tabs.lua")()
GUI.req("Classes/Class - Slider.lua")()
GUI.req("Classes/Class - Menubox.lua")()
-- If any of the requested libraries weren't found, abort the script.
if missing_lib then return 0 end
GUI.name = "MusicMath"
GUI.x, GUI.y, GUI.w, GUI.h = 0, 0, 210, 470
GUI.anchor, GUI.corner = "mouse", "C"
GUI.New("tabs", "Tabs", 1, 0, 0, 64, 20, "mS,Hz", 16)
-- Telling the tabs which z layers to display
-- See Classes/Tabs.lua for more detail
GUI.elms.tabs:update_sets(
-- Tab
-- Layers
{ [1] = {2},
[2] = {3},
}
)
GUI.tooltip_time = 0.1
-- <hide-code desc='Tab ms'>
GUI.New("bpm_label", "Label", {
z = 2,
x = 70,
y = 32,
caption = "",
font = 1,
color = "txt",
bg = "wnd_bg",
shadow = false
})
-- <hide-code desc='1/1'>
GUI.New("btn_1_1", "Button", {
z = 2,
x = 26.0,
y = 76.0,
w = 48,
h = 48,
caption = "1/1",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
GUI.New("btn_1_1dot", "Button", {
z = 2,
x = 80.0,
y = 76.0,
w = 48,
h = 48,
caption = "1/1.",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
GUI.New("btn_1_1t", "Button", {
z = 2,
x = 134.0,
y = 76.0,
w = 48,
h = 48,
caption = "1/1t",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
-- </hide-code>
-- <hide-code desc='1/2'>
GUI.New("btn_1_2", "Button", {
z = 2,
x = 26.0,
y = 130.0,
w = 48,
h = 48,
caption = "1/2",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
GUI.New("btn_1_2dot", "Button", {
z = 2,
x = 80.0,
y = 130.0,
w = 48,
h = 48,
caption = "1/2.",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
GUI.New("btn_1_2t", "Button", {
z = 2,
x = 134.0,
y = 130.0,
w = 48,
h = 48,
caption = "1/2t",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
-- </hide-code>
-- <hide-code desc='1/4'>
GUI.New("btn_1_4", "Button", {
z = 2,
x = 26.0,
y = 184.0,
w = 48,
h = 48,
caption = "1/4",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
GUI.New("btn_1_4dot", "Button", {
z = 2,
x = 80.0,
y = 184.0,
w = 48,
h = 48,
caption = "1/4.",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
GUI.New("btn_1_4t", "Button", {
z = 2,
x = 134.0,
y = 184.0,
w = 48,
h = 48,
caption = "1/4t",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
-- </hide-code>
-- <hide-code desc='1/8'>
GUI.New("btn_1_8", "Button", {
z = 2,
x = 26.0,
y = 238.0,
w = 48,
h = 48,
caption = "1/8",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
GUI.New("btn_1_8dot", "Button", {
z = 2,
x = 80.0,
y = 238.0,
w = 48,
h = 48,
caption = "1/8.",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
GUI.New("btn_1_8t", "Button", {
z = 2,
x = 134.0,
y = 238.0,
w = 48,
h = 48,
caption = "1/8t",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
-- </hide-code>
-- <hide-code desc='1/16'>
GUI.New("btn_1_16", "Button", {
z = 2,
x = 26.0,
y = 292.0,
w = 48,
h = 48,
caption = "1/16",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
GUI.New("btn_1_16dot", "Button", {
z = 2,
x = 80.0,
y = 292.0,
w = 48,
h = 48,
caption = "1/16.",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
GUI.New("btn_1_16t", "Button", {
z = 2,
x = 134.0,
y = 292.0,
w = 48,
h = 48,
caption = "1/16t",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
-- </hide-code>
-- <hide-code desc='1/32'>
GUI.New("btn_1_32", "Button", {
z = 2,
x = 26.0,
y = 346.0,
w = 48,
h = 48,
caption = "1/32",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
GUI.New("btn_1_32dot", "Button", {
z = 2,
x = 80.0,
y = 346.0,
w = 48,
h = 48,
caption = "1/32.",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
GUI.New("btn_1_32t", "Button", {
z = 2,
x = 134.0,
y = 346.0,
w = 48,
h = 48,
caption = "1/32t",
font = 2,
col_txt = "txt",
col_fill = "elm_frame"
})
-- </hide-code>
GUI.New("ms_label", "Label", {
z = 2,
x = 105,
y = 410,
caption = "0 ms",
font = 1,
color = "txt",
bg = "wnd_bg",
shadow = false,
tooltip = "Click to copy to clipboard"
})
function check_Tempo ()
local tempo = reaper.Master_GetTempo()
local tempo_str = tempo .." bpm"
GUI.Val("bpm_label", tempo_str)
--Centrerar bpm_label och ms_label mittpunkt
local x = (GUI.w / 2)
GUI.elms.bpm_label.x = x - ((gfx.measurestr(tempo_str)) / 2)
GUI.elms.ms_label.x = x - ((gfx.measurestr(GUI.elms.ms_label.caption)) / 2)
return tempo
end
function GUI.elms.ms_label:onmousedown()
GUI.Label.onmousedown(self)
GUI.elms.ms_label.bg = "elm_fill"
GUI.elms.ms_label:init()
GUI.elms.ms_label:redraw()
end
function GUI.elms.ms_label:onmouseup()
GUI.Label.onmouseup(self)
local str = string.gsub(GUI.elms.ms_label.caption, " ms", "")
reaper.CF_SetClipboard(str)
GUI.elms.ms_label.bg = "wnd_bg"
GUI.elms.ms_label:init()
GUI.elms.ms_label:redraw()
end
-- <hide-code desc='btn_1_1'>
function GUI.elms.btn_1_1dot:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 1)
end
function GUI.elms.btn_1_1:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 2)
end
function GUI.elms.btn_1_1t:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 3)
end
-- </hide-code>
-- <hide-code desc='1/2'>
function GUI.elms.btn_1_2dot:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 4)
end
function GUI.elms.btn_1_2:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 5)
end
function GUI.elms.btn_1_2t:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 6)
end
-- </hide-code>
-- <hide-code desc='1/4'>
function GUI.elms.btn_1_4dot:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 7)
end
function GUI.elms.btn_1_4:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 8)
end
function GUI.elms.btn_1_4t:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 9)
end
-- </hide-code>
-- <hide-code desc='1/8'>
function GUI.elms.btn_1_8dot:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 10)
end
function GUI.elms.btn_1_8:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 11)
end
function GUI.elms.btn_1_8t:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 12)
end
-- </hide-code>
-- <hide-code desc='1/16'>
function GUI.elms.btn_1_16dot:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 13)
end
function GUI.elms.btn_1_16:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 14)
end
function GUI.elms.btn_1_16t:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 15)
end
-- </hide-code>
-- <hide-code desc='1/32'>
function GUI.elms.btn_1_32dot:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 16)
end
function GUI.elms.btn_1_32:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 17)
end
function GUI.elms.btn_1_32t:onmouseup()
GUI.Button.onmouseup(self)
local tempo = check_Tempo()
check_ms(tempo, 18)
end
-- </hide-code>
function check_ms (bpm, notvarde)
local mSeconds = 60000 / bpm
if notvarde == 1 then
value_ms = mSeconds * 6 --1/1.
elseif notvarde == 2 then
value_ms = mSeconds * 4 -- 1/1
elseif notvarde == 3 then
value_ms = mSeconds * 2.666 -- 1/1T
elseif notvarde == 4 then
value_ms = mSeconds * 3 -- 1/2.
elseif notvarde == 5 then
value_ms = mSeconds * 2 -- 1/2
elseif notvarde == 6 then
value_ms = mSeconds * 1.333 -- 1/2T
elseif notvarde == 7 then
value_ms = mSeconds * 1.5 -- 1/4.
elseif notvarde == 8 then
value_ms = mSeconds * 1 -- 1/4
elseif notvarde == 9 then
value_ms = mSeconds * 0.666 -- 1/4T
elseif notvarde == 10 then
value_ms = mSeconds * 0.75 -- 1/8.
elseif notvarde == 11 then
value_ms = mSeconds * 0.5 -- 1/8
elseif notvarde == 12 then
value_ms = mSeconds * 0.333 -- 1/8T
elseif notvarde == 13 then
value_ms = mSeconds * 0.375 --1/16.
elseif notvarde == 14 then
value_ms = mSeconds * 0.25 --1/16
elseif notvarde == 15 then
value_ms = mSeconds * 0.1665 --1/16T
elseif notvarde == 16 then
value_ms = mSeconds * 0.1875 --1/32.
elseif notvarde == 17 then
value_ms = mSeconds * 0.125 -- 1/32
elseif notvarde == 18 then
value_ms = mSeconds * 0.08325 -- 1/32T
end
local ms_str = round(value_ms, 3) .." ms"
GUI.Val("ms_label", ms_str)
--Centrerar ms_label mittpunkt
local x = (GUI.w / 2)
GUI.elms.ms_label.x = x - ((gfx.measurestr(ms_str)) / 2)
end
function round(number, decimals)
local power = 10^decimals
return math.floor(number * power) / power
end
-- </hide-code>
-- <hide-code desc='Tab Hz'>
GUI.New("tunings", "Menubox", {
z = 3,
x = 108,
y = 42,
w = 50,
h = 20,
caption = "Tuning:",
opts = "432, 434, 436, 438, 440, 442, 444, 446",
retval = 3.0,
font_a = 2,
font_b = 4,
col_txt = "txt",
col_cap = "txt",
bg = "wnd_bg",
pad = 2,
noarrow = false,
align = 2
})
GUI.New("note_sldr", "Slider", {
z = 3,
x = 58,
y = 106,
w = 250,
caption = "Note",
min = 0,
max = 11,
defaults = 11,
inc = 1,
dir = "v",
font_a = 2,
font_b = 4,
col_txt = "txt",
col_fill = "elm_bg",
bg = "wnd_bg",
show_handles = true,
show_values = false,
cap_x = 0,
cap_y = 0
})
GUI.New("octave_sldr", "Slider", {
z = 3,
x = 141,
y = 106,
w = 250,
caption = "Octave",
min = 0,
max = 8,
defaults = 4,
inc = 1,
dir = "v",
font_a = 2,
font_b = 4,
col_txt = "txt",
col_fill = "elm_bg",
bg = "wnd_bg",
show_handles = true,
show_values = false,
cap_x = 0,
cap_y = 0
})
GUI.New("note_octave_lbl", "Label", {
z = 3,
x = 95,
y = 375,
caption = "C4",
font = 2,
color = "txt",
bg = "wnd_bg",
shadow = false
})
GUI.New("hz_label", "Label", {
z = 3,
x = 105,
y = 410,
caption = "0 Hz",
font = 1,
color = "txt",
bg = "wnd_bg",
shadow = false,
tooltip = "Click to copy to clipboard"
})
-- <hide-code desc='Tunings Menubox'>
function GUI.elms.tunings:onwheel()
GUI.Menubox.onwheel(self)
check_notename(GUI.Val("note_sldr"), GUI.Val("octave_sldr"), GUI.Val("tunings"))
end
function GUI.elms.tunings:onmouseup()
GUI.Menubox.onmouseup(self)
check_notename(GUI.Val("note_sldr"), GUI.Val("octave_sldr"), GUI.Val("tunings"))
end
-- </hide-code>
-- <hide-code desc='note-slider'>
function GUI.elms.note_sldr:onmousedown()
GUI.Slider.onmousedown(self)
check_notename(GUI.Val("note_sldr"), GUI.Val("octave_sldr"), GUI.Val("tunings"))
end
function GUI.elms.note_sldr:ondrag()
GUI.Slider.ondrag(self)
check_notename(GUI.Val("note_sldr"), GUI.Val("octave_sldr"), GUI.Val("tunings"))
end
function GUI.elms.note_sldr:onwheel()
GUI.Slider.onwheel(self)
check_notename(GUI.Val("note_sldr"), GUI.Val("octave_sldr"), GUI.Val("tunings"))
end
function GUI.elms.note_sldr:ondoubleclick()
GUI.Slider.ondoubleclick(self)
check_notename(GUI.Val("note_sldr"), GUI.Val("octave_sldr"), GUI.Val("tunings"))
end
-- </hide-code>
-- <hide-code desc='octave-slider'>
function GUI.elms.octave_sldr:onmousedown()
GUI.Slider.onmousedown(self)
check_notename(GUI.Val("note_sldr"), GUI.Val("octave_sldr"), GUI.Val("tunings"))
end
function GUI.elms.octave_sldr:ondrag()
GUI.Slider.ondrag(self)
check_notename(GUI.Val("note_sldr"), GUI.Val("octave_sldr"), GUI.Val("tunings"))
end
function GUI.elms.octave_sldr:onwheel()
GUI.Slider.onwheel(self)
check_notename(GUI.Val("note_sldr"), GUI.Val("octave_sldr"), GUI.Val("tunings"))
end
function GUI.elms.octave_sldr:ondoubleclick()
GUI.Slider.ondoubleclick(self)
check_notename(GUI.Val("note_sldr"), GUI.Val("octave_sldr"), GUI.Val("tunings"))
end
-- </hide-code>
function check_tunings (tunings_val)
if tunings_val == 1 then
return 432
elseif tunings_val == 2 then
return 434
elseif tunings_val == 3 then
return 436
elseif tunings_val == 4 then
return 438
elseif tunings_val == 5 then
return 440
elseif tunings_val == 6 then
return 442
elseif tunings_val == 7 then
return 444
elseif tunings_val == 8 then
return 446
end
end
function check_notename (note, octave, tunings)
local notsteg
local notename
if note == 0 then
notename = "C"..octave
notsteg = -9
elseif note == 1 then
notename = "C#/Db"..octave
notsteg = -8
elseif note == 2 then
notename = "D"..octave
notsteg = -7
elseif note == 3 then
notename = "D#/Eb"..octave
notsteg = -6
elseif note == 4 then
notename = "E"..octave
notsteg = -5
elseif note == 5 then
notename = "F"..octave
notsteg = -4
elseif note == 6 then
notename = "F#/Gb"..octave
notsteg = -3
elseif note == 7 then
notename = "G"..octave
notsteg = -2
elseif note == 8 then
notename = "G#/Ab"..octave
notsteg = -1
elseif note == 9 then
notename = "A"..octave
notsteg = 0
elseif note == 10 then
notename = "A#/Bb"..octave
notsteg = 1
elseif note == 11 then
notename = "B"..octave
notsteg = 2
end
local tuningHz
if octave == 0 then
tuningHz = check_tunings(tunings)
tuningHz = tuningHz / 16
elseif octave == 1 then
tuningHz = check_tunings(tunings)
tuningHz = tuningHz / 8
elseif octave == 2 then
tuningHz = check_tunings(tunings)
tuningHz = tuningHz / 4
elseif octave == 3 then
tuningHz = check_tunings(tunings)
tuningHz = tuningHz / 2
elseif octave == 4 then
tuningHz = check_tunings(tunings)
elseif octave == 5 then
tuningHz = check_tunings(tunings)
tuningHz = tuningHz * 2
elseif octave == 6 then
tuningHz = check_tunings(tunings)
tuningHz = tuningHz * 4
elseif octave == 7 then
tuningHz = check_tunings(tunings)
tuningHz = tuningHz * 8
elseif octave == 8 then
tuningHz = check_tunings(tunings)
tuningHz = tuningHz * 16
end
local hz = tuningHz * 1.05946309436^notsteg
hz = round(hz, 3)
--reaper.ShowConsoleMsg(hz)
local hz_str = hz .." Hz"
GUI.Val("hz_label", hz_str)
local x = (GUI.w / 2)
--Centrerar hz_label mittpunkt
GUI.elms.hz_label.x = x - ((gfx.measurestr(hz_str)) / 2)
GUI.Val("note_octave_lbl", notename)
local x = (GUI.w / 2)
GUI.elms.note_octave_lbl.x = x - ((gfx.measurestr(notename)) / 2)
end
function GUI.elms.hz_label:onmousedown()
GUI.Label.onmousedown(self)
GUI.elms.hz_label.bg = "elm_fill"
GUI.elms.hz_label:init()
GUI.elms.hz_label:redraw()
end
function GUI.elms.hz_label:onmouseup()
GUI.Label.onmouseup(self)
local str = string.gsub(GUI.elms.hz_label.caption, " Hz", "")
reaper.CF_SetClipboard(str)
GUI.elms.hz_label.bg = "wnd_bg"
GUI.elms.hz_label:init()
GUI.elms.hz_label:redraw()
end
-- </hide-code>
------------------------------------
-------- Main functions ------------
------------------------------------
-- This will be run on every update loop of the GUI script; anything you would put
-- inside a reaper.defer() loop should go here. (The function name doesn't matter)
local function Main()
-- Prevent the user from resizing the window
if GUI.resized then
-- If the window's size has been changed, reopen it
-- at the current position with the size we specified
local __, x, y, w, h = gfx.dock(-1, 0, 0, 0, 0)
gfx.quit()
gfx.init(GUI.name, GUI.w, GUI.h, 0, x, y)
GUI.redraw_z[0] = true
end
check_Tempo()
end
-- Open the script window and initialize a few things
GUI.Init()
--GUI.elms.tunings.x = x - ((gfx.measurestr(GUI.elms.tunings.caption) - 90) / 2)
GUI.Val("tunings", 5) -- select 440 HZ
check_notename(GUI.Val("note_sldr"), GUI.Val("octave_sldr"), GUI.Val("tunings"))
-- Tell the GUI library to run Main on each update loop
-- Individual elements are updated first, then GUI.func is run, then the GUI is redrawn
GUI.func = Main
-- How often (in seconds) to run GUI.func. 0 = every loop.
GUI.freq = 0
-- Start the main loop
GUI.Main()