Last active
September 24, 2018 04:18
-
-
Save ShigekiKarita/f1f946f03530419aa8250e0fcc3b9f88 to your computer and use it in GitHub Desktop.
D言語でVST/AUプラグイン開発1 (環境構築・検証編) ref: https://qiita.com/ShigekiKarita/items/e67d26b4cfaffd648033
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # powershell | |
| set-item env:VST2_SDK C:\Users\skarita\Downloads\vstsdk3610_11_06_2018_build_37\VST_SDK\VST2_SDK |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git clone https://github.com/AuburnSounds/Dplug -b 7.1.2 | |
| cd Dplug/examples/ms-encode | |
| dub build --arch=x86 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| Copyright: Guillaume Piolat 2015-2017. | |
| License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) | |
| */ | |
| import std.math; | |
| import dplug.core, dplug.client, dplug.vst; | |
| /** VST用のボイラープレートを挿入 */ | |
| // This create the DLL entry point | |
| mixin(DLLEntryPoint!()); | |
| // This create the VST entry point | |
| mixin(VSTEntryPoint!MSEncode); | |
| enum : int { paramOnOff } // パラメータの識別子 | |
| /// あなたが作れる最もシンプルなVSTプラグイン | |
| final class MSEncode : dplug.client.Client { | |
| public: | |
| /// (必須) | |
| override PluginInfo buildPluginInfo() | |
| { | |
| // PluginInfoはplugin.jsonをコンパイル時にパースして作る | |
| // 設定は一か所にまとめる方がよい、手動の初期化はお勧めしない | |
| static immutable PluginInfo pluginInfo = parsePluginInfo(import("plugin.json")); | |
| return pluginInfo; | |
| } | |
| /// (オプション) Parameter の構築 | |
| /// 返り値のメモリ確保は GC による new ではなく、mallocによるメモリ確保をしなくてはいけない | |
| /// GC管理ではないのでメモリ開放は手動でfreeするか、dplug.core.vec.Vecにfreeを任せる | |
| /// std::vector相当の型 https://github.com/AuburnSounds/Dplug/blob/v7.1.2/core/dplug/core/vec.d | |
| /// malloc系の関数 https://github.com/AuburnSounds/Dplug/blob/v7.1.2/core/dplug/core/nogc.d | |
| override Parameter[] buildParameters() | |
| { | |
| // DAWのGUIで「on/off」というパラメータを表示 | |
| auto params = makeVec!Parameter(); | |
| params.pushBack( mallocNew!BoolParameter(paramOnOff, "on/off", true) ); | |
| return params.releaseData(); | |
| } | |
| /// (必須) IO組み合わせが対応していると通知するメソッド。ここでも返り値にGCを使ってはいけない | |
| override LegalIO[] buildLegalIO() | |
| { | |
| auto io = makeVec!LegalIO(); | |
| io.pushBack(LegalIO(2, 2)); // 2in-2out のみ対応 | |
| return io.releaseData(); | |
| } | |
| /// (必須) 状態(例:リサイズや遅延線)や確保したバッファのクリアに使う | |
| /// 重要:オーディオ用スレッドから呼ばれるのでGCを使ってはいけない (nothrow, nogc) | |
| override void reset(double sampleRate, int maxFrames, int numInputs, int numOutputs) nothrow @nogc | |
| { | |
| } | |
| /// (必須) オーディオ処理を行うメソッド | |
| /// float*ポインタはプラグインがlegalIOとしたチャネルで正常なポインタであることが保証され、未接続のチャネルもゼロ埋めされる | |
| /// framesは最後にreset()が呼ばれたとき以上の値をとることが保証される | |
| /// inputsとoutputsは最後にreset()が呼ばれたときと全く同じであることが保証される | |
| /// 警告 outputs のポインタを変更してはいけない (値のみを変更する) | |
| override void processAudio(const(float*)[] inputs, float*[]outputs, int frames, TimeInfo info) nothrow @nogc | |
| { | |
| if (readBoolParamValue(paramOnOff)) // MS処理をするとき | |
| { | |
| // M チャンネル、パワーをLRのときと同じにするために 1/sqrt(2) 倍している | |
| outputs[0][0..frames] = ( (inputs[0][0..frames] + inputs[1][0..frames]) ) * SQRT1_2; | |
| // S チャンネル | |
| outputs[1][0..frames] = ( (inputs[0][0..frames] - inputs[1][0..frames]) ) * SQRT1_2; | |
| } | |
| else // 普通にLRをバイパスするとき (注意:ポインタを付け替えてはいけない、愚直にコピーする) | |
| { | |
| outputs[0][0..frames] = inputs[0][0..frames]; | |
| outputs[1][0..frames] = inputs[1][0..frames]; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git clone https://github.com/AuburnSounds/Dplug -b 7.1.2 | |
| cd Dplug/examples/ms-encode | |
| dub build --arch=x86 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| Copyright: Guillaume Piolat 2015-2017. | |
| License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) | |
| */ | |
| import std.math; | |
| import dplug.core, dplug.client, dplug.vst; | |
| /** VST用のボイラープレートを挿入 */ | |
| // This create the DLL entry point | |
| mixin(DLLEntryPoint!()); | |
| // This create the VST entry point | |
| mixin(VSTEntryPoint!MSEncode); | |
| enum : int { paramOnOff } // パラメータの識別子 | |
| /// あなたが作れる最もシンプルなVSTプラグイン | |
| final class MSEncode : dplug.client.Client { | |
| public: | |
| /// (必須) | |
| override PluginInfo buildPluginInfo() | |
| { | |
| // PluginInfoはplugin.jsonをコンパイル時にパースして作る | |
| // 設定は一か所にまとめる方がよい、手動の初期化はお勧めしない | |
| static immutable PluginInfo pluginInfo = parsePluginInfo(import("plugin.json")); | |
| return pluginInfo; | |
| } | |
| /// (オプション) Parameter の構築 | |
| /// 返り値のメモリ確保は GC による new ではなく、mallocによるメモリ確保をしなくてはいけない | |
| /// GC管理ではないのでメモリ開放は手動でfreeするか、dplug.core.vec.Vecにfreeを任せる | |
| /// std::vector相当の型 https://github.com/AuburnSounds/Dplug/blob/v7.1.2/core/dplug/core/vec.d | |
| /// malloc系の関数 https://github.com/AuburnSounds/Dplug/blob/v7.1.2/core/dplug/core/nogc.d | |
| override Parameter[] buildParameters() | |
| { | |
| // DAWのGUIで「on/off」というパラメータを表示 | |
| auto params = makeVec!Parameter(); | |
| params.pushBack( mallocNew!BoolParameter(paramOnOff, "on/off", true) ); | |
| return params.releaseData(); | |
| } | |
| /// (必須) IO組み合わせが対応していると通知するメソッド。ここでも返り値にGCを使ってはいけない | |
| override LegalIO[] buildLegalIO() | |
| { | |
| auto io = makeVec!LegalIO(); | |
| io.pushBack(LegalIO(2, 2)); // 2in-2out のみ対応 | |
| return io.releaseData(); | |
| } | |
| /// (必須) 状態(例:リサイズや遅延線)や確保したバッファのクリアに使う | |
| /// 重要:オーディオ用スレッドから呼ばれるのでGCを使ってはいけない (nothrow, nogc) | |
| override void reset(double sampleRate, int maxFrames, int numInputs, int numOutputs) nothrow @nogc | |
| { | |
| } | |
| /// (必須) オーディオ処理を行うメソッド | |
| /// float*ポインタはプラグインがlegalIOとしたチャネルで正常なポインタであることが保証され、未接続のチャネルもゼロ埋めされる | |
| /// framesは最後にreset()が呼ばれたとき以上の値をとることが保証される | |
| /// inputsとoutputsは最後にreset()が呼ばれたときと全く同じであることが保証される | |
| /// 警告 outputs のポインタを変更してはいけない (値のみを変更する) | |
| override void processAudio(const(float*)[] inputs, float*[]outputs, int frames, TimeInfo info) nothrow @nogc | |
| { | |
| if (readBoolParamValue(paramOnOff)) // MS処理をするとき | |
| { | |
| // M チャンネル、パワーをLRのときと同じにするために 1/sqrt(2) 倍している | |
| outputs[0][0..frames] = ( (inputs[0][0..frames] + inputs[1][0..frames]) ) * SQRT1_2; | |
| // S チャンネル | |
| outputs[1][0..frames] = ( (inputs[0][0..frames] - inputs[1][0..frames]) ) * SQRT1_2; | |
| } | |
| else // 普通にLRをバイパスするとき (注意:ポインタを付け替えてはいけない、愚直にコピーする) | |
| { | |
| outputs[0][0..frames] = inputs[0][0..frames]; | |
| outputs[1][0..frames] = inputs[1][0..frames]; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/dub.json b/dub.json | |
| index 6509441..9200d46 100644 | |
| --- a/dub.json | |
| +++ b/dub.json | |
| @@ -99,7 +99,7 @@ | |
| "name": "vst", | |
| "sourcePaths": [ "vst/dplug/vst" ], | |
| "importPaths": [ "vst" ], | |
| - "stringImportPaths": [ "$VST2_SDK/pluginterfaces/vst2.x" ], | |
| + "dflags": ["-J$VST2_SDK/pluginterfaces/vst2.x"], | |
| "dependencies": { | |
| "dplug:client": "*" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| // 仕様 | |
| "$schema": "https://raw.githubusercontent.com/AuburnSounds/dplug/master/plugin-schema.json", | |
| // ベンダーの名前 | |
| "vendorName": "No Name Audio", | |
| // 4文字のユニークなベンダーID | |
| "vendorUniqueID": "NoAu", | |
| // プラグインの名前 | |
| "pluginName": "MSEncodator", | |
| // 4文字のユニークなプラグインID、互換性が破壊されたときは変更する必要がある | |
| "pluginUniqueID": "NAms", | |
| // majorバージョンが一致する場合は互換性がなくてはならない | |
| "publicVersion": "1.0.0", | |
| // OSX用の何らかの設定 | |
| "CFBundleIdentifierPrefix": "com.nonameaudio", | |
| // GUIの有無 | |
| "hasGUI": false, | |
| // VSTインストルメントかどうか | |
| "isSynth": false, | |
| // MIDI入力をとるか | |
| "receivesMIDI": false, | |
| // プラグインのカテゴリ。列挙値はschemaを見る | |
| "category": "effectImaging" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mixin(DLLEntryPoint!()); | |
| version(VST) | |
| { | |
| import dplug.vst; | |
| mixin(VSTEntryPoint!ClipitClient); | |
| } | |
| version(AU) | |
| { | |
| import dplug.au; | |
| mixin(AUEntryPoint!ClipitClient); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| // 仕様 | |
| "$schema": "https://raw.githubusercontent.com/AuburnSounds/dplug/master/plugin-schema.json", | |
| // ベンダーの名前 | |
| "vendorName": "No Name Audio", | |
| // 4文字のユニークなベンダーID | |
| "vendorUniqueID": "NoAu", | |
| // プラグインの名前 | |
| "pluginName": "MSEncodator", | |
| // 4文字のユニークなプラグインID、互換性が破壊されたときは変更する必要がある | |
| "pluginUniqueID": "NAms", | |
| // majorバージョンが一致する場合は互換性がなくてはならない | |
| "publicVersion": "1.0.0", | |
| // OSX用の何らかの設定 | |
| "CFBundleIdentifierPrefix": "com.nonameaudio", | |
| // GUIの有無 | |
| "hasGUI": false, | |
| // VSTインストルメントかどうか | |
| "isSynth": false, | |
| // MIDI入力をとるか | |
| "receivesMIDI": false, | |
| // プラグインのカテゴリ。列挙値はschemaを見る | |
| "category": "effectImaging" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| // 仕様 | |
| "$schema": "https://raw.githubusercontent.com/AuburnSounds/dplug/master/plugin-schema.json", | |
| // ベンダーの名前 | |
| "vendorName": "No Name Audio", | |
| // 4文字のユニークなベンダーID | |
| "vendorUniqueID": "NoAu", | |
| // プラグインの名前 | |
| "pluginName": "MSEncodator", | |
| // 4文字のユニークなプラグインID、互換性が破壊されたときは変更する必要がある | |
| "pluginUniqueID": "NAms", | |
| // majorバージョンが一致する場合は互換性がなくてはならない | |
| "publicVersion": "1.0.0", | |
| // OSX用の何らかの設定 | |
| "CFBundleIdentifierPrefix": "com.nonameaudio", | |
| // GUIの有無 | |
| "hasGUI": false, | |
| // VSTインストルメントかどうか | |
| "isSynth": false, | |
| // MIDI入力をとるか | |
| "receivesMIDI": false, | |
| // プラグインのカテゴリ。列挙値はschemaを見る | |
| "category": "effectImaging" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment