Last active
October 3, 2018 13:44
-
-
Save ShigekiKarita/c54bc5b43f5b83c3a5990b621221c432 to your computer and use it in GitHub Desktop.
D言語でVST/AUプラグイン開発3 (GUI編) ref: https://qiita.com/ShigekiKarita/items/271ab246131526ae4c65
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
| module gui; | |
| import dplug.pbrwidgets; | |
| /** module dplug.pbrwidgets.pbrbackgroundgui に定義 | |
| class PBRBackgroundGUI(string baseColorPath, // 一番下にでてくるRGB背景画像(png/jpg) | |
| string emissivePath, // 光の強さを指定するグレー画像 | |
| string materialPath, // 金属っぽさを指定するグレー画像 | |
| string physicalPath, // 物理レンダリングの強さを指定するグレー画像 | |
| string depthPath, // 3Dっぽい質感を出すための深さを指定するグレー画像 | |
| string skyboxPath, // 反射光を作るときの向かい側の画像(空とか) | |
| string absoluteGfxDirectory) // デバッグ用の画像フォルダ指定 | |
| */ | |
| class SimpleDelayGUI : PBRBackgroundGUI!("black.png", "black.png", "black.png", | |
| "black.png", "black.png", "black.png", | |
| "") |
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
| override void reflow(box2i availableSpace) | |
| { | |
| _position = availableSpace; | |
| } |
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
| emacs -nw gui.d # GUIの編集 | |
| dub build --arch=x86_64 --compiler=dmd | |
| ~/Downloads/juce-5.3.2-windows/JUCE/extras/AudioPluginHost/Builds/VisualStudio2017/x64/Debug/App/AudioPluginHost.exe |
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: Shigeki Karita | |
| License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) | |
| */ | |
| module gui; | |
| import dplug.pbrwidgets : PBRBackgroundGUI; | |
| // pngはresourceフォルダに配置 | |
| class SimpleDelayGUI : PBRBackgroundGUI!("black.png", "black.png", "black.png", | |
| "black.png", "black.png", "black.png", | |
| "") | |
| { | |
| public nothrow @nogc: | |
| import gfm.math : box2i; | |
| import dplug.core : mallocNew, destroyFree; | |
| import dplug.gui : PBRCompositor; | |
| import dplug.pbrwidgets : Font, RGBA, UIKnob, UILabel; | |
| import dplug.client : Parameter, FloatParameter; | |
| import main : Param; | |
| Font _font; | |
| this(Parameter[] parameters...) | |
| { | |
| _font = mallocNew!Font(cast(ubyte[])( import("VeraBd.ttf") )); | |
| super(620, 200); // size | |
| PBRCompositor comp = cast(PBRCompositor)compositor; | |
| RGBA litTrailDiffuse = RGBA(151, 119, 255, 100); | |
| RGBA unlitTrailDiffuse = RGBA(81, 54, 108, 0); | |
| int marginW=10; | |
| int marginH=10; | |
| const n = cast(int) parameters.length; | |
| int w, h; | |
| this.getGUISize(&w, &h); | |
| const kW = (w - 2 * marginW) / n; | |
| const kH = h - 2 * marginH; | |
| foreach (int i, param; parameters) { | |
| auto p = cast(FloatParameter) param; | |
| const x = marginW + kW * i; | |
| // 物理レンダリングされるノブ | |
| UIKnob knob; | |
| addChild(knob = mallocNew!UIKnob(context(), p)); | |
| knob.position = box2i.rectangle(x, marginH, kW, kH); | |
| knob.knobRadius = 0.65f; | |
| knob.knobDiffuse = RGBA(50, 50, 100, 0); // color of knob | |
| // NOTE: material とは [R(smooth), G(metal), B(shiny), A(phisycal)] | |
| knob.knobMaterial = RGBA(255, 255, 255, 255); | |
| knob.numLEDs = 0; // ノブ上のLEDによる装飾(0: 無し) | |
| knob.litTrailDiffuse = litTrailDiffuse; | |
| knob.unlitTrailDiffuse = unlitTrailDiffuse; | |
| knob.LEDDiffuseLit = RGBA(0, 0, 40, 100); | |
| knob.LEDDiffuseUnlit = RGBA(0, 0, 40, 0); | |
| knob.LEDRadiusMin = 0.06f; | |
| knob.LEDRadiusMax = 0.06f; | |
| // パラメータ名のテキスト表示 | |
| UILabel label; | |
| addChild(label = mallocNew!UILabel(context(), _font, p.name)); | |
| label.position = box2i.rectangle(x, kH, kW, marginH); | |
| label.textColor(RGBA(200, 200, 200, 255)); | |
| } | |
| } | |
| ~this() | |
| { | |
| _font.destroyFree(); | |
| } | |
| } |
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
| final class SimpleDelay : Client | |
| { | |
| ... | |
| override IGraphics createGraphics() | |
| { | |
| import gui : SimpleDelayGUI; | |
| return mallocNew!SimpleDelayGUI( | |
| this.param(Param.delayDryWetRatio), | |
| this.param(Param.delayFeedbackRatio), | |
| this.param(Param.delayTimeSecondL), | |
| this.param(Param.delayTimeSecondR) | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment