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