File: VstSdk.cs

package info (click to toggle)
cadencii 3.3.9%2Bsvn20110818.r1732-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 35,764 kB
  • ctags: 26,929
  • sloc: cs: 160,836; java: 42,449; cpp: 7,605; ansic: 1,728; perl: 1,087; makefile: 236; php: 142; xml: 117; sh: 21
file content (999 lines) | stat: -rw-r--r-- 38,305 bytes parent folder | download | duplicates (6)
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
#if !JAVA
#define VST_2_4_EXTENSIONS

using System;
using System.Runtime.InteropServices;

namespace VstSdk {
    #region VST SDK 2.4 declarations
    using VstInt32 = System.Int32;
    using VstIntPtr = System.Int32;
    using VstInt16 = System.Int16;

    /// <summary>
    /// 定数値のコンテナクラス
    /// </summary>
    public static class Constants {
        /// <summary>
        /// VST SDKのバージョンを表す定数
        /// </summary>
        public const int kVstVersion = 2400;
    }

    /// <summary>
    /// String length limits (in characters excl. 0 byte)
    /// </summary>
    public static class VstStringConstants {
        /// <summary>
        /// used for #effGetProgramName, #effSetProgramName, #effGetProgramNameIndexed
        /// </summary>
        public const int kVstMaxProgNameLen = 24;
        /// <summary>
        /// used for #effGetParamLabel, #effGetParamDisplay, #effGetParamName
        /// </summary>
        public const int kVstMaxParamStrLen = 8;
        /// <summary>
        /// used for #effGetVendorString, #audioMasterGetVendorString
        /// </summary>
        public const int kVstMaxVendorStrLen = 64;
        /// <summary>
        /// used for #effGetProductString, #audioMasterGetProductString
        /// </summary>
        public const int kVstMaxProductStrLen = 64;
        /// <summary>
        /// used for #effGetEffectName
        /// </summary>
        public const int kVstMaxEffectNameLen = 32;
    }

    public static class AudioMasterOpcodes {
        /// <summary>
        /// [index]: parameter index [opt]: parameter value  @see AudioEffect::setParameterAutomated
        /// </summary>
        public const int audioMasterAutomate = 0;
        /// <summary>
        /// [return value]: Host VST version (for example 2400 for VST 2.4) @see AudioEffect::getMasterVersion
        /// </summary>
        public const int audioMasterVersion = 1;
        /// <summary>
        /// [return value]: current unique identifier on shell plug-in  @see AudioEffect::getCurrentUniqueId
        /// </summary>
        public const int audioMasterCurrentId = 2;
        /// <summary>
        /// no arguments  @see AudioEffect::masterIdle
        /// </summary>
        public const int audioMasterIdle = 3;
        /// <summary>
        /// deprecated in VST 2.4 r2
        /// </summary>
        [Obsolete]
        public const int __audioMasterPinConnectedDeprecated = 4;
    }

    /// <summary>
    /// Basic dispatcher Opcodes (Host to Plug-in)
    /// </summary>
    public static class AEffectOpcodes {
        /// <summary>
        /// no arguments  @see AudioEffect::open
        /// </summary>
        public const int effOpen = 0;
        /// <summary>
        /// no arguments  @see AudioEffect::close
        /// </summary>
        public const int effClose = 1;

        /// <summary>
        /// [value]: new program number  @see AudioEffect::setProgram
        /// </summary>
        public const int effSetProgram = 2;
        /// <summary>
        /// [return value]: current program number  @see AudioEffect::getProgram
        /// </summary>
        public const int effGetProgram = 3;
        /// <summary>
        /// [ptr]: char* with new program name, limited to #kVstMaxProgNameLen  @see AudioEffect::setProgramName
        /// </summary>
        public const int effSetProgramName = 4;
        /// <summary>
        /// [ptr]: char buffer for current program name, limited to #kVstMaxProgNameLen  @see AudioEffect::getProgramName
        /// </summary>
        public const int effGetProgramName = 5;

        /// <summary>
        /// [ptr]: char buffer for parameter label, limited to #kVstMaxParamStrLen  @see AudioEffect::getParameterLabel
        /// </summary>
        public const int effGetParamLabel = 6;
        /// <summary>
        /// [ptr]: char buffer for parameter display, limited to #kVstMaxParamStrLen  @see AudioEffect::getParameterDisplay
        /// </summary>
        public const int effGetParamDisplay = 7;
        /// <summary>
        /// [ptr]: char buffer for parameter name, limited to #kVstMaxParamStrLen  @see AudioEffect::getParameterName
        /// </summary>
        public const int effGetParamName = 8;

        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effGetVuDeprecated = 9;

        /// <summary>
        /// [opt]: new sample rate for audio processing  @see AudioEffect::setSampleRate
        /// </summary>
        public const int effSetSampleRate = 10;
        /// <summary>
        /// [value]: new maximum block size for audio processing  @see AudioEffect::setBlockSize
        /// </summary>
        public const int effSetBlockSize = 11;
        /// <summary>
        /// [value]: 0 means "turn off", 1 means "turn on"  @see AudioEffect::suspend @see AudioEffect::resume
        /// </summary>
        public const int effMainsChanged = 12;

        /// <summary>
        /// [ptr]: #ERect** receiving pointer to editor size  @see ERect @see AEffEditor::getRect
        /// </summary>
        public const int effEditGetRect = 13;
        /// <summary>
        /// [ptr]: system dependent Window pointer, e.g. HWND on Windows  @see AEffEditor::open
        /// </summary>
        public const int effEditOpen = 14;
        /// <summary>
        /// no arguments @see AEffEditor::close
        /// </summary>
        public const int effEditClose = 15;

        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effEditDrawDeprecated = 16;
        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effEditMouseDeprecated = 17;
        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effEditKeyDeprecated = 18;

        /// <summary>
        /// no arguments @see AEffEditor::idle
        /// </summary>
        public const int effEditIdle = 19;

        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effEditTopDeprecated = 20;
        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effEditSleepDeprecated = 21;
        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effIdentifyDeprecated = 22;

        /// <summary>
        /// [ptr]: void** for chunk data address [index]: 0 for bank, 1 for program  @see AudioEffect::getChunk
        /// </summary>
        public const int effGetChunk = 23;
        /// <summary>
        /// [ptr]: chunk data [value]: byte size [index]: 0 for bank, 1 for program  @see AudioEffect::setChunk
        /// </summary>
        public const int effSetChunk = 24;

        public const int effNumOpcodes = 25;
    }

    public static class AEffectXOpcodes {
        /// <summary>
        /// [ptr]: #VstEvents*  @see AudioEffectX::processEvents
        /// </summary>
        public const int effProcessEvents = 25;

        /// <summary>
        /// [index]: parameter index [return value]: 1=true, 0=false  @see AudioEffectX::canParameterBeAutomated
        /// </summary>
        public const int effCanBeAutomated = 26;
        /// <summary>
        /// [index]: parameter index [ptr]: parameter String [return value]: true for success  @see AudioEffectX::string2parameter
        /// </summary>
        public const int effString2Parameter = 27;

        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effGetNumProgramCategoriesDeprecated = 28;

        /// <summary>
        /// [index]: program index [ptr]: buffer for program name, limited to #kVstMaxProgNameLen [return value]: true for success  @see AudioEffectX::getProgramNameIndexed
        /// </summary>
        public const int effGetProgramNameIndexed = 29;

        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effCopyProgramDeprecated = 30;
        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effConnectInputDeprecated = 31;
        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effConnectOutputDeprecated = 32;

        /// <summary>
        /// [index]: input index [ptr]: #VstPinProperties* [return value]: 1 if supported  @see AudioEffectX::getInputProperties
        /// </summary>
        public const int effGetInputProperties = 33;
        /// <summary>
        /// [index]: output index [ptr]: #VstPinProperties* [return value]: 1 if supported  @see AudioEffectX::getOutputProperties
        /// </summary>
        public const int effGetOutputProperties = 34;
        /// <summary>
        /// [return value]: category  @see VstPlugCategory @see AudioEffectX::getPlugCategory
        /// </summary>
        public const int effGetPlugCategory = 35;

        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effGetCurrentPositionDeprecated = 36;
        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effGetDestinationBufferDeprecated = 37;

        /// <summary>
        /// [ptr]: #VstAudioFile array [value]: count [index]: start flag  @see AudioEffectX::offlineNotify
        /// </summary>
        public const int effOfflineNotify = 38;
        /// <summary>
        /// [ptr]: #VstOfflineTask array [value]: count  @see AudioEffectX::offlinePrepare
        /// </summary>
        public const int effOfflinePrepare = 39;
        /// <summary>
        /// [ptr]: #VstOfflineTask array [value]: count  @see AudioEffectX::offlineRun
        /// </summary>
        public const int effOfflineRun = 40;

        /// <summary>
        /// [ptr]: #VstVariableIo*  @see AudioEffectX::processVariableIo
        /// </summary>
        public const int effProcessVarIo = 41;
        /// <summary>
        /// [value]: input #VstSpeakerArrangement* [ptr]: output #VstSpeakerArrangement*  @see AudioEffectX::setSpeakerArrangement
        /// </summary>
        public const int effSetSpeakerArrangement = 42;

        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effSetBlockSizeAndSampleRateDeprecated = 43;

        /// <summary>
        /// [value]: 1 = bypass, 0 = no bypass  @see AudioEffectX::setBypass
        /// </summary>
        public const int effSetBypass = 44;
        /// <summary>
        /// [ptr]: buffer for effect name, limited to #kVstMaxEffectNameLen  @see AudioEffectX::getEffectName
        /// </summary>
        public const int effGetEffectName = 45;

        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effGetErrorTextDeprecated = 46;

        /// <summary>
        /// [ptr]: buffer for effect vendor String, limited to #kVstMaxVendorStrLen  @see AudioEffectX::getVendorString
        /// </summary>
        public const int effGetVendorString = 47;
        /// <summary>
        /// [ptr]: buffer for effect vendor String, limited to #kVstMaxProductStrLen  @see AudioEffectX::getProductString
        /// </summary>
        public const int effGetProductString = 48;
        /// <summary>
        /// [return value]: vendor-specific version  @see AudioEffectX::getVendorVersion
        /// </summary>
        public const int effGetVendorVersion = 49;
        /// <summary>
        /// no definition, vendor specific handling  @see AudioEffectX::vendorSpecific
        /// </summary>
        public const int effVendorSpecific = 50;
        /// <summary>
        /// [ptr]: "can do" String [return value]: 0: "don't know" -1: "no" 1: "yes"  @see AudioEffectX::canDo
        /// </summary>
        public const int effCanDo = 51;
        /// <summary>
        /// [return value]: tail size (for example the reverb time of a reverb plug-in); 0 is default (return 1 for 'no tail')
        /// </summary>
        public const int effGetTailSize = 52;

        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effIdleDeprecated = 53;
        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effGetIconDeprecated = 54;
        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effSetViewPositionDeprecated = 55;

        /// <summary>
        /// [index]: parameter index [ptr]: #VstParameterProperties* [return value]: 1 if supported  @see AudioEffectX::getParameterProperties
        /// </summary>
        public const int effGetParameterProperties = 56;

        /// <summary>
        /// deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effKeysRequiredDeprecated = 57;

        /// <summary>
        /// [return value]: VST version  @see AudioEffectX::getVstVersion
        /// </summary>
        public const int effGetVstVersion = 58;

        /// <summary>
        /// [index]: ASCII character [value]: virtual key [opt]: modifiers [return value]: 1 if key used  @see AEffEditor::onKeyDown
        /// </summary>
        public const int effEditKeyDown = 59;
        /// <summary>
        /// [index]: ASCII character [value]: virtual key [opt]: modifiers [return value]: 1 if key used  @see AEffEditor::onKeyUp
        /// </summary>
        public const int effEditKeyUp = 60;
        /// <summary>
        /// [value]: knob mode 0: circular, 1: circular relativ, 2: linear (CKnobMode in VSTGUI)  @see AEffEditor::setKnobMode
        /// </summary>
        public const int effSetEditKnobMode = 61;

        /// <summary>
        /// [index]: MIDI channel [ptr]: #MidiProgramName* [return value]: number of used programs, 0 if unsupported  @see AudioEffectX::getMidiProgramName
        /// </summary>
        public const int effGetMidiProgramName = 62;
        /// <summary>
        /// [index]: MIDI channel [ptr]: #MidiProgramName* [return value]: index of current program  @see AudioEffectX::getCurrentMidiProgram
        /// </summary>
        public const int effGetCurrentMidiProgram = 63;
        /// <summary>
        /// [index]: MIDI channel [ptr]: #MidiProgramCategory* [return value]: number of used categories, 0 if unsupported  @see AudioEffectX::getMidiProgramCategory
        /// </summary>
        public const int effGetMidiProgramCategory = 64;
        /// <summary>
        /// [index]: MIDI channel [return value]: 1 if the #MidiProgramName(s) or #MidiKeyName(s) have changed  @see AudioEffectX::hasMidiProgramsChanged
        /// </summary>
        public const int effHasMidiProgramsChanged = 65;
        /// <summary>
        /// [index]: MIDI channel [ptr]: #MidiKeyName* [return value]: true if supported, false otherwise  @see AudioEffectX::getMidiKeyName
        /// </summary>
        public const int effGetMidiKeyName = 66;

        /// <summary>
        /// no arguments  @see AudioEffectX::beginSetProgram
        /// </summary>
        public const int effBeginSetProgram = 67;
        /// <summary>
        /// no arguments  @see AudioEffectX::endSetProgram
        /// </summary>
        public const int effEndSetProgram = 68;
        /// <summary>
        /// [value]: input #VstSpeakerArrangement* [ptr]: output #VstSpeakerArrangement*  @see AudioEffectX::getSpeakerArrangement
        /// </summary>
        public const int effGetSpeakerArrangement = 69;
        /// <summary>
        /// [ptr]: buffer for plug-in name, limited to #kVstMaxProductStrLen [return value]: next plugin's uniqueID  @see AudioEffectX::getNextShellPlugin
        /// </summary>
        public const int effShellGetNextPlugin = 70;

        /// <summary>
        /// no arguments  @see AudioEffectX::startProcess
        /// </summary>
        public const int effStartProcess = 71;
        /// <summary>
        /// no arguments  @see AudioEffectX::stopProcess
        /// </summary>
        public const int effStopProcess = 72;
        /// <summary>
        /// [value]: number of samples to process, offline only!  @see AudioEffectX::setTotalSampleToProcess
        /// </summary>
        public const int effSetTotalSampleToProcess = 73;
        /// <summary>
        /// [value]: pan law [opt]: gain  @see VstPanLawType @see AudioEffectX::setPanLaw
        /// </summary>
        public const int effSetPanLaw = 74;

        /// <summary>
        /// [ptr]: #VstPatchChunkInfo* [return value]: -1: bank can't be loaded, 1: bank can be loaded, 0: unsupported  @see AudioEffectX::beginLoadBank
        /// </summary>
        public const int effBeginLoadBank = 75;
        /// <summary>
        /// [ptr]: #VstPatchChunkInfo* [return value]: -1: prog can't be loaded, 1: prog can be loaded, 0: unsupported  @see AudioEffectX::beginLoadProgram
        /// </summary>
        public const int effBeginLoadProgram = 76;
        /// <summary>
        /// [value]: @see VstProcessPrecision  @see AudioEffectX::setProcessPrecision
        /// </summary>
        public const int effSetProcessPrecision = 77;
        /// <summary>
        /// [return value]: number of used MIDI input channels (1-15)  @see AudioEffectX::getNumMidiInputChannels
        /// </summary>
        public const int effGetNumMidiInputChannels = 78;
        /// <summary>
        /// [return value]: number of used MIDI output channels (1-15)  @see AudioEffectX::getNumMidiOutputChannels
        /// </summary>
        public const int effGetNumMidiOutputChannels = 79;
    }

