-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LCB_CoreMIDI_0.6.1.3.lcb
executable file
·2071 lines (1851 loc) · 116 KB
/
LCB_CoreMIDI_0.6.1.3.lcb
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
/**
This library contains bindings for macOS & iOS CoreMIDI, useful sending musical performance data to other applications or communicating with external musical devices.
OS:
macOS, iOS (untested)
Edition: Community
Description:
This library is a (currently incomplete) wrapper for Apple's CoreMIDI API.
>*Note:* This library is MIT licensed (permissive).
> Please share and share a like.
*/
library org.openxtalk.coremidi.paulmcclernan
use com.livecode.engine
use com.livecode.foreign
use com.livecode.objc
use com.livecode.array
use com.livecode.list
use com.livecode.byte
use com.livecode.char
use com.livecode.binary
use com.livecode.logic
use com.livecode.assert
metadata version is "0.6"
metadata author is "Paul McClernan"
metadata title is "CoreMIDI library"
metadata svgicon is "M541.208,278.627c5.155-6.229,7.713-15.661,5.716-24.663c-7.97,0.751-16.543,7.303-21.699,13.533c-4.019,6.122-7.714,15.661-5.717,24.662C528.724,292.439,537.297,285.888,541.208,278.627z M591.706,363.468c-0.924,2.385-22.17-3.654-24.424-27.565c-1.824-19.356,13.151-31.106,14.29-31.213c-10.397-12.805-25.306-12.548-29.969-13.258c-12.633,0.042-23.267,9.085-28.961,9.622c-5.692,0.537-16.583-5.329-26.831-4.363c-13.663,1.288-24.3,10.331-30.058,22.361c-10.393,22.954-0.053,53.481,13.578,72.396h-42.334c0,0,14.162-11.127,20.231-19.22c-2.022-2.023-4.046-4.046-7.081-7.081c-4.046,4.046-8.092,6.07-11.127,8.093s-11.988,5.855-22.255,5.058s-20.645-9.355-25.289-21.243s-3.978-31.36-3.978-31.36l67.707-0.022c0,0-2.707-22.839-10.116-35.382c-2.572-4.354-16.947-20.4-38.744-19.069c-13.13,0.802-21.95,6.931-27.008,11.988c-5.058,4.046-10.116,11.127-14.162,19.22c-1.2,1.8-10.365,16.995-9.427,44.57c1.083,31.833,26.624,45.459,26.624,45.459h-39.452v-1.012c0-2.023,0-3.035-1.011-4.046c-1.012-1.012-3.035-1.012-7.081-2.023c-4.047,0-6.069-1.011-8.093-1.011c-1.012-1.012-3.035-2.023-4.046-3.035c-4.047-7.081-3.035-64.74-3.035-64.74s0-7.081,3.035-12.139c1.011-3.035,3.034-5.058,5.058-5.058h1.012c1.011,0,3.034,1.012,5.058,3.035c4.046,3.035,7.081,5.058,11.127,5.058c4.047,0,7.081-2.023,9.104-5.058c2.022-4.046,4.046-8.092,4.046-12.139c0-5.058-2.023-9.104-5.058-12.139c-3.035-3.035-7.081-5.058-11.127-5.058c-3.035,0-12.882,6.543-15.174,11.127s-7.081,14.162-7.081,14.162v-30.347h-8.093c-1.012,1.012-2.022,3.035-3.034,5.058c-2.023,4.046-6.07,8.092-11.127,12.139c-5.058,4.046-10.116,6.07-16.185,7.081v5.058c0,2.023,1.011,3.035,3.035,3.035c3.035,1.011,6.069,2.023,8.092,3.035c1.012,1.012,2.023,4.046,2.023,4.046s2.023,70.81,0,73.844c-1.012,2.023-8.093,5.058-12.139,6.07c-2.023,1.011-3.035,1.011-4.046,2.023c0,1.012,0,3.035,0,3.035h-28.324c1.012-1.012,2.023-1.012,3.035-1.012c8.093-6.069,15.173-15.173,20.231-27.312c3.035-8.093,5.058-18.208,5.058-31.359c0-7.081-1.011-14.162-4.046-22.254c-3.035-8.093-6.07-15.174-11.127-21.243c-9.104-12.139-22.254-18.208-39.451-18.208c-8.093,0-14.162,1.011-20.231,3.035c-5.058,2.023-11.127,5.058-16.185,10.116c-4.046,3.035-7.081,7.081-10.116,12.139s-5.058,11.127-7.081,17.197c-2.023,7.081-3.035,13.15-3.035,19.22c0,13.15,2.023,23.266,6.069,32.37s10.116,16.185,19.22,23.266c1.012,1.012,4.046,3.035,4.046,3.035h-52.602l11.127-7.081l7.081-41.474l-12.139,1.012c0,0-15.173,23.266-24.278,30.347c-8.092,7.081-17.196,10.116-25.289,10.116s-15.174-2.023-22.254-7.081c-5.058-3.035-10.116-7.081-13.15-13.15c-21.243-36.417-19.22-104.192,2.023-129.481c9.104-11.127,18.208-18.208,30.347-18.208c10.116,0,19.22,3.035,27.312,9.104c8.092,6.069,24.277,28.324,24.277,28.324h11.127l-9.104-44.509c0,0-16.185-4.046-24.278-5.058c-9.104-1.012-18.208-2.023-28.324-2.023c-24.278,0-44.509,9.104-60.694,28.324S13.15,274.106,13.15,302.43c0,12.139,1.012,23.266,4.046,32.37c3.035,10.116,6.069,18.208,12.139,27.312c5.058,8.093,12.139,15.174,21.243,22.255c4.046,3.035,8.092,5.058,13.15,7.081H5.058v199.28h54.625V438.992h27.312v151.735h54.625V438.992h27.312v151.735h53.613v-180.06c0-5.058-2.023-9.104-5.058-12.139c2.023,0,3.035,0,5.058,0c7.081,0,14.162-2.023,20.231-4.047v196.245h54.625V394.482h21.243v45.521h126.446v103.181H373.27v-75.868h-54.625v124.424h160.84c10.115,0,19.22-8.093,19.22,19.221V411.68c0-0.222-0.024-0.441-0.032-0.663c3.684,2.274,7.56,3.47,11.61,2.63c4.063-0.384,6.949-1.743,9.665-3.309v180.39h54.625V400.033c3.299-3.847,6.128-8.77,8.926-13.965C590.396,373.93,591.706,363.468,591.706,363.468z M394.513,289.279c4.046-6.069,9.104-9.104,14.162-9.104c4.046,0,7.081,1.012,11.127,4.046s6.069,7.081,8.093,12.139c2.022,5.058,3.034,10.116,3.034,16.185c-1.012,0-3.034,0-3.034,0c-1.012,0-3.035,0-5.059,0c-3.034,0-6.069,0-7.08,0h-27.312C387.432,302.43,390.466,294.337,394.513,289.279z M221,385.5c-12,0-25.307-25.195-25.54-51.053s15.464-52.987,28.002-52.217s23.243,30.316,23.361,47.512C247,355.5,233,385.5,221,385.5z"
------------------------------------------------------------------------- Core Foundation / Objective C utility bindings --------------------
private foreign handler objC_NSApplicationSharedApplication() returns ObjcId binds to "objc:NSApplication.+sharedApplication"
private foreign handler objC_NSURLfileURLWithPath(in pPathString as ObjcId) returns ObjcId binds to "objc:NSURL.+fileURLWithPath:"
private foreign handler objC_NSURLURLWithString(in pURLString as ObjcId) returns ObjcId binds to "objc:NSURL.+URLWithString:"
private foreign handler objC_NSURLfileOrDirURLWithPath(in pPathString as ObjcId, in pIsDir as CBool) returns ObjcId binds to "objc:.NSURL.+fileURLWithPath:isDirectory:"
private foreign handler objC_NSFileHandleFileHandleForWritingAtWithPath(in pPathString as ObjcId) returns optional ObjcId binds to "objc:.NSFileHandle:+fileHandleForWritingAtPath:"
private foreign handler objC_NSErrorAlloc() returns ObjcId binds to "objc:NSError.+alloc"
private foreign handler objC_NSMutableArrayAlloc() returns ObjcRetainedId binds to "objc:NSMutableArray.+alloc"
private foreign handler objC_NSMutableArrayInitWithCapacity(in pNSMutableArray as ObjcId, in pCapacity as NaturalFloat) returns ObjcId binds to "objc:NSMutableArray.-initWithCapacity:"
private foreign handler objC_NSMutableArrayInitWithNSArray(in pNSMutableArray as ObjcId, in pNSArray as ObjcId) returns ObjcId binds to "objc:NSMutableArray.-initWithArray:"
private foreign handler objC_NSObjectRetain(in pNSObj as ObjcId) returns ObjcId binds to "objc:NSObject.-retain"
private foreign handler objC_NSObjectAutoRealease(in pNSObj as ObjcId) returns ObjcId binds to "objc:NSObject.-autorelease"
private foreign handler objC_NSObjectRelease(in pNSObj as ObjcId) returns nothing binds to "objc:NSObject.-release"
private foreign handler c_CFErrorCopyDescription(in pCFErrorRef as ObjcId) returns ObjcId binds to "c:CFErrorCopyDescription"
----------------------------------------------------------------- Data Buffer ------------------------------------------------------------
private foreign handler objC_NSMutableDataWithLength(in pDataLength as ObjcId) returns ObjcId binds to "objc:NSMutableData.+dataWithLength:" -- Creates and returns an mutable data object containing a given number of zeroed bytes. Toll free bridges to CFMutableDataRef for Foundation C APIs
private foreign handler objC_NSMutableDataWithCapacity(in pDataLength as ObjcId) returns ObjcId binds to "objc:NSMutableData.+dataWithCapacity:"
private foreign handler objC_NSMutableDataBytesPtr(in pMutableDataRef as ObjcId) returns Pointer binds to "objc:NSMutableData.mutableBytes"
private foreign handler objC_NSMutableDataWithBytes(in pRawDataPointer as Pointer, in pDataLength as ObjcId) returns ObjcId binds to "objc:NSMutableData.+dataWithBytes:length:"
private foreign handler objC_NSDataGetLength(in pMutableDataRef as ObjcId) returns ObjCId binds to "objc:NSData.length"
private foreign handler objC_NSMutableDataSetData(in pMutableDataRef as ObjcId, in pNSDataToSet as ObjcId) returns nothing binds to "objc:NSMutableData.-setData:"
private foreign handler objC_NSDataBytesPtr(inout pMutableDataRef as ObjcId) returns Pointer binds to "objc:NSData.bytes"
private foreign handler c_CFArrayGetCount(in pCFArrayRef as Pointer) returns LCUInt binds to "c:CFArrayGetCount"
private foreign handler objC_NSArrayCount(in pNSArray as ObjcId) returns LCUInt binds to "objc:NSArray.count"
private foreign handler objC_NSDataWithBytes(in pDataRef as ObjcId, in pReadLengthNSNum as ObjcId ) returns ObjcId binds to "objc:NSData.+dataWithBytes:length:"
private foreign handler objC_NSMutableDataWithBytesNoCopy(in pDataRef as ObjcId, in pReadLengthNSNum as ObjcId ) returns ObjcId binds to "objc:NSMutableData.+dataWithBytesNoCopy:length:"
private foreign handler objC_NSMutableDataWithBytesNoCopyFreeWhenDone(in pDataRef as ObjcId, in pReadLengthNSNum as ObjcId, in pFreeWhenDone as CBool) returns ObjcId binds to "objc:NSMutableData.+dataWithBytesNoCopy:length:freeWhenDone:"
-------------------------------------------------------- Types & Structs ------------------------------------
-- public foreign type MIDIPacket binds to "MCAggregateTypeInfo:kihhh" --kihhhhhhhh... k=UInt64 i=UInt16 h=3 x UInt8 -- MIDIPacket (timeStamp: MIDITimeStamp, length: UInt16, data: Data: ARRAY OF Bytes(256) x UInt8 ) -- UInt64,UInt16,Data(256))
public foreign type MIDIPacket binds to "MCAggregateTypeInfo:kihhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"
-- public foreign type MIDIPacket binds to "MCAggregateTypeInfo:jjihhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"
public foreign type MIDIMsg binds to "MCAggregateTypeInfo:hhh" -- h=3 x UInt8
public foreign type MIDIPacketList binds to "MCAggregateTypeInfo:jr" -- Declaration (numPackets: UInt32, *packet(MIDIPacket)) -- j = UInt32
public foreign type TimeBaseInfo binds to "MCAggregateTypeInfo:jj"
public type MIDITimeStamp is UInt64
public type MIDIObjRef is UInt32
public foreign type FourCharCode binds to "MCAggregateTypeInfo:bbbb" -- message ID, message size
-- foreign handler Uint32To4CharCode(out rMemChunk as FourCharCode, in pPointer as Pointer, in pSize as UIntSize) returns nothing binds to "c:memcpy"
------------------------------------------------ MIDI Clients------------------------------------------------
private foreign handler c_MIDIClientCreate(in pClientNameCFStrngRef as ObjcId, in pMIDINotifyProc as optional ObjcBlockPointer, in pNotifyRefCon as optional Pointer, \
out rMIDIClientRef as MIDIObjRef) returns CSInt binds to "c:CoreMIDI.framework>MIDIClientCreate"
private foreign handler c_MIDIClientCreateWithBlock(in pClientNameCFStrngRef as ObjcId, out rMIDIClientRef as MIDIObjRef, in pMIDINotifyProc as optional ObjcBlockPointer) \
returns CSInt binds to "c:CoreMIDI.framework>MIDIClientCreateWithBlock"
private foreign handler c_MIDIClientDispose(in pMIDIClientRef as ObjcId) returns CSInt binds to "c:CoreMIDI.framework>MIDIClientDispose"
------------------------------------------------ MIDI Ports ------------------------------------------------------------
private foreign handler c_MIDIInputPortCreate(in pMIDIClientRef as MIDIObjRef, in pInputPortNameCFStrngRef as ObjCId, out rMIDIInputPortRef as MIDIObjRef) returns CSInt binds to "c:CoreMIDI.framework>MIDIInputPortCreate"
private foreign handler c_MIDIOutputPortCreate(in pMIDIClientRef as MIDIObjRef, in pOutPortNameCFStrngRef as ObjCId, out rMIDIOutPortRef as MIDIObjRef) returns CSInt binds to "c:CoreMIDI.framework>MIDIOutputPortCreate"
private foreign handler c_MIDIPortDispose( in pMIDIPortRef as MIDIObjRef) returns CSInt binds to "c:CoreMIDI.framework>MIDIPortDispose"
private foreign handler c_MIDIPortConnectSource(in pMIDIPortToConnectRef as MIDIObjRef, in MIDISourceEndpointToConnectRef as ObjcId, in connRefCon as optional any) returns CSInt binds to "c:CoreMIDI.framework>MIDIPortConnectSource"
private foreign handler c_MIDIPortDisonnectSource( in pMIDIPortRef as MIDIObjRef,in pMIDIEndpointRef as ObjCId) returns CSInt binds to "c:CoreMIDI.framework>MIDIPortDisonnectSource"
------------------------------------------------ MIDI Sources ------------------------------------------------------------
private foreign handler c_MIDISourceCreate(in pMIDIClientRef as MIDIObjRef, in pSourceNameStrRef as ObjCId, out rMIDISourceEndPointRef as MIDIObjRef) \
returns CSInt binds to "c:CoreMIDI.framework>MIDISourceCreate"
private foreign handler c_MIDIGetNumberOfSources() returns CInt binds to "c:CoreMIDI.framework>MIDIGetNumberOfSources"
private foreign handler c_MIDIGetSource( in pSourceIndexNum as optional UInt32) returns optional MIDIObjRef binds to "c:CoreMIDI.framework>MIDIGetSource" -- Returns a reference to a source, or NULL if an error occurred.
------------------------------------------------ MIDI Destinations ------------------------------------------------------------
-- OSStatus MIDIDestinationCreateWithBlock(MIDIClientRef client, CFStringRef name, MIDIEndpointRef *outDest, MIDIReadBlock readBlock);
private foreign handler c_MIDIDestinationCreateWithBlock(in pMIDIClientRef as MIDIObjRef, in pMIDIDestinationNameStrRef as ObjcId, \
out rMIDIDestEndpointRef as MIDIObjRef, in pMIDIReadProc as ObjcBlockPointer) returns CSInt binds to "c:CoreMIDI.framework>MIDIDestinationCreateWithBlock"
-- OSStatus MIDIDestinationCreate(MIDIClientRef client, CFStringRef name, MIDIReadProc readProc, void *refCon, MIDIEndpointRef *outDest); Creates a virtual destination in a client.
--private foreign handler c_MIDIDestinationCreate(in pMIDIClientRef as MIDIObjRef, in pMIDIDestinationNameStrRef as ObjcId, in pMIDIReadProc as Pointer, in pRefConst as optional ObjcId, \
-- out rMIDIDestEndpointRef as MIDIObjRef) returns CSInt binds to "c:CoreMIDI.framework>MIDIDestinationCreate"
private foreign handler c_MIDIGetNumberOfDestinations() returns CInt binds to "c:CoreMIDI.framework>MIDIGetNumberOfDestinations"
private foreign handler c_MIDIGetDestination(in pSourceIndexNum as optional UInt32) returns MIDIObjRef binds to "c:CoreMIDI.framework>MIDIGetDestination"
------------------------------------------------ MIDI Endpoints------------------------------------------------------------
-- OSStatus MIDIEndpointDispose(MIDIEndpointRef endpt); -- Disposes a virtual source or destination your client created.
-- endpt = The endpoint to be disposed, returns a result code.
private foreign handler c_MIDIEndpointDispose(in pMIDIEndpointRef as MIDIObjRef) returns CSInt binds to "c:CoreMIDI.framework>MIDIEndpointDispose"
-- OSStatus MIDIEndpointGetEntity(MIDIEndpointRef inEndpoint, MIDIEntityRef *outEntity);
-- inEndpoint = The endpoint being queried. outEntity = On exit, the endpoint's owning entity, or NULL if none.
private foreign handler c_MIDIEndpointGetEntity(in pMIDIEndpointRef as MIDIObjRef, out pEntityRef as optional MIDIObjRef) returns CSInt binds to "c:CoreMIDI.framework>MIDIEndpointGetEntity"
-- OSStatus MIDIEntityGetDevice(MIDIEntityRef inEntity, MIDIDeviceRef *outDevice);
-- inEntity = The entity being queried. outDevice = On successful return, the entity's owning device.
------------------------------------------------ MIDI Entities ------------------------------------------------------------
private foreign handler c_MIDIEntityGetDevice(in pMIDIEntitytRef as MIDIObjRef, out rDeviceRef as optional MIDIObjRef) returns CSInt binds to "c:CoreMIDI.framework>MIDIEntityGetDevice"
-- ItemCount MIDIEntityGetNumberOfSources(MIDIEntityRef entity);
private foreign handler c_MIDIEntityGetNumberOfSources(in pMIDIEntityRef as MIDIObjRef) returns CInt binds to "c:CoreMIDI.framework>MIDIEntityGetNumberOfSources"
-- MIDIEndpointRef MIDIEntityGetSource(MIDIEntityRef entity, ItemCount sourceIndex0);
-- entity = entity being queried, sourceIndex0 = index (0...MIDIEntityGetNumberOfSources(entity)-1) of the source to return. Return Value is reference to a source, or NULL if an error occurred.
private foreign handler c_MIDIEntityGetSource(in pMIDIEntitytRef as MIDIObjRef, in pSourceIndex as Cint) returns MIDIObjRef binds to "c:CoreMIDI.framework>MIDIEntityGetSource"
-- ItemCount MIDIEntityGetNumberOfDestinations(MIDIEntityRef entity);
private foreign handler c_MIDIEntityGetNumberOfDestinations(in pMIDIEntityRef as MIDIObjRef) returns CInt binds to "c:CoreMIDI.framework>MIDIEntityGetNumberOfDestinations"
-- MIDIEndpointRef MIDIEntityGetDestination(MIDIEntityRef entity, ItemCount destIndex0);
-- entity = entity being queried, sourceIndex0 = index (0...MIDIEntityGetNumberOfDestinations(entity)-1) of the source to return. Return Value is reference to a source, or NULL if an error occurred.
private foreign handler c_MIDIEntityGetDestination(in pMIDIEntitytRef as MIDIObjRef, in pDestIndex as Cint) returns MIDIObjRef binds to "c:CoreMIDI.framework>MIDIEntityGetDestination"
----------------------------------------------------------------- MIDI Devices ------------------------------------------------------------
private foreign handler c_MIDIGetNumberOfDevices() returns CInt binds to "c:CoreMIDI.framework>MIDIGetNumberOfDevices"
private foreign handler c_MIDIGetNumberOfExternalDevices() returns CInt binds to "c:CoreMIDI.framework>MIDIGetNumberOfExternalDevices"
private foreign handler c_MIDIGetExternalDevice(in pSourceIndexNum as optional UInt32) returns MIDIObjRef binds to "c:CoreMIDI.framework>MIDIGetExternalDevice"
private foreign handler c_MIDIGetDevice(in pSourceIndexNum as optional UInt32) returns MIDIObjRef binds to "c:CoreMIDI.framework>MIDIGetDevice"
private foreign handler c_MIDIDeviceGetNumberOfEntities(in pMIDIDeviceRef as MIDIObjRef) returns CInt binds to "c:CoreMIDI.framework>MIDIDeviceGetNumberOfEntities"
private foreign handler c_MIDIDeviceGetEntity(in pDeviceRef as MIDIObjRef, in pSourceIndexNum as UInt32) returns MIDIObjRef binds to "c:CoreMIDI.framework>MIDIDeviceGetEntity"
----------------------------------------------------------------- MIDI IO --------------------------------------------------------------------------
private foreign handler c_MIDIReceived(in pMIDIEndpointRef as MIDIObjRef, in pMIDIPacketListPtr as Pointer) returns CSInt binds to "c:CoreMIDI.framework>MIDIReceived" -- OSStatus MIDIReceived(MIDIEndpointRef src, const MIDIPacketList *pktlist);ai -- Use for SENDING Notes To Virstual Source (not MIDISend)
private foreign handler c_MIDISend(in pMIDIPortRef as MIDIObjRef, in pMIDIEndpointRef as ObjCId, in pMIDIPacketList as Pointer) returns CSInt binds to "c:CoreMIDI.framework>MIDISend"
private foreign handler c_MIDIPacketListInit(in pMIDIPacketListByteBuffer as Pointer) returns Pointer binds to "c:CoreMIDI.framework>MIDIPacketListInit"
private foreign handler c_MIDIPacketNext(in pMIDIPacketListByteBuffer as Pointer) returns Pointer binds to "c:CoreMIDI.framework>MIDIPacketNext"
private foreign handler c_MIDIPacketListAdd(in pMIDIPacketListByteBuffer as Pointer, in pPacketsCnt as UInt32, in pMIDIPacket as Pointer, in pMIDITimeStamp as UInt64, pPcktByteCnt as UInt16, in pPacket as Pointer) returns Pointer binds to "c:CoreMIDI.framework>MIDIPacketListAdd"
private foreign handler c_MIDIRestart() returns CSInt binds to "c:CoreMIDI.framework>MIDIRestart" -- OSStatus MIDIRestart(void); This is useful for forcing CoreMIDI to ask its drivers to rescan for hardware.
private foreign handler c_MIDIFlushOutput(in MIDIEndpointRef as optional MIDIObjRef) returns CSInt binds to "c:CoreMIDI.framework>MIDIFlushOutput" -- OSStatus MIDIFlushOutput(MIDIEndpointRef dest); -- Parameters dest, All pending events scheduled to be sent to this destination are unscheduled. If NULL, the operation applies to all destinations.
----------------------------------------------------------------- MIDI Object Properties ------------------------------------------------------------
-- OSStatus = MIDIObjectFindByUniqueID(MIDIUniqueID inUniqueID, MIDIObjectRef *outObject, MIDIObjectType *outObjectType);
-- inUniqueID of object to search for (This should be the result of an earlier call to MIDIObjectGetIntegerProperty "UniqueID")
-- outObject returned object, or NULL if the object was not found or an error occurred. This should be cast to the appropriate type (MIDIDeviceRef, MIDIEntityRef, MIDIEndpointRef), according to *outObjectType.
-- outObjectType on exit, the type of object which was found; undefined if none found.
-- Return Value is sn OSStatus error code, including kMIDIObjectNotFound if there is no object with the specified uniqueID.
private foreign handler c_MIDIObjectFindByUniqueID(in pMIDIObjectUID as SInt32, out rMIDIObjectRef as optional MIDIObjRef, out rMIDIObjectType as optional SInt32) returns CSInt binds to "c:CoreMIDI.framework>MIDIObjectFindByUniqueID"
-- OSStatus MIDIObjectGetIntegerProperty(MIDIObjectRef obj, CFStringRef propertyID, SInt32 *outValue);
private foreign handler c_MIDIObjectGetIntegerProperty(in pMIDIObjectRef as optional MIDIObjRef, in rPropertyIDCFStrRef as ObjCId, out rPropertyVal as optional SInt32) returns CSInt binds to "c:CoreMIDI.framework>MIDIObjectGetIntegerProperty"
--OSStatus MIDIObjectSetIntegerProperty(MIDIObjectRef obj, CFStringRef propertyID, SInt32 newvalue);
private foreign handler c_MIDIObjectSetIntegerProperty(in pMIDIObjectRef as MIDIObjRef, in rPropertyIDCFStrRef as ObjCId, in rPropertyVal as optional SInt32) returns CSInt binds to "c:CoreMIDI.framework>MIDIObjectSetIntegerProperty"
-- OSStatus MIDIObjectGetStringProperty(MIDIObjectRef obj, CFStringRef propertyID, CFStringRef _Nullable *str);
-- obj = object whose property is to be returned, propertyID = Name of the property to return, str = on success the value of the property, Returns result code.
private foreign handler c_MIDIObjectGetStringProperty(in pMIDIObjectRef as MIDIObjRef, in rPropertyIDCFStrRef as ObjCId, out rPropertyValCFStrRef as optional ObjCId) returns CSInt binds to "c:CoreMIDI.framework>MIDIObjectGetStringProperty"
-- MIDIObjectGetProperties -- Gets all of an object's properties.
-- OSStatus MIDIObjectGetProperties(MIDIObjectRef obj, CFPropertyListRef _Nullable *outProperties, Boolean deep);
private foreign handler c_MIDIObjectGetProperties(in pMIDIObjectRef as MIDIObjRef, out rCFPropertyListRef as ObjCId, in pDeep as Boolean) returns CSInt binds to "c:CoreMIDI.framework>MIDIObjectGetProperties"
--CFDataRef CFPropertyListCreateData(CFAllocatorRef allocator, CFPropertyListRef propertyList, CFPropertyListFormat format, CFOptionFlags options, CFErrorRef *error); -- CFOptionFlags parameter is currently unused and should be set to 0.
private foreign handler c_CFPropertyListCreateData(in pCFAllocatorRef as optional ObjCId, in pCFPropertyListRef as ObjCId, in pFormat as CInt, in pOptionFlags as CUInt, out rCFErrorRef as optional any) returns ObjCId binds to "c:CFPropertyListCreateData"
-- pFormat kCFPropertyListXMLFormat_v1_0 = 100 or kCFPropertyListBinaryFormat_v1_0 = 200 or kCFPropertyListOpenStepFormat = 1 (discouraged)
----------------------------------------------------------------- AudioToolbox MusicPlayer MusicSequence stuff ------------------------------------------------------------
private foreign handler c_ATNewMusicSequence(out rMusicSequence as ObjCId ) returns CSInt binds to "c:AudioToolbox.framework>NewMusicSequence"
private foreign handler c_ATMusicSequenceNewTrack(in pMusicSequence as ObjCId, out rMusicSequenceTrack as optional Pointer ) returns CSInt binds to "c:AudioToolbox.framework>MusicSequenceNewTrack"
private foreign handler c_ATMusicSequenceFileLoad(in pMusicSequence as ObjCId, in pFileURL as ObjCId, in pFileTypeFlag as UInt32, in pFileParsingFlag as UInt32) returns CSInt binds to "c:AudioToolbox.framework>MusicSequenceFileLoad"
private foreign handler c_ATMusicTrackNewMIDINoteEvent(in pMusicSequenceTrack as Pointer, in pMusicTrackBeat as ObjCId, in pMIDIMsg as ObjCId) returns CSInt binds to "c:AudioToolbox.framework>MusicTrackNewMIDINoteEvent"
private foreign handler c_ATNewMusicSequenceGetInfoDict(in pMusicSequence as ObjCId ) returns ObjCId binds to "c:AudioToolbox.framework>MusicSequenceGetInfoDictionary"
-- The track count provided by following function excludes the tempo track:
private foreign handler c_ATMusicSequenceGetSequenceType(in pMusicSequence as ObjCId, out rMusicSequenceType as FourCharCode ) returns CSInt binds to "c:AudioToolbox.framework>MusicSequenceGetSequenceType"
private foreign handler c_ATMusicSequenceGetTrackCount(in pMusicSequence as ObjCId, out rTrackCount as Uint32) returns CSInt binds to "c:AudioToolbox.framework>MusicSequenceGetTrackCount"
private foreign handler c_ATMusicSequenceGetTempoTrack(in pMusicSequence as ObjCId, out rMusicSequenceTempoTrack as optional Pointer) returns CSInt binds to "c:AudioToolbox.framework>MusicSequenceGetTempoTrack"
private foreign handler c_ATMusicSequenceGetIndexTrack(in pMusicSequence as ObjCId, in pIndex as UInt32, out rMusicSequenceTrack as optional Pointer) returns CSInt binds to "c:AudioToolbox.framework>MusicSequenceGetIndTrack"
private foreign handler c_ATMusicSequenceGetTrackIndex(in pMusicSequence as ObjCId, in pMusicSequenceTrack as Pointer, out rIndex as Uint32) returns CSInt binds to "c:AudioToolbox.framework>MusicSequenceGetTrackIndex"
private foreign handler c_ATMusicSequenceDisposeTrack(in pMusicSequence as ObjCId, in pMusicSequenceTrack as Pointer) returns CSInt binds to "c:AudioToolbox.framework>MusicSequenceDisposeTrack"
--OSStatus MusicTrackSetProperty(MusicTrack inTrack, UInt32 inPropertyID, void *inData, UInt32 inLength);
private foreign handler c_ATMusicTrackSetProperty(in pMusicSequenceTrack as Pointer, in pPropertyIDenum as Uint32, in rData as optional Pointer, in rDataLength as optional Uint32) returns CSInt binds to "c:AudioToolbox.framework>MusicTrackSetProperty"
private foreign handler c_ATMusicTrackGetProperty(in pMusicSequenceTrack as Pointer, in pPropertyIDenum as Uint32, out rData as optional Pointer, out rDataLength as optional Uint32) returns CSInt binds to "c:AudioToolbox.framework>MusicTrackGetProperty"
private foreign handler c_ATMusicTempoTrackGetTimeRes(in pMusicSequenceTempoTrack as Pointer, in pPropertyIDenum as Uint32, out rData as SInt16, out rDataLength as optional Uint32) returns CSInt binds to "c:AudioToolbox.framework>MusicTrackGetProperty"
private foreign handler c_ATMusicTrackGetMuteStatus(in pMusicSequenceTrack as Pointer, in pPropertyIDenum as Uint32, out rData as CBool, out rDataLength as Uint32) returns CSInt binds to "c:AudioToolbox.framework>MusicTrackGetProperty"
private foreign handler c_ATMusicTrackGetSoloStatus(in pMusicSequenceTrack as Pointer, in pPropertyIDenum as Uint32, out rData as CBool, out rDataLength as Uint32) returns CSInt binds to "c:AudioToolbox.framework>MusicTrackGetProperty"
private foreign handler c_ATMusicTrackSetMuteStatus(in pMusicSequenceTrack as Pointer, in pPropertyIDenum as Uint32, in pMuteStatus as Boolean, in rDataLength as Uint32) returns CSInt binds to "c:AudioToolbox.framework>MusicTrackSetProperty"
private foreign handler c_ATMusicTrackSetSoloStatus(in pMusicSequenceTrack as Pointer, in pPropertyIDenum as Uint32, in pSoloStatus as Boolean, in rDataLength as Uint32) returns CSInt binds to "c:AudioToolbox.framework>MusicTrackSetProperty"
private foreign handler c_ATMusicTrackGetLength(in pMusicSequenceTrack as Pointer, in pPropertyIDenum as Uint32, out rData as Float64, out rDataLength as Uint32) returns CSInt binds to "c:AudioToolbox.framework>MusicTrackGetProperty"
private foreign handler c_ATCAShow(in pMusicObj as Pointer) returns nothing binds to "c:AudioToolbox.framework>CAShow"
private foreign handler c_ATCAShowFile(in pMusicObj as Pointer, in pCFFileRef as ObjcId) returns nothing binds to "c:AudioToolbox.framework>CAShowFile"
-- void CAShowFile(void *inObject, FILE *inFile);
----------------------------------------------------------------- Time Stamping ------------------------------------------------------------
-- https://developer.apple.com/documentation/kernel/1462446-mach_absolute_time?language=objc
-- private foreign handler c_mach_absolute_time() returns MIDITimeStamp binds to "c:Kernel.framework>mach_absolute_time"
private foreign handler c_mach_absolute_time() returns UInt64 binds to "c:mach_absolute_time"
private foreign handler c_mach_timebase_info(inout pTimeBaseInfo as TimeBaseInfo) returns nothing binds to "c:mach_timebase_info"
----------------------------------------------------------------- LiveCode RunLoop Control? ------------------------------------------------------------
public type MCRunloopActionCallback is Pointer
public type MCRunloopActionRef is Pointer
__safe foreign handler MCEngineAddRunloopAction(in pCallback as MCRunloopActionCallback, in pContext as optional Pointer, out rAction as MCRunloopActionRef) returns CBool binds to "<builtin>"
__safe foreign handler MCEngineRemoveRunloopAction(in pAction as MCRunloopActionRef) returns nothing binds to "<builtin>"
__safe foreign handler MCEngineRunloopWait() returns CBool binds to "<builtin>"
__safe foreign handler MCEngineRunloopBreakWait() returns nothing binds to "<builtin>"
----------------------------------------------------------------- Constants ------------------------------------------------------------
----------------------------------------------------------------- MIDIObjectTypes Constants ------------------------------------------------------------
constant kMIDIObjectType_ExternalDestination is 0x10 --- 0x10 is just a temporary bitfield place holder
constant kMIDIObjectType_ExternalSource is 0x10 --- 0x10 is just a temporary bitfield place holder
constant kMIDIObjectType_ExternalEntity is 0x10 --- 0x10 is just a temporary bitfield place holder
constant kMIDIObjectType_ExternalDevice is 0x10 --- 0x10 is just a temporary bitfield place holder
constant kMIDIObjectType_Destination is 3
constant kMIDIObjectType_Source is 2
constant kMIDIObjectType_Entity is 1
constant kMIDIObjectType_Device is 0
constant kMIDIObjectType_Other is -1
private variable sMusicSequence as optional ObjcId
private variable sMusicSequenceTrack as optional Pointer
private variable sMusicSequenceTempoTrack as optional Pointer
public handler AudioToolboxCreateSequenceFromSMF(in pMIDIfilePath as String) returns optional any
variable tCFError as optional ObjCId
variable tOSStatus as optional CSInt
variable tOBJ as optional ObjCId
variable tMIDIfilePathNSURL as optional ObjCId
variable tSeqInfoDictArray as optional Array
variable rMusicSequenceTypeUint32 as optional UInt32
variable rMusicSequenceTypeCode as FourCharCode
variable rTrackCountUint32 as optional UInt32
variable rMusicSequenceTempoTrack as optional Pointer
variable tElement as optional any
variable tStr as String
variable tNum as Number
variable tTimeRes as Sint16
variable rTrackPropertyData as Pointer
variable tTrackPropertyEnum as optional UInt32
unsafe
put objC_NSURLfileURLWithPath(StringToNSString(pMIDIfilePath)) into tMIDIfilePathNSURL
put c_ATNewMusicSequence(sMusicSequence) into tOSStatus
-- put c_ATMusicSequenceNewTrack(sMusicSequence,rMusicSequenceTrack) into tOSStatus
put c_ATMusicSequenceFileLoad(sMusicSequence, tMIDIfilePathNSURL, 1835623529 , 0) into tOSStatus
-- kMusicSequenceFile (type Uint32) _AnyType = 0 _iMelodyType = 1768777068 _midiType = 1835623529-- kMusicSequenceLoadSMF_PreserveTracks = 0 (type UInt32)
put c_ATNewMusicSequenceGetInfoDict(sMusicSequence) into tOBJ
put ArrayFromNSDictionary(tOBJ) into tSeqInfoDictArray
log tSeqInfoDictArray
put c_ATMusicSequenceGetSequenceType(sMusicSequence, rMusicSequenceTypeCode ) into tOSStatus
repeat for each element tElement in rMusicSequenceTypeCode
put the char with code tElement before tStr
end repeat
log tStr -- this string should be one of the following: "beat","secs","samp"
put c_ATMusicSequenceGetTempoTrack(sMusicSequence,sMusicSequenceTempoTrack) into tOSStatus
log "Tempo Track:"
log sMusicSequenceTempoTrack
put c_ATMusicTempoTrackGetTimeRes(sMusicSequenceTempoTrack,6,tTimeRes,tNum) into tOSStatus -- kSequenceTrackProperty_TimeResolution = 6 -- A read-only SInt16 value that is valid only for a tempo track
log "Tempo Track Time Resolution:"
log tTimeRes
put c_ATMusicSequenceGetTrackCount(sMusicSequence, rTrackCountUint32) into tOSStatus
log "TrackCount:"
log rTrackCountUint32
put c_ATMusicSequenceGetIndexTrack(sMusicSequence, 0, sMusicSequenceTrack) into tOSStatus
if tOSStatus is 0 then
log sMusicSequenceTrack
end if
end unsafe
end handler
public handler AudioToolboxSequenceGetInfoDict() returns optional any
variable tCFError as optional ObjCId
variable tOSStatus as optional CSInt
variable tOBJ as optional ObjCId
variable tSeqInfoDictArray as optional Array
unsafe
put c_ATNewMusicSequenceGetInfoDict(sMusicSequence) into tOBJ
put ArrayFromNSDictionary(tOBJ) into tSeqInfoDictArray
log tSeqInfoDictArray
-- put objC_NSURLfileURLWithPath(StringToNSString(pMIDIfilePath)) into tMIDIfilePathNSURL
--put objC_NSFileHandleFileHandleForWritingAtWithPath(StringToNSString("~/Desktop/CAShowFileOutput.txt")) into tOBJ
-- private foreign handler objC_NSURLfileURLWithPath(in pPathString as ObjcId) returns ObjcId binds to "objc:NSURL.+fileURLWithPath:"
--put objC_NSURLfileURLWithPath(StringToNSString("/macOS_Sierra/Users/paul/Desktop/CAShowFileOutput.txt")) into tOBJ
--c_ATCAShowFile(sMusicSequenceTrack,tOBJ)
-- c_ATCAShow(sMusicSequenceTrack)
-- c_ATCAShow(sMusicSequence)
end unsafe
end handler
public handler AudioToolboxCreateNewSequence() returns optional any
variable tCFError as optional ObjCId
variable tOSStatus as optional CSInt
variable tOBJ as optional ObjCId
variable tSeqInfoDictArray as optional Array
variable rMusicSequenceTypeUint32 as optional UInt32
variable rMusicSequenceTypeCode as FourCharCode
variable rTrackCountUint32 as optional UInt32
variable rTrack as optional Pointer
variable tElement as optional any
variable tStr as String
variable tNum as UInt32
variable tData as Data
variable rTrackMute as Boolean
variable rTrackRes as SInt16
variable rDataLength as optional UInt32
variable rTrackPropertyData as Pointer
variable tTrackPropertyEnum as optional UInt32
unsafe
put c_ATNewMusicSequence(sMusicSequence) into tOSStatus
put c_ATMusicSequenceNewTrack(sMusicSequence, rTrack) into tOSStatus
put c_ATNewMusicSequenceGetInfoDict(sMusicSequence) into tOBJ
put ArrayFromNSDictionary(tOBJ) into tSeqInfoDictArray
log tSeqInfoDictArray
put c_ATMusicSequenceGetSequenceType(sMusicSequence, rMusicSequenceTypeCode ) into tOSStatus
-- Uint32To4CharCode(rMusicSequenceTypeCode,rMusicSequenceTypeUint32,4)
repeat for each element tElement in rMusicSequenceTypeCode
put the char with code tElement before tStr
end repeat
log tStr -- this string should be one of the following: "beat","secs","samp"
put c_ATMusicSequenceGetTrackCount(sMusicSequence, rTrackCountUint32) into tOSStatus
log "TrackCount:"
log rTrackCountUint32
put c_ATMusicSequenceGetTempoTrack(sMusicSequence,sMusicSequenceTempoTrack) into tOSStatus
log sMusicSequenceTempoTrack
put c_ATMusicTempoTrackGetTimeRes(sMusicSequenceTempoTrack, 6, rTrackRes, rDataLength) into tOSStatus -- kSequenceTrackProperty_TimeResolution = 6
log "Track Time Res:"
log rTrackRes
-- put c_ATMusicTrackGetProperty(rMusicSequenceTempoTrack,tTrackPropertyEnum,nothing,tNum) into tOSStatus
end unsafe
end handler
public type MusicTimeStamp is Float64
-- foreign handler PointerToTimeStamp(out rMusicTimeStamp as MusicTimeStamp, in pPointer as Pointer, in pSize as UIntSize) returns nothing binds to "c:memcpy"
public handler AudioToolboxSequenceGetTrackLength() returns Number
variable tMusicTimeStamp as MusicTimeStamp
-- variable tMIDITimeStamp as optional MusicTimeStamp
variable tOSStatus as optional CSInt
variable rLengthUint32 as optional UInt32
-- variable tTrackPropertyEnum as optional UInt32
unsafe
put 0 into rLengthUint32
put 0 into tMusicTimeStamp
put c_ATMusicTrackGetLength(sMusicSequenceTrack,5,tMusicTimeStamp,rLengthUint32) into tOSStatus -- kSequenceTrackProperty_TrackLength = 5
if tOSStatus is 0 then
log "Track Object:"
log sMusicSequenceTrack
log "Data Length:"
log rLengthUint32
log "MusicTimeStamp:"
log tMusicTimeStamp
return tMusicTimeStamp
end if
end unsafe
end handler
public handler AudioToolboxSequenceGetTrackMuteStatus() returns Boolean
variable rTrackMute as Boolean
variable tOSStatus as optional CSInt
variable rLengthUint32 as optional UInt32
-- variable tTrackPropertyEnum as optional UInt32
unsafe
put 0 into rLengthUint32
put c_ATMusicTrackGetMuteStatus(sMusicSequenceTrack,2,rTrackMute,rLengthUint32) into tOSStatus -- kSequenceTrackProperty_MuteStatus = 2
if tOSStatus is 0 then
log "Track Object:"
log sMusicSequenceTrack
log "Data Length:"
log rLengthUint32
log "Mute Status:"
log rTrackMute
return rTrackMute
end if
end unsafe
end handler
public handler AudioToolboxSequenceSetTrackMuteStatus( in pMutesStatus as Boolean)
variable tOSStatus as optional CSInt
-- variable tTrackPropertyEnum as optional UInt32
variable pMutesStatusCBool as CBool
put pMutesStatus into pMutesStatusCBool
unsafe
if pMutesStatus is false then
put c_ATMusicTrackSetMuteStatus(sMusicSequenceTrack,2,pMutesStatusCBool,1) into tOSStatus -- kSequenceTrackProperty_MuteStatus = 2
if tOSStatus is 0 then
log "Track Object:"
log sMusicSequenceTrack
log "Mute:"
log pMutesStatus
else
log "Error:"
log tOSStatus
end if
else
put c_ATMusicTrackSetMuteStatus(sMusicSequenceTrack,2,pMutesStatusCBool,1) into tOSStatus -- kSequenceTrackProperty_MuteStatus = 2
if tOSStatus is 0 then
log "Track Object:"
log sMusicSequenceTrack
log "Mute:"
log pMutesStatus
else
log "Error:"
log tOSStatus
end if
end if
end unsafe
end handler
public handler AudioToolboxSequenceGetTrackSoloStatus() returns Boolean
variable rTrackSolo as Boolean
variable tOSStatus as optional CSInt
variable rLengthUint32 as optional UInt32
-- variable tTrackPropertyEnum as optional UInt32
unsafe
put 0 into rLengthUint32
put c_ATMusicTrackGetSoloStatus(sMusicSequenceTrack,3,rTrackSolo,rLengthUint32) into tOSStatus -- kSequenceTrackProperty_SoloStatus = 3
if tOSStatus is 0 then
log "Track Object:"
log sMusicSequenceTrack
log "Data Length:"
log rLengthUint32
log "Solo Status:"
log rTrackSolo
return rTrackSolo
end if
end unsafe
end handler
public handler AudioToolboxSequenceSetTrackSoloStatus( in pSoloStatus as Boolean)
variable tOSStatus as optional CSInt
-- variable tTrackPropertyEnum as optional UInt32
unsafe
if pSoloStatus is false then
put c_ATMusicTrackSetSoloStatus(sMusicSequenceTrack,3,false,1) into tOSStatus -- kSequenceTrackProperty_SoloStatus = 3
if tOSStatus is 0 then
log "Track Object:"
log sMusicSequenceTrack
log "Solo:"
log pSoloStatus
else
log "Error:"
log tOSStatus
end if
else
put c_ATMusicTrackSetSoloStatus(sMusicSequenceTrack,3,true,1) into tOSStatus -- kSequenceTrackProperty_SoloStatus = 3
if tOSStatus is 0 then
log "Track Object:"
log sMusicSequenceTrack
log "Solo:"
log pSoloStatus
else
log "Error:"
log tOSStatus
end if
end if
end unsafe
end handler
public handler AudioToolboxSequenceGetTrackCount() returns optional any
variable tOSStatus as optional CSInt
variable rTrackCountUint32 as optional UInt32
unsafe
put c_ATMusicSequenceGetTrackCount(sMusicSequence, rTrackCountUint32) into tOSStatus
end unsafe
return rTrackCountUint32
end handler
public handler AudioToolboxSequenceSelectedTrackIndex() returns optional any
variable tOSStatus as optional CSInt
variable tTrackIndex as Uint32
-- if sMusicSequence is nothing then
-- return "Error: Current Sequence is null"
-- end if
-- if sMusicSequenceTrack is nothing then -- This seems to crash the LC engine if sMusicSequenceTrack is undefined or null for some reason
-- return "Error: Current Track is not selected"
-- end if
unsafe
put c_ATMusicSequenceGetTrackIndex(sMusicSequence, sMusicSequenceTrack, tTrackIndex) into tOSStatus
end unsafe
if tOSStatus is 0 then
-- if tTrackIndex is not nothing then
return tTrackIndex +1 -1
-- end if
else
return "Error: " & ( tOSStatus formatted as string )
end if
end handler
-- c_AudioToolboxMusicSequenceGetIndTrack(MusicSequence inSequence, UInt32 inTrackIndex, MusicTrack _Nullable *outTrack) into OSStatus
public handler AudioToolboxMusicSequenceGetIndexTrack(in pIndex as UInt32) -- returns optional any
variable tCFError as optional ObjCId
variable tOSStatus as optional CSInt
unsafe
put c_ATMusicSequenceGetIndexTrack(sMusicSequence,pIndex,sMusicSequenceTrack) into tOSStatus
if tOSStatus is 0 then
log "Music Track Pointer:"
log sMusicSequenceTrack
end if
end unsafe
end handler
public handler AudioToolboxSequenceNewTrack() returns optional any
variable tCFError as optional ObjCId
variable tOSStatus as optional CSInt
unsafe
put c_ATMusicSequenceNewTrack(sMusicSequence,sMusicSequenceTrack) into tOSStatus
if tOSStatus is 0 then
log sMusicSequenceTrack
end if
end unsafe
end handler
public handler AudioToolboxSequenceDisposeTrack(in pTrackIndexNum as UInt32) returns optional any
variable tCFError as optional ObjCId
variable tOSStatus as optional CSInt
unsafe
put c_ATMusicSequenceGetIndexTrack(sMusicSequence,pTrackIndexNum,sMusicSequenceTrack) into tOSStatus
if tOSStatus is 0 then
put c_ATMusicSequenceDisposeTrack(sMusicSequence,sMusicSequenceTrack) into tOSStatus
end if
end unsafe
end handler
public handler AudioToolboxTrackNewMIDINoteEvent() returns optional any
variable tCFError as optional ObjCId
variable tOSStatus as optional CSInt
variable tMIDINoteEvent as optional any
unsafe
put c_ATMusicTrackNewMIDINoteEvent(sMusicSequence,sMusicSequenceTrack,tMIDINoteEvent) into tOSStatus
end unsafe
end handler
-----------------------------------------------------------------------------------------------------------------------------
public handler CoreMIDIObjectTypeToString(in pMIDIObjTypeEnum as optional Number) returns optional String
if pMIDIObjTypeEnum is -1 then
return "Other"
-- post "CoreMIDIPropertyChanged Other"
end if
if pMIDIObjTypeEnum is 0 then
return "Device"
-- post "CoreMIDIPropertyChanged Device"
end if
if pMIDIObjTypeEnum is 1 then
return "Entity"
-- post "CoreMIDIPropertyChanged Entity"
end if
if pMIDIObjTypeEnum is 2 then
return "Source"
--post "CoreMIDIPropertyChanged Source"
end if
if pMIDIObjTypeEnum is 3 then
return "Destination"
-- post "CoreMIDIPropertyChanged Destination"
else
return "External" -- temporary, bitfield holds additonal information
end if
-- post "CoreMIDIPropertyChanged " && tString
end handler
----------------------------------------------------------------- Variables ------------------------------------------------------------
private variable sNSAppSharedApp as ObjcId
private variable sMIDIClientRef as MIDIObjRef
private variable sMIDIOutPortRef as MIDIObjRef
private variable sMIDIInputPortRef as MIDIObjRef
private variable sMIDIDestEndpointRef as MIDIObjRef
private variable sMIDISourceEndpointRef as MIDIObjRef
private variable sMIDIPacketPtr as Pointer
private variable sMIDIPacketListPtr as Pointer
private variable sMIDIPacketByteBufferNSMutableDataRef as ObjcId
private variable sMIDIPacketByteBufferPtr as Pointer
private variable sCoreMIDISetupChangedHandler as optional ObjcBlockPointer
private variable sTarget as ScriptObject
public foreign type MIDINotificationIDnSize binds to "MCAggregateTypeInfo:Jj" -- message ID, message size
public foreign type MIDIObjectAddRemoveNotification binds to "MCAggregateTypeInfo:JjjJjJ" -- message ID, message size, ...
public foreign type MIDIObjectPropertyChangeNotification binds to "MCAggregateTypeInfo:JjjJr" -- message ID, message size
--public foreign type MIDINotifyStructPtr binds to "MCAggregateTypeInfo:r" -- pointer to notification struct
-------------------------- UTIL ----------------------------
foreign handler PointerToMIDINotificationIDnSize(out rAggregate as MIDINotificationIDnSize, in pPointer as Pointer, in pSize as UIntSize) returns nothing binds to "c:memcpy"
foreign handler PointerToMIDIObjectAddRemoveNotification(out rAggregate as MIDIObjectAddRemoveNotification, in pPointer as Pointer, in pSize as UIntSize) returns nothing binds to "c:memcpy"
foreign handler PointerToMIDIObjectPropertyChangeNotification(out rAggregate as MIDIObjectPropertyChangeNotification, in pPointer as Pointer, in pSize as UIntSize) returns nothing binds to "c:memcpy"
private foreign handler c_CFStringCreateCopy(in pCFAllocatorRef as Pointer, in pCFStringRef as optional ObjCId) returns optional ObjCId binds to "c:Foundation.framework>CFStringCreateCopy"
private foreign handler c_CFBridgingRelease(in pCFStringRef as Pointer) returns optional ObjCId binds to "c:Foundation.framework>CFBridgingRelease"
foreign handler MCStringCreateWithCString(in pString as Pointer, out rString as String) returns CBool binds to "<builtin>"
-- public handler CoreMIDISetupChangedCallbackProc(in pContext as optional ObjcBlockPointer,in pMIDINotification as MIDINotification, in pRefCon as optional Pointer)
public handler CoreMIDISetupChangedCallbackProc( in pContext as optional ObjcBlockPointer,in pMIDINotifyStructPtr as Pointer)
-- public handler CoreMIDISetupChangedCallbackProc(in pContext as optional ObjcBlockPointer,in pMIDINotification as Data)
-- MIDINotification is a structure passed to a MIDINotifyProc, when CoreMIDI wishes to inform a client of a change in the state of the system
-- const MIDINotification *message, void *refCon
-- *message = MIDINotificationMessageID : SInt32 and messageSize : UInt32
-- post "CoreMIDISetupChanged" to sTarget
-- variable tSize as Integer
variable tOSStatus as optional CSInt
variable tCFError as optional ObjCId
variable tPropertyValSInt32 as optional SInt32
variable tMIDINotificationIDnSize as optional MIDINotificationIDnSize
-- variable tCFStringRef as Pointer
variable tCFStringRef as Pointer
-- variable tNSStringObj as optional ObjcRetainedId
-- variable tNSStringObj as ObjcObject
variable tNSStringObj as optional ObjcObject
variable tString as optional String
variable tMIDIObjectAddRemoveNotification as optional MIDIObjectAddRemoveNotification
variable tMIDIObjectPropertyChangeNotification as optional MIDIObjectPropertyChangeNotification
unsafe
PointerToMIDINotificationIDnSize(tMIDINotificationIDnSize,pMIDINotifyStructPtr,8)
if element 1 of tMIDINotificationIDnSize = 1 then
log "CoreMIDISetupChanged"
-- post "CoreMIDISetupChanged" to sTarget --- basic notification, -- can ignore if 2-6 are handled
-- no other data follows so size is always 8 Bytes
end if
if element 1 of tMIDINotificationIDnSize = 2 then
PointerToMIDIObjectAddRemoveNotification(tMIDIObjectAddRemoveNotification,pMIDINotifyStructPtr,24)
log "CoreMIDIObjectAdded"
put CoreMIDIObjectTypeToString(element 6 of tMIDIObjectAddRemoveNotification) into tString
log tString
log tMIDIObjectAddRemoveNotification
-- Child_MIDIObjRef
-- post "CoreMIDIObjectAdded" to sTarget
-- get element 5 of tMIDIObjectAddRemoveNotification
put c_MIDIObjectGetIntegerProperty( element 5 of tMIDIObjectAddRemoveNotification, StringToNSString("uniqueID"), tPropertyValSInt32) into tOSStatus
if tPropertyValSInt32 is not nothing then
log tPropertyValSInt32
end if
put c_MIDIObjectGetStringProperty( element 5 of tMIDIObjectAddRemoveNotification, StringToNSString("name"),tNSStringObj) into tOSStatus
if tNSStringObj is not nothing then
put StringFromNSString(tNSStringObj) into tString
log tString
end if
-- ID SInt32, Size UInt32, Parrent_MIDIObjRef UInt32, Parrent_MIDIObjectType SInt32, Child_MIDIObjRef UInt32, Child_MIDIObjectType SInt32
--- 24 Bytes
end if
if element 1 of tMIDINotificationIDnSize = 3 then
PointerToMIDIObjectAddRemoveNotification(tMIDIObjectAddRemoveNotification,pMIDINotifyStructPtr,24)
log "CoreMIDIObjectRemoved"
put CoreMIDIObjectTypeToString(element 4 of tMIDIObjectAddRemoveNotification) into tString
log tString
log tMIDIObjectAddRemoveNotification
post "CoreMIDIObjectRemoved" to sTarget
-- put c_MIDIObjectGetIntegerProperty( element 3 of tMIDIObjectAddRemoveNotification, StringToNSString("uniqueID"), tPropertyValSInt32) into tOSStatus
-- log tPropertyValSInt32
put c_MIDIObjectGetStringProperty( element 3 of tMIDIObjectAddRemoveNotification, StringToNSString("name"),tNSStringObj) into tOSStatus
if tNSStringObj is not nothing then
put StringFromNSString(tNSStringObj) into tString
log tString
end if
-- MIDIObjectAddRemoveNotification
-- ID SInt32, Size UInt32, Parrent_MIDIObjRef UInt32, Parrent_MIDIObjectType SInt32, Child_MIDIObjRef UInt32, Child_MIDIObjectType SInt32
--- 24 Bytes
end if
if element 1 of tMIDINotificationIDnSize = 4 then
log "CoreMIDIPropertyChanged"
PointerToMIDIObjectPropertyChangeNotification(tMIDIObjectPropertyChangeNotification,pMIDINotifyStructPtr, element 2 of tMIDINotificationIDnSize )
log tMIDIObjectPropertyChangeNotification
put element 5 of tMIDIObjectPropertyChangeNotification into tCFStringRef
log tCFStringRef
--put PointerToObjcObject(nothing) into tNSStringObj
-- put PointerToObjcObject(tCFStringRef) into tNSStringObj
-- if tNSStringObj is not nothing then
-- put StringFromNSString(tNSStringObj) into tString
-- log tString
--end if
-- CFStringRef CFStringCreateCopy(CFAllocatorRef alloc, CFStringRef theString);
-- put PointerToObjcObject(tCFStringRef) into tNSStringObj
-- put StringFromNSString(tNSStringObj) into tString
-- put StringFromNSString(tCFStringRef) into tString
-- log tString
-- put c_CFStringCreateCopy(nothing,element 5 of tMIDIObjectPropertyChangeNotification) into tNSStringObj
-- put StringFromNSString(tCFStringRef) into tCFStringRefString
-- if MCStringCreateWithCString(element 5 of tMIDIObjectPropertyChangeNotification, tCFStringRefString) then
-- log element 5 of tMIDIObjectPropertyChangeNotification
-- log tCFStringRef
put CoreMIDIObjectTypeToString(element 4 of tMIDIObjectPropertyChangeNotification) into tString
log tString
-- execute script "CoreMIDIPropertyChanged " && tString in sTarget
-- post "CoreMIDIPropertyChanged " && tString
put c_MIDIObjectGetStringProperty(element 3 of tMIDIObjectPropertyChangeNotification,StringToNSString("name"),tNSStringObj) into tOSStatus
if tNSStringObj is not nothing then
put StringFromNSString(tNSStringObj) into tString
log tString
end if
put c_MIDIObjectGetIntegerProperty( element 3 of tMIDIObjectPropertyChangeNotification, StringToNSString("uniqueID"), tPropertyValSInt32) into tOSStatus
log tPropertyValSInt32
-- MIDIObjectPropertyChangeNotification: A message describing the addition or removal of an object.
-- ID SInt32, Size UInt32, MIDIObjRef UInt32, MIDIObjectType SInt32, propertyName CFStringRef (or CFString? (length?)
--- 4 to 18? 20? N Bytes
end if
if element 1 of tMIDINotificationIDnSize = 5 then
log "CoreMIDIThruConnectionsChanged"
-- post "CoreMIDIThruConnectionsChanged" to sTarget
--- basic notification, no other data follows so size is always 8 Bytes
end if
if element 1 of tMIDINotificationIDnSize = 6 then
log "CoreMIDISerialPortOwnerChanged"
--post "CoreMIDISerialPortOwnerChanged" to sTarget
--- basic notification, no other data follows so size is always 8 Bytes
end if
if element 1 of tMIDINotificationIDnSize = 7 then
log "CoreMIDIIOErrorOccured"
--post "CoreMIDIIOErrorOccured" to sTarget
-- ID SInt32, Size UInt32, Driver MIDIDeviceRef UInt32, OSStatus CSInt (2 or 4 bytes?)
-- 14 or 16 Bytes?
end if
-- log tMIDINotificationIDnSize
end unsafe
-- execute script "CoreMIDISetupChanged"
-- send "CoreMIDISetupChanged" to sTarget with NotificationID
-- variable sMIDINotificationObj as ObjcObject
-- put PointerToObjcObject(pMIDINotification) into sMIDINotificationObj
end handler
/**
Creates a MIDI Client and asigns it a name.
Example:
CoreMIDIClientCreate("My LiveCode CoreMIDI Client")
Parameters:
clientName (String): The text string to use as the MIDI Client's name
Description:
Creates a MIDI Client named with string provided (client name is not generally visible to other applications)
*/
public handler CoreMIDIClientCreate(in clientName as String) returns nothing
variable tClientNameStrRef as ObjcObject
variable tOSStatus as optional CSInt
-- variable tMIDINotifyProc as optional any
-- variable tNotifyRefCon as optional Pointer
if not CreateObjcBlockPointerFromHandler(CoreMIDISetupChangedCallbackProc, sCoreMIDISetupChangedHandler) then
put nothing into sCoreMIDISetupChangedHandler
end if
-- put nothing into tNotifyRefCon
put StringToNSString(clientName) into tClientNameStrRef
unsafe
-- put NSApplicationSharedApplication() into sNSAppSharedApp
-- put c_MIDIClientCreate(tClientNameStrRef,sCoreMIDISetupChangedHandler,CoreMIDIClientCreate,sMIDIClientRef) into tOSStatus
-- OSStatus MIDIClientCreateWithBlock(CFStringRef name, MIDIClientRef *outClient, MIDINotifyBlock notifyBlock);
-- put c_MIDIClientCreate(tClientNameStrRef,sCoreMIDISetupChangedHandler,tNotifyRefCon,sMIDIClientRef) into tOSStatus
put c_MIDIClientCreateWithBlock(tClientNameStrRef,sMIDIClientRef,sCoreMIDISetupChangedHandler) into tOSStatus
end unsafe
resolve script object "this stack"
put the result into sTarget
log sTarget
end handler
public handler CoreMIDIClientSetScriptObject(in pNameOfScriptObject as optional String) returns nothing
if pNameOfScriptObject is not nothing and pNameOfScriptObject is not the empty string then
resolve script object pNameOfScriptObject
put the result into sTarget
log sTarget
else
resolve script object "this stack"
put the result into sTarget
log sTarget
end if
end handler
/**
Sends arbitrary bytes to the MIDI Client.
Type: command
Example:
CoreMIDISendMIDIbytesNow <pMIDIMsgData>
Parameters:
pMIDIMsgData: arbitrary bytes, does not check for the bytes for validity as MIDI messages
Description:
Sends arbitrary bytes to the MIDI Client immediately (as fast as possible).
A MIDI Client must be created first using CoreMIDIClientCreate.
*/
public handler CoreMIDISendMIDIbytesNow(in pMIDIMsgData as Data) returns nothing
variable tOSStatus as optional CSInt
variable tTimeStamp as MIDITimeStamp
variable tMIDIPacket as MIDIPacket
variable tMIDIPacketList as MIDIPacketList
variable tBufferSize as Number
variable tCnt as Number
variable tMIDIMsgBytesNSDataRef as ObjCId
variable tMIDIMsgBytesPtr as Pointer
put the number of bytes in pMIDIMsgData into tCnt
put 256 into tBufferSize
put 0 into tTimeStamp
unsafe
put objC_NSMutableDataWithLength(NumberToNSNumber(tBufferSize)) into sMIDIPacketByteBufferNSMutableDataRef
put objC_NSMutableDataBytesPtr(sMIDIPacketByteBufferNSMutableDataRef) into sMIDIPacketByteBufferPtr
put c_MIDIPacketListInit(sMIDIPacketByteBufferPtr) into sMIDIPacketPtr
put objC_NSMutableDataWithLength(NumberToNSNumber(tCnt)) into tMIDIMsgBytesNSDataRef
objC_NSMutableDataSetData(tMIDIMsgBytesNSDataRef, DataToNSData(pMIDIMsgData))
put objC_NSMutableDataBytesPtr(tMIDIMsgBytesNSDataRef) into tMIDIMsgBytesPtr
put c_MIDIPacketListAdd(sMIDIPacketByteBufferPtr,tBufferSize,sMIDIPacketPtr,tTimeStamp,tCnt,tMIDIMsgBytesPtr) into sMIDIPacketPtr
put c_MIDIReceived(sMIDISourceEndpointRef,sMIDIPacketByteBufferPtr) into tOSStatus
end unsafe
end handler
/**
Immediately sends a MIDI Note On message with the given pitch and velocity on the given channel.
Type: command
Syntax: CoreMIDINoteOn <MIDINoteNumber>,pMIDIVelocityNumber,<pMIDIChannelNumber>
Example:
CoreMIDINoteOn 60,127,1 -- 60=Middle C, 127=Full velocity, 1=MIDI channel 1
Parameters:
pMIDINoteNum: The number of the pitch to turn on, 0 to 127, 60 = Middle C
pMIDIVeloNum: The velocity to play the given pitch at, 0 to 127
pMIDIChanNum: The MIDI Channel to play the note on, 1 to 16
Description: Immediately sends a MIDI Note On message with the given pitch and velocity on the given channel.
*/
public handler CoreMIDINoteOn(in pMIDINoteNum as UInt8,in pMIDIVeloNum as UInt8,in pMIDIChanNum as UInt8) returns nothing
expect that (pMIDINoteNum >= 0 and pMIDINoteNum <= 127 ) because "MIDI pitch values must be in the range of 0 to 127"
expect that (pMIDIVeloNum >= 0 and pMIDIVeloNum <= 127 ) because "MIDI veloctiy values must be in the range of 0 to 127"
expect that (pMIDIChanNum >= 1 and pMIDIChanNum <= 16 ) because "MIDI channel values must be in the range of 1 to 16"
variable tMIDIMsgData as Data
add 143 to pMIDIChanNum -- 143 instead of 144 so that channel numbers can be passed with 1 to 16 range instead of 0 to 15
put the byte with code pMIDIChanNum into tMIDIMsgData
put the byte with code pMIDINoteNum after tMIDIMsgData
put the byte with code pMIDIVeloNum after tMIDIMsgData
CoreMIDISendMIDIbytesNow(tMIDIMsgData)
end handler
/**
Name: CoreMIDINoteOff
Type: command
Syntax: CoreMIDINoteOff <MIDINoteNumber>,<MIDIChannelNumber>
Summary:
Immediately sends a MIDI Note Off message with the given pitch and velocity on the given channel.
Example:
CoreMIDINoteOff 60,1 -- Turns off Middle C on MIDI channel 1
Parameters:
pMIDINoteNum: The number of the pitch to turn off, 0 to 127, 60 = Middle C
pMIDIChanNum: The MIDI Channel to send the message to, 0 to 15, 0 = Channel 1
Description:
Immediately sends a MIDI Note Off message with the given pitch on the given channel.
*/
public handler CoreMIDINoteOff(in pMIDINoteNum as UInt8,in pMIDIChanNum as UInt8) returns nothing
expect that (pMIDINoteNum >= 0 and pMIDINoteNum <= 127 ) because "MIDI pitch values must be in the range of 0 to 127"
expect that (pMIDIChanNum >= 1 and pMIDIChanNum <= 16 ) because "MIDI channel values must be in the range of 1 to 16"
variable tMIDIMsgData as Data
add 127 to pMIDIChanNum -- 127 instead of 128 for Channel range of 1 to 16 (instead of 0 to 15)
put the byte with code pMIDIChanNum into tMIDIMsgData
put the byte with code pMIDINoteNum after tMIDIMsgData
put the byte with code 0 after tMIDIMsgData
CoreMIDISendMIDIbytesNow(tMIDIMsgData)
end handler
/**
Name: CoreMIDIController
Type: command
Syntax: CoreMIDIController(<pController>,<pControllerVal><pMIDIChanNum>)
Summary:
The send a controller with a single data byte value to on a given channel
Example:
CoreMIDIController 7,127,1 -- 7 = Volume Controller, Data Byte 1, channel 1
Parameters:
pController: The number of the MIDI Controller to set values for
pControllerVal: The value byte one
pMIDIChanNum: MIDI Channel to send the controller value on, 1 to 16
Description:
The send a controller with a single data byte value to on a given channel
*/
public handler CoreMIDIController(in pController as UInt8,in pControllerVal as UInt8,in pMIDIChanNum as UInt8) returns nothing
expect that (pController >= 0 and pController <= 127 ) because "MIDI controller selection must be in the range of 0 to 127"
expect that (pControllerVal >= 0 and pControllerVal <= 127 ) because "MIDI controller values must be in the range of 0 to 127"
expect that (pMIDIChanNum >= 1 and pMIDIChanNum <= 16 ) because "MIDI channel values must be in the range of 1 to 16"
variable tMIDIMsgData as Data
add 175 to pMIDIChanNum -- 176 is MIDI CC
put the byte with code pMIDIChanNum into tMIDIMsgData
put the byte with code pController after tMIDIMsgData
put the byte with code pControllerVal after tMIDIMsgData
CoreMIDISendMIDIbytesNow(tMIDIMsgData)
end handler
/**
The send pitchbend with fine range from 0 to 16384, 8192 is centered (no bend)
Type: command
Syntax: CoreMIDIPitchbendFine <pPitchBendCoarseNFine>,<pMIDIChanNum>
Example:
CoreMIDIPitchbendFine 0,1 -- Pitchbend Maximum Down, channel 1
CoreMIDIPitchbendFine 16384,1 -- Pitchbend Maximum Up, channel 1
CoreMIDIPitchbendFine 8192,1 -- Centered / No Bend, channel 1
Parameters:
pPitchBendCoarseNFine\: The number of the pitch bend 'position'
pMIDIChanNum: MIDI Channel to send the bend value on, 1 to 16
Description:
The send pitchbend with fine range from 0 to 16384, 8192 is centered (no bend)
*/
public handler CoreMIDIPitchbendFine(in pPitchBendCoarseNFine as Number,in pMIDIChanNum as UInt8) returns nothing
expect that (pPitchBendCoarseNFine >= 0 and pPitchBendCoarseNFine <= 16384 ) because "MIDI controller selection must be in the range of 0 to 127"
expect that (pMIDIChanNum >= 1 and pMIDIChanNum <= 16 ) because "MIDI channel values must be in the range of 1 to 16"
variable tMIDIMsgData as Data
variable tNum as Number
variable pPitchBendCoarse as UInt8
variable pPitchBendFine as UInt8
add 224 to pMIDIChanNum -- 0xEx Pitchbend + channel
put pPitchBendCoarseNFine into tNum
divide tNum by 128
round tNum
put tNum into pPitchBendCoarse
put pPitchBendCoarseNFine into tNum
put tNum mod 128 into tNum
round tNum
put tNum into pPitchBendFine
put the byte with code pMIDIChanNum into tMIDIMsgData
put the byte with code pPitchBendFine after tMIDIMsgData
put the byte with code pPitchBendCoarse after tMIDIMsgData
CoreMIDISendMIDIbytesNow(tMIDIMsgData)
end handler
/**
The send pitchbend with coarse range from 0 to 127, 64 is centered (no bend)
Type: command
Syntax: CoreMIDIPitchbend <pPitchBendCoarse>,<pMIDIChannelNum>
Example:
CoreMIDIPitchbendFine 0,1 -- Pitchbend Maximum Down, channel 1
CoreMIDIPitchbendFine 127,1 -- Pitchbend Maximum Up, channel 1
CoreMIDIPitchbendFine 64,1 -- Centered No Bend, channel 1
Parameters:
pPitchBendCoarse: The number of the pitch bend 'position'
pMIDIChanNum: MIDI Channel to send the bend value on, 1 to 16
Description:
The send a controller with a single data byte value to on a given channel
*/
public handler CoreMIDIPitchbend(in pPitchBendCoarse as UInt8,in pMIDIChanNum as UInt8) returns nothing
expect that (pPitchBendCoarse >= 0 and pPitchBendCoarse <= 127 ) because "MIDI controller selection must be in the range of 0 to 127"
expect that (pMIDIChanNum >= 1 and pMIDIChanNum <= 16 ) because "MIDI channel values must be in the range of 1 to 16"
variable tMIDIMsgData as Data
add 224 to pMIDIChanNum
put the byte with code pMIDIChanNum into tMIDIMsgData
put the byte with code 0 after tMIDIMsgData -- no "fine" steps, just 128 "coarse" steps
put the byte with code pPitchBendCoarse after tMIDIMsgData
CoreMIDISendMIDIbytesNow(tMIDIMsgData)
end handler
/**
The send Aftertouch (key pressure) for specified note on the given channel
Type: command
Example:
CoreMIDIAftertouch 60,127,1 -- Middle C=60, 127=Maximum Pressure, channel 1
Parameters:
pNoteNum (Integer): The number of the pitch/key to apply pressure value to
pKeyPressure (Integer): The pitch/key pressure value, range 0 to 127
pMIDIChanNum (Integer): MIDI Channel to send the value on, 1 to 16
Description:
The send Aftertouch (key pressure) for specified note on the given channel. MIDI Controllers can have pressure sensors under each key that can transmit this value for each note.
*/
public handler CoreMIDIAftertouch(in pNoteNum as UInt8,in pKeyPressure as UInt8,in pMIDIChanNum as UInt8) returns nothing
expect that (pNoteNum >= 0 and pNoteNum <= 127 ) because "MIDI controller selection must be in the range of 0 to 127"
expect that (pKeyPressure >= 0 and pKeyPressure <= 127 ) because "MIDI controller values must be in the range of 0 to 127"
expect that (pMIDIChanNum >= 1 and pMIDIChanNum <= 16 ) because "MIDI channel values must be in the range of 1 to 16"
variable tMIDIMsgData as Data
add 160 to pMIDIChanNum
put the byte with code pMIDIChanNum into tMIDIMsgData
put the byte with code pNoteNum after tMIDIMsgData
put the byte with code pKeyPressure after tMIDIMsgData
CoreMIDISendMIDIbytesNow(tMIDIMsgData)
end handler
/**
The send Channel Pressure on the given channel
Type: command
Example:
CoreMIDIChannelPressure 127,1 -- 127=Maximum Pressure, channel 1
Parameters:
pChannelPressure (Integer): The channel pressure value, range 0 to 127
pMIDIChanNum (Integer): MIDI Channel to send the value on, 1 to 16
Description: