1 //-----------------------------------------------------------------------------
2 // LICENSE
3 // (c) 2005, Steinberg Media Technologies GmbH, All Rights Reserved
4 // (c) 2018, Guillaume Piolat (contact@auburnsounds.com)
5 //-----------------------------------------------------------------------------
6 //
7 // This Software Development Kit is licensed under the terms of the General
8 // Public License (GPL) Version 3.
9 //
10 // This source is part of the "Auburn Sounds (Guillaume Piolat) extension to the 
11 // Steinberg VST 3 Plug-in SDK".
12 //
13 // Details of that license can be found at: www.gnu.org/licenses/gpl-3.0.html
14 //
15 // Dual-licence:
16 // 
17 // The "Auburn Sounds (Guillaume Piolat) extension to the Steinberg VST 3 Plug-in
18 // SDK", hereby referred to as DPLUG:VST3, is a language translation of the VST3 
19 // SDK suitable for usage in Dplug. Any Licensee of a currently valid Steinberg 
20 // VST 3 Plug-In SDK Licensing Agreement (version 2.2.4 or ulterior, hereby referred
21 // to as the AGREEMENT), is granted by Auburn Sounds (Guillaume Piolat) a non-exclusive, 
22 // worldwide, nontransferable license during the term the AGREEMENT to use parts
23 // of DPLUG:VST3 not covered by the AGREEMENT, as if they were originally 
24 // inside the Licensed Software Developer Kit mentionned in the AGREEMENT. 
25 // Under this licence all conditions that apply to the Licensed Software Developer 
26 // Kit also apply to DPLUG:VST3.
27 //
28 //-----------------------------------------------------------------------------
29 module dplug.vst3.ivstcomponent;
30 
31 version(VST3):
32 
33 import dplug.vst3.ftypes;
34 import dplug.vst3.ipluginbase;
35 import dplug.vst3.ibstream;
36 
37 
38 
39 /** \defgroup vstBus VST Buses
40 Bus Description
41 
42 A bus can be understood as a "collection of data channels" belonging together.
43 It describes a data input or a data output of the Plug-in.
44 A VST component can define any desired number of buses, but this number must \b never change.
45 Dynamic usage of buses is handled in the host by activating and deactivating buses.
46 The component has to define the maximum number of supported buses and it has to
47 define which of them are active by default. A host that can handle multiple buses,
48 allows the user to activate buses that were initially inactive.
49 
50 See also: IComponent::getBusInfo, IComponent::activateBus
51 
52 @{*/
53 
54 /** Bus media types */
55 alias MediaTypes = int;
56 enum : MediaTypes
57 {
58     kAudio = 0,     ///< audio
59     kEvent,         ///< events
60     kNumMediaTypes
61 }
62 
63 /** Bus directions */
64 enum : BusDirection
65 {
66     kInput = 0,     ///< input bus
67     kOutput         ///< output bus
68 }
69 
70 /** Bus types */
71 alias BusTypes = int;
72 enum : BusTypes
73 {
74     kMain = 0,      ///< main bus
75     kAux            ///< auxiliary bus (sidechain)
76 }
77 
78 /** BusInfo:
79 This is the structure used with getBusInfo, informing the host about what is a specific given bus.
80 \n See also: IComponent::getBusInfo */
81 struct BusInfo
82 {
83 nothrow:
84 @nogc:
85     MediaType mediaType;    ///< Media type - has to be a value of \ref MediaTypes
86     BusDirection direction; ///< input or output \ref BusDirections
87     int32 channelCount;     ///< number of channels (if used then need to be recheck after \ref
88                             /// IAudioProcessor::setBusArrangements is called).
89                             /// For a bus of type MediaTypes::kEvent the channelCount corresponds
90                             /// to the number of supported MIDI channels by this bus
91     String128 name;         ///< name of the bus
92     BusType busType;        ///< main or aux - has to be a value of \ref BusTypes
93     uint32 flags;           ///< flags - a combination of \ref BusFlags
94     enum BusFlags
95     {
96         kDefaultActive = 1 << 0 ///< bus active per default
97     }
98 
99     void setName(wstring newName)
100     {
101         name[] = '\0';
102         int len = cast(int)(newName.length);
103         if (len > 127) len = 127;
104         name[0..len] = newName[0..len];
105     }
106 }
107 
108 mixin SMTG_TYPE_SIZE_CHECK!(BusInfo, 276, 276, 276);
109 
110 /** I/O modes */
111 alias IoModes = int;
112 enum : IoModes
113 {
114     kSimple = 0,        ///< 1:1 Input / Output. Only used for Instruments. See \ref vst3IoMode
115     kAdvanced,          ///< n:m Input / Output. Only used for Instruments.
116     kOfflineProcessing  ///< Plug-in used in an offline processing context
117 }
118 
119 /** Routing Information:
120 When the Plug-in supports multiple I/O buses, a host may want to know how the buses are related. The
121 relation of an event-input-channel to an audio-output-bus in particular is of interest to the host
122 (in order to relate MIDI-tracks to audio-channels)
123 \n See also: IComponent::getRoutingInfo, \ref vst3Routing */
124 struct RoutingInfo
125 {
126     MediaType mediaType;    ///< media type see \ref MediaTypes
127     int32 busIndex;         ///< bus index
128     int32 channel;          ///< channel (-1 for all channels)
129 }
130 
131 mixin SMTG_TYPE_SIZE_CHECK!(RoutingInfo, 12, 12, 12);
132 
133 // IComponent Interface
134 /** Component Base Interface
135 \ingroup vstIPlug vst300
136 - [plug imp]
137 - [released: 3.0.0]
138 - [mandatory]
139 
140 This is the basic interface for a VST component and must always be supported.
141 It contains the common parts of any kind of processing class. The parts that
142 are specific to a media type are defined in a separate interface. An implementation
143 component must provide both the specific interface and IComponent.
144 */
145 interface IComponent: IPluginBase
146 {
147 public:
148 nothrow:
149 @nogc:
150     /** Called before initializing the component to get information about the controller class. */
151     tresult getControllerClassId (TUID* classId);
152 
153     /** Called before 'initialize' to set the component usage (optional). See \ref IoModes */
154     tresult setIoMode (IoMode mode);
155 
156     /** Called after the Plug-in is initialized. See \ref MediaTypes, BusDirections */
157     int32 getBusCount (MediaType type, BusDirection dir);
158 
159     /** Called after the Plug-in is initialized. See \ref MediaTypes, BusDirections */
160     tresult getBusInfo (MediaType type, BusDirection dir, int32 index, ref BusInfo bus /*out*/);
161 
162     /** Retrieves routing information (to be implemented when more than one regular input or output bus exists).
163         The inInfo always refers to an input bus while the returned outInfo must refer to an output bus! */
164     tresult getRoutingInfo (ref RoutingInfo inInfo, ref RoutingInfo outInfo /*out*/);
165 
166     /** Called upon (de-)activating a bus in the host application. The Plug-in should only processed an activated bus,
167         the host could provide less see \ref AudioBusBuffers in the process call (see \ref IAudioProcessor::process) if last buses are not activated */
168     tresult activateBus (MediaType type, BusDirection dir, int32 index, TBool state);
169 
170     /** Activates / deactivates the component. */
171     tresult setActive (TBool state);
172 
173     /** Sets complete state of component. */
174     tresult setState (IBStream state);
175 
176     /** Retrieves complete state of component. */
177     tresult getState (IBStream state);
178 
179     __gshared immutable TUID iid = INLINE_UID(0xE831FF31, 0xF2D54301, 0x928EBBEE, 0x25697802);
180 }
181