    public static class VstAEffectFlags {
        /// <summary>
        /// set if the plug-in provides a custom editor
        /// </summary>
        public const int effFlagsHasEditor = 1 << 0;
        /// <summary>
        /// supports replacing process mode (which should the default mode in VST 2.4)
        /// </summary>
        public const int effFlagsCanReplacing = 1 << 4;
        /// <summary>
        /// program data is handled in formatless chunks
        /// </summary>
        public const int effFlagsProgramChunks = 1 << 5;
        /// <summary>
        /// plug-in is a synth (VSTi), Host may assign mixer channels for its outputs
        /// </summary>
        public const int effFlagsIsSynth = 1 << 8;
        /// <summary>
        /// plug-in does not produce sound when input is all silence
        /// </summary>
        public const int effFlagsNoSoundInStop = 1 << 9;
#if VST_2_4_EXTENSIONS
        /// <summary>
        /// plug-in supports double precision processing
        /// </summary>
        public const int effFlagsCanDoubleReplacing = 1 << 12;
#endif
        /// <summary>
        /// \deprecated deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effFlagsHasClipDeprecated = 1 << 1;
        /// <summary>
        /// \deprecated deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effFlagsHasVuDeprecated = 1 << 2;
        /// <summary>
        /// \deprecated deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effFlagsCanMonoDeprecated = 1 << 3;
        /// <summary>
        /// \deprecated deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effFlagsExtIsAsyncDeprecated = 1 << 10;
        /// <summary>
        /// \deprecated deprecated in VST 2.4
        /// </summary>
        [Obsolete]
        public const int __effFlagsExtHasBufferDeprecated = 1 << 11;
    }

    public delegate VstIntPtr AEffectDispatcherProc( ref AEffect effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, IntPtr ptr, float opt );
    public delegate void AEffectProcessProc( ref AEffect effect, IntPtr inputs, IntPtr outputs, VstInt32 sampleFrames );
    public delegate void AEffectProcessDoubleProc( ref AEffect effect, IntPtr inputs, IntPtr outputs, VstInt32 sampleFrames );
    public delegate void AEffectSetParameterProc( ref AEffect effect, VstInt32 index, float parameter );
    public delegate float AEffectGetParameterProc( ref AEffect effect, VstInt32 index );

    [UnmanagedFunctionPointer( CallingConvention.Cdecl )]
    public delegate VstIntPtr audioMasterCallback( ref AEffect effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, IntPtr ptr, float opt );

    public class AEffectWrapper {
        public AEffect aeffect;

        private AEffectDispatcherProc dispatcherProc = null;
        private AEffectProcessProc processProc = null;
        private AEffectSetParameterProc setParameterProc = null;
        private AEffectGetParameterProc getParameterProc = null;
        private AEffectProcessProc processReplacingProc = null;
        private AEffectProcessDoubleProc processDoubleReplacingProc = null;

        /// <summary>
        /// Host to Plug-in dispatcher @see AudioEffect::dispatcher
        /// </summary>
        public VstIntPtr Dispatch( VstInt32 opcode, VstInt32 index, VstIntPtr value, IntPtr ptr, float opt ) {
            if ( dispatcherProc == null && aeffect.dispatcher != IntPtr.Zero ) {
                dispatcherProc = (AEffectDispatcherProc)Marshal.GetDelegateForFunctionPointer( aeffect.dispatcher, typeof( AEffectDispatcherProc ) );
            }
            VstIntPtr ret = 0;
            try {
                if ( dispatcherProc != null ) {
                    ret = dispatcherProc( ref aeffect, opcode, index, value, ptr, opt );
                }
            } catch ( Exception ex ) {
                Console.Error.WriteLine( "AEffectWrapper#Dispatch; ex=" + ex );
            }
            return ret;
        }

        /// <summary>
        /// deprecated Accumulating process mode is deprecated in VST 2.4! Use AEffect::processReplacing instead!
        /// </summary>
        public void __ProcessDeprecated( IntPtr inputs, IntPtr outputs, VstInt32 sampleFrames ) {
            if ( processProc == null && aeffect.__processDeprecated != IntPtr.Zero ) {
                processProc = (AEffectProcessProc)Marshal.GetDelegateForFunctionPointer( aeffect.__processDeprecated, typeof( AEffectProcessProc ) );
            }
            try {
                if ( processProc != null ) {
                    processProc( ref aeffect, inputs, outputs, sampleFrames );
                }
            } catch ( Exception ex ) {
                Console.Error.WriteLine( "AEffect#__ProcessDeprecated; ex=" + ex );
            }
        }

