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.ivstunit;
30 
31 version(VST3):
32 
33 import dplug.vst3.ftypes;
34 import dplug.vst3.ibstream;
35 
36 
37 enum UnitID kRootUnitId = 0;        ///< identifier for the top level unit (root)
38 enum UnitID kNoParentUnitId = -1;   ///< used for the root unit which doesn't have a parent.
39 
40 /** Special ProgramListIDs for UnitInfo */
41 enum ProgramListID kNoProgramListId = -1;   ///< no programs are used in the unit.
42 
43 /** Basic Unit Description.
44 \see IUnitInfo */
45 struct UnitInfo
46 {
47     UnitID id;                      ///< unit identifier
48     UnitID parentUnitId;            ///< identifier of parent unit (kNoParentUnitId: does not apply, this unit is the root)
49     String128 name;                 ///< name, optional for the root component, required otherwise
50     ProgramListID programListId;    ///< id of program list used in unit (kNoProgramListId = no programs used in this unit)
51 }
52 
53 mixin SMTG_TYPE_SIZE_CHECK!(UnitInfo, 268, 268, 268);
54 
55 /** Basic Program List Description.
56 \see IUnitInfo */
57 struct ProgramListInfo
58 {
59     ProgramListID id;               ///< program list identifier
60     String128 name;                 ///< name of program list
61     int32 programCount;             ///< number of programs in this list
62 }
63 
64 mixin SMTG_TYPE_SIZE_CHECK!(ProgramListInfo, 264, 264, 264);
65 
66 /** Special programIndex value for IUnitHandler::notifyProgramListChange */
67 enum int32 kAllProgramInvalid = -1;     ///< all program information is invalid
68 
69 /** Host callback for unit support.
70 \ingroup vstIHost vst300
71 - [host imp]
72 - [extends IComponentHandler]
73 - [released: 3.0.0]
74 
75 Host callback interface, used with IUnitInfo.
76 Retrieve via queryInterface from IComponentHandler.
77 
78 \see \ref vst3Units, IUnitInfo */
79 interface IUnitHandler: FUnknown
80 {
81 public:
82 nothrow:
83 @nogc:
84     /** Notify host when a module is selected in Plug-in GUI. */
85     tresult notifyUnitSelection (UnitID unitId);
86 
87     /** Tell host that the Plug-in controller changed a program list (rename, load, PitchName changes).
88         \param listId is the specified program list ID to inform.
89         \param programIndex : when kAllProgramInvalid, all program information is invalid, otherwise only the program of given index. */
90     tresult notifyProgramListChange (ProgramListID listId, int32 programIndex);
91 
92     __gshared immutable TUID iid = INLINE_UID( 0x4B5147F8, 0x4654486B, 0x8DAB30BA, 0x163A3C56);
93 }
94 
95 
96 /** Edit controller extension to describe the Plug-in structure.
97 \ingroup vstIPlug vst300
98 - [plug imp]
99 - [extends IEditController]
100 - [released: 3.0.0]
101 
102 IUnitInfo describes the internal structure of the Plug-in.
103 - The root unit is the component itself, so getUnitCount must return 1 at least.
104 - The root unit id has to be 0 (kRootUnitId).
105 - Each unit can reference one program list - this reference must not change.
106 - Each unit using a program list, references one program of the list.
107 
108 \see \ref vst3Units, IUnitHandler */
109 interface IUnitInfo: FUnknown
110 {
111 public:
112 nothrow:
113 @nogc:
114     /** Returns the flat count of units. */
115     int32 getUnitCount ();
116 
117     /** Gets UnitInfo for a given index in the flat list of unit. */
118     tresult getUnitInfo (int32 unitIndex, ref UnitInfo info /*out*/);
119 
120     /** Component intern program structure. */
121     /** Gets the count of Program List. */
122     int32 getProgramListCount ();
123 
124     /** Gets for a given index the Program List Info. */
125     tresult getProgramListInfo (int32 listIndex, ref ProgramListInfo info /*out*/);
126 
127     /** Gets for a given program list ID and program index its program name. */
128     tresult getProgramName (ProgramListID listId, int32 programIndex, String128* name /*out*/);
129 
130     /** Gets for a given program list ID, program index and attributeId the associated attribute value. */
131     tresult getProgramInfo (ProgramListID listId, int32 programIndex,
132         const(wchar)* attributeId /*in*/, String128* attributeValue /*out*/);
133 
134     /** Returns kResultTrue if the given program index of a given program list ID supports PitchNames. */
135     tresult hasProgramPitchNames (ProgramListID listId, int32 programIndex);
136 
137     /** Gets the PitchName for a given program list ID, program index and pitch.
138         If PitchNames are changed the Plug-in should inform the host with IUnitHandler::notifyProgramListChange. */
139     tresult getProgramPitchName (ProgramListID listId, int32 programIndex,
140         int16 midiPitch, String128* name /*out*/);
141 
142     // units selection --------------------
143     /** Gets the current selected unit. */
144     UnitID getSelectedUnit ();
145 
146     /** Sets a new selected unit. */
147     tresult selectUnit (UnitID unitId);
148 
149     /** Gets the according unit if there is an unambiguous relation between a channel or a bus and a unit.
150         This method mainly is intended to find out which unit is related to a given MIDI input channel. */
151     tresult getUnitByBus (MediaType type, BusDirection dir, int32 busIndex,
152         int32 channel, ref UnitID unitId /*out*/);
153 
154     /** Receives a preset data stream.
155         - If the component supports program list data (IProgramListData), the destination of the data
156           stream is the program specified by list-Id and program index (first and second parameter)
157         - If the component supports unit data (IUnitData), the destination is the unit specified by the first
158           parameter - in this case parameter programIndex is < 0). */
159     tresult setUnitProgramData (int32 listOrUnitId, int32 programIndex, IBStream data);
160 
161 
162     __gshared immutable TUID iid = INLINE_UID( 0x3D4BD6B5, 0x913A4FD2, 0xA886E768, 0xA5EB92C1);
163 }
164 
165 /+
166 
167 /** Component extension to access program list data.
168 \ingroup vstIPlug vst300
169 - [plug imp]
170 - [extends IComponent]
171 - [released: 3.0.0]
172 
173 A component can either support program list data via this interface or
174 unit preset data (IUnitData), but not both!
175 
176 \see \ref vst3UnitPrograms */
177 
178 class IProgramListData: public FUnknown
179 {
180 public:
181 
182     /** Returns kResultTrue if the given Program List ID supports Program Data. */
183     virtual tresult PLUGIN_API programDataSupported (ProgramListID listId) = 0;
184 
185     /** Gets for a given program list ID and program index the program Data. */
186     virtual tresult PLUGIN_API getProgramData (ProgramListID listId, int32 programIndex, IBStream* data) = 0;
187 
188     /** Sets for a given program list ID and program index a program Data. */
189     virtual tresult PLUGIN_API setProgramData (ProgramListID listId, int32 programIndex, IBStream* data) = 0;
190 
191 
192     static const FUID iid;
193 };
194 
195 DECLARE_CLASS_IID (IProgramListData, 0x8683B01F, 0x7B354F70, 0xA2651DEC, 0x353AF4FF)
196 
197 
198 /** Component extension to access unit data.
199 \ingroup vstIPlug vst300
200 - [plug imp]
201 - [extends IComponent]
202 - [released: 3.0.0]
203 
204 A component can either support unit preset data via this interface or
205 program list data (IProgramListData), but not both!
206 
207 \see \ref vst3UnitPrograms */
208 
209 class IUnitData: public FUnknown
210 {
211 public:
212 
213     /** Returns kResultTrue if the specified unit supports export and import of preset data. */
214     virtual tresult PLUGIN_API unitDataSupported (UnitID unitID) = 0;
215 
216     /** Gets the preset data for the specified unit. */
217     virtual tresult PLUGIN_API getUnitData (UnitID unitId, IBStream* data) = 0;
218 
219     /** Sets the preset data for the specified unit. */
220     virtual tresult PLUGIN_API setUnitData (UnitID unitId, IBStream* data) = 0;
221 
222 
223     static const FUID iid;
224 };
225 
226 DECLARE_CLASS_IID (IUnitData, 0x6C389611, 0xD391455D, 0xB870B833, 0x94A0EFDD)
227 
228 +/