├── .config └── dotnet-tools.json ├── .gitattributes ├── .github └── workflows │ ├── build.yaml │ └── release.yaml ├── .gitignore ├── .gitmodules ├── FaustDSP ├── CSharpFaustBase.cs ├── DSPCompiler.cs └── FaustDSP.csproj ├── FaustHost ├── FaustHost.csproj └── Program.cs ├── FaustImageProcessor ├── FaustImageProcessor.csproj └── Program.cs ├── FaustVst.sln ├── FaustVst ├── Content │ ├── Content.mgcb │ └── Textures │ │ ├── ImageManifest.xml │ │ └── UISheet0.png ├── FaustLayout.cs ├── FaustVst.cs ├── FaustVst.csproj ├── README.txt └── UIElements.cs ├── IRTest ├── IRTest.csproj └── Program.cs ├── LICENSE.txt ├── README.md └── SrcTextures ├── .gitignore └── UserInterface ├── .gitignore ├── ButtonPressed.png ├── ButtonUnpressed.png ├── DialBackground.png ├── DialPointer.png ├── FileEdit.svg ├── FileOpen.svg ├── HoverTextOutline.png ├── LevelDisplay.png ├── LevelDisplayHorizontal.png ├── PluginBackground.png ├── PopupBackground.png ├── Reload.svg ├── SingleWhitePixel.png └── VerticalSlider.png /.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "dotnet-mgcb": { 6 | "version": "3.8.1.303", 7 | "commands": [ 8 | "mgcb" 9 | ] 10 | }, 11 | "dotnet-mgcb-editor": { 12 | "version": "3.8.1.303", 13 | "commands": [ 14 | "mgcb-editor" 15 | ] 16 | }, 17 | "dotnet-mgcb-editor-linux": { 18 | "version": "3.8.1.303", 19 | "commands": [ 20 | "mgcb-editor-linux" 21 | ] 22 | }, 23 | "dotnet-mgcb-editor-windows": { 24 | "version": "3.8.1.303", 25 | "commands": [ 26 | "mgcb-editor-windows" 27 | ] 28 | }, 29 | "dotnet-mgcb-editor-mac": { 30 | "version": "3.8.1.303", 31 | "commands": [ 32 | "mgcb-editor-mac" 33 | ] 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | [workflow_dispatch, push, pull_request] 5 | 6 | jobs: 7 | build-windows: 8 | name: Build Windows 9 | runs-on: windows-latest 10 | steps: 11 | - uses: actions/checkout@v4 12 | with: 13 | submodules: recursive 14 | 15 | - name: Setup MSBuild and add to PATH 16 | uses: microsoft/setup-msbuild@v1.3.1 17 | 18 | - name: Restore NuGet Packages 19 | run: 20 | dotnet restore 21 | 22 | - name: Run Image Processor 23 | working-directory: ${{github.workspace}} 24 | run: | 25 | msbuild .\FaustVst.sln /t:FaustImageProcessor /p:Configuration="Release" 26 | FaustImageProcessor\bin\Release\net6.0-windows\FaustImageProcessor.exe 27 | 28 | - name: Run MSBuild for Plugin 29 | working-directory: ${{github.workspace}} 30 | run: msbuild .\FaustVst.sln /t:FaustVst /p:Configuration=Release 31 | 32 | - name: Create Plugin Artifact 33 | uses: actions/upload-artifact@v4 34 | with: 35 | name: FaustVST3Plugin 36 | path: ${{github.workspace}}\FaustVst\bin\Release\net6.0-windows 37 | 38 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | create_release: 8 | name: Create release 9 | runs-on: ubuntu-latest 10 | outputs: 11 | upload_url: ${{steps.create_release.outputs.upload_url}} 12 | steps: 13 | - name: Check out repository 14 | uses: actions/checkout@v4 15 | with: 16 | submodules: recursive 17 | 18 | - name: Create release 19 | id: create_release 20 | uses: actions/create-release@v1 21 | env: 22 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 23 | with: 24 | draft: true 25 | tag_name: ${{github.ref}} 26 | release_name: Release ${{github.ref}} 27 | 28 | build-windows: 29 | name: Build Windows 30 | needs: create_release 31 | runs-on: windows-latest 32 | steps: 33 | - uses: actions/checkout@v4 34 | with: 35 | submodules: recursive 36 | 37 | - name: Setup MSBuild and add to PATH 38 | uses: microsoft/setup-msbuild@v1.3.1 39 | 40 | - name: Restore NuGet Packages 41 | run: 42 | dotnet restore 43 | 44 | - name: Run Image Processor 45 | working-directory: ${{github.workspace}} 46 | run: | 47 | msbuild .\FaustVst.sln /t:FaustImageProcessor /p:Configuration="Release" 48 | FaustImageProcessor\bin\Release\net6.0-windows\FaustImageProcessor.exe 49 | 50 | - name: Run MSBuild for Plugin 51 | working-directory: ${{github.workspace}} 52 | run: msbuild .\FaustVst.sln /t:FaustVst /p:Configuration=Release 53 | 54 | - name: Add Plugin Archive 55 | working-directory: ${{github.workspace}} 56 | run: | 57 | mkdir plugin-build 58 | move FaustVst\bin\Release\net6.0-windows plugin-build\FaustVst 59 | cp FaustVst\README.txt plugin-build 60 | Compress-Archive -Path plugin-build\* -Destination FaustVST3Plugin.zip 61 | 62 | - name: Upload Plugin Asset 63 | uses: actions/upload-release-asset@v1 64 | env: 65 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 66 | with: 67 | upload_url: ${{ needs.create_release.outputs.upload_url }} 68 | asset_path: ./FaustVST3Plugin.zip 69 | asset_name: FaustVST3Plugin.zip 70 | asset_content_type: application/zip 71 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Dependencies/UILayout"] 2 | path = Dependencies/UILayout 3 | url = https://github.com/mikeoliphant/UILayout 4 | -------------------------------------------------------------------------------- /FaustDSP/CSharpFaustBase.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | FAUST Architecture File 3 | Copyright (C) 2021 Mike Oliphant 4 | --------------------------------------------------------------------- 5 | This Architecture section is free software; you can redistribute it 6 | and/or modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 3 of 8 | the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; If not, see . 17 | 18 | EXCEPTION : As a special exception, you may create a larger work 19 | that contains this FAUST architecture section and distribute 20 | that work under terms of your choice, so long as this FAUST 21 | architecture section is not modified. 22 | 23 | ************************************************************************ 24 | ************************************************************************/ 25 | 26 | using System; 27 | using System.Collections.Generic; 28 | 29 | public class FaustMetaData 30 | { 31 | Dictionary metaData = new Dictionary(); 32 | 33 | public void Declare(String name, String value) 34 | { 35 | metaData[name] = value; 36 | } 37 | 38 | public string GetValue(string name) 39 | { 40 | if (!metaData.ContainsKey(name)) 41 | return null; 42 | 43 | return metaData[name]; 44 | } 45 | } 46 | 47 | public class FaustVariableAccessor 48 | { 49 | public string ID { get; set; } 50 | public Action SetValue { get; set; } 51 | public Func GetValue { get; set; } 52 | } 53 | 54 | public enum EFaustUIBoxType 55 | { 56 | } 57 | 58 | public enum EFaustUIElementType 59 | { 60 | TabBox, 61 | HorizontalBox, 62 | VerticalBox, 63 | Button, 64 | CheckBox, 65 | VerticalSlider, 66 | HorizontalSlider, 67 | NumEntry, 68 | HorizontalBargraph, 69 | VerticalBargraph 70 | } 71 | 72 | public class FaustUIElement 73 | { 74 | public EFaustUIElementType ElementType { get; set; } 75 | public string Label { get; set; } 76 | public Dictionary MetaData { get; set; } 77 | 78 | public string GetMetaData(string key) 79 | { 80 | if (MetaData == null) 81 | return null; 82 | 83 | if (MetaData.ContainsKey(key)) 84 | return MetaData[key]; 85 | 86 | return null; 87 | } 88 | } 89 | 90 | public class FaustBoxElement : FaustUIElement 91 | { 92 | public List Children { get; set; } 93 | 94 | public FaustBoxElement(EFaustUIElementType elementType, string label) 95 | { 96 | this.ElementType = elementType; 97 | this.Label = label; 98 | this.Children = new List(); 99 | } 100 | } 101 | 102 | public class FaustUIVariableElement : FaustUIElement 103 | { 104 | public FaustVariableAccessor VariableAccessor { get; set; } 105 | 106 | public FaustUIVariableElement(EFaustUIElementType elementType, string label, FaustVariableAccessor variableAccessor) 107 | { 108 | this.ElementType = elementType; 109 | this.Label = label; 110 | this.VariableAccessor = variableAccessor; 111 | } 112 | } 113 | 114 | public class FaustUIFloatElement : FaustUIVariableElement 115 | { 116 | public double MinValue { get; set; } 117 | public double MaxValue { get; set; } 118 | 119 | public double GetNormalizedValue(double value) 120 | { 121 | return (value - MinValue) / (MaxValue - MinValue); 122 | } 123 | 124 | public double GetDenormalizedValue(double value) 125 | { 126 | return MinValue + ((MaxValue - MinValue) * value); 127 | } 128 | 129 | public FaustUIFloatElement(EFaustUIElementType elementType, string label, FaustVariableAccessor variableAccessor, double minValue, double maxValue) 130 | : base(elementType, label, variableAccessor) 131 | { 132 | this.MinValue = minValue; 133 | this.MaxValue = maxValue; 134 | } 135 | } 136 | 137 | public class FaustUIWriteableFloatElement : FaustUIFloatElement 138 | { 139 | public double Step { get; set; } 140 | public double DefaultValue { get; set; } 141 | 142 | public FaustUIWriteableFloatElement(EFaustUIElementType elementType, string label, FaustVariableAccessor variableAccessor, double defaultValue, double minValue, double maxValue, double step) 143 | : base(elementType, label, variableAccessor, minValue, maxValue) 144 | { 145 | this.DefaultValue = defaultValue; 146 | this.Step = step; 147 | } 148 | } 149 | 150 | public class FaustUIDefinition 151 | { 152 | public FaustUIElement RootElement { get; set; } 153 | 154 | Stack boxStack = new Stack(); 155 | 156 | Dictionary> uiMetaData = new Dictionary>(); 157 | 158 | public void DeclareElementMetaData(string elementID, string key, string value) 159 | { 160 | Dictionary elementData; 161 | 162 | if (uiMetaData.ContainsKey(elementID)) 163 | { 164 | elementData = uiMetaData[elementID]; 165 | } 166 | else 167 | { 168 | elementData = new Dictionary(); 169 | 170 | uiMetaData[elementID] = elementData; 171 | } 172 | 173 | elementData[key] = value; 174 | } 175 | 176 | public void StartBox(FaustBoxElement box) 177 | { 178 | if (boxStack.Count == 0) 179 | { 180 | RootElement = box; 181 | } 182 | else 183 | { 184 | boxStack.Peek().Children.Add(box); 185 | } 186 | 187 | boxStack.Push(box); 188 | } 189 | 190 | public void EndBox() 191 | { 192 | boxStack.Pop(); 193 | } 194 | 195 | public void AddElement(FaustUIElement element) 196 | { 197 | if (element is FaustUIVariableElement) 198 | { 199 | string id = (element as FaustUIVariableElement).VariableAccessor.ID; 200 | 201 | if (uiMetaData.ContainsKey(id)) 202 | { 203 | element.MetaData = uiMetaData[id]; 204 | } 205 | } 206 | 207 | boxStack.Peek().Children.Add(element); 208 | } 209 | } 210 | 211 | public interface IFaustDSP 212 | { 213 | FaustUIDefinition UIDefinition { get; } 214 | FaustMetaData MetaData { get; } 215 | 216 | int GetNumInputs(); 217 | int GetNumOutputs(); 218 | void ClassInit(int sample_rate); 219 | void InstanceConstants(int sample_rate); 220 | void InstanceResetUserInterface(); 221 | void InstanceClear(); 222 | void Init(int sample_rate); 223 | void InstanceInit(int sample_rate); 224 | void Compute(int count, double[][] inputs, double[][] outputs); 225 | } 226 | 227 | public class dsp 228 | { 229 | public FaustUIDefinition UIDefinition { get; private set; } 230 | public FaustMetaData MetaData { get; private set; } 231 | 232 | public dsp() 233 | { 234 | UIDefinition = new FaustUIDefinition(); 235 | MetaData = new FaustMetaData(); 236 | } 237 | 238 | public static double FMod(double val1, double val2) 239 | { 240 | return val1 % val2; 241 | } 242 | 243 | public static float FModF(float val1, float val2) 244 | { 245 | return val1 % val2; 246 | } 247 | 248 | public static bool IsInfinity(double d) 249 | { 250 | return double.IsNegativeInfinity(d) || double.IsPositiveInfinity(d); 251 | } 252 | 253 | public static bool IsInfinityF(float d) 254 | { 255 | return float.IsNegativeInfinity(d) || float.IsPositiveInfinity(d); 256 | } 257 | } 258 | 259 | 260 | -------------------------------------------------------------------------------- /FaustDSP/DSPCompiler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Reflection; 6 | using System.Text; 7 | using System.Runtime.Loader; 8 | using Microsoft.CodeAnalysis; 9 | using Microsoft.CodeAnalysis.Emit; 10 | using Microsoft.CodeAnalysis.CSharp; 11 | 12 | namespace FaustDSP 13 | { 14 | public class DspCompiler 15 | { 16 | int version = 1; 17 | 18 | public IFaustDSP CompileDSP(string dspPath) 19 | { 20 | return CompileDSP(dspPath, AssemblyLoadContext.Default); 21 | } 22 | 23 | public IFaustDSP CompileDSP(string dspPath, AssemblyLoadContext loadContext) 24 | { 25 | StringBuilder compilerOutput = new StringBuilder(); 26 | StringBuilder compilerError = new StringBuilder(); 27 | 28 | using (Process process = new Process()) 29 | { 30 | process.StartInfo.FileName = @"C:\Program Files\faust\bin\faust.exe"; 31 | process.StartInfo.Arguments = @"-lang csharp -a CSharpFaustClass.cs -double " + dspPath; 32 | process.StartInfo.CreateNoWindow = true; 33 | process.StartInfo.RedirectStandardOutput = true; 34 | process.StartInfo.RedirectStandardInput = true; 35 | process.StartInfo.RedirectStandardError = true; 36 | process.StartInfo.UseShellExecute = false; 37 | 38 | process.OutputDataReceived += (sender, args) => compilerOutput.AppendLine(args.Data); 39 | process.ErrorDataReceived += (sender, args) => compilerError.AppendLine(args.Data); 40 | 41 | if (process.Start()) 42 | { 43 | process.BeginOutputReadLine(); 44 | process.BeginErrorReadLine(); 45 | 46 | process.WaitForExit(); 47 | 48 | if (process.ExitCode != 0) 49 | { 50 | throw new FaustCompileException("Faust compile failed: " + compilerError.ToString()); 51 | } 52 | 53 | List refs = new List(); 54 | 55 | Assembly executingAssembly = this.GetType().Assembly; 56 | 57 | refs.Add(MetadataReference.CreateFromFile(executingAssembly.Location)); 58 | 59 | refs.Add(MetadataReference.CreateFromFile(typeof(Object).Assembly.Location)); 60 | 61 | foreach (AssemblyName assemblyName in executingAssembly.GetReferencedAssemblies()) 62 | { 63 | refs.Add(MetadataReference.CreateFromFile(Assembly.Load(assemblyName).Location)); 64 | } 65 | 66 | CSharpCompilationOptions options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel: OptimizationLevel.Release, 67 | assemblyIdentityComparer: DesktopAssemblyIdentityComparer.Default); 68 | 69 | CSharpCompilation csharpCompilation = CSharpCompilation.Create("DynamicPlugin" + version, new[] { CSharpSyntaxTree.ParseText(compilerOutput.ToString()) }, refs, options); 70 | 71 | version++; 72 | 73 | using (var memoryStream = new MemoryStream()) 74 | { 75 | EmitResult result = csharpCompilation.Emit(memoryStream); 76 | 77 | if (result.Success) 78 | { 79 | memoryStream.Seek(0, SeekOrigin.Begin); 80 | 81 | Assembly assembly = loadContext.LoadFromStream(memoryStream); 82 | 83 | Type dspType = assembly.GetType("mydsp"); 84 | 85 | if (dspType == null) 86 | { 87 | string typeStr = "Couldn't find type in assembly with types: "; 88 | 89 | foreach (Type type in assembly.GetTypes()) 90 | { 91 | typeStr += type.FullName + ", "; 92 | } 93 | 94 | typeStr += "\nDiagnostics: "; 95 | 96 | foreach (Diagnostic diagnostic in result.Diagnostics) 97 | { 98 | typeStr += diagnostic.ToString() + "\n"; 99 | } 100 | 101 | throw new FaustCompileException(typeStr); 102 | } 103 | 104 | IFaustDSP dspClass = Activator.CreateInstance(dspType) as IFaustDSP; 105 | 106 | return dspClass; 107 | } 108 | else 109 | { 110 | string errStr = null; 111 | 112 | foreach (Diagnostic diag in result.Diagnostics) 113 | { 114 | errStr += diag.ToString(); 115 | } 116 | 117 | throw new FaustCompileException("CSharpCompilation failed: " + errStr); 118 | } 119 | } 120 | } 121 | } 122 | 123 | return null; 124 | } 125 | 126 | public class FaustCompileException : Exception 127 | { 128 | public FaustCompileException() 129 | { 130 | } 131 | 132 | public FaustCompileException(string message) 133 | : base(message) 134 | { 135 | } 136 | 137 | public FaustCompileException(string message, Exception inner) 138 | : base(message, inner) 139 | { 140 | } 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /FaustDSP/FaustDSP.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /FaustHost/FaustHost.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /FaustHost/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AudioPlugSharpHost; 3 | using FaustVst; 4 | 5 | namespace FaustHost 6 | { 7 | class Program 8 | { 9 | [STAThread] 10 | static void Main(string[] args) 11 | { 12 | FaustVst.FaustVst plugin = new FaustVst.FaustVst(); 13 | 14 | WindowsFormsHost host = new WindowsFormsHost(plugin); 15 | 16 | host.Run(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /FaustImageProcessor/FaustImageProcessor.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Exe 4 | net6.0-windows 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /FaustImageProcessor/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.IO; 4 | using System.Reflection; 5 | 6 | namespace FaustImageProcessor 7 | { 8 | class FaustImageProcessor : ImageSheetProcessor.ImageSheetProcessor 9 | { 10 | public void RenderImages(string destPath) 11 | { 12 | BeginRenderImages(destPath); 13 | Render(); 14 | 15 | EndRenderImages(); 16 | } 17 | 18 | public void Render() 19 | { 20 | MaxImageSheetSize = 2048; 21 | 22 | BeginSpriteSheetGroup("UISheet"); 23 | 24 | AddFont("MainFont", "Calibri", FontStyle.Bold, 36); 25 | AddFont("SmallFont", "Calibri", FontStyle.Bold, 30); 26 | 27 | PushDirectory("UserInterface"); 28 | 29 | Add("SingleWhitePixel"); 30 | 31 | AddWithShadow("HoverTextOutline"); 32 | 33 | Add("DialBackground"); 34 | Add("DialPointer"); 35 | 36 | Add("PopupBackground"); 37 | Add("PluginBackground"); 38 | Add("ButtonPressed"); 39 | Add("ButtonUnpressed"); 40 | 41 | Add("LevelDisplay"); 42 | Add("LevelDisplayHorizontal"); 43 | 44 | Add("VerticalSlider"); 45 | 46 | AddSvg("FileOpen", 50); 47 | AddSvg("FileEdit", 50); 48 | AddSvg("Reload", 50); 49 | 50 | PopDirectory(); 51 | 52 | EndSpriteSheetGroup(); 53 | } 54 | } 55 | 56 | 57 | class Program 58 | { 59 | static void Main(string[] args) 60 | { 61 | var processor = new FaustImageProcessor(); 62 | 63 | string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"..\..\..\.."); 64 | 65 | processor.ForceRegen = false; 66 | 67 | processor.SrcPath = Path.Combine(path, "SrcTextures"); 68 | 69 | processor.RenderImages(Path.Combine(path, @"FaustVst\Content\Textures")); 70 | } 71 | 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /FaustVst.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.10.35027.167 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FaustVst", "FaustVst\FaustVst.csproj", "{A405DD0C-FD72-4103-89BD-3B120050162B}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FaustDSP", "FaustDSP\FaustDSP.csproj", "{DB6C01B9-863E-4B81-8BE2-5C2459E99313}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IRTest", "IRTest\IRTest.csproj", "{3E157C73-AEF1-414F-96C2-CD53A8375B5A}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FaustHost", "FaustHost\FaustHost.csproj", "{E9A2D634-DFA8-49F3-B38C-A880A5329071}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FaustImageProcessor", "FaustImageProcessor\FaustImageProcessor.csproj", "{DA5DAE0E-DE74-4D89-9F24-AC413BA749B2}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UILayout.MonoGame.WindowsDX", "Dependencies\UILayout\UILayout.MonoGame.WindowsDX\UILayout.MonoGame.WindowsDX.csproj", "{03B294AF-A2CC-4625-93D4-1DFAF2A7D116}" 17 | EndProject 18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSheetProcessor", "Dependencies\UILayout\ImageSheetProcessor\ImageSheetProcessor.csproj", "{FE3BF348-E94D-418A-93FB-96794A9C7CA5}" 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Any CPU = Debug|Any CPU 23 | Debug|x64 = Debug|x64 24 | Debug|x86 = Debug|x86 25 | Release|Any CPU = Release|Any CPU 26 | Release|x64 = Release|x64 27 | Release|x86 = Release|x86 28 | EndGlobalSection 29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 30 | {A405DD0C-FD72-4103-89BD-3B120050162B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {A405DD0C-FD72-4103-89BD-3B120050162B}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {A405DD0C-FD72-4103-89BD-3B120050162B}.Debug|x64.ActiveCfg = Debug|Any CPU 33 | {A405DD0C-FD72-4103-89BD-3B120050162B}.Debug|x64.Build.0 = Debug|Any CPU 34 | {A405DD0C-FD72-4103-89BD-3B120050162B}.Debug|x86.ActiveCfg = Debug|Any CPU 35 | {A405DD0C-FD72-4103-89BD-3B120050162B}.Debug|x86.Build.0 = Debug|Any CPU 36 | {A405DD0C-FD72-4103-89BD-3B120050162B}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {A405DD0C-FD72-4103-89BD-3B120050162B}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {A405DD0C-FD72-4103-89BD-3B120050162B}.Release|x64.ActiveCfg = Release|Any CPU 39 | {A405DD0C-FD72-4103-89BD-3B120050162B}.Release|x64.Build.0 = Release|Any CPU 40 | {A405DD0C-FD72-4103-89BD-3B120050162B}.Release|x86.ActiveCfg = Release|Any CPU 41 | {A405DD0C-FD72-4103-89BD-3B120050162B}.Release|x86.Build.0 = Release|Any CPU 42 | {DB6C01B9-863E-4B81-8BE2-5C2459E99313}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {DB6C01B9-863E-4B81-8BE2-5C2459E99313}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {DB6C01B9-863E-4B81-8BE2-5C2459E99313}.Debug|x64.ActiveCfg = Debug|Any CPU 45 | {DB6C01B9-863E-4B81-8BE2-5C2459E99313}.Debug|x64.Build.0 = Debug|Any CPU 46 | {DB6C01B9-863E-4B81-8BE2-5C2459E99313}.Debug|x86.ActiveCfg = Debug|Any CPU 47 | {DB6C01B9-863E-4B81-8BE2-5C2459E99313}.Debug|x86.Build.0 = Debug|Any CPU 48 | {DB6C01B9-863E-4B81-8BE2-5C2459E99313}.Release|Any CPU.ActiveCfg = Release|Any CPU 49 | {DB6C01B9-863E-4B81-8BE2-5C2459E99313}.Release|Any CPU.Build.0 = Release|Any CPU 50 | {DB6C01B9-863E-4B81-8BE2-5C2459E99313}.Release|x64.ActiveCfg = Release|Any CPU 51 | {DB6C01B9-863E-4B81-8BE2-5C2459E99313}.Release|x64.Build.0 = Release|Any CPU 52 | {DB6C01B9-863E-4B81-8BE2-5C2459E99313}.Release|x86.ActiveCfg = Release|Any CPU 53 | {DB6C01B9-863E-4B81-8BE2-5C2459E99313}.Release|x86.Build.0 = Release|Any CPU 54 | {3E157C73-AEF1-414F-96C2-CD53A8375B5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 55 | {3E157C73-AEF1-414F-96C2-CD53A8375B5A}.Debug|Any CPU.Build.0 = Debug|Any CPU 56 | {3E157C73-AEF1-414F-96C2-CD53A8375B5A}.Debug|x64.ActiveCfg = Debug|Any CPU 57 | {3E157C73-AEF1-414F-96C2-CD53A8375B5A}.Debug|x64.Build.0 = Debug|Any CPU 58 | {3E157C73-AEF1-414F-96C2-CD53A8375B5A}.Debug|x86.ActiveCfg = Debug|Any CPU 59 | {3E157C73-AEF1-414F-96C2-CD53A8375B5A}.Debug|x86.Build.0 = Debug|Any CPU 60 | {3E157C73-AEF1-414F-96C2-CD53A8375B5A}.Release|Any CPU.ActiveCfg = Release|Any CPU 61 | {3E157C73-AEF1-414F-96C2-CD53A8375B5A}.Release|Any CPU.Build.0 = Release|Any CPU 62 | {3E157C73-AEF1-414F-96C2-CD53A8375B5A}.Release|x64.ActiveCfg = Release|Any CPU 63 | {3E157C73-AEF1-414F-96C2-CD53A8375B5A}.Release|x64.Build.0 = Release|Any CPU 64 | {3E157C73-AEF1-414F-96C2-CD53A8375B5A}.Release|x86.ActiveCfg = Release|Any CPU 65 | {3E157C73-AEF1-414F-96C2-CD53A8375B5A}.Release|x86.Build.0 = Release|Any CPU 66 | {E9A2D634-DFA8-49F3-B38C-A880A5329071}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 67 | {E9A2D634-DFA8-49F3-B38C-A880A5329071}.Debug|Any CPU.Build.0 = Debug|Any CPU 68 | {E9A2D634-DFA8-49F3-B38C-A880A5329071}.Debug|x64.ActiveCfg = Debug|Any CPU 69 | {E9A2D634-DFA8-49F3-B38C-A880A5329071}.Debug|x64.Build.0 = Debug|Any CPU 70 | {E9A2D634-DFA8-49F3-B38C-A880A5329071}.Debug|x86.ActiveCfg = Debug|Any CPU 71 | {E9A2D634-DFA8-49F3-B38C-A880A5329071}.Debug|x86.Build.0 = Debug|Any CPU 72 | {E9A2D634-DFA8-49F3-B38C-A880A5329071}.Release|Any CPU.ActiveCfg = Release|Any CPU 73 | {E9A2D634-DFA8-49F3-B38C-A880A5329071}.Release|Any CPU.Build.0 = Release|Any CPU 74 | {E9A2D634-DFA8-49F3-B38C-A880A5329071}.Release|x64.ActiveCfg = Release|Any CPU 75 | {E9A2D634-DFA8-49F3-B38C-A880A5329071}.Release|x64.Build.0 = Release|Any CPU 76 | {E9A2D634-DFA8-49F3-B38C-A880A5329071}.Release|x86.ActiveCfg = Release|Any CPU 77 | {E9A2D634-DFA8-49F3-B38C-A880A5329071}.Release|x86.Build.0 = Release|Any CPU 78 | {DA5DAE0E-DE74-4D89-9F24-AC413BA749B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 79 | {DA5DAE0E-DE74-4D89-9F24-AC413BA749B2}.Debug|Any CPU.Build.0 = Debug|Any CPU 80 | {DA5DAE0E-DE74-4D89-9F24-AC413BA749B2}.Debug|x64.ActiveCfg = Debug|Any CPU 81 | {DA5DAE0E-DE74-4D89-9F24-AC413BA749B2}.Debug|x64.Build.0 = Debug|Any CPU 82 | {DA5DAE0E-DE74-4D89-9F24-AC413BA749B2}.Debug|x86.ActiveCfg = Debug|Any CPU 83 | {DA5DAE0E-DE74-4D89-9F24-AC413BA749B2}.Debug|x86.Build.0 = Debug|Any CPU 84 | {DA5DAE0E-DE74-4D89-9F24-AC413BA749B2}.Release|Any CPU.ActiveCfg = Release|Any CPU 85 | {DA5DAE0E-DE74-4D89-9F24-AC413BA749B2}.Release|Any CPU.Build.0 = Release|Any CPU 86 | {DA5DAE0E-DE74-4D89-9F24-AC413BA749B2}.Release|x64.ActiveCfg = Release|Any CPU 87 | {DA5DAE0E-DE74-4D89-9F24-AC413BA749B2}.Release|x64.Build.0 = Release|Any CPU 88 | {DA5DAE0E-DE74-4D89-9F24-AC413BA749B2}.Release|x86.ActiveCfg = Release|Any CPU 89 | {DA5DAE0E-DE74-4D89-9F24-AC413BA749B2}.Release|x86.Build.0 = Release|Any CPU 90 | {03B294AF-A2CC-4625-93D4-1DFAF2A7D116}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 91 | {03B294AF-A2CC-4625-93D4-1DFAF2A7D116}.Debug|Any CPU.Build.0 = Debug|Any CPU 92 | {03B294AF-A2CC-4625-93D4-1DFAF2A7D116}.Debug|x64.ActiveCfg = Debug|Any CPU 93 | {03B294AF-A2CC-4625-93D4-1DFAF2A7D116}.Debug|x64.Build.0 = Debug|Any CPU 94 | {03B294AF-A2CC-4625-93D4-1DFAF2A7D116}.Debug|x86.ActiveCfg = Debug|Any CPU 95 | {03B294AF-A2CC-4625-93D4-1DFAF2A7D116}.Debug|x86.Build.0 = Debug|Any CPU 96 | {03B294AF-A2CC-4625-93D4-1DFAF2A7D116}.Release|Any CPU.ActiveCfg = Release|Any CPU 97 | {03B294AF-A2CC-4625-93D4-1DFAF2A7D116}.Release|Any CPU.Build.0 = Release|Any CPU 98 | {03B294AF-A2CC-4625-93D4-1DFAF2A7D116}.Release|x64.ActiveCfg = Release|Any CPU 99 | {03B294AF-A2CC-4625-93D4-1DFAF2A7D116}.Release|x64.Build.0 = Release|Any CPU 100 | {03B294AF-A2CC-4625-93D4-1DFAF2A7D116}.Release|x86.ActiveCfg = Release|Any CPU 101 | {03B294AF-A2CC-4625-93D4-1DFAF2A7D116}.Release|x86.Build.0 = Release|Any CPU 102 | {FE3BF348-E94D-418A-93FB-96794A9C7CA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 103 | {FE3BF348-E94D-418A-93FB-96794A9C7CA5}.Debug|Any CPU.Build.0 = Debug|Any CPU 104 | {FE3BF348-E94D-418A-93FB-96794A9C7CA5}.Debug|x64.ActiveCfg = Debug|Any CPU 105 | {FE3BF348-E94D-418A-93FB-96794A9C7CA5}.Debug|x64.Build.0 = Debug|Any CPU 106 | {FE3BF348-E94D-418A-93FB-96794A9C7CA5}.Debug|x86.ActiveCfg = Debug|Any CPU 107 | {FE3BF348-E94D-418A-93FB-96794A9C7CA5}.Debug|x86.Build.0 = Debug|Any CPU 108 | {FE3BF348-E94D-418A-93FB-96794A9C7CA5}.Release|Any CPU.ActiveCfg = Release|Any CPU 109 | {FE3BF348-E94D-418A-93FB-96794A9C7CA5}.Release|Any CPU.Build.0 = Release|Any CPU 110 | {FE3BF348-E94D-418A-93FB-96794A9C7CA5}.Release|x64.ActiveCfg = Release|Any CPU 111 | {FE3BF348-E94D-418A-93FB-96794A9C7CA5}.Release|x64.Build.0 = Release|Any CPU 112 | {FE3BF348-E94D-418A-93FB-96794A9C7CA5}.Release|x86.ActiveCfg = Release|Any CPU 113 | {FE3BF348-E94D-418A-93FB-96794A9C7CA5}.Release|x86.Build.0 = Release|Any CPU 114 | EndGlobalSection 115 | GlobalSection(SolutionProperties) = preSolution 116 | HideSolutionNode = FALSE 117 | EndGlobalSection 118 | GlobalSection(ExtensibilityGlobals) = postSolution 119 | SolutionGuid = {EA56973A-6A9B-4942-9C18-DD06A2006C59} 120 | EndGlobalSection 121 | GlobalSection(SharedMSBuildProjectFiles) = preSolution 122 | Dependencies\UILayout\UILayout.MonoGame\UILayout.MonoGame.projitems*{03b294af-a2cc-4625-93d4-1dfaf2a7d116}*SharedItemsImports = 5 123 | Dependencies\UILayout\UILayout\UILayout.projitems*{03b294af-a2cc-4625-93d4-1dfaf2a7d116}*SharedItemsImports = 5 124 | Dependencies\UILayout\UILayout.MonoGame\UILayout.MonoGame.projitems*{fe3bf348-e94d-418a-93fb-96794a9c7ca5}*SharedItemsImports = 5 125 | Dependencies\UILayout\UILayout\UILayout.projitems*{fe3bf348-e94d-418a-93fb-96794a9c7ca5}*SharedItemsImports = 5 126 | EndGlobalSection 127 | EndGlobal 128 | -------------------------------------------------------------------------------- /FaustVst/Content/Content.mgcb: -------------------------------------------------------------------------------- 1 | 2 | #----------------------------- Global Properties ----------------------------# 3 | 4 | /outputDir:bin/$(Platform) 5 | /intermediateDir:obj/$(Platform) 6 | /platform:Windows 7 | /config: 8 | /profile:Reach 9 | /compress:False 10 | 11 | #-------------------------------- References --------------------------------# 12 | 13 | 14 | #---------------------------------- Content ---------------------------------# 15 | 16 | #begin Textures/ImageManifest.xml 17 | /copy:Textures/ImageManifest.xml 18 | 19 | #begin Textures/UISheet0.png 20 | /importer:TextureImporter 21 | /processor:TextureProcessor 22 | /processorParam:ColorKeyColor=255,0,255,255 23 | /processorParam:ColorKeyEnabled=True 24 | /processorParam:GenerateMipmaps=True 25 | /processorParam:PremultiplyAlpha=True 26 | /processorParam:ResizeToPowerOfTwo=False 27 | /processorParam:MakeSquare=False 28 | /processorParam:TextureFormat=Color 29 | /build:Textures/UISheet0.png 30 | 31 | -------------------------------------------------------------------------------- /FaustVst/Content/Textures/UISheet0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeoliphant/FaustVst/cbccaa9bda313ad0b7e41b85579a0a58ff40cb9d/FaustVst/Content/Textures/UISheet0.png -------------------------------------------------------------------------------- /FaustVst/FaustLayout.cs: -------------------------------------------------------------------------------- 1 | using FaustDSP; 2 | using Microsoft.Xna.Framework; 3 | using SharpDX.Direct3D9; 4 | using System; 5 | using System.Diagnostics; 6 | using System.IO; 7 | using System.Windows.Forms; 8 | using UILayout; 9 | 10 | namespace FaustVst 11 | { 12 | public class FaustLayout : MonoGameLayout 13 | { 14 | FaustVst plugin; 15 | Dock mainDock; 16 | HorizontalStack paramStack; 17 | TextBlock pluginFileText; 18 | UIColor foregroundColor = UIColor.Black; 19 | 20 | public FaustLayout(FaustVst plugin) 21 | { 22 | this.plugin = plugin; 23 | } 24 | 25 | public override void SetHost(Game host) 26 | { 27 | base.SetHost(host); 28 | 29 | Host.InactiveSleepTime = TimeSpan.Zero; 30 | 31 | Host.Window.Title = "FaustVst"; 32 | 33 | LoadImageManifest("ImageManifest.xml"); 34 | 35 | GraphicsContext.SingleWhitePixelImage = GetImage("SingleWhitePixel"); 36 | GraphicsContext.SamplerState = new Microsoft.Xna.Framework.Graphics.SamplerState() 37 | { 38 | AddressU = Microsoft.Xna.Framework.Graphics.TextureAddressMode.Clamp, 39 | AddressV = Microsoft.Xna.Framework.Graphics.TextureAddressMode.Clamp, 40 | Filter = Microsoft.Xna.Framework.Graphics.TextureFilter.Anisotropic, 41 | MipMapLevelOfDetailBias = -0.8f 42 | }; 43 | 44 | DefaultFont = GetFont("MainFont"); 45 | DefaultFont.SpriteFont.Spacing = 1; 46 | 47 | GetFont("SmallFont").SpriteFont.Spacing = 0; 48 | 49 | DefaultForegroundColor = UIColor.Black; 50 | 51 | DefaultOutlineNinePatch = GetImage("PopupBackground"); 52 | 53 | DefaultPressedNinePatch = GetImage("ButtonPressed"); 54 | DefaultUnpressedNinePatch = GetImage("ButtonUnpressed"); 55 | 56 | DefaultDragImage = GetImage("ButtonPressed"); 57 | 58 | RootUIElement = mainDock = new Dock() 59 | { 60 | BackgroundColor = new UIColor(230, 230, 230), 61 | Padding = new LayoutPadding(20) 62 | }; 63 | 64 | VerticalStack vStack = new VerticalStack() 65 | { 66 | HorizontalAlignment = EHorizontalAlignment.Stretch, 67 | VerticalAlignment = EVerticalAlignment.Stretch 68 | }; 69 | mainDock.Children.Add(vStack); 70 | 71 | HorizontalStack pluginLoadStack = new HorizontalStack() 72 | { 73 | HorizontalAlignment = EHorizontalAlignment.Right, 74 | DesiredHeight = 80 75 | }; 76 | 77 | vStack.Children.Add(pluginLoadStack); 78 | 79 | pluginFileText = new TextBlock() 80 | { 81 | Margin = new LayoutPadding(10), 82 | VerticalAlignment = EVerticalAlignment.Center 83 | }; 84 | 85 | pluginLoadStack.Children.Add(pluginFileText); 86 | 87 | pluginLoadStack.Children.Add(new ImageButton("FileOpen") 88 | { 89 | VerticalAlignment = EVerticalAlignment.Stretch, 90 | ClickAction = LoadPlugin 91 | }); 92 | 93 | pluginLoadStack.Children.Add(new ImageButton("FileEdit") 94 | { 95 | VerticalAlignment = EVerticalAlignment.Stretch, 96 | ClickAction = EditPlugin 97 | }); 98 | 99 | pluginLoadStack.Children.Add(new ImageButton("Reload") 100 | { 101 | VerticalAlignment = EVerticalAlignment.Stretch, 102 | ClickAction = ReloadPlugin 103 | }); 104 | 105 | UIElementWrapper wrapper = new UIElementWrapper() 106 | { 107 | HorizontalAlignment = EHorizontalAlignment.Stretch, 108 | VerticalAlignment = EVerticalAlignment.Stretch 109 | }; 110 | vStack.Children.Add(wrapper); 111 | 112 | paramStack = new HorizontalStack() 113 | { 114 | HorizontalAlignment = EHorizontalAlignment.Center, 115 | VerticalAlignment = EVerticalAlignment.Center 116 | }; 117 | 118 | wrapper.Child = paramStack; 119 | 120 | UpdateParameters(); 121 | } 122 | 123 | void UpdateParameters() 124 | { 125 | pluginFileText.Text = String.IsNullOrEmpty(plugin.PluginFilePath) ? "No Plugin Loaded" : Path.GetFileName(plugin.PluginFilePath); 126 | 127 | paramStack.Children.Clear(); 128 | 129 | if (plugin.FaustDsp != null) 130 | AddParameters(plugin.FaustDsp.UIDefinition.RootElement, paramStack); 131 | 132 | mainDock.UpdateContentLayout(); 133 | } 134 | 135 | void AddParameters(FaustUIElement element, ListUIElement container) 136 | { 137 | if (element is FaustBoxElement) 138 | { 139 | NinePatchWrapper outline = new NinePatchWrapper(Layout.Current.GetImage("PluginBackground")) 140 | { 141 | HorizontalAlignment = EHorizontalAlignment.Stretch, 142 | VerticalAlignment = EVerticalAlignment.Stretch, 143 | Padding = new LayoutPadding(30) 144 | }; 145 | container.Children.Add(outline); 146 | 147 | VerticalStack verticalStack = new VerticalStack() 148 | { 149 | HorizontalAlignment = EHorizontalAlignment.Stretch, 150 | VerticalAlignment = EVerticalAlignment.Stretch, 151 | ChildSpacing = 10 152 | }; 153 | 154 | outline.Child = verticalStack; 155 | 156 | verticalStack.Children.Add(new TextBlock(element.Label)); 157 | 158 | UIElementWrapper wrapper = new UIElementWrapper() 159 | { 160 | HorizontalAlignment = EHorizontalAlignment.Stretch, 161 | VerticalAlignment = EVerticalAlignment.Stretch 162 | }; 163 | verticalStack.Children.Add(wrapper); 164 | 165 | ListUIElement stack = element.ElementType == EFaustUIElementType.HorizontalBox ? new HorizontalStack() : new VerticalStack(); 166 | stack.HorizontalAlignment = EHorizontalAlignment.Center; 167 | stack.VerticalAlignment = EVerticalAlignment.Center; 168 | wrapper.Child = stack; 169 | 170 | foreach (FaustUIElement child in (element as FaustBoxElement).Children) 171 | { 172 | AddParameters(child, stack); 173 | } 174 | } 175 | else 176 | { 177 | if (element is FaustUIVariableElement) 178 | { 179 | if ((element.ElementType == EFaustUIElementType.Button) || (element.ElementType == EFaustUIElementType.CheckBox)) 180 | { 181 | FaustUIVariableElement variableElement = element as FaustUIVariableElement; 182 | 183 | TextButton button = new TextButton(element.Label) 184 | { 185 | HorizontalAlignment = EHorizontalAlignment.Center, 186 | VerticalAlignment = EVerticalAlignment.Center 187 | }; 188 | 189 | button.IsToggleButton = (element.ElementType == EFaustUIElementType.CheckBox); 190 | 191 | button.SetPressed(variableElement.VariableAccessor.GetValue() == 1.0f); 192 | 193 | button.PressAction = delegate 194 | { 195 | variableElement.VariableAccessor.SetValue(button.IsPressed ? 1.0 : 0.0); 196 | }; 197 | 198 | container.Children.Add(button); 199 | } 200 | else if ((element.ElementType == EFaustUIElementType.HorizontalBargraph) || (element.ElementType == EFaustUIElementType.VerticalBargraph)) 201 | { 202 | FaustUIFloatElement floatElement = element as FaustUIFloatElement; 203 | 204 | VerticalStack controlVStack = new VerticalStack() 205 | { 206 | HorizontalAlignment = EHorizontalAlignment.Stretch, 207 | VerticalAlignment = EVerticalAlignment.Stretch 208 | }; 209 | 210 | controlVStack.Children.Add(new TextBlock(element.Label) 211 | { 212 | Margin = new LayoutPadding(5, 0), 213 | HorizontalAlignment = EHorizontalAlignment.Center, 214 | TextColor = foregroundColor, 215 | TextFont = Layout.Current.GetFont("SmallFont") 216 | }); 217 | 218 | LevelBar levelBar = null; 219 | 220 | if (element.ElementType == EFaustUIElementType.HorizontalBargraph) 221 | { 222 | levelBar = new HorizontalLevelBar() 223 | { 224 | DesiredHeight = 40, 225 | DesiredWidth = 300, 226 | HorizontalAlignment = EHorizontalAlignment.Center, 227 | VerticalAlignment = EVerticalAlignment.Center, 228 | Margin = new LayoutPadding(20), 229 | }; 230 | } 231 | else 232 | { 233 | levelBar = new VerticalLevelBar() 234 | { 235 | DesiredHeight = 300, 236 | DesiredWidth = 40, 237 | HorizontalAlignment = EHorizontalAlignment.Center, 238 | VerticalAlignment = EVerticalAlignment.Center, 239 | Margin = new LayoutPadding(20), 240 | }; 241 | } 242 | 243 | if (element.GetMetaData("unit") == "dB") 244 | { 245 | levelBar.GetValue = delegate 246 | { 247 | return DB2Linear(floatElement.VariableAccessor.GetValue()); 248 | }; 249 | 250 | levelBar.DoLogDisplay = true; 251 | } 252 | else 253 | { 254 | levelBar.GetValue = delegate 255 | { 256 | return floatElement.GetNormalizedValue(floatElement.VariableAccessor.GetValue()); 257 | }; 258 | } 259 | 260 | controlVStack.Children.Add(levelBar); 261 | 262 | container.Children.Add(controlVStack); 263 | } 264 | } 265 | 266 | if (element is FaustUIWriteableFloatElement) 267 | { 268 | FaustUIWriteableFloatElement floatElement = element as FaustUIWriteableFloatElement; 269 | 270 | VerticalStack controlVStack = new VerticalStack() 271 | { 272 | HorizontalAlignment = EHorizontalAlignment.Stretch, 273 | VerticalAlignment = EVerticalAlignment.Stretch 274 | }; 275 | 276 | controlVStack.Children.Add(new TextBlock(floatElement.Label) 277 | { 278 | Margin = new LayoutPadding(5, 0), 279 | HorizontalAlignment = EHorizontalAlignment.Center, 280 | TextColor = foregroundColor, 281 | TextFont = Layout.Current.GetFont("SmallFont") 282 | }); 283 | 284 | string valueFormat = "{0:0.0}"; 285 | 286 | string unit = element.GetMetaData("unit"); 287 | 288 | if (!string.IsNullOrEmpty(unit)) 289 | { 290 | valueFormat += unit; 291 | } 292 | 293 | Dock controlDock = new Dock() { HorizontalAlignment = EHorizontalAlignment.Stretch, VerticalAlignment = EVerticalAlignment.Center }; 294 | controlVStack.Children.Add(controlDock); 295 | 296 | float strWidthMax; 297 | float strHeightMax; 298 | Layout.Current.GetFont("SmallFont").MeasureString(String.Format(valueFormat, floatElement.MaxValue), out strWidthMax, out strHeightMax); 299 | float strWidthMin; 300 | float strHeightMin; 301 | Layout.Current.GetFont("SmallFont").MeasureString(String.Format(valueFormat, floatElement.MinValue), out strWidthMin, out strHeightMin); 302 | 303 | ParameterValueDisplay valueDisplay = new ParameterValueDisplay() 304 | { 305 | HorizontalAlignment = EHorizontalAlignment.Absolute, 306 | VerticalAlignment = EVerticalAlignment.Absolute, 307 | Margin = new LayoutPadding(-Math.Max(strWidthMin, strWidthMax), -Math.Max(strHeightMin, strHeightMax)), 308 | ValueFormat = valueFormat 309 | }; 310 | 311 | if (element.GetMetaData("style") == "knob") 312 | { 313 | ParameterDial dial = new ParameterDial() 314 | { 315 | MinValue = floatElement.MinValue, 316 | MaxValue = floatElement.MaxValue, 317 | DefaultValue = floatElement.DefaultValue 318 | }; 319 | 320 | controlDock.Children.Add(dial); 321 | 322 | dial.SetDialColor(UIColor.Black); 323 | 324 | dial.SetPointerColor(((foregroundColor.R + foregroundColor.G + foregroundColor.B) / 3) > 128 ? UIColor.Black : UIColor.White); 325 | 326 | dial.SetValue(floatElement.VariableAccessor.GetValue()); 327 | 328 | dial.ValueChangedAction = delegate (double val) 329 | { 330 | floatElement.VariableAccessor.SetValue(val); 331 | 332 | valueDisplay.SetValue(val); 333 | }; 334 | } 335 | else if ((element.ElementType == EFaustUIElementType.HorizontalSlider) || (element.ElementType == EFaustUIElementType.VerticalSlider)) 336 | { 337 | Slider slider = null; 338 | 339 | if (element.ElementType == EFaustUIElementType.HorizontalSlider) 340 | { 341 | slider = new HorizontalSlider("VerticalSlider") 342 | { 343 | HorizontalAlignment = EHorizontalAlignment.Center, 344 | DesiredWidth = 300 345 | }; 346 | } 347 | else 348 | { 349 | slider = new VerticalSlider("VerticalSlider") 350 | { 351 | InvertLevel = true, 352 | HorizontalAlignment = EHorizontalAlignment.Center, 353 | DesiredHeight = 300 354 | }; 355 | }; 356 | 357 | slider.ChangeAction = delegate (float value) 358 | { 359 | value = (float)floatElement.GetDenormalizedValue(value); 360 | 361 | floatElement.VariableAccessor.SetValue(value); 362 | 363 | valueDisplay.SetValue(value); 364 | }; 365 | 366 | slider.SetLevel((float)floatElement.GetNormalizedValue(floatElement.VariableAccessor.GetValue())); 367 | 368 | controlDock.Children.Add(slider); 369 | } 370 | 371 | controlDock.Children.Add(valueDisplay); 372 | 373 | container.Children.Add(controlVStack); 374 | } 375 | } 376 | } 377 | 378 | double DB2Linear(double value) 379 | { 380 | return Math.Pow(10.0f, value / 20.0f); 381 | } 382 | 383 | void ReloadPlugin() 384 | { 385 | if (!string.IsNullOrEmpty(plugin.PluginFilePath)) 386 | { 387 | LoadPlugin(plugin.PluginFilePath); 388 | } 389 | } 390 | 391 | void EditPlugin() 392 | { 393 | if (!string.IsNullOrEmpty(plugin.PluginFilePath)) 394 | { 395 | try 396 | { 397 | using (Process fileopener = new Process()) 398 | { 399 | 400 | fileopener.StartInfo.FileName = "explorer"; 401 | fileopener.StartInfo.Arguments = "\"" + plugin.PluginFilePath + "\""; 402 | fileopener.Start(); 403 | } 404 | } 405 | catch (Exception ex) 406 | { 407 | MessageBox.Show("Error: " + ex.ToString()); 408 | } 409 | } 410 | } 411 | 412 | 413 | void LoadPlugin() 414 | { 415 | OpenFileDialog openFileDialog = new OpenFileDialog(); 416 | 417 | openFileDialog.Filter = "Faust Files|*.dsp"; 418 | 419 | if (openFileDialog.ShowDialog() == DialogResult.OK) 420 | { 421 | if (!string.IsNullOrEmpty(openFileDialog.FileName)) 422 | { 423 | LoadPlugin(openFileDialog.FileName); 424 | } 425 | } 426 | } 427 | 428 | void LoadPlugin(string pluginFilePath) 429 | { 430 | try 431 | { 432 | plugin.LoadPlugin(pluginFilePath); 433 | } 434 | catch (Exception ex) 435 | { 436 | if (ex is DspCompiler.FaustCompileException) 437 | { 438 | MessageBox.Show(ex.Message); 439 | } 440 | else 441 | { 442 | MessageBox.Show("An error occurred: " + ex.ToString()); 443 | } 444 | } 445 | 446 | UpdateParameters(); 447 | } 448 | } 449 | } 450 | -------------------------------------------------------------------------------- /FaustVst/FaustVst.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using System.Runtime.Loader; 5 | using System.Threading; 6 | using AudioPlugSharp; 7 | using FaustDSP; 8 | using UILayout; 9 | 10 | namespace FaustVst 11 | { 12 | public class FaustVst : AudioPluginBase 13 | { 14 | public string PluginFilePath; 15 | 16 | AudioIOPort stereoInput; 17 | AudioIOPort stereoOutput; 18 | 19 | public IFaustDSP FaustDsp { get; private set; } = null; 20 | double[][] inBuf = new double[2][]; 21 | double[][] outBuf = new double[2][]; 22 | 23 | MonoGameHost GameHost; 24 | DspCompiler compiler = new DspCompiler(); 25 | 26 | public FaustVst() 27 | { 28 | Company = "Nostatic Software"; 29 | Website = "github.com/mikeoliphant"; 30 | Contact = "contact@nostatic.org"; 31 | PluginName = "FaustPlugin"; 32 | PluginCategory = "Fx"; 33 | PluginVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(this.GetType().Assembly.Location).FileVersion; 34 | 35 | PluginID = 0xA7D6AED74104A2C5; 36 | 37 | HasUserInterface = true; 38 | EditorWidth = 800; 39 | EditorHeight = 400; 40 | } 41 | 42 | public override void Initialize() 43 | { 44 | base.Initialize(); 45 | 46 | //Logger.Log("Plugin has " + plugin.GetNumInputs() + " inputs and " + plugin.GetNumOutputs() + " outputs"); 47 | 48 | InputPorts = new AudioIOPort[] { stereoInput = new AudioIOPort("Stereo Input", EAudioChannelConfiguration.Stereo) }; 49 | OutputPorts = new AudioIOPort[] { stereoOutput = new AudioIOPort("Stereo Output", EAudioChannelConfiguration.Stereo) }; 50 | } 51 | 52 | public void LoadPlugin(string path) 53 | { 54 | PluginFilePath = path; 55 | 56 | Logger.Log("Compiling plugin"); 57 | 58 | Assembly faustAssembly = typeof(IFaustDSP).Assembly; 59 | 60 | Logger.Log("FaustDSP location: " + faustAssembly.Location); 61 | 62 | AssemblyLoadContext loadContext = AssemblyLoadContext.GetLoadContext(faustAssembly); 63 | 64 | Logger.Log("LoadContext: " + loadContext.ToString()); 65 | 66 | FaustDsp = compiler.CompileDSP(path, loadContext); 67 | 68 | if (FaustDsp != null) 69 | { 70 | FaustDsp.InstanceResetUserInterface(); 71 | FaustDsp.Init((int)Host.SampleRate); 72 | } 73 | else 74 | { 75 | Logger.Log("*** Plugin is null"); 76 | } 77 | } 78 | 79 | IntPtr parentWindow; 80 | 81 | public override void ShowEditor(IntPtr parentWindow) 82 | { 83 | Logger.Log("Show Editor"); 84 | 85 | this.parentWindow = parentWindow; 86 | 87 | if (parentWindow == IntPtr.Zero) 88 | { 89 | RunGame(); 90 | } 91 | else 92 | { 93 | Thread thread = new Thread(new ThreadStart(RunGame)); 94 | 95 | thread.SetApartmentState(ApartmentState.STA); 96 | 97 | thread.Start(); 98 | } 99 | } 100 | 101 | void RunGame() 102 | { 103 | Logger.Log("Start game"); 104 | 105 | try 106 | { 107 | int screenWidth = (int)EditorWidth; 108 | int screenHeight = (int)EditorHeight; 109 | 110 | FaustLayout layout = new FaustLayout(this); 111 | 112 | layout.Scale = 0.35f; 113 | 114 | using (GameHost = new MonoGameHost(parentWindow, screenWidth, screenHeight, fullscreen: false)) 115 | { 116 | GameHost.IsMouseVisible = true; 117 | 118 | GameHost.StartGame(layout); 119 | } 120 | 121 | layout = null; 122 | } 123 | catch (Exception ex) 124 | { 125 | Logger.Log("Run game failed with: " + ex.ToString()); 126 | } 127 | } 128 | 129 | public override void ResizeEditor(uint newWidth, uint newHeight) 130 | { 131 | base.ResizeEditor(newWidth, newHeight); 132 | 133 | if (GameHost != null) 134 | { 135 | GameHost.RequestResize((int)newWidth, (int)newHeight); 136 | } 137 | } 138 | 139 | 140 | public override void HideEditor() 141 | { 142 | base.HideEditor(); 143 | 144 | GameHost.Exit(); 145 | } 146 | 147 | public override void InitializeProcessing() 148 | { 149 | base.InitializeProcessing(); 150 | 151 | if (FaustDsp != null) 152 | { 153 | FaustDsp.Init((int)Host.SampleRate); 154 | } 155 | } 156 | 157 | public override void SetMaxAudioBufferSize(uint maxSamples, EAudioBitsPerSample bitsPerSample) 158 | { 159 | base.SetMaxAudioBufferSize(maxSamples, bitsPerSample); 160 | 161 | inBuf[0] = new double[maxSamples]; 162 | inBuf[1] = new double[maxSamples]; 163 | 164 | outBuf[0] = new double[maxSamples]; 165 | outBuf[1] = new double[maxSamples]; 166 | } 167 | 168 | public override void Process() 169 | { 170 | base.Process(); 171 | 172 | Host.ProcessAllEvents(); 173 | 174 | if (FaustDsp == null) 175 | { 176 | stereoInput.PassThroughTo(stereoOutput); 177 | } 178 | else 179 | { 180 | for (int i = 0; i < FaustDsp.GetNumInputs(); i++) 181 | { 182 | stereoInput.GetAudioBuffer(i).CopyTo(inBuf[i]); 183 | } 184 | 185 | FaustDsp.Compute((int)Host.CurrentAudioBufferSize, inBuf, outBuf); 186 | 187 | int numOutputs = FaustDsp.GetNumOutputs(); 188 | 189 | for (int i = 0; i < 2; i++) 190 | { 191 | outBuf[i % numOutputs].CopyTo(stereoOutput.GetAudioBuffer(i)); 192 | } 193 | } 194 | } 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /FaustVst/FaustVst.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0-windows 5 | 0.1.0 6 | true 7 | false 8 | true 9 | true 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /FaustVst/README.txt: -------------------------------------------------------------------------------- 1 | FaustVst 2 | 3 | Copyright (c) 2024 Mike Oliphant 4 | 5 | Source code and license information can be found here: 6 | 7 | https://github.com/mikeoliphant/FaustVst 8 | 9 | This is a VST3 plugin, and as such must be run within a VST host such as a DAW (Digital Audio Workstation) application. 10 | 11 | For your host to see the plugin, the "FaustVst" folder must be copied to your VST3 path - usually "C:\Program Files\Common Files\VST3". 12 | -------------------------------------------------------------------------------- /FaustVst/UIElements.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Configuration; 3 | using System.Drawing; 4 | using UILayout; 5 | 6 | namespace FaustVst 7 | { 8 | public class ParameterDial : Dock 9 | { 10 | public double MinValue { get; set; } 11 | public double MaxValue { get; set; } 12 | public double DefaultValue { get; set; } 13 | public double RangePower { get; set; } = 1.0; 14 | public Action ValueChangedAction { get; set; } 15 | public Action HoldAction { get; set; } 16 | 17 | ImageElement background; 18 | RotatingImageElement pointer; 19 | double currentValue; 20 | 21 | public ParameterDial() 22 | { 23 | MinValue = 0; 24 | MaxValue = 1; 25 | DefaultValue = 0.5; 26 | 27 | background = new ImageElement("DialBackground") { HorizontalAlignment = EHorizontalAlignment.Center, VerticalAlignment = EVerticalAlignment.Center }; 28 | Children.Add(background); 29 | 30 | pointer = new RotatingImageElement("DialPointer") { HorizontalAlignment = EHorizontalAlignment.Center, VerticalAlignment = EVerticalAlignment.Center, Color = UIColor.Black }; 31 | Children.Add(pointer); 32 | 33 | SetValue(DefaultValue); 34 | } 35 | 36 | public void SetDialColor(UIColor color) 37 | { 38 | background.Color = color; 39 | } 40 | 41 | public void SetPointerColor(UIColor color) 42 | { 43 | pointer.Color = color; 44 | } 45 | 46 | public void SetValue(double value) 47 | { 48 | currentValue = MathUtil.Clamp(value, MinValue, MaxValue); 49 | 50 | double val = (currentValue - MinValue) / (MaxValue - MinValue); 51 | 52 | double maxAngle = 143; 53 | 54 | double angle = -maxAngle + (val * maxAngle * 2); 55 | 56 | pointer.Rotation = MathUtil.ToRadians((float)angle); 57 | } 58 | 59 | double touchStartValue; 60 | 61 | public override bool HandleTouch(in Touch touch) 62 | { 63 | switch (touch.TouchState) 64 | { 65 | case ETouchState.Pressed: 66 | CaptureTouch(touch); 67 | touchStartValue = currentValue; 68 | break; 69 | case ETouchState.Moved: 70 | case ETouchState.Held: 71 | if (HaveTouchCapture) 72 | { 73 | double delta = TouchCaptureStartPosition.Y - touch.Position.Y; 74 | 75 | double range = MaxValue - MinValue; 76 | 77 | double newValue = touchStartValue + ((delta * range) / 160); //(double)PixGame.Instance.ScreenPPI); 78 | 79 | newValue = MathUtil.Clamp(newValue, MinValue, MaxValue); 80 | 81 | SetValue(newValue); 82 | 83 | if (ValueChangedAction != null) 84 | ValueChangedAction(newValue); 85 | } 86 | break; 87 | case ETouchState.Released: 88 | case ETouchState.Invalid: 89 | ReleaseTouch(); 90 | break; 91 | default: 92 | break; 93 | } 94 | 95 | if (IsDoubleTap(touch)) 96 | { 97 | SetValue(DefaultValue); 98 | 99 | if (ValueChangedAction != null) 100 | ValueChangedAction(DefaultValue); 101 | } 102 | 103 | return true; 104 | } 105 | 106 | //public override bool HandleGesture(PixGesture gesture) 107 | //{ 108 | // if (gesture.GestureType == EPixGestureType.Hold) 109 | // { 110 | // if (HoldAction != null) 111 | // { 112 | // HoldAction(); 113 | 114 | // return true; 115 | // } 116 | // } 117 | 118 | // return base.HandleGesture(gesture); 119 | //} 120 | } 121 | 122 | public class ParameterValueDisplay : NinePatchWrapper 123 | { 124 | public float HoldSeconds { get; set; } 125 | public float FadeSeconds { get; set; } 126 | public string ValueFormat { get; set; } = "0.0"; 127 | 128 | float visibleSeconds = 0; 129 | StringBuilderTextBlock textBlock; 130 | double value = double.MinValue; 131 | 132 | public ParameterValueDisplay() 133 | : base(Layout.Current.GetImage("HoverTextOutline")) 134 | { 135 | Visible = false; 136 | 137 | HorizontalAlignment = EHorizontalAlignment.Center; 138 | VerticalAlignment = EVerticalAlignment.Center; 139 | 140 | HoldSeconds = 0.25f; 141 | FadeSeconds = 0.25f; 142 | 143 | textBlock = new StringBuilderTextBlock 144 | { 145 | TextColor = UIColor.Black, 146 | TextFont = Layout.Current.GetFont("SmallFont"), 147 | Margin = new LayoutPadding(5, 5), 148 | HorizontalAlignment = EHorizontalAlignment.Center, 149 | VerticalAlignment = EVerticalAlignment.Center 150 | }; 151 | 152 | Child = textBlock; 153 | } 154 | 155 | public void SetValue(double value) 156 | { 157 | if (value != this.value) 158 | { 159 | this.value = value; 160 | 161 | textBlock.StringBuilder.Clear(); 162 | textBlock.StringBuilder.AppendFormat(ValueFormat, value); 163 | } 164 | 165 | UpdateActive(); 166 | } 167 | 168 | public void UpdateActive() 169 | { 170 | Visible = true; 171 | 172 | visibleSeconds = 0; 173 | 174 | Color = new UIColor((byte)Color.R, (byte)Color.G, (byte)Color.B, (byte)255); 175 | } 176 | 177 | protected override void DrawContents() 178 | { 179 | base.DrawContents(); 180 | 181 | if (Visible) 182 | { 183 | visibleSeconds += Layout.Current.SecondsElapsed; 184 | 185 | if (visibleSeconds > HoldSeconds) 186 | { 187 | if (visibleSeconds > (HoldSeconds + FadeSeconds)) 188 | { 189 | Visible = false; 190 | } 191 | else 192 | { 193 | byte alpha = (byte)(255 * MathUtil.Saturate(1.0f - ((visibleSeconds - HoldSeconds) / FadeSeconds))); 194 | 195 | Color = new UIColor((byte)Color.R, (byte)Color.G, (byte)Color.B, alpha); 196 | } 197 | } 198 | } 199 | } 200 | } 201 | 202 | public class LevelBar : Dock 203 | { 204 | public bool DoLogDisplay { get; set; } 205 | public double WarnLevel { get; set; } 206 | public Func GetValue { get; set; } 207 | 208 | bool isHorizontal = false; 209 | ImageElement activeLevelImage; 210 | double lastValue = 0; 211 | double clip = 0; 212 | 213 | public LevelBar() 214 | : this(isHorizontal: false) 215 | { 216 | } 217 | 218 | public LevelBar(bool isHorizontal) 219 | { 220 | this.isHorizontal = isHorizontal; 221 | 222 | WarnLevel = 0.8f; 223 | BackgroundColor = UIColor.Black; 224 | HorizontalAlignment = EHorizontalAlignment.Stretch; 225 | VerticalAlignment = EVerticalAlignment.Stretch; 226 | 227 | string imageName = isHorizontal ? "LevelDisplayHorizontal" : "LevelDisplay"; 228 | 229 | Children.Add(new ImageElement(imageName) 230 | { 231 | Color = new UIColor(20, 20, 20), 232 | }); 233 | 234 | activeLevelImage = new ImageElement(imageName) 235 | { 236 | HorizontalAlignment = isHorizontal ? EHorizontalAlignment.Left : EHorizontalAlignment.Stretch, 237 | VerticalAlignment = isHorizontal ? EVerticalAlignment.Stretch : EVerticalAlignment.Bottom, 238 | Color = UIColor.Green, 239 | }; 240 | activeLevelImage.Visible = false; 241 | Children.Add(activeLevelImage); 242 | } 243 | 244 | public void SetValue(double value) 245 | { 246 | if (value < 0.01) 247 | value = 0; 248 | 249 | if (clip > 0) 250 | { 251 | clip -= 0.1; 252 | 253 | if (clip <= 0) 254 | activeLevelImage.Color = UIColor.Green; 255 | } 256 | 257 | if (value >= 1.0) 258 | { 259 | clip = 1; 260 | activeLevelImage.Color = UIColor.Red; 261 | } 262 | else if (value >= WarnLevel) 263 | { 264 | clip = 1; 265 | activeLevelImage.Color = UIColor.Orange; 266 | } 267 | 268 | if (value != lastValue) 269 | { 270 | lastValue = value; 271 | 272 | double displayValue = DoLogDisplay ? Math.Min(Math.Log10((value * 9.0) + 1.0), 1.0) : value; 273 | 274 | if (isHorizontal) 275 | { 276 | int width = (int)((double)activeLevelImage.Image.Width * displayValue); 277 | 278 | if (width > activeLevelImage.Image.Width) 279 | width = activeLevelImage.Image.Width; 280 | 281 | activeLevelImage.SourceRectangle = new Rectangle(0, 0, width, activeLevelImage.Image.Height); 282 | activeLevelImage.DesiredWidth = ContentBounds.Width * (float)displayValue; 283 | activeLevelImage.Visible = (displayValue > 0); 284 | } 285 | else 286 | { 287 | int height = (int)((double)activeLevelImage.Image.Height * displayValue); 288 | 289 | if (height > activeLevelImage.Image.Height) 290 | height = activeLevelImage.Image.Height; 291 | 292 | activeLevelImage.SourceRectangle = new Rectangle(0, activeLevelImage.Image.Height - height, activeLevelImage.Image.Width, height); 293 | activeLevelImage.DesiredHeight = ContentBounds.Height * (float)displayValue; 294 | activeLevelImage.Visible = (displayValue > 0); 295 | } 296 | 297 | UpdateContentLayout(); 298 | } 299 | } 300 | 301 | protected override void DrawContents() 302 | { 303 | if (GetValue != null) 304 | { 305 | SetValue(GetValue()); 306 | } 307 | 308 | base.DrawContents(); 309 | } 310 | } 311 | 312 | public class VerticalLevelBar : LevelBar 313 | { 314 | public VerticalLevelBar() 315 | : base(isHorizontal: false) 316 | { 317 | 318 | } 319 | } 320 | 321 | public class HorizontalLevelBar : LevelBar 322 | { 323 | public HorizontalLevelBar() 324 | : base(isHorizontal: true) 325 | { 326 | 327 | } 328 | } 329 | } 330 | -------------------------------------------------------------------------------- /IRTest/IRTest.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /IRTest/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using FaustDSP; 4 | 5 | namespace IRTest 6 | { 7 | class Program 8 | { 9 | static bool Verbose = false; 10 | static bool WriteOutput = false; 11 | static int ComputeBlockSize = 64; 12 | 13 | static void Main(string[] args) 14 | { 15 | ExecuteTests(@"C:\Code\faust\tests\impulse-tests"); 16 | } 17 | 18 | static void ExecuteTests(string testPath) 19 | { 20 | string dspPath = Path.Combine(testPath, "dsp"); 21 | string irPath = Path.Combine(testPath, "reference"); 22 | 23 | DspCompiler compiler = new DspCompiler(); 24 | 25 | int numSucceeded = 0; 26 | int numFailed = 0; 27 | 28 | foreach (string dspFile in Directory.GetFiles(dspPath, "*.dsp")) 29 | { 30 | //if (!dspFile.EndsWith("UITester.dsp")) 31 | // continue; 32 | 33 | if (Verbose) 34 | Console.WriteLine("Compiling: " + dspFile); 35 | 36 | IFaustDSP dsp = null; 37 | 38 | bool succeeded = false; 39 | 40 | try 41 | { 42 | try 43 | { 44 | dsp = compiler.CompileDSP(dspFile); 45 | } 46 | catch (Exception ex) 47 | { 48 | if (Verbose) 49 | Console.WriteLine("Dsp computation failed with: " + ex.ToString()); 50 | } 51 | 52 | if (dsp != null) 53 | { 54 | string irFile = Path.Combine(irPath, Path.GetFileNameWithoutExtension(dspFile) + ".ir"); 55 | 56 | if (!File.Exists(irFile)) 57 | { 58 | if (Verbose) 59 | Console.WriteLine("Unable to find ir file: " + irFile); 60 | } 61 | else 62 | { 63 | double[][] irData = ReadIRFile(irFile); 64 | 65 | if (irData == null) 66 | { 67 | if (Verbose) 68 | Console.WriteLine("Unable to read ir data from: " + irFile); 69 | } 70 | else 71 | { 72 | dsp.Init(44100); 73 | 74 | int numFrames = irData[0].Length / 4; 75 | 76 | if (Verbose) 77 | Console.WriteLine("IR files has " + dsp.GetNumInputs() + " inputs, " + dsp.GetNumOutputs() + " outputs, and " + numFrames + " frames"); 78 | 79 | double[][] inputData = new double[dsp.GetNumInputs()][]; 80 | for (int inputChannel = 0; inputChannel < dsp.GetNumInputs(); inputChannel++) 81 | { 82 | inputData[inputChannel] = new double[ComputeBlockSize]; 83 | } 84 | 85 | double[][] outputData = new double[dsp.GetNumOutputs()][]; 86 | for (int outputChannel = 0; outputChannel < dsp.GetNumOutputs(); outputChannel++) 87 | { 88 | outputData[outputChannel] = new double[ComputeBlockSize]; 89 | } 90 | 91 | double error = 0; 92 | double maxErrror = 0; 93 | 94 | int computeRun = 0; 95 | int framesLeft = numFrames; 96 | int currentFrame = 0; 97 | 98 | while (framesLeft > 0) 99 | { 100 | if (computeRun == 0) 101 | { 102 | for (int inputChannel = 0; inputChannel < dsp.GetNumInputs(); inputChannel++) 103 | { 104 | inputData[inputChannel][0] = 1; 105 | } 106 | 107 | SetButtons(dsp.UIDefinition.RootElement, 1); 108 | } 109 | else if (computeRun == 1) 110 | { 111 | for (int inputChannel = 0; inputChannel < dsp.GetNumInputs(); inputChannel++) 112 | { 113 | inputData[inputChannel][0] = 0; 114 | } 115 | 116 | SetButtons(dsp.UIDefinition.RootElement, 0); 117 | } 118 | 119 | dsp.Compute(ComputeBlockSize, inputData, outputData); 120 | 121 | int blockSize = Math.Min(ComputeBlockSize, framesLeft); 122 | 123 | for (int sample = 0; sample < blockSize; sample++) 124 | { 125 | string compString = null; 126 | 127 | for (int outputChannel = 0; outputChannel < outputData.Length; outputChannel++) 128 | { 129 | double outputValue = outputData[outputChannel][sample]; 130 | 131 | outputValue = Math.Round(outputValue * 1000000) / 1000000; 132 | 133 | double diff = irData[outputChannel][currentFrame] - outputValue; 134 | 135 | if (WriteOutput) 136 | compString += irData[outputChannel][currentFrame] + "/" + outputValue + " "; 137 | 138 | if (Math.Abs(diff) > maxErrror) 139 | { 140 | maxErrror = Math.Abs(diff); 141 | } 142 | 143 | if (diff != 0) 144 | { 145 | } 146 | 147 | error += diff * diff; 148 | } 149 | 150 | currentFrame++; 151 | 152 | if (WriteOutput) 153 | Console.WriteLine(compString); 154 | } 155 | 156 | framesLeft -= blockSize; 157 | computeRun++; 158 | } 159 | 160 | error = Math.Sqrt(error / (double)(irData.Length * numFrames)); 161 | 162 | if (Verbose) 163 | { 164 | Console.WriteLine("Root-mean-square error is: " + error.ToString("0.########") + " Max error is: " + maxErrror.ToString("0.########")); 165 | Console.WriteLine(); 166 | } 167 | else 168 | { 169 | succeeded = (maxErrror < 0.001); 170 | } 171 | } 172 | } 173 | } 174 | } 175 | catch (Exception ex) 176 | { 177 | if (Verbose) 178 | { 179 | Console.WriteLine("Testing failed with: " + ex.ToString()); 180 | } 181 | else 182 | { 183 | Console.WriteLine(Path.GetFileName(dspFile) + " - *** Failed"); 184 | } 185 | } 186 | 187 | Console.WriteLine(Path.GetFileName(dspFile) + " - " + (succeeded ? "Success" : "*** Failed")); 188 | 189 | if (succeeded) 190 | numSucceeded++; 191 | else 192 | numFailed++; 193 | } 194 | 195 | Console.WriteLine(); 196 | Console.WriteLine(numSucceeded + " tests succeeded. " + numFailed + " tests failed"); 197 | } 198 | 199 | static void SetButtons(FaustUIElement element, double value) 200 | { 201 | if (element is FaustBoxElement) 202 | { 203 | foreach (FaustUIElement child in (element as FaustBoxElement).Children) 204 | { 205 | SetButtons(child, value); 206 | } 207 | } 208 | else 209 | { 210 | if (element is FaustUIVariableElement) 211 | { 212 | if (element.ElementType == EFaustUIElementType.Button) 213 | { 214 | FaustUIVariableElement variableElement = (element as FaustUIVariableElement); 215 | 216 | variableElement.VariableAccessor.SetValue(value); 217 | } 218 | } 219 | } 220 | } 221 | 222 | static double[][] ReadIRFile(string irFile) 223 | { 224 | double[][] irData = null; 225 | 226 | using (StreamReader reader = new StreamReader(irFile)) 227 | { 228 | int numInputs = -1; 229 | int numOutputs = -1; 230 | int numFrames = -1; 231 | 232 | numInputs = ReadIRHeader(reader, "number_of_inputs"); 233 | 234 | if (numInputs != -1) 235 | { 236 | numOutputs = ReadIRHeader(reader, "number_of_outputs"); 237 | 238 | if (numOutputs != -1) 239 | { 240 | numFrames = ReadIRHeader(reader, "number_of_frames"); 241 | 242 | if (numFrames != -1) 243 | { 244 | irData = new double[numOutputs][]; 245 | 246 | for (int outputChannel = 0; outputChannel < numOutputs; outputChannel++) 247 | { 248 | irData[outputChannel] = new double[numFrames]; 249 | } 250 | 251 | for (int i = 0; i < numFrames; i++) 252 | { 253 | string frameLine = reader.ReadLine(); 254 | 255 | if (frameLine != null) 256 | { 257 | string[] frameSplit = frameLine.Split(':'); 258 | 259 | if (frameSplit.Length == 2) 260 | { 261 | string[] valueSplit = frameSplit[1].Trim().Split(' '); 262 | 263 | if (valueSplit.Length == numOutputs) 264 | { 265 | try 266 | { 267 | for (int outputChannel = 0; outputChannel < numOutputs; outputChannel++) 268 | { 269 | irData[outputChannel][i] = double.Parse(valueSplit[outputChannel]); 270 | } 271 | 272 | continue; 273 | } 274 | catch { }; 275 | } 276 | } 277 | } 278 | 279 | Console.WriteLine("Error reading frame data at frame " + i); 280 | 281 | return null; 282 | } 283 | } 284 | } 285 | } 286 | } 287 | 288 | return irData; 289 | } 290 | 291 | static int ReadIRHeader(StreamReader reader, string parameterName) 292 | { 293 | string line = reader.ReadLine(); 294 | 295 | if (line != null) 296 | { 297 | string[] lineSplit = line.Split(':'); 298 | 299 | if (lineSplit.Length == 2) 300 | { 301 | if (lineSplit[0].Trim().ToLower() == parameterName) 302 | { 303 | return int.Parse(lineSplit[1]); 304 | } 305 | } 306 | } 307 | 308 | Console.WriteLine("IR file does not contain parameter " + parameterName); 309 | 310 | return -1; 311 | } 312 | } 313 | } 314 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FaustVst 2 | 3 | FaustVst is a VST3 plugin that allows you to dynamically load/compile/edit [Faust](https://faust.grame.fr/) effects from source dsp files. 4 | 5 | It is lets you do quick iteration (make a change and reload it nearly instantly), all while running integrated in your DAW. 6 | 7 | Here is an example of a simple gain/pan plugin with output level meters: 8 | 9 | ![GainPan](https://github.com/user-attachments/assets/c39db00f-8691-4125-b5bd-62b5339eab95) 10 | 11 | and this is the source Faust dsp code that generated it: 12 | 13 | ``` 14 | import("stdfaust.lib"); 15 | 16 | gain_pan(x, y) = sp.constantPowerPan(pan, x, y) : gainxy 17 | with { 18 | gainxy(x, y) = x * gain, y * gain; 19 | gain = vslider("[0] Gain [unit:dB] [style:knob]", 0, -40, 40, 1) : ba.db2linear; 20 | pan = vslider("[1] Pan [style:knob]", 0.5, 0, 1, .01); 21 | }; 22 | 23 | left_meter(x) = attach(x, ba.linear2db(x) : vbargraph("Left [unit:dB]", -96, 10)); 24 | right_meter(x) = attach(x, ba.linear2db(x) : vbargraph("Right [unit:dB]", -96, 10)); 25 | 26 | process = hgroup("Stereo Gain/Pan", hgroup("Gain/Pan", gain_pan) : hgroup("Output", (left_meter, right_meter))); 27 | ``` 28 | 29 | # Installation and requirements 30 | 31 | You can download the VST plugin from the releases section [here](https://github.com/mikeoliphant/FaustVst/releases/latest). 32 | 33 | To install, unpack the .zip file and copy the "FaustVst" folder to your VST3 folder - usually "C:\Program Files\Common Files\VST3". 34 | 35 | FaustVst is currently Windows-only. 36 | 37 | FaustVst requires that you have Faust installed. It expects the Faust compiler to be located at "C:\Program Files\Faust\bin\faust.exe". 38 | 39 | To edit files, just make sure that the ".dsp" extension is assocated with your editor of choice. 40 | 41 | # Current limitations 42 | 43 | - Maximum of 2 input/output audio channels. 44 | - No MIDI support (yet). 45 | - Not all UI metadata is supported. 46 | 47 | # Performance 48 | 49 | FaustVst is intended to provide a quick-iteration framework for working on Faust effects. While it does produce relatively well optimized code that is suitable for realtime testing, performance will be not as good as a compiled C++ effect. 50 | 51 | # How does it work? 52 | 53 | FaustVst uses the faust compiler to create C# code, which is then dynamically compiled into an assembly and run in the plugin (using [AudioPlugSharp](https://github.com/mikeoliphant/AudioPlugSharp)). 54 | 55 | The plugin UI is done using [UILayout](https://github.com/mikeoliphant/UILayout), a lightweight UI library that runs on top of [MonoGame](https://github.com/MonoGame/MonoGame). 56 | 57 | 58 | -------------------------------------------------------------------------------- /SrcTextures/.gitignore: -------------------------------------------------------------------------------- 1 | tmp/ -------------------------------------------------------------------------------- /SrcTextures/UserInterface/.gitignore: -------------------------------------------------------------------------------- 1 | DialPointerRotations.png -------------------------------------------------------------------------------- /SrcTextures/UserInterface/ButtonPressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeoliphant/FaustVst/cbccaa9bda313ad0b7e41b85579a0a58ff40cb9d/SrcTextures/UserInterface/ButtonPressed.png -------------------------------------------------------------------------------- /SrcTextures/UserInterface/ButtonUnpressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeoliphant/FaustVst/cbccaa9bda313ad0b7e41b85579a0a58ff40cb9d/SrcTextures/UserInterface/ButtonUnpressed.png -------------------------------------------------------------------------------- /SrcTextures/UserInterface/DialBackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeoliphant/FaustVst/cbccaa9bda313ad0b7e41b85579a0a58ff40cb9d/SrcTextures/UserInterface/DialBackground.png -------------------------------------------------------------------------------- /SrcTextures/UserInterface/DialPointer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeoliphant/FaustVst/cbccaa9bda313ad0b7e41b85579a0a58ff40cb9d/SrcTextures/UserInterface/DialPointer.png -------------------------------------------------------------------------------- /SrcTextures/UserInterface/FileEdit.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /SrcTextures/UserInterface/FileOpen.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /SrcTextures/UserInterface/HoverTextOutline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeoliphant/FaustVst/cbccaa9bda313ad0b7e41b85579a0a58ff40cb9d/SrcTextures/UserInterface/HoverTextOutline.png -------------------------------------------------------------------------------- /SrcTextures/UserInterface/LevelDisplay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeoliphant/FaustVst/cbccaa9bda313ad0b7e41b85579a0a58ff40cb9d/SrcTextures/UserInterface/LevelDisplay.png -------------------------------------------------------------------------------- /SrcTextures/UserInterface/LevelDisplayHorizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeoliphant/FaustVst/cbccaa9bda313ad0b7e41b85579a0a58ff40cb9d/SrcTextures/UserInterface/LevelDisplayHorizontal.png -------------------------------------------------------------------------------- /SrcTextures/UserInterface/PluginBackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeoliphant/FaustVst/cbccaa9bda313ad0b7e41b85579a0a58ff40cb9d/SrcTextures/UserInterface/PluginBackground.png -------------------------------------------------------------------------------- /SrcTextures/UserInterface/PopupBackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeoliphant/FaustVst/cbccaa9bda313ad0b7e41b85579a0a58ff40cb9d/SrcTextures/UserInterface/PopupBackground.png -------------------------------------------------------------------------------- /SrcTextures/UserInterface/Reload.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /SrcTextures/UserInterface/SingleWhitePixel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeoliphant/FaustVst/cbccaa9bda313ad0b7e41b85579a0a58ff40cb9d/SrcTextures/UserInterface/SingleWhitePixel.png -------------------------------------------------------------------------------- /SrcTextures/UserInterface/VerticalSlider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeoliphant/FaustVst/cbccaa9bda313ad0b7e41b85579a0a58ff40cb9d/SrcTextures/UserInterface/VerticalSlider.png --------------------------------------------------------------------------------