        /// <summary>
        /// Set new value of automatable parameter @see AudioEffect::setParameter
        /// </summary>
        public void SetParameter( VstInt32 index, float parameter ) {
            if ( setParameterProc == null && aeffect.setParameter != IntPtr.Zero ) {
                setParameterProc = (AEffectSetParameterProc)Marshal.GetDelegateForFunctionPointer( aeffect.setParameter, typeof( AEffectSetParameterProc ) );
            }
            try {
                if ( setParameterProc != null ) {
                    setParameterProc( ref aeffect, index, parameter );
                }
            } catch ( Exception ex ) {
                Console.Error.WriteLine( "AEffect#SetParameter; ex=" + ex );
            }
        }

        /// <summary>
        /// Returns current value of automatable parameter @see AudioEffect::getParameter
        /// </summary>
        public float GetParameter( VstInt32 index ) {
            if ( getParameterProc == null && aeffect.getParameter != IntPtr.Zero ) {
                getParameterProc = (AEffectGetParameterProc)Marshal.GetDelegateForFunctionPointer( aeffect.getParameter, typeof( AEffectGetParameterProc ) );
            }
            float ret = 0.0f;
            try {
                if ( getParameterProc != null ) {
                    ret = getParameterProc( ref aeffect, index );
                }
            } catch ( Exception ex ) {
                Console.Error.WriteLine( "AEffect#GetParameter; ex=" + ex );
            }
            return ret;
        }

        /// <summary>
        /// Process audio samples in replacing mode @see AudioEffect::processReplacing
        /// </summary>
        public void ProcessReplacing( IntPtr inputs, IntPtr outputs, VstInt32 sampleFrames ) {
            if ( processReplacingProc == null && aeffect.processReplacing != IntPtr.Zero ) {
                processReplacingProc = (AEffectProcessProc)Marshal.GetDelegateForFunctionPointer( aeffect.processReplacing, typeof( AEffectProcessProc ) );
            }
            try {
                if ( processReplacingProc != null ) {
                    processReplacingProc( ref aeffect, inputs, outputs, sampleFrames );
                }
            } catch ( Exception ex ) {
                Console.Error.WriteLine( "AEffect#ProcessReplacing; ex=" + ex );
            }
        }

#if VST_2_4_EXTENSIONS
        /// <summary>
        /// Process double-precision audio samples in replacing mode @see AudioEffect::processDoubleReplacing
        /// </summary>
        /// <param name="inputs"></param>
        /// <param name="outputs"></param>
        /// <param name="sampleFrames"></param>
        public void ProcessDoubleReplacing( IntPtr inputs, IntPtr outputs, VstInt32 sampleFrames ) {
            if ( processDoubleReplacingProc == null && aeffect.processDoubleReplacing != IntPtr.Zero ) {
                processDoubleReplacingProc = (AEffectProcessDoubleProc)Marshal.GetDelegateForFunctionPointer( aeffect.processDoubleReplacing, typeof( AEffectProcessDoubleProc ) );
            }
            try {
                if ( processDoubleReplacingProc != null ) {
                    processDoubleReplacingProc( ref aeffect, inputs, outputs, sampleFrames );
                }
            } catch ( Exception ex ) {
                Console.Error.WriteLine( "AEffect#ProcessDoubleReplacing; ex=" + ex );
            }
        }
#endif
    }

    [StructLayout( LayoutKind.Sequential, Pack = 1 )]
    public struct AEffect {
        /// <summary>
        /// must be #kEffectMagic ('VstP')
        /// </summary>
        public VstInt32 magic;
        public IntPtr dispatcher;
        public IntPtr __processDeprecated;
        public IntPtr setParameter;
        public IntPtr getParameter;
        /// <summary>
        /// number of programs
        /// </summary>
        public VstInt32 numPrograms;
        /// <summary>
        /// all programs are assumed to have numParams parameters
        /// </summary>
        public VstInt32 numParams;
        /// <summary>
        /// number of audio inputs
        /// </summary>
        public VstInt32 numInputs;
        /// <summary>
        /// number of audio outputs
        /// </summary>
        public VstInt32 numOutputs;

        /// <summary>
        /// @see VstAEffectFlags
        /// </summary>
        public VstInt32 flags;

        /// <summary>
        /// reserved for Host, must be 0
        /// </summary>
        public VstIntPtr resvd1;
        /// <summary>
        /// reserved for Host, must be 0
        /// </summary>
        public VstIntPtr resvd2;

