-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathreaper_python.py
8034 lines (6571 loc) · 312 KB
/
reaper_python.py
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
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# REAPER 5.95
import re
from ctypes import *
# lowercase rpr_ functions are for internal use
_ft={}
def rpr_initft(ft):
if (len(_ft) == 0):
_ft.update(ft)
def rpr_getfp(fn):
return _ft[fn]
def rpr_packp(t,v):
m=re.match('^\((\w+\*|HWND)\)0x([0-9A-F]+)$', str(v))
if (m != None):
(_t,_v)=m.groups()
if (_t == t or t == 'void*'):
a=int(_v[:8],16)
b=int(_v[8:],16);
p=c_uint64((a<<32)|b).value
if (RPR_ValidatePtr(p,t)):
return p
return 0
def rpr_unpackp(t,v):
if (v == None):
v=0
a=int(v>>32)
b=int(v&0xFFFFFFFF)
return '(%s)0x%08X%08X' % (t,a,b)
def RPR_ValidatePtr(p,t):
"""
Python: Boolean RPR_ValidatePtr(void pointer, String ctypename)
see ValidatePtr2
"""
a=_ft['ValidatePtr']
f=CFUNCTYPE(c_byte,c_uint64,c_char_p)(a)
return f(c_uint64(p),rpr_packsc(t))
def rpr_packsc(v):
return c_char_p(str(v).encode())
def rpr_packs(v):
MAX_STRBUF=4*1024*1024
return create_string_buffer(str(v).encode(),MAX_STRBUF)
def rpr_unpacks(v):
return str(v.value.decode())
def RPR_GetAudioAccessorSamples(accessor,samplerate,numchannels,starttime_sec,numsamplesperchannel,samplebuffer):
"""
Python: (Int retval, AudioAccessor accessor, Int samplerate, Int numchannels, Float starttime_sec, Int numsamplesperchannel, Float samplebuffer) = RPR_GetAudioAccessorSamples(accessor, samplerate, numchannels, starttime_sec, numsamplesperchannel, samplebuffer)
Get a block of samples from the audio accessor. Samples are extracted immediately pre-FX, and returned interleaved (first sample of first channel, first sample of second channel...). Returns 0 if no audio, 1 if audio, -1 on error. See CreateTakeAudioAccessor
, CreateTrackAudioAccessor
, DestroyAudioAccessor
, GetAudioAccessorHash
, GetAudioAccessorStartTime
, GetAudioAccessorEndTime
.
This function has special handling in Python, and only returns two objects, the API function return value, and the sample buffer. Example usage:
tr = RPR_GetTrack(0, 0)
aa = RPR_CreateTrackAudioAccessor(tr)
buf = list([0]*2*1024) # 2 channels, 1024 samples each, initialized to zero
pos = 0.0
(ret, buf) = GetAudioAccessorSamples(aa, 44100, 2, pos, 1024, buf)
# buf now holds the first 2*1024 audio samples from the track.
# typically GetAudioAccessorSamples() would be called within a loop, increasing pos each time.
"""
a=_ft['GetAudioAccessorSamples']
f=CFUNCTYPE(c_int,c_uint64,c_int,c_int,c_double,c_int,c_void_p)(a)
v=cast((c_double*numchannels*numsamplesperchannel)(),POINTER(c_double))
t=(rpr_packp('void*',accessor),c_int(samplerate),c_int(numchannels),c_double(starttime_sec),c_int(numsamplesperchannel),v)
r=f(t[0],t[1],t[2],t[3],t[4],t[5])
for i in range(numchannels*numsamplesperchannel):
samplebuffer[i]=float(v[i])
return (r,samplebuffer)
def RPR_AddMediaItemToTrack(tr):
"""
Python: MediaItem RPR_AddMediaItemToTrack(MediaTrack tr)
creates a new media item.
"""
a=_ft['AddMediaItemToTrack']
f=CFUNCTYPE(c_uint64,c_uint64)(a)
t=(rpr_packp('MediaTrack*',tr),)
r=f(t[0])
return rpr_unpackp('MediaItem*',r)
def RPR_AddProjectMarker(proj,isrgn,pos,rgnend,name,wantidx):
"""
Python: Int RPR_AddProjectMarker(ReaProject proj, Boolean isrgn, Float pos, Float rgnend, String name, Int wantidx)
Returns the index of the created marker/region, or -1 on failure. Supply wantidx>=0 if you want a particular index number, but you'll get a different index number a region and wantidx is already in use.
"""
a=_ft['AddProjectMarker']
f=CFUNCTYPE(c_int,c_uint64,c_byte,c_double,c_double,c_char_p,c_int)(a)
t=(rpr_packp('ReaProject*',proj),c_byte(isrgn),c_double(pos),c_double(rgnend),rpr_packsc(name),c_int(wantidx))
r=f(t[0],t[1],t[2],t[3],t[4],t[5])
return r
def RPR_AddProjectMarker2(proj,isrgn,pos,rgnend,name,wantidx,color):
"""
Python: Int RPR_AddProjectMarker2(ReaProject proj, Boolean isrgn, Float pos, Float rgnend, String name, Int wantidx, Int color)
Returns the index of the created marker/region, or -1 on failure. Supply wantidx>=0 if you want a particular index number, but you'll get a different index number a region and wantidx is already in use. color should be 0 (default color), or ColorToNative(r,g,b)|0x1000000
"""
a=_ft['AddProjectMarker2']
f=CFUNCTYPE(c_int,c_uint64,c_byte,c_double,c_double,c_char_p,c_int,c_int)(a)
t=(rpr_packp('ReaProject*',proj),c_byte(isrgn),c_double(pos),c_double(rgnend),rpr_packsc(name),c_int(wantidx),c_int(color))
r=f(t[0],t[1],t[2],t[3],t[4],t[5],t[6])
return r
def RPR_AddRemoveReaScript(add,sectionID,scriptfn,commit):
"""
Python: Int RPR_AddRemoveReaScript(Boolean add, Int sectionID, String scriptfn, Boolean commit)
Add a ReaScript (return the new command ID, or 0 if failed) or remove a ReaScript (return >0 on success). Use commit==true when adding/removing a single script. When bulk adding/removing n scripts, you can optimize the n-1 first calls with commit==false and commit==true for the last call.
"""
a=_ft['AddRemoveReaScript']
f=CFUNCTYPE(c_int,c_byte,c_int,c_char_p,c_byte)(a)
t=(c_byte(add),c_int(sectionID),rpr_packsc(scriptfn),c_byte(commit))
r=f(t[0],t[1],t[2],t[3])
return r
def RPR_AddTakeToMediaItem(item):
"""
Python: MediaItem_Take RPR_AddTakeToMediaItem(MediaItem item)
creates a new take in an item
"""
a=_ft['AddTakeToMediaItem']
f=CFUNCTYPE(c_uint64,c_uint64)(a)
t=(rpr_packp('MediaItem*',item),)
r=f(t[0])
return rpr_unpackp('MediaItem_Take*',r)
def RPR_AddTempoTimeSigMarker(proj,timepos,bpm,timesig_num,timesig_denom,lineartempochange):
"""
Python: Boolean RPR_AddTempoTimeSigMarker(ReaProject proj, Float timepos, Float bpm, Int timesig_num, Int timesig_denom, Boolean lineartempochange)
Deprecated. Use SetTempoTimeSigMarker with ptidx=-1.
"""
a=_ft['AddTempoTimeSigMarker']
f=CFUNCTYPE(c_byte,c_uint64,c_double,c_double,c_int,c_int,c_byte)(a)
t=(rpr_packp('ReaProject*',proj),c_double(timepos),c_double(bpm),c_int(timesig_num),c_int(timesig_denom),c_byte(lineartempochange))
r=f(t[0],t[1],t[2],t[3],t[4],t[5])
return r
def RPR_adjustZoom(amt,forceset,doupd,centermode):
"""
Python: RPR_adjustZoom(Float amt, Int forceset, Boolean doupd, Int centermode)
forceset=0,doupd=true,centermode=-1 for default
"""
a=_ft['adjustZoom']
f=CFUNCTYPE(None,c_double,c_int,c_byte,c_int)(a)
t=(c_double(amt),c_int(forceset),c_byte(doupd),c_int(centermode))
f(t[0],t[1],t[2],t[3])
def RPR_AnyTrackSolo(proj):
"""
Python: Boolean RPR_AnyTrackSolo(ReaProject proj)
"""
a=_ft['AnyTrackSolo']
f=CFUNCTYPE(c_byte,c_uint64)(a)
t=(rpr_packp('ReaProject*',proj),)
r=f(t[0])
return r
def RPR_APIExists(function_name):
"""
Python: Boolean RPR_APIExists(String function_name)
Returns true if function_name exists in the REAPER API
"""
a=_ft['APIExists']
f=CFUNCTYPE(c_byte,c_char_p)(a)
t=(rpr_packsc(function_name),)
r=f(t[0])
return r
def RPR_APITest():
"""
Python: RPR_APITest()
Displays a message window if the API was successfully called.
"""
a=_ft['APITest']
f=CFUNCTYPE(None)(a)
f()
def RPR_ApplyNudge(project,nudgeflag,nudgewhat,nudgeunits,value,reverse,copies):
"""
Python: Boolean RPR_ApplyNudge(ReaProject project, Int nudgeflag, Int nudgewhat, Int nudgeunits, Float value, Boolean reverse, Int copies)
nudgeflag: &1=set to value (otherwise nudge by value), &2=snap
nudgewhat: 0=position, 1=left trim, 2=left edge, 3=right edge, 4=contents, 5=duplicate, 6=edit cursor
nudgeunit: 0=ms, 1=seconds, 2=grid, 3=256th notes, ..., 15=whole notes, 16=measures.beats (1.15 = 1 measure + 1.5 beats), 17=samples, 18=frames, 19=pixels, 20=item lengths, 21=item selections
value: amount to nudge by, or value to set to
reverse: in nudge mode, nudges left (otherwise ignored)
copies: in nudge duplicate mode, number of copies (otherwise ignored)
"""
a=_ft['ApplyNudge']
f=CFUNCTYPE(c_byte,c_uint64,c_int,c_int,c_int,c_double,c_byte,c_int)(a)
t=(rpr_packp('ReaProject*',project),c_int(nudgeflag),c_int(nudgewhat),c_int(nudgeunits),c_double(value),c_byte(reverse),c_int(copies))
r=f(t[0],t[1],t[2],t[3],t[4],t[5],t[6])
return r
def RPR_ArmCommand(cmd,sectionname):
"""
Python: RPR_ArmCommand(Int cmd, String sectionname)
arms a command (or disarms if 0 passed) in section sectionname (empty string for main)
"""
a=_ft['ArmCommand']
f=CFUNCTYPE(None,c_int,c_char_p)(a)
t=(c_int(cmd),rpr_packsc(sectionname))
f(t[0],t[1])
def RPR_Audio_Init():
"""
Python: RPR_Audio_Init()
open all audio and MIDI devices, if not open
"""
a=_ft['Audio_Init']
f=CFUNCTYPE(None)(a)
f()
def RPR_Audio_IsPreBuffer():
"""
Python: Int RPR_Audio_IsPreBuffer()
is in pre-buffer? threadsafe
"""
a=_ft['Audio_IsPreBuffer']
f=CFUNCTYPE(c_int)(a)
r=f()
return r
def RPR_Audio_IsRunning():
"""
Python: Int RPR_Audio_IsRunning()
is audio running at all? threadsafe
"""
a=_ft['Audio_IsRunning']
f=CFUNCTYPE(c_int)(a)
r=f()
return r
def RPR_Audio_Quit():
"""
Python: RPR_Audio_Quit()
close all audio and MIDI devices, if open
"""
a=_ft['Audio_Quit']
f=CFUNCTYPE(None)(a)
f()
def RPR_AudioAccessorValidateState(accessor):
"""
Python: Boolean RPR_AudioAccessorValidateState(AudioAccessor accessor)
Validates the current state of the audio accessor -- must ONLY call this from the main thread. Returns true if the state changed.
"""
a=_ft['AudioAccessorValidateState']
f=CFUNCTYPE(c_byte,c_uint64)(a)
t=(rpr_packp('AudioAccessor*',accessor),)
r=f(t[0])
return r
def RPR_BypassFxAllTracks(bypass):
"""
Python: RPR_BypassFxAllTracks(Int bypass)
-1 = bypass all if not all bypassed,otherwise unbypass all
"""
a=_ft['BypassFxAllTracks']
f=CFUNCTYPE(None,c_int)(a)
t=(c_int(bypass),)
f(t[0])
def RPR_ClearAllRecArmed():
"""
Python: RPR_ClearAllRecArmed()
"""
a=_ft['ClearAllRecArmed']
f=CFUNCTYPE(None)(a)
f()
def RPR_ClearConsole():
"""
Python: RPR_ClearConsole()
Clear the ReaScript console. See ShowConsoleMsg
"""
a=_ft['ClearConsole']
f=CFUNCTYPE(None)(a)
f()
def RPR_ClearPeakCache():
"""
Python: RPR_ClearPeakCache()
resets the global peak caches
"""
a=_ft['ClearPeakCache']
f=CFUNCTYPE(None)(a)
f()
def RPR_ColorFromNative(col,rOut,gOut,bOut):
"""
Python: (Int col, Int rOut, Int gOut, Int bOut) = RPR_ColorFromNative(col, rOut, gOut, bOut)
Extract RGB values from an OS dependent color. See ColorToNative
.
"""
a=_ft['ColorFromNative']
f=CFUNCTYPE(None,c_int,c_void_p,c_void_p,c_void_p)(a)
t=(c_int(col),c_int(rOut),c_int(gOut),c_int(bOut))
f(t[0],byref(t[1]),byref(t[2]),byref(t[3]))
return (col,int(t[1].value),int(t[2].value),int(t[3].value))
def RPR_ColorToNative(r,g,b):
"""
Python: Int RPR_ColorToNative(Int r, Int g, Int b)
Make an OS dependent color from RGB values (e.g. RGB() macro on Windows). r,g and b are in [0..255]. See ColorFromNative
.
"""
a=_ft['ColorToNative']
f=CFUNCTYPE(c_int,c_int,c_int,c_int)(a)
t=(c_int(r),c_int(g),c_int(b))
r=f(t[0],t[1],t[2])
return r
def RPR_CountAutomationItems(env):
"""
Python: Int RPR_CountAutomationItems(TrackEnvelope env)
Returns the number of automation items on this envelope. See GetSetAutomationItemInfo
"""
a=_ft['CountAutomationItems']
f=CFUNCTYPE(c_int,c_uint64)(a)
t=(rpr_packp('TrackEnvelope*',env),)
r=f(t[0])
return r
def RPR_CountEnvelopePoints(envelope):
"""
Python: Int RPR_CountEnvelopePoints(TrackEnvelope envelope)
Returns the number of points in the envelope.
"""
a=_ft['CountEnvelopePoints']
f=CFUNCTYPE(c_int,c_uint64)(a)
t=(rpr_packp('TrackEnvelope*',envelope),)
r=f(t[0])
return r
def RPR_CountEnvelopePointsEx(envelope,autoitem_idx):
"""
Python: Int RPR_CountEnvelopePointsEx(TrackEnvelope envelope, Int autoitem_idx)
Returns the number of points in the envelope. autoitem_idx==-1 for the underlying envelope, 0 for the first automation item on the envelope, etc.
"""
a=_ft['CountEnvelopePointsEx']
f=CFUNCTYPE(c_int,c_uint64,c_int)(a)
t=(rpr_packp('TrackEnvelope*',envelope),c_int(autoitem_idx))
r=f(t[0],t[1])
return r
def RPR_CountMediaItems(proj):
"""
Python: Int RPR_CountMediaItems(ReaProject proj)
count the number of items in the project (proj=0 for active project)
"""
a=_ft['CountMediaItems']
f=CFUNCTYPE(c_int,c_uint64)(a)
t=(rpr_packp('ReaProject*',proj),)
r=f(t[0])
return r
def RPR_CountProjectMarkers(proj,num_markersOut,num_regionsOut):
"""
Python: (Int retval, ReaProject proj, Int num_markersOut, Int num_regionsOut) = RPR_CountProjectMarkers(proj, num_markersOut, num_regionsOut)
num_markersOut and num_regionsOut may be NULL.
"""
a=_ft['CountProjectMarkers']
f=CFUNCTYPE(c_int,c_uint64,c_void_p,c_void_p)(a)
t=(rpr_packp('ReaProject*',proj),c_int(num_markersOut),c_int(num_regionsOut))
r=f(t[0],byref(t[1]),byref(t[2]))
return (r,proj,int(t[1].value),int(t[2].value))
def RPR_CountSelectedMediaItems(proj):
"""
Python: Int RPR_CountSelectedMediaItems(ReaProject proj)
count the number of selected items in the project (proj=0 for active project)
"""
a=_ft['CountSelectedMediaItems']
f=CFUNCTYPE(c_int,c_uint64)(a)
t=(rpr_packp('ReaProject*',proj),)
r=f(t[0])
return r
def RPR_CountSelectedTracks(proj):
"""
Python: Int RPR_CountSelectedTracks(ReaProject proj)
Count the number of selected tracks in the project (proj=0 for active project). This function ignores the master track, see CountSelectedTracks2
.
"""
a=_ft['CountSelectedTracks']
f=CFUNCTYPE(c_int,c_uint64)(a)
t=(rpr_packp('ReaProject*',proj),)
r=f(t[0])
return r
def RPR_CountSelectedTracks2(proj,wantmaster):
"""
Python: Int RPR_CountSelectedTracks2(ReaProject proj, Boolean wantmaster)
Count the number of selected tracks in the project (proj=0 for active project).
"""
a=_ft['CountSelectedTracks2']
f=CFUNCTYPE(c_int,c_uint64,c_byte)(a)
t=(rpr_packp('ReaProject*',proj),c_byte(wantmaster))
r=f(t[0],t[1])
return r
def RPR_CountTakeEnvelopes(take):
"""
Python: Int RPR_CountTakeEnvelopes(MediaItem_Take take)
See GetTakeEnvelope
"""
a=_ft['CountTakeEnvelopes']
f=CFUNCTYPE(c_int,c_uint64)(a)
t=(rpr_packp('MediaItem_Take*',take),)
r=f(t[0])
return r
def RPR_CountTakes(item):
"""
Python: Int RPR_CountTakes(MediaItem item)
count the number of takes in the item
"""
a=_ft['CountTakes']
f=CFUNCTYPE(c_int,c_uint64)(a)
t=(rpr_packp('MediaItem*',item),)
r=f(t[0])
return r
def RPR_CountTCPFXParms(project,track):
"""
Python: Int RPR_CountTCPFXParms(ReaProject project, MediaTrack track)
Count the number of FX parameter knobs displayed on the track control panel.
"""
a=_ft['CountTCPFXParms']
f=CFUNCTYPE(c_int,c_uint64,c_uint64)(a)
t=(rpr_packp('ReaProject*',project),rpr_packp('MediaTrack*',track))
r=f(t[0],t[1])
return r
def RPR_CountTempoTimeSigMarkers(proj):
"""
Python: Int RPR_CountTempoTimeSigMarkers(ReaProject proj)
Count the number of tempo/time signature markers in the project. See GetTempoTimeSigMarker
, SetTempoTimeSigMarker
, AddTempoTimeSigMarker
.
"""
a=_ft['CountTempoTimeSigMarkers']
f=CFUNCTYPE(c_int,c_uint64)(a)
t=(rpr_packp('ReaProject*',proj),)
r=f(t[0])
return r
def RPR_CountTrackEnvelopes(track):
"""
Python: Int RPR_CountTrackEnvelopes(MediaTrack track)
see GetTrackEnvelope
"""
a=_ft['CountTrackEnvelopes']
f=CFUNCTYPE(c_int,c_uint64)(a)
t=(rpr_packp('MediaTrack*',track),)
r=f(t[0])
return r
def RPR_CountTrackMediaItems(track):
"""
Python: Int RPR_CountTrackMediaItems(MediaTrack track)
count the number of items in the track
"""
a=_ft['CountTrackMediaItems']
f=CFUNCTYPE(c_int,c_uint64)(a)
t=(rpr_packp('MediaTrack*',track),)
r=f(t[0])
return r
def RPR_CountTracks(proj):
"""
Python: Int RPR_CountTracks(ReaProject proj)
count the number of tracks in the project (proj=0 for active project)
"""
a=_ft['CountTracks']
f=CFUNCTYPE(c_int,c_uint64)(a)
t=(rpr_packp('ReaProject*',proj),)
r=f(t[0])
return r
def RPR_CreateNewMIDIItemInProj(track,starttime,endtime,qnInOptional):
"""
Python: MediaItem RPR_CreateNewMIDIItemInProj(MediaTrack track, Float starttime, Float endtime, const bool qnInOptional)
Create a new MIDI media item, containing no MIDI events. Time is in seconds unless qn is set.
"""
a=_ft['CreateNewMIDIItemInProj']
f=CFUNCTYPE(c_uint64,c_uint64,c_double,c_double,c_void_p)(a)
t=(rpr_packp('MediaTrack*',track),c_double(starttime),c_double(endtime),c_byte(qnInOptional))
r=f(t[0],t[1],t[2],byref(t[3]))
return (rpr_unpackp('MediaItem*',r),track,starttime,endtime,int(t[3].value))
def RPR_CreateTakeAudioAccessor(take):
"""
Python: AudioAccessor RPR_CreateTakeAudioAccessor(MediaItem_Take take)
Create an audio accessor object for this take. Must only call from the main thread. See CreateTrackAudioAccessor
, DestroyAudioAccessor
, GetAudioAccessorHash
, GetAudioAccessorStartTime
, GetAudioAccessorEndTime
, GetAudioAccessorSamples
.
"""
a=_ft['CreateTakeAudioAccessor']
f=CFUNCTYPE(c_uint64,c_uint64)(a)
t=(rpr_packp('MediaItem_Take*',take),)
r=f(t[0])
return rpr_unpackp('AudioAccessor*',r)
def RPR_CreateTrackAudioAccessor(track):
"""
Python: AudioAccessor RPR_CreateTrackAudioAccessor(MediaTrack track)
Create an audio accessor object for this track. Must only call from the main thread. See CreateTakeAudioAccessor
, DestroyAudioAccessor
, GetAudioAccessorHash
, GetAudioAccessorStartTime
, GetAudioAccessorEndTime
, GetAudioAccessorSamples
.
"""
a=_ft['CreateTrackAudioAccessor']
f=CFUNCTYPE(c_uint64,c_uint64)(a)
t=(rpr_packp('MediaTrack*',track),)
r=f(t[0])
return rpr_unpackp('AudioAccessor*',r)
def RPR_CreateTrackSend(tr,desttrInOptional):
"""
Python: Int RPR_CreateTrackSend(MediaTrack tr, MediaTrack desttrInOptional)
Create a send/receive (desttrInOptional!=NULL), or a hardware output (desttrInOptional==NULL) with default properties, return >=0 on success (== new send/receive index). See RemoveTrackSend
, GetSetTrackSendInfo
, GetTrackSendInfo_Value
, SetTrackSendInfo_Value
.
"""
a=_ft['CreateTrackSend']
f=CFUNCTYPE(c_int,c_uint64,c_uint64)(a)
t=(rpr_packp('MediaTrack*',tr),rpr_packp('MediaTrack*',desttrInOptional))
r=f(t[0],t[1])
return r
def RPR_CSurf_FlushUndo(force):
"""
Python: RPR_CSurf_FlushUndo(Boolean force)
call this to force flushing of the undo states after using CSurf_On*Change()
"""
a=_ft['CSurf_FlushUndo']
f=CFUNCTYPE(None,c_byte)(a)
t=(c_byte(force),)
f(t[0])
def RPR_CSurf_GetTouchState(trackid,isPan):
"""
Python: Boolean RPR_CSurf_GetTouchState(MediaTrack trackid, Int isPan)
"""
a=_ft['CSurf_GetTouchState']
f=CFUNCTYPE(c_byte,c_uint64,c_int)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(isPan))
r=f(t[0],t[1])
return r
def RPR_CSurf_GoEnd():
"""
Python: RPR_CSurf_GoEnd()
"""
a=_ft['CSurf_GoEnd']
f=CFUNCTYPE(None)(a)
f()
def RPR_CSurf_GoStart():
"""
Python: RPR_CSurf_GoStart()
"""
a=_ft['CSurf_GoStart']
f=CFUNCTYPE(None)(a)
f()
def RPR_CSurf_NumTracks(mcpView):
"""
Python: Int RPR_CSurf_NumTracks(Boolean mcpView)
"""
a=_ft['CSurf_NumTracks']
f=CFUNCTYPE(c_int,c_byte)(a)
t=(c_byte(mcpView),)
r=f(t[0])
return r
def RPR_CSurf_OnArrow(whichdir,wantzoom):
"""
Python: RPR_CSurf_OnArrow(Int whichdir, Boolean wantzoom)
"""
a=_ft['CSurf_OnArrow']
f=CFUNCTYPE(None,c_int,c_byte)(a)
t=(c_int(whichdir),c_byte(wantzoom))
f(t[0],t[1])
def RPR_CSurf_OnFwd(seekplay):
"""
Python: RPR_CSurf_OnFwd(Int seekplay)
"""
a=_ft['CSurf_OnFwd']
f=CFUNCTYPE(None,c_int)(a)
t=(c_int(seekplay),)
f(t[0])
def RPR_CSurf_OnFXChange(trackid,en):
"""
Python: Boolean RPR_CSurf_OnFXChange(MediaTrack trackid, Int en)
"""
a=_ft['CSurf_OnFXChange']
f=CFUNCTYPE(c_byte,c_uint64,c_int)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(en))
r=f(t[0],t[1])
return r
def RPR_CSurf_OnInputMonitorChange(trackid,monitor):
"""
Python: Int RPR_CSurf_OnInputMonitorChange(MediaTrack trackid, Int monitor)
"""
a=_ft['CSurf_OnInputMonitorChange']
f=CFUNCTYPE(c_int,c_uint64,c_int)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(monitor))
r=f(t[0],t[1])
return r
def RPR_CSurf_OnInputMonitorChangeEx(trackid,monitor,allowgang):
"""
Python: Int RPR_CSurf_OnInputMonitorChangeEx(MediaTrack trackid, Int monitor, Boolean allowgang)
"""
a=_ft['CSurf_OnInputMonitorChangeEx']
f=CFUNCTYPE(c_int,c_uint64,c_int,c_byte)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(monitor),c_byte(allowgang))
r=f(t[0],t[1],t[2])
return r
def RPR_CSurf_OnMuteChange(trackid,mute):
"""
Python: Boolean RPR_CSurf_OnMuteChange(MediaTrack trackid, Int mute)
"""
a=_ft['CSurf_OnMuteChange']
f=CFUNCTYPE(c_byte,c_uint64,c_int)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(mute))
r=f(t[0],t[1])
return r
def RPR_CSurf_OnMuteChangeEx(trackid,mute,allowgang):
"""
Python: Boolean RPR_CSurf_OnMuteChangeEx(MediaTrack trackid, Int mute, Boolean allowgang)
"""
a=_ft['CSurf_OnMuteChangeEx']
f=CFUNCTYPE(c_byte,c_uint64,c_int,c_byte)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(mute),c_byte(allowgang))
r=f(t[0],t[1],t[2])
return r
def RPR_CSurf_OnPanChange(trackid,pan,relative):
"""
Python: Float RPR_CSurf_OnPanChange(MediaTrack trackid, Float pan, Boolean relative)
"""
a=_ft['CSurf_OnPanChange']
f=CFUNCTYPE(c_double,c_uint64,c_double,c_byte)(a)
t=(rpr_packp('MediaTrack*',trackid),c_double(pan),c_byte(relative))
r=f(t[0],t[1],t[2])
return r
def RPR_CSurf_OnPanChangeEx(trackid,pan,relative,allowGang):
"""
Python: Float RPR_CSurf_OnPanChangeEx(MediaTrack trackid, Float pan, Boolean relative, Boolean allowGang)
"""
a=_ft['CSurf_OnPanChangeEx']
f=CFUNCTYPE(c_double,c_uint64,c_double,c_byte,c_byte)(a)
t=(rpr_packp('MediaTrack*',trackid),c_double(pan),c_byte(relative),c_byte(allowGang))
r=f(t[0],t[1],t[2],t[3])
return r
def RPR_CSurf_OnPause():
"""
Python: RPR_CSurf_OnPause()
"""
a=_ft['CSurf_OnPause']
f=CFUNCTYPE(None)(a)
f()
def RPR_CSurf_OnPlay():
"""
Python: RPR_CSurf_OnPlay()
"""
a=_ft['CSurf_OnPlay']
f=CFUNCTYPE(None)(a)
f()
def RPR_CSurf_OnPlayRateChange(playrate):
"""
Python: RPR_CSurf_OnPlayRateChange(Float playrate)
"""
a=_ft['CSurf_OnPlayRateChange']
f=CFUNCTYPE(None,c_double)(a)
t=(c_double(playrate),)
f(t[0])
def RPR_CSurf_OnRecArmChange(trackid,recarm):
"""
Python: Boolean RPR_CSurf_OnRecArmChange(MediaTrack trackid, Int recarm)
"""
a=_ft['CSurf_OnRecArmChange']
f=CFUNCTYPE(c_byte,c_uint64,c_int)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(recarm))
r=f(t[0],t[1])
return r
def RPR_CSurf_OnRecArmChangeEx(trackid,recarm,allowgang):
"""
Python: Boolean RPR_CSurf_OnRecArmChangeEx(MediaTrack trackid, Int recarm, Boolean allowgang)
"""
a=_ft['CSurf_OnRecArmChangeEx']
f=CFUNCTYPE(c_byte,c_uint64,c_int,c_byte)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(recarm),c_byte(allowgang))
r=f(t[0],t[1],t[2])
return r
def RPR_CSurf_OnRecord():
"""
Python: RPR_CSurf_OnRecord()
"""
a=_ft['CSurf_OnRecord']
f=CFUNCTYPE(None)(a)
f()
def RPR_CSurf_OnRecvPanChange(trackid,recv_index,pan,relative):
"""
Python: Float RPR_CSurf_OnRecvPanChange(MediaTrack trackid, Int recv_index, Float pan, Boolean relative)
"""
a=_ft['CSurf_OnRecvPanChange']
f=CFUNCTYPE(c_double,c_uint64,c_int,c_double,c_byte)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(recv_index),c_double(pan),c_byte(relative))
r=f(t[0],t[1],t[2],t[3])
return r
def RPR_CSurf_OnRecvVolumeChange(trackid,recv_index,volume,relative):
"""
Python: Float RPR_CSurf_OnRecvVolumeChange(MediaTrack trackid, Int recv_index, Float volume, Boolean relative)
"""
a=_ft['CSurf_OnRecvVolumeChange']
f=CFUNCTYPE(c_double,c_uint64,c_int,c_double,c_byte)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(recv_index),c_double(volume),c_byte(relative))
r=f(t[0],t[1],t[2],t[3])
return r
def RPR_CSurf_OnRew(seekplay):
"""
Python: RPR_CSurf_OnRew(Int seekplay)
"""
a=_ft['CSurf_OnRew']
f=CFUNCTYPE(None,c_int)(a)
t=(c_int(seekplay),)
f(t[0])
def RPR_CSurf_OnRewFwd(seekplay,Dir):
"""
Python: RPR_CSurf_OnRewFwd(Int seekplay, Int dir)
"""
a=_ft['CSurf_OnRewFwd']
f=CFUNCTYPE(None,c_int,c_int)(a)
t=(c_int(seekplay),c_int(Dir))
f(t[0],t[1])
def RPR_CSurf_OnScroll(xdir,ydir):
"""
Python: RPR_CSurf_OnScroll(Int xdir, Int ydir)
"""
a=_ft['CSurf_OnScroll']
f=CFUNCTYPE(None,c_int,c_int)(a)
t=(c_int(xdir),c_int(ydir))
f(t[0],t[1])
def RPR_CSurf_OnSelectedChange(trackid,selected):
"""
Python: Boolean RPR_CSurf_OnSelectedChange(MediaTrack trackid, Int selected)
"""
a=_ft['CSurf_OnSelectedChange']
f=CFUNCTYPE(c_byte,c_uint64,c_int)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(selected))
r=f(t[0],t[1])
return r
def RPR_CSurf_OnSendPanChange(trackid,send_index,pan,relative):
"""
Python: Float RPR_CSurf_OnSendPanChange(MediaTrack trackid, Int send_index, Float pan, Boolean relative)
"""
a=_ft['CSurf_OnSendPanChange']
f=CFUNCTYPE(c_double,c_uint64,c_int,c_double,c_byte)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(send_index),c_double(pan),c_byte(relative))
r=f(t[0],t[1],t[2],t[3])
return r
def RPR_CSurf_OnSendVolumeChange(trackid,send_index,volume,relative):
"""
Python: Float RPR_CSurf_OnSendVolumeChange(MediaTrack trackid, Int send_index, Float volume, Boolean relative)
"""
a=_ft['CSurf_OnSendVolumeChange']
f=CFUNCTYPE(c_double,c_uint64,c_int,c_double,c_byte)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(send_index),c_double(volume),c_byte(relative))
r=f(t[0],t[1],t[2],t[3])
return r
def RPR_CSurf_OnSoloChange(trackid,solo):
"""
Python: Boolean RPR_CSurf_OnSoloChange(MediaTrack trackid, Int solo)
"""
a=_ft['CSurf_OnSoloChange']
f=CFUNCTYPE(c_byte,c_uint64,c_int)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(solo))
r=f(t[0],t[1])
return r
def RPR_CSurf_OnSoloChangeEx(trackid,solo,allowgang):
"""
Python: Boolean RPR_CSurf_OnSoloChangeEx(MediaTrack trackid, Int solo, Boolean allowgang)
"""
a=_ft['CSurf_OnSoloChangeEx']
f=CFUNCTYPE(c_byte,c_uint64,c_int,c_byte)(a)
t=(rpr_packp('MediaTrack*',trackid),c_int(solo),c_byte(allowgang))
r=f(t[0],t[1],t[2])
return r
def RPR_CSurf_OnStop():
"""
Python: RPR_CSurf_OnStop()
"""
a=_ft['CSurf_OnStop']
f=CFUNCTYPE(None)(a)
f()
def RPR_CSurf_OnTempoChange(bpm):
"""
Python: RPR_CSurf_OnTempoChange(Float bpm)
"""
a=_ft['CSurf_OnTempoChange']
f=CFUNCTYPE(None,c_double)(a)
t=(c_double(bpm),)
f(t[0])
def RPR_CSurf_OnTrackSelection(trackid):
"""
Python: RPR_CSurf_OnTrackSelection(MediaTrack trackid)
"""
a=_ft['CSurf_OnTrackSelection']
f=CFUNCTYPE(None,c_uint64)(a)
t=(rpr_packp('MediaTrack*',trackid),)
f(t[0])
def RPR_CSurf_OnVolumeChange(trackid,volume,relative):
"""
Python: Float RPR_CSurf_OnVolumeChange(MediaTrack trackid, Float volume, Boolean relative)
"""
a=_ft['CSurf_OnVolumeChange']
f=CFUNCTYPE(c_double,c_uint64,c_double,c_byte)(a)
t=(rpr_packp('MediaTrack*',trackid),c_double(volume),c_byte(relative))
r=f(t[0],t[1],t[2])
return r
def RPR_CSurf_OnVolumeChangeEx(trackid,volume,relative,allowGang):
"""
Python: Float RPR_CSurf_OnVolumeChangeEx(MediaTrack trackid, Float volume, Boolean relative, Boolean allowGang)
"""
a=_ft['CSurf_OnVolumeChangeEx']
f=CFUNCTYPE(c_double,c_uint64,c_double,c_byte,c_byte)(a)
t=(rpr_packp('MediaTrack*',trackid),c_double(volume),c_byte(relative),c_byte(allowGang))
r=f(t[0],t[1],t[2],t[3])
return r
def RPR_CSurf_OnWidthChange(trackid,width,relative):
"""
Python: Float RPR_CSurf_OnWidthChange(MediaTrack trackid, Float width, Boolean relative)
"""
a=_ft['CSurf_OnWidthChange']
f=CFUNCTYPE(c_double,c_uint64,c_double,c_byte)(a)
t=(rpr_packp('MediaTrack*',trackid),c_double(width),c_byte(relative))
r=f(t[0],t[1],t[2])
return r
def RPR_CSurf_OnWidthChangeEx(trackid,width,relative,allowGang):
"""
Python: Float RPR_CSurf_OnWidthChangeEx(MediaTrack trackid, Float width, Boolean relative, Boolean allowGang)
"""
a=_ft['CSurf_OnWidthChangeEx']
f=CFUNCTYPE(c_double,c_uint64,c_double,c_byte,c_byte)(a)
t=(rpr_packp('MediaTrack*',trackid),c_double(width),c_byte(relative),c_byte(allowGang))
r=f(t[0],t[1],t[2],t[3])
return r
def RPR_CSurf_OnZoom(xdir,ydir):
"""
Python: RPR_CSurf_OnZoom(Int xdir, Int ydir)
"""
a=_ft['CSurf_OnZoom']
f=CFUNCTYPE(None,c_int,c_int)(a)
t=(c_int(xdir),c_int(ydir))
f(t[0],t[1])
def RPR_CSurf_ResetAllCachedVolPanStates():
"""
Python: RPR_CSurf_ResetAllCachedVolPanStates()
"""
a=_ft['CSurf_ResetAllCachedVolPanStates']
f=CFUNCTYPE(None)(a)
f()
def RPR_CSurf_ScrubAmt(amt):
"""
Python: RPR_CSurf_ScrubAmt(Float amt)
"""
a=_ft['CSurf_ScrubAmt']
f=CFUNCTYPE(None,c_double)(a)
t=(c_double(amt),)
f(t[0])
def RPR_CSurf_SetAutoMode(mode,ignoresurf):
"""
Python: RPR_CSurf_SetAutoMode(Int mode, IReaperControlSurface ignoresurf)
"""
a=_ft['CSurf_SetAutoMode']
f=CFUNCTYPE(None,c_int,c_uint64)(a)
t=(c_int(mode),rpr_packp('IReaperControlSurface*',ignoresurf))
f(t[0],t[1])
def RPR_CSurf_SetPlayState(play,pause,rec,ignoresurf):
"""
Python: RPR_CSurf_SetPlayState(Boolean play, Boolean pause, Boolean rec, IReaperControlSurface ignoresurf)
"""
a=_ft['CSurf_SetPlayState']
f=CFUNCTYPE(None,c_byte,c_byte,c_byte,c_uint64)(a)
t=(c_byte(play),c_byte(pause),c_byte(rec),rpr_packp('IReaperControlSurface*',ignoresurf))
f(t[0],t[1],t[2],t[3])
def RPR_CSurf_SetRepeatState(rep,ignoresurf):
"""