        /// <summary>
        /// for algorithms which need input in the first place (Group delay or latency in Samples). This value should be initialized in a resume state.
        /// </summary>
        public VstInt32 initialDelay;

        /// <summary>
        /// unused member
        /// </summary>
        [Obsolete]
        public VstInt32 __realQualitiesDeprecated;
        /// <summary>
        /// unused member
        /// </summary>
        [Obsolete]
        public VstInt32 __offQualitiesDeprecated;
        /// <summary>
        /// unused member
        /// </summary>
        [Obsolete]
        public float __ioRatioDeprecated;

        /// <summary>
        /// #AudioEffect class pointer
        /// </summary>
        public IntPtr obj;
        /// <summary>
        /// user-defined pointer
        /// </summary>
        public IntPtr user;

        /// <summary>
        /// registered unique identifier (register it at Steinberg 3rd party support Web). This is used to identify a plug-in during save+load of preset and project.
        /// </summary>
        public VstInt32 uniqueID;
        /// <summary>
        /// plug-in version (example 1100 for version 1.1.0.0)
        /// </summary>
        public VstInt32 version;

        public IntPtr processReplacing;

#if VST_2_4_EXTENSIONS
        public IntPtr processDoubleReplacing;

        /// <summary>
        /// reserved for future use (please zero)
        /// </summary>
        public byte future01;
        public byte future02;
        public byte future03;
        public byte future04;
        public byte future05;
        public byte future06;
        public byte future07;
        public byte future08;
        public byte future09;
        public byte future10;
        public byte future11;
        public byte future12;
        public byte future13;
        public byte future14;
        public byte future15;
        public byte future16;
        public byte future17;
        public byte future18;
        public byte future19;
        public byte future20;
        public byte future21;
        public byte future22;
        public byte future23;
        public byte future24;
        public byte future25;
        public byte future26;
        public byte future27;
        public byte future28;
        public byte future29;
        public byte future30;
        public byte future31;
        public byte future32;
        public byte future33;
        public byte future34;
        public byte future35;
        public byte future36;
        public byte future37;
        public byte future38;
        public byte future39;
        public byte future40;
        public byte future41;
        public byte future42;
        public byte future43;
        public byte future44;
        public byte future45;
        public byte future46;
        public byte future47;
        public byte future48;
        public byte future49;
        public byte future50;
        public byte future51;
        public byte future52;
        public byte future53;
        public byte future54;
        public byte future55;
        public byte future56;
#else
        /// <summary>
        /// reserved for future use (please zero)
        /// </summary>
        public byte future01;
        public byte future02;
        public byte future03;
        public byte future04;
        public byte future05;
        public byte future06;
        public byte future07;
        public byte future08;
        public byte future09;
        public byte future10;
        public byte future11;
        public byte future12;
        public byte future13;
        public byte future14;
        public byte future15;
        public byte future16;
        public byte future17;
        public byte future18;
        public byte future19;
        public byte future20;
        public byte future21;
        public byte future22;
        public byte future23;
        public byte future24;
        public byte future25;
        public byte future26;
        public byte future27;
        public byte future28;
        public byte future29;
        public byte future30;
        public byte future31;
        public byte future32;
        public byte future33;
        public byte future34;
        public byte future35;
        public byte future36;
        public byte future37;
        public byte future38;
        public byte future39;
        public byte future40;
        public byte future41;
        public byte future42;
        public byte future43;
        public byte future44;
        public byte future45;
        public byte future46;
        public byte future47;
        public byte future48;
        public byte future49;
        public byte future50;
        public byte future51;
        public byte future52;
        public byte future53;
        public byte future54;
        public byte future55;
        public byte future56;
        public byte future57;
        public byte future58;
        public byte future59;
        public byte future60;
#endif
    }

    /// <summary>
    /// A generic timestamped event.
    /// </summary>
    [StructLayout( LayoutKind.Sequential, Pack = 1 )]
    public unsafe struct VstEvent {
        /// <summary>
        /// @see VstEventTypes
        /// </summary>
        public VstInt32 type;
        /// <summary>
        /// size of this event, excl. type and byteSize
        /// </summary>
        public VstInt32 byteSize;
        /// <summary>
        /// sample frames related to the current block start sample position
        /// </summary>
        public VstInt32 deltaFrames;
        /// <summary>
        /// generic flags, none defined yet
        /// </summary>
        public VstInt32 flags;
        /// <summary>
        /// data size may vary, depending on event type
        /// </summary>
        public fixed byte data[16];
    }

    public static class VstEventTypes {
        /// <summary>
        /// MIDI event  @see VstMidiEvent
        /// </summary>
        public const int kVstMidiType = 1;
        /// <summary>
        /// unused event type
        /// </summary>
        [Obsolete]
        public const int __kVstAudioTypeDeprecated = 2;
        /// <summary>
        /// unused event type
        /// </summary>
        [Obsolete]
        public const int __kVstVideoTypeDeprecated = 3;
        /// <summary>
        /// unused event type
        /// </summary>
        [Obsolete]
        public const int __kVstParameterTypeDeprecated = 4;
        /// <summary>
        /// unused event type
        /// </summary>
        [Obsolete]
        public const int __kVstTriggerTypeDeprecated = 5;
        /// <summary>
        /// MIDI system exclusive  @see VstMidiSysexEvent
        /// </summary>
        public const int kVstSysExType = 6;
    }

    /// <summary>
    /// A block of events for the current processed audio block.
    /// </summary>
    [StructLayout( LayoutKind.Sequential, Pack = 1 )]
    public unsafe struct VstEvents {
        const int MAX_VST_EVENTS = 1024;
        /// <summary>
        /// number of Events in array
        /// </summary>
        public VstInt32 numEvents;
        /// <summary>
        /// zero (Reserved for future use)
        /// </summary>
        public VstIntPtr reserved;
        //[MarshalAs( UnmanagedType.ByValArray, SizeConst = MAX_VST_EVENTS )]
        /// <summary>
        /// event pointer array, variable size
        /// </summary>
        public fixed int events[MAX_VST_EVENTS];
    }

    /// <summary>
    /// MIDI Event (to be casted from VstEvent).
    /// </summary>
    [StructLayout( LayoutKind.Sequential, Pack = 1 )]
    public unsafe struct VstMidiEvent {
        /// <summary>
        /// #kVstMidiType
        /// </summary>
        public VstInt32 type;
        /// <summary>
        /// sizeof (VstMidiEvent)
        /// </summary>
        public VstInt32 byteSize;
        /// <summary>
        /// sample frames related to the current block start sample position
        /// </summary>
        public VstInt32 deltaFrames;
        /// <summary>
        /// @see VstMidiEventFlags
        /// </summary>
        public VstInt32 flags;
        /// <summary>
        /// (in sample frames) of entire note, if available, else 0
        /// </summary>
        public VstInt32 noteLength;
        /// <summary>
        /// offset (in sample frames) into note from note start if available, else 0
        /// </summary>
        public VstInt32 noteOffset;
        /// <summary>
        /// 1 to 3 MIDI bytes; midiData[3] is reserved (zero)
        /// </summary>
        public fixed byte midiData[4];
        /// <summary>
        /// -64 to +63 cents; for scales other than 'well-tempered' ('microtuning')
        /// </summary>
        public byte detune;
        /// <summary>
        /// Note Off Velocity [0, 127]
        /// </summary>
        public byte noteOffVelocity;
        /// <summary>
        /// zero (Reserved for future use)
        /// </summary>
        public byte reserved1;
        /// <summary>
        /// zero (Reserved for future use)
        /// </summary>
        public byte reserved2;
    }

    [StructLayout( LayoutKind.Sequential, Pack = 1 )]
    public struct ERect {
        /// <summary>
        /// top coordinate
        /// </summary>
        public VstInt16 top;
        /// <summary>
        /// left coordinate
        /// </summary>
        public VstInt16 left;
        /// <summary>
        /// bottom coordinate
        /// </summary>
        public VstInt16 bottom;
        /// <summary>
        /// right coordinate
        /// </summary>
        public VstInt16 right;

        public override String ToString() {
            return "{top=" + top + ", left=" + left + ", bottom=" + bottom + ", right=" + right + "}";
        }
    }
    #endregion

}
#endif