├── images
└── screenshot_1.png
├── .gitignore
├── plugin.json
├── .github
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── src
├── format_code.sh
├── .astylerc
├── plugin.hpp
├── Amalgamated.hpp
├── plugin.cpp
├── WidgetAccess.hpp
├── ProtoFaust.hpp
├── faust
│ ├── rack.dsp
│ ├── architecture_rack.cpp
│ ├── gui.dsp
│ └── main.dsp
├── lint.sh
├── ProtoFaustWidget.hpp
├── ProtoFaust.cpp
└── ProtoFaustWidget.cpp
├── Makefile
├── .dir-locals.el
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── autogen.py
├── README.md
├── helper.py
└── LICENSE
/images/screenshot_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mzuther/ProtoFaust/HEAD/images/screenshot_1.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | /dist
3 | /faust
4 | /plugin.so
5 | /plugin.dylib
6 | /plugin.dll
7 | /src/faust/output
8 | /src/faust/main-svg
9 | /src/faust_generated.cpp
10 | .DS_Store
11 |
--------------------------------------------------------------------------------
/plugin.json:
--------------------------------------------------------------------------------
1 | {
2 | "slug": "MartinZuther-Prototype",
3 | "name": "Prototype",
4 | "version": "1.0.5",
5 | "license": "GPL-3.0-or-later",
6 | "brand": "",
7 | "author": "Martin Zuther",
8 | "authorEmail": "",
9 | "authorUrl": "http://code.mzuther.de/",
10 | "pluginUrl": "https://github.com/mzuther/ProtoFaust",
11 | "manualUrl": "https://github.com/mzuther/ProtoFaust",
12 | "sourceUrl": "https://github.com/mzuther/ProtoFaust",
13 | "donateUrl": "",
14 | "modules": [
15 | {
16 | "slug": "ProtoFaust",
17 | "name": "ProtoFaust",
18 | "description": "DSP prototyping in Faust for VCV Rack",
19 | "tags": [
20 | "Prototype",
21 | "Utility"]
22 | }
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: 'Feature request: '
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | ### Is your feature request related to a problem? If so, please describe.
11 |
12 | A *clear and concise* description of what the problem is. (I'm always frustrated when ...)
13 |
14 |
15 | ### Describe the solution you'd like
16 |
17 | A *clear and concise* description of what you want to happen.
18 |
19 |
20 | ### Describe alternatives you've considered
21 |
22 | A *clear and concise* description of any alternative solutions or features you've considered.
23 |
24 |
25 | ### Additional context
26 |
27 | Add any other context or screenshots about the feature request here.
28 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: 'Bug: '
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | ### Describe the bug
11 |
12 | A *clear and concise* description of what the bug is.
13 |
14 |
15 | ### Steps to reproduce
16 |
17 | List *all* steps to reproduce the behavior:
18 |
19 | 1. [ start VCV Rack ]
20 | 2. [ create a new song ]
21 | 3. [ add module compiled from ProtoFaust ]
22 | 4. [ see error ... ]
23 |
24 |
25 | ### Expected behavior
26 |
27 | A *clear and concise* description of what you expected to happen.
28 |
29 |
30 | ### Screenshots
31 |
32 | If applicable, add screenshots to help explain your problem.
33 |
34 |
35 | ### Environment (please complete the following information)
36 |
37 | - OS: [ Windows 10 (64-bit), Linux AV v2020.4.10 (32-bit) ]
38 | - VCV Rack: [ v1.1.6 (64-bit) ]
39 | - Proto Faust: [ v1.0.0 (64-bit), commit master/2e4dbe3 (64-bit)]
40 |
41 |
42 | ### Tool set
43 |
44 | You only need to add the tools you actually used:
45 |
46 | - Compiler: [ gcc Ubuntu v7.5.0 ]
47 | - SDK: [ VCV Rack SDK v1.1.6 ]
48 | - Faust: [ v2.20.2, master-dev, ... ]
49 | - ...
50 |
51 |
52 | ### Additional context
53 |
54 | Add any other context about the problem here.
55 |
--------------------------------------------------------------------------------
/src/format_code.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env bash
2 |
3 | # ----------------------------------------------------------------------------
4 | #
5 | # ProtoFaust
6 | # ==========
7 | # DSP prototyping in Faust for VCV Rack
8 | #
9 | # Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
10 | # contributors
11 | #
12 | # This program is free software: you can redistribute it and/or modify
13 | # it under the terms of the GNU General Public License as published by
14 | # the Free Software Foundation, either version 3 of the License, or
15 | # (at your option) any later version.
16 | #
17 | # This program is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | # GNU General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU General Public License
23 | # along with this program. If not, see .
24 | #
25 | # Thank you for using free software!
26 | #
27 | # ----------------------------------------------------------------------------
28 |
29 |
30 | astyle --recursive --exclude="faust_generated.cpp" --options=./.astylerc \
31 | "*.cpp"
32 |
33 | printf "\n"
34 |
35 | astyle --recursive --options=./.astylerc \
36 | "*.hpp"
37 |
--------------------------------------------------------------------------------
/src/.astylerc:
--------------------------------------------------------------------------------
1 | # indent using given number of spaces
2 | --indent=spaces=3
3 |
4 | # pad empty lines around header blocks ('if', 'for', 'while'...)
5 | --break-blocks
6 |
7 | # set the maximum of # spaces to indent a continuation line
8 | --max-continuation-indent=60
9 |
10 | # indent 'switch' blocks so that the 'case X:' statements are indented
11 | # in the switch block
12 | --indent-switches
13 |
14 |
15 | # opening braces are broken from namespace, class, and function
16 | # definitions; braces are attached to everything else
17 | --style=linux
18 |
19 | # add brackets to one line conditional statements ('if', 'for', 'while'...)
20 | --add-braces
21 |
22 |
23 |
24 | # insert space padding around paren on the inside only
25 | --pad-paren-in
26 |
27 | # insert space padding after paren headers only ('if', 'for', 'while'...)
28 | --pad-header
29 |
30 | # insert space padding around operators
31 | --pad-oper
32 |
33 | # attach pointer or reference operators (* or &) to the variable type (left)
34 | --align-pointer=type
35 |
36 |
37 |
38 | # display optional information
39 | --verbose
40 |
41 | # only display changed files
42 | --formatted
43 |
44 | # force Linux-style line endings (LF)
45 | --lineend=linux
46 |
47 | # do not retain a backup of the original file
48 | --suffix=none
49 |
50 |
51 | # Local Variables:
52 | # mode: conf
53 | # End:
54 |
--------------------------------------------------------------------------------
/src/plugin.hpp:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------------
2 |
3 | ProtoFaust
4 | ==========
5 | DSP prototyping in Faust for VCV Rack
6 |
7 | Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
8 | contributors
9 |
10 | This program is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program. If not, see .
22 |
23 | Thank you for using free software!
24 |
25 | ---------------------------------------------------------------------------- */
26 |
27 |
28 | #include
29 |
30 |
31 | using namespace rack;
32 |
33 | // Declare the Plugin, defined in plugin.cpp
34 | extern Plugin* pluginInstance;
35 |
36 | // Declare each Model, defined in each module source file
37 | extern Model* modelProtoFaust;
38 |
--------------------------------------------------------------------------------
/src/Amalgamated.hpp:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------------
2 |
3 | ProtoFaust
4 | ==========
5 | DSP prototyping in Faust for VCV Rack
6 |
7 | Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
8 | contributors
9 |
10 | This program is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program. If not, see .
22 |
23 | Thank you for using free software!
24 |
25 | ---------------------------------------------------------------------------- */
26 |
27 | #ifndef AMALGAMATED_HPP
28 | #define AMALGAMATED_HPP
29 |
30 | #include "plugin.hpp"
31 |
32 |
33 | // include Faust SDK and generated code
34 | namespace faust
35 | {
36 | #include "faust_generated.cpp"
37 | }
38 |
39 |
40 | // pre includes
41 | #include "WidgetAccess.hpp"
42 |
43 | // normal includes
44 | #include "ProtoFaust.hpp"
45 | #include "ProtoFaustWidget.hpp"
46 |
47 |
48 | #endif // AMALGAMATED_HPP
49 |
--------------------------------------------------------------------------------
/src/plugin.cpp:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------------
2 |
3 | ProtoFaust
4 | ==========
5 | DSP prototyping in Faust for VCV Rack
6 |
7 | Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
8 | contributors
9 |
10 | This program is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program. If not, see .
22 |
23 | Thank you for using free software!
24 |
25 | ---------------------------------------------------------------------------- */
26 |
27 |
28 | #include "plugin.hpp"
29 |
30 |
31 | Plugin* pluginInstance;
32 |
33 |
34 | void init( Plugin* p )
35 | {
36 | pluginInstance = p;
37 |
38 | // Add modules here
39 | p->addModel( modelProtoFaust );
40 |
41 | // Any other plugin initialization may go here.
42 | // As an alternative, consider lazy-loading assets and lookup tables when your module is created to reduce startup times of Rack.
43 | }
44 |
--------------------------------------------------------------------------------
/src/WidgetAccess.hpp:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------------
2 |
3 | ProtoFaust
4 | ==========
5 | DSP prototyping in Faust for VCV Rack
6 |
7 | Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
8 | contributors
9 |
10 | This program is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program. If not, see .
22 |
23 | Thank you for using free software!
24 |
25 | ---------------------------------------------------------------------------- */
26 |
27 | #ifndef WIDGET_ACCESS_HPP
28 | #define WIDGET_ACCESS_HPP
29 |
30 | #include
31 | #include
32 |
33 |
34 | struct WidgetAccess {
35 | typedef std::function setFunction;
36 | typedef std::function getFunction;
37 |
38 | int widgetType;
39 | int parameterId;
40 |
41 | setFunction faustSet;
42 | getFunction faustGet;
43 |
44 | WidgetAccess( int widget_type,
45 | int parameter_id,
46 | setFunction& set,
47 | getFunction& get ) :
48 | widgetType( widget_type ),
49 | parameterId( parameter_id ),
50 | faustSet( set ),
51 | faustGet( get )
52 | {};
53 | };
54 |
55 | #endif // WIDGET_ACCESS_HPP
56 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # If RACK_DIR is not defined when calling the Makefile, default to two directories above
2 | RACK_DIR ?= ../Rack-SDK
3 |
4 | # FLAGS will be passed to both the C and C++ compiler
5 | FLAGS +=
6 | CFLAGS +=
7 | CXXFLAGS +=
8 |
9 | # Careful about linking to shared libraries, since you can't assume much about the user's environment and library search path.
10 | # Static libraries are fine, but they should be added to this plugin's build system.
11 | LDFLAGS +=
12 |
13 | # Add .cpp files to the build
14 | SOURCES += $(wildcard src/*.cpp)
15 |
16 | # Add files to the ZIP package when running `make dist`
17 | # The compiled plugin and "plugin.json" are automatically added.
18 | DISTRIBUTABLES += res
19 | DISTRIBUTABLES += $(wildcard LICENSE*)
20 |
21 | # Include the Rack plugin Makefile framework
22 | include $(RACK_DIR)/plugin.mk
23 |
24 |
25 | all: faust $(TARGET)
26 | @RACK_DIR=$(RACK_DIR) $(MAKE) -f $(RACK_DIR)/plugin.mk $@
27 |
28 |
29 | clean: faust-clean
30 | @RACK_DIR=$(RACK_DIR) $(MAKE) -f $(RACK_DIR)/plugin.mk $@
31 |
32 |
33 | faust: src/faust_generated.cpp src/faust/main-svg/process.svg
34 |
35 |
36 | faust-clean:
37 | @echo
38 | @echo "Cleaning files generated by Faust..."
39 | rm -f src/faust_generated.cpp
40 | rm -rf src/faust/main-svg/*
41 | @echo "Done."
42 | @echo
43 |
44 |
45 | run: install
46 | Rack
47 |
48 |
49 | src/faust/main-svg/process.svg:
50 | @echo
51 | @echo "Generating Faust diagrams..."
52 | faust2svg --simple-names --simplify-diagrams --fold-complexity 8 src/faust/main.dsp
53 | @echo "Done."
54 | @echo
55 |
56 |
57 | src/faust_generated.cpp: $(wildcard src/faust/*.dsp) src/faust/architecture_rack.cpp
58 | @echo
59 | @echo "Compiling Faust files..."
60 | faust -a src/faust/architecture_rack.cpp -o src/faust_generated.cpp -os -cn FaustDSP src/faust/main.dsp
61 | @echo "Done."
62 |
63 |
64 | .PHONY: clean dist
65 | .DEFAULT_GOAL := all
66 |
--------------------------------------------------------------------------------
/src/ProtoFaust.hpp:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------------
2 |
3 | ProtoFaust
4 | ==========
5 | DSP prototyping in Faust for VCV Rack
6 |
7 | Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
8 | contributors
9 |
10 | This program is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program. If not, see .
22 |
23 | Thank you for using free software!
24 |
25 | ---------------------------------------------------------------------------- */
26 |
27 | #ifndef PROTO_FAUST_HPP
28 | #define PROTO_FAUST_HPP
29 |
30 | #include
31 | #include
32 |
33 |
34 | struct ProtoFaust : Module {
35 | public:
36 | const int numberOfChannels = 8;
37 | const FAUSTFLOAT voltageScaling = 5.0f;
38 |
39 | faust::FaustDSP FaustDSP;
40 | faust::VCVRACKUI FaustUI;
41 |
42 | ProtoFaust();
43 |
44 | void onAdd() override;
45 | void process( const ProcessArgs& args ) override;
46 |
47 | void addParameter( int widgetType,
48 | int parameterId,
49 | const std::string& faustStringId );
50 |
51 | void addParameterLed( int widgetType,
52 | int parameterId,
53 | const std::string& faustStringId );
54 |
55 | private:
56 | std::vector activeWidgets;
57 | std::vector passiveWidgets;
58 |
59 | void updateParameterIn( WidgetAccess& widget );
60 | void updateParameterOut( WidgetAccess& widget );
61 | };
62 |
63 | #endif // PROTO_FAUST_HPP
64 |
--------------------------------------------------------------------------------
/src/faust/rack.dsp:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------------
2 |
3 | ProtoFaust
4 | ==========
5 | DSP prototyping in Faust for VCV Rack
6 |
7 | Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
8 | contributors
9 |
10 | This program is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program. If not, see .
22 |
23 | Thank you for using free software!
24 |
25 | ---------------------------------------------------------------------------- */
26 |
27 |
28 | // Converts 1 V/oct to frequency in Hertz.
29 | //
30 | // The conversion formula is: 440 * 2 ^ (volts - 0.75)
31 | // The factor 0.75 shifts 0 V to C-4 (261.6256 Hz)
32 | cv_pitch2freq(cv_pitch) = 440 * 2 ^ (cv_pitch - 0.75);
33 |
34 |
35 | // Converts frequency in Hertz to 1 V/oct.
36 | //
37 | // The conversion formula is: log2(hertz / 440) + 0.75
38 | // The factor 0.75 shifts 0 V to C-4 (261.6256 Hz)
39 | freq2cv_pitch(freq) = ma.log2(freq / 440) + 0.75;
40 |
41 |
42 | // Converts 200 mV/oct to frequency in Hertz.
43 | i_cv_pitch2freq(i_cv_pitch) = i_cv_pitch : internal2cv_pitch : cv_pitch2freq;
44 |
45 |
46 | // Converts frequency in Hertz to 200 mV/oct.
47 | freq2i_cv_pitch(freq) = freq : freq2cv_pitch : cv_pitch2internal;
48 |
49 |
50 | // Converts Eurorack's 1 V/oct to internal 200 mv/oct.
51 | cv_pitch2internal(cv_pitch) = cv_pitch / 5;
52 |
53 |
54 | // Converts internal 200 mv/oct to Eurorack's 1 V/oct.
55 | internal2cv_pitch(i_cv_pitch) = i_cv_pitch * 5;
56 |
57 |
58 | // Converts Eurorack's CV (range of 10V) to internal CV (range of 1V)
59 | cv2internal(cv) = cv / 10;
60 |
61 |
62 | // Converts internal CV (range of 1V) to Eurorack's CV (range of 10V)
63 | internal2cv(i_cv) = i_cv * 10;
64 |
--------------------------------------------------------------------------------
/.dir-locals.el:
--------------------------------------------------------------------------------
1 | ;; ----------------------------------------------------------------------------
2 | ;;
3 | ;; ProtoFaust
4 | ;; ==========
5 | ;; DSP prototyping in Faust for VCV Rack
6 | ;;
7 | ;; Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
8 | ;; contributors
9 | ;;
10 | ;; This program is free software: you can redistribute it and/or modify
11 | ;; it under the terms of the GNU General Public License as published by
12 | ;; the Free Software Foundation, either version 3 of the License, or
13 | ;; (at your option) any later version.
14 | ;;
15 | ;; This program is distributed in the hope that it will be useful,
16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | ;; GNU General Public License for more details.
19 | ;;
20 | ;; You should have received a copy of the GNU General Public License
21 | ;; along with this program. If not, see .
22 | ;;
23 | ;; Thank you for using free software!
24 | ;;
25 | ;; ----------------------------------------------------------------------------
26 |
27 |
28 | (
29 | (nil . ((eval . (let* ((relative-root "")
30 | (root (concat (projectile-project-root) relative-root))
31 | (language-standard "c++11")
32 | (include-path (list
33 | (concat root "../Rack-SDK/dep/include")
34 | (concat root "../Rack-SDK/include")
35 | ))
36 | (includes (list
37 | (concat root "src/Amalgamated.hpp")
38 | )))
39 |
40 | (setq-local flycheck-clang-language-standard language-standard)
41 | (setq-local flycheck-clang-include-path include-path)
42 | (setq-local flycheck-clang-includes includes)
43 |
44 | (setq-local flycheck-gcc-language-standard language-standard)
45 | (setq-local flycheck-gcc-include-path include-path)
46 | (setq-local flycheck-gcc-includes includes)))))
47 | (c-mode . ((mode . c++)
48 | ( c-basic-offset . 3)))
49 | (c++-mode (c-basic-offset . 3))
50 | )
51 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | *All notable changes to this project will be documented in this
4 | file. This change log follows the conventions of
5 | [keepachangelog.com].*
6 |
7 |
8 | ## [Unreleased]
9 | ### Added
10 | ### Changed
11 | ### Fixed
12 |
13 |
14 |
15 | ## [1.0.5] - 2020-07-18
16 | ### Added
17 |
18 | - add custom UI handler
19 |
20 | - add linter script and fix warnings
21 |
22 | ### Changed
23 |
24 | - use lambda set/get functions to update controllers (thanks to
25 | Stéphane Letz)
26 |
27 | - use 'alloca' which is faster than std::vector and will also work on
28 | Windows (thanks to Stéphane Letz)
29 |
30 | - move some UI handling to class "ProtoFaustWidget"
31 |
32 | - allow easier debugging of RGB LEDs (enjoy fireworks of light ...)
33 |
34 | - re-factor code
35 |
36 | - change selection of files formatted by astyle
37 |
38 | ### Fixed
39 |
40 | - fix crash on opening module selection window
41 |
42 |
43 |
44 | ## [1.0.4] - 2020-07-14
45 | ### Added
46 |
47 | - documentation: describe signal ranges
48 |
49 | ### Changed
50 |
51 | - prevent filter from exploding
52 |
53 | - re-factor Faust scripts and improve readability
54 |
55 | ### Fixed
56 |
57 | - APP->engine->getSampleRate() should not be used anymore (change
58 | sample rate in process; thanks to Stéphane Letz)
59 |
60 |
61 |
62 | ## [1.0.3] - 2020-07-10
63 | ### Changed
64 |
65 | - re-factor code
66 |
67 | - change IDs of RGB LED in Faust code
68 |
69 | ### Fixed
70 |
71 | - fix wrong scaling of three-way switches
72 |
73 |
74 |
75 | ## [1.0.2] - 2020-07-09
76 | ### Changed
77 |
78 | - re-factor code
79 |
80 | - beautify output of Makefile
81 |
82 |
83 |
84 | ## [1.0.1] - 2020-07-06
85 | ### Added
86 |
87 | - add documentation, change log and code of conduct
88 |
89 | ### Changed
90 |
91 | - improve readability of Faust code (`src/faust/rack.dsp`; thanks to
92 | Stéphane Letz)
93 |
94 |
95 |
96 | ## [1.0.0] - 2019-08-18
97 | ### Changed
98 |
99 | - This is the first release.
100 |
101 |
102 | [keepachangelog.com]: http://keepachangelog.com/
103 | [Unreleased]: https://github.com/mzuther/ProtoFaust/tree/develop
104 |
105 | [1.0.0]: https://github.com/mzuther/ProtoFaust/commits/v1.0.0
106 | [1.0.1]: https://github.com/mzuther/ProtoFaust/commits/v1.0.1
107 | [1.0.2]: https://github.com/mzuther/ProtoFaust/commits/v1.0.2
108 | [1.0.3]: https://github.com/mzuther/ProtoFaust/commits/v1.0.3
109 | [1.0.4]: https://github.com/mzuther/ProtoFaust/commits/v1.0.4
110 | [1.0.5]: https://github.com/mzuther/ProtoFaust/commits/v1.0.5
111 |
--------------------------------------------------------------------------------
/src/faust/architecture_rack.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************
2 | IMPORTANT NOTE : this file contains two clearly delimited sections :
3 | the ARCHITECTURE section (in two parts) and the USER section. Each section
4 | is governed by its own copyright and license. Please check individually
5 | each section for license and copyright information.
6 | *************************************************************************/
7 |
8 | /*******************BEGIN ARCHITECTURE SECTION (part 1/2)****************/
9 |
10 | /************************************************************************
11 | FAUST Architecture File
12 | Copyright (C) 2003-2019 GRAME, Centre National de Creation Musicale
13 | ---------------------------------------------------------------------
14 | This Architecture section is free software; you can redistribute it
15 | and/or modify it under the terms of the GNU General Public License
16 | as published by the Free Software Foundation; either version 3 of
17 | the License, or (at your option) any later version.
18 |
19 | This program is distributed in the hope that it will be useful,
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | GNU General Public License for more details.
23 |
24 | You should have received a copy of the GNU General Public License
25 | along with this program; If not, see .
26 |
27 | EXCEPTION : As a special exception, you may create a larger work
28 | that contains this FAUST architecture section and distribute
29 | that work under terms of your choice, so long as this FAUST
30 | architecture section is not modified.
31 |
32 | ************************************************************************
33 | ************************************************************************/
34 |
35 | #include
36 |
37 | #include "faust/gui/MapUI.h"
38 | #include "faust/gui/meta.h"
39 | #include "faust/dsp/one-sample-dsp.h"
40 |
41 | // *INDENT-OFF* --> make astyle behave ...
42 |
43 | /******************************************************************************
44 | *******************************************************************************
45 |
46 | VECTOR INTRINSICS
47 |
48 | *******************************************************************************
49 | *******************************************************************************/
50 |
51 | <>
52 |
53 | /********************END ARCHITECTURE SECTION (part 1/2)****************/
54 |
55 | /**************************BEGIN USER SECTION **************************/
56 |
57 | <>
58 |
59 | /***************************END USER SECTION ***************************/
60 |
61 | /*******************BEGIN ARCHITECTURE SECTION (part 2/2)***************/
62 |
63 | // *INDENT-ON* --> give astyle free reign ...
64 |
65 | class VCVRACKUI : public MapUI
66 | {
67 | public:
68 | VCVRACKUI() : MapUI() {}
69 | virtual ~VCVRACKUI() {}
70 |
71 | virtual void declare( FAUSTFLOAT* zone, const char* key, const char* val ) override
72 | {
73 | MapUI::declare( zone, key, val );
74 | }
75 | };
76 |
77 | /********************END ARCHITECTURE SECTION (part 2/2)****************/
78 |
--------------------------------------------------------------------------------
/src/lint.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env bash
2 |
3 | # ----------------------------------------------------------------------------
4 | #
5 | # ProtoFaust
6 | # ==========
7 | # DSP prototyping in Faust for VCV Rack
8 | #
9 | # Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
10 | # contributors
11 | #
12 | # This program is free software: you can redistribute it and/or modify
13 | # it under the terms of the GNU General Public License as published by
14 | # the Free Software Foundation, either version 3 of the License, or
15 | # (at your option) any later version.
16 | #
17 | # This program is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | # GNU General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU General Public License
23 | # along with this program. If not, see .
24 | #
25 | # Thank you for using free software!
26 | #
27 | # ----------------------------------------------------------------------------
28 |
29 |
30 | ###############################################################################
31 | #
32 | # WARNING: this file is auto-generated, please do not edit!
33 | #
34 | ###############################################################################
35 |
36 | project_home=$(pwd)/..
37 |
38 |
39 | function lint_file
40 | {
41 | filename="$1"
42 | dirname=$(dirname "$1")
43 | project_home="$2"
44 |
45 | printf "%s\n" "$filename"
46 |
47 | clang \
48 | -x c++ - \
49 | -include "$project_home/src/Amalgamated.hpp" \
50 | -I "$project_home/../Rack-SDK/dep/include" \
51 | -I "$project_home/../Rack-SDK/include" \
52 | -I "$dirname" \
53 | -fsyntax-only \
54 | -fno-caret-diagnostics \
55 | -fcolor-diagnostics \
56 | -std=c++14 \
57 | -Wall \
58 | < "$filename"
59 |
60 | cppcheck \
61 | --template=gcc \
62 | --enable=style \
63 | --inline-suppr \
64 | --language=c++ \
65 | --force \
66 | --quiet \
67 | "$filename" 2>&1 | \
68 | sed -Ee 's/[^:]+://' | \
69 | GREP_COLORS="mt=01;31" grep --extended-regexp --colour=always \
70 | --label "$filename" --with-filename \
71 | '[^0-9:].*'
72 |
73 | # find error-like codetags
74 | GREP_COLORS="mt=01;31" grep --extended-regexp --colour=always \
75 | --with-filename --line-number \
76 | '\<(BUG|FIXME|XXX)\>' \
77 | "$filename"
78 |
79 | # find warning-like codetags
80 | GREP_COLORS="mt=01;33" grep --extended-regexp --colour=always \
81 | --with-filename --line-number \
82 | '\<(HACK|TODO|@todo)\>' \
83 | "$filename"
84 | }
85 |
86 |
87 | export -f lint_file
88 | printf "\n"
89 |
90 | find . -maxdepth 1 \( -iname "*.cpp" -or -iname "*.hpp" \) \
91 | ! -name "Amalgamated.hpp" \
92 | ! -name "faust_generated.cpp" -print | \
93 | sort | \
94 | parallel --will-cite --group \
95 | lint_file {} "$project_home"
96 |
97 | printf "\n"
98 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to make participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies within all project spaces, and it also applies when
49 | an individual is representing the project or its community in public spaces.
50 | Examples of representing a project or community include using an official
51 | project e-mail address, posting via an official social media account, or acting
52 | as an appointed representative at an online or offline event. Representation of
53 | a project may be further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at http://www.mzuther.de/en/contact/. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
78 |
--------------------------------------------------------------------------------
/src/faust/gui.dsp:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------------
2 |
3 | ProtoFaust
4 | ==========
5 | DSP prototyping in Faust for VCV Rack
6 |
7 | Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
8 | contributors
9 |
10 | This program is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program. If not, see .
22 |
23 | Thank you for using free software!
24 |
25 | ---------------------------------------------------------------------------- */
26 |
27 | import("stdfaust.lib");
28 |
29 |
30 | main_group(x) = vgroup("ProtoFaust", x);
31 |
32 | button_group(x) = main_group(hgroup("[2] Buttons", x));
33 |
34 | button_1 = button_group(vslider("1 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
35 | button_2 = button_group(vslider("2 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
36 | button_3 = button_group(vslider("3 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
37 | button_4 = button_group(vslider("4 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
38 | button_5 = button_group(vslider("5 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
39 | button_6 = button_group(vslider("6 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
40 | button_7 = button_group(vslider("7 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
41 | button_8 = button_group(vslider("8 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
42 |
43 | knob_group(x) = main_group(hgroup("[1] Knobs", x));
44 |
45 | knob_1 = knob_group(vslider("1 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
46 | knob_2 = knob_group(vslider("2 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
47 | knob_3 = knob_group(vslider("3 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
48 | knob_4 = knob_group(vslider("4 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
49 | knob_5 = knob_group(vslider("5 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
50 | knob_6 = knob_group(vslider("6 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
51 | knob_7 = knob_group(vslider("7 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
52 | knob_8 = knob_group(vslider("8 [style:knob]" , 0.5 , 0 , 1 , 1e-3));
53 |
54 | led_group(x) = main_group(hgroup("[3] Lights", x));
55 |
56 | led_1_r = led_group(vbargraph("1 Red [style:led]" , 0 , 1));
57 | led_1_g = led_group(vbargraph("1 Green [style:led]" , 0 , 1));
58 | led_1_b = led_group(vbargraph("1 Blue [style:led]" , 0 , 1));
59 |
60 | led_2_r = led_group(vbargraph("2 Red [style:led]" , 0 , 1));
61 | led_2_g = led_group(vbargraph("2 Green [style:led]" , 0 , 1));
62 | led_2_b = led_group(vbargraph("2 Blue [style:led]" , 0 , 1));
63 |
64 | led_3_r = led_group(vbargraph("3 Red [style:led]" , 0 , 1));
65 | led_3_g = led_group(vbargraph("3 Green [style:led]" , 0 , 1));
66 | led_3_b = led_group(vbargraph("3 Blue [style:led]" , 0 , 1));
67 |
68 | led_4_r = led_group(vbargraph("4 Red [style:led]" , 0 , 1));
69 | led_4_g = led_group(vbargraph("4 Green [style:led]" , 0 , 1));
70 | led_4_b = led_group(vbargraph("4 Blue [style:led]" , 0 , 1));
71 |
72 | led_5_r = led_group(vbargraph("5 Red [style:led]" , 0 , 1));
73 | led_5_g = led_group(vbargraph("5 Green [style:led]" , 0 , 1));
74 | led_5_b = led_group(vbargraph("5 Blue [style:led]" , 0 , 1));
75 |
76 | led_6_r = led_group(vbargraph("6 Red [style:led]" , 0 , 1));
77 | led_6_g = led_group(vbargraph("6 Green [style:led]" , 0 , 1));
78 | led_6_b = led_group(vbargraph("6 Blue [style:led]" , 0 , 1));
79 |
80 | led_7_r = led_group(vbargraph("7 Red [style:led]" , 0 , 1));
81 | led_7_g = led_group(vbargraph("7 Green [style:led]" , 0 , 1));
82 | led_7_b = led_group(vbargraph("7 Blue [style:led]" , 0 , 1));
83 |
84 | led_8_r = led_group(vbargraph("8 Red [style:led]" , 0 , 1));
85 | led_8_g = led_group(vbargraph("8 Green [style:led]" , 0 , 1));
86 | led_8_b = led_group(vbargraph("8 Blue [style:led]" , 0 , 1));
87 |
--------------------------------------------------------------------------------
/src/ProtoFaustWidget.hpp:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------------
2 |
3 | ProtoFaust
4 | ==========
5 | DSP prototyping in Faust for VCV Rack
6 |
7 | Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
8 | contributors
9 |
10 | This program is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program. If not, see .
22 |
23 | Thank you for using free software!
24 |
25 | ---------------------------------------------------------------------------- */
26 |
27 | #ifndef PROTO_FAUST_WIDGET_HPP
28 | #define PROTO_FAUST_WIDGET_HPP
29 |
30 | #include
31 |
32 |
33 | struct ProtoFaustWidget : ModuleWidget {
34 | public:
35 | enum WidgetTypes {
36 | TOGGLE_SWITCH,
37 | THREE_WAY_SWITCH,
38 | PUSH_BUTTON,
39 | KNOB_WHITE,
40 | KNOB_RED,
41 | PORT_INPUT,
42 | PORT_OUTPUT,
43 | LED_RGB,
44 | SCREW,
45 |
46 | NUM_WIDGET_TYPES
47 | };
48 |
49 | enum ParamIds {
50 | BUTTON_1_PARAM,
51 | BUTTON_2_PARAM,
52 | BUTTON_3_PARAM,
53 | BUTTON_4_PARAM,
54 | BUTTON_5_PARAM,
55 | BUTTON_6_PARAM,
56 | BUTTON_7_PARAM,
57 | BUTTON_8_PARAM,
58 |
59 | KNOB_1_PARAM,
60 | KNOB_2_PARAM,
61 | KNOB_3_PARAM,
62 | KNOB_4_PARAM,
63 | KNOB_5_PARAM,
64 | KNOB_6_PARAM,
65 | KNOB_7_PARAM,
66 | KNOB_8_PARAM,
67 |
68 | NUM_PARAMS
69 | };
70 |
71 | enum InputIds {
72 | IN_1_INPUT,
73 | IN_2_INPUT,
74 | IN_3_INPUT,
75 | IN_4_INPUT,
76 | IN_5_INPUT,
77 | IN_6_INPUT,
78 | IN_7_INPUT,
79 | IN_8_INPUT,
80 |
81 | NUM_INPUTS
82 | };
83 |
84 | enum OutputIds {
85 | OUT_1_OUTPUT,
86 | OUT_2_OUTPUT,
87 | OUT_3_OUTPUT,
88 | OUT_4_OUTPUT,
89 | OUT_5_OUTPUT,
90 | OUT_6_OUTPUT,
91 | OUT_7_OUTPUT,
92 | OUT_8_OUTPUT,
93 |
94 | NUM_OUTPUTS
95 | };
96 |
97 | enum LedIds {
98 | LED_1,
99 | LED_1_GREEN_INTERNAL_USE_ONLY,
100 | LED_1_BLUE_INTERNAL_USE_ONLY,
101 |
102 | LED_2,
103 | LED_2_GREEN_INTERNAL_USE_ONLY,
104 | LED_2_BLUE_INTERNAL_USE_ONLY,
105 |
106 | LED_3,
107 | LED_3_GREEN_INTERNAL_USE_ONLY,
108 | LED_3_BLUE_INTERNAL_USE_ONLY,
109 |
110 | LED_4,
111 | LED_4_GREEN_INTERNAL_USE_ONLY,
112 | LED_4_BLUE_INTERNAL_USE_ONLY,
113 |
114 | LED_5,
115 | LED_5_GREEN_INTERNAL_USE_ONLY,
116 | LED_5_BLUE_INTERNAL_USE_ONLY,
117 |
118 | LED_6,
119 | LED_6_GREEN_INTERNAL_USE_ONLY,
120 | LED_6_BLUE_INTERNAL_USE_ONLY,
121 |
122 | LED_7,
123 | LED_7_GREEN_INTERNAL_USE_ONLY,
124 | LED_7_BLUE_INTERNAL_USE_ONLY,
125 |
126 | LED_8,
127 | LED_8_GREEN_INTERNAL_USE_ONLY,
128 | LED_8_BLUE_INTERNAL_USE_ONLY,
129 |
130 | NUM_LED_PINS
131 | };
132 |
133 | enum GenericIds {
134 | GENERIC_SCREW,
135 |
136 | NUM_GENERIC_IDS
137 | };
138 |
139 | explicit ProtoFaustWidget( ProtoFaust* currentModule );
140 |
141 | private:
142 | void addWidget( int widgetType,
143 | int parameterId,
144 | float x,
145 | float y );
146 |
147 | void addWidgetAndParameter( int widgetType,
148 | int parameterId,
149 | const std::string& faustStringId,
150 | float x,
151 | float y );
152 |
153 | ProtoFaust* _module = nullptr;
154 | };
155 |
156 | #endif // PROTO_FAUST_WIDGET_HPP
157 |
--------------------------------------------------------------------------------
/autogen.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | """ProtoFaust
4 | ==========
5 | DSP prototyping in Faust for VCV Rack
6 |
7 | Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
8 | contributors
9 |
10 | This program is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program. If not, see .
22 |
23 | Thank you for using free software!
24 |
25 | """
26 |
27 | import pyinotify
28 |
29 | import datetime
30 | import os
31 | import subprocess
32 |
33 |
34 | class OnWriteHandler(pyinotify.ProcessEvent):
35 | def __init__(self, payload_command):
36 | print()
37 | print('==> initial run')
38 | print()
39 |
40 | # initialise payload command
41 | self.payload_command = payload_command
42 |
43 | # run payload once on startup
44 | self.run_payload()
45 |
46 |
47 |
48 | def print_current_file(self, filename):
49 | current_time = datetime.datetime.now()
50 | formatted_time = current_time.strftime('%H:%M:%S')
51 |
52 | output = '{0:s} ==> {1:s}'.format(formatted_time, filename)
53 | print(output)
54 | print()
55 |
56 |
57 | # is called on completed writes
58 | def process_IN_CLOSE_WRITE(self, event):
59 | # ignore temporary files
60 | if event.name.endswith('#'):
61 | return
62 | # ignore compiled Python files
63 | elif event.name.endswith('.pyc'):
64 | return
65 |
66 | # get name of changed file
67 | if event.name:
68 | filename = os.path.join(event.path, event.name)
69 | else:
70 | filename = event.path
71 |
72 | # print name of changed file
73 | print('==> ' + filename)
74 | print()
75 |
76 | # run payload
77 | self.run_payload()
78 |
79 |
80 | def run_payload(self):
81 | # run payload
82 | proc = subprocess.Popen(self.payload_command,
83 | shell=True,
84 | stdin=subprocess.PIPE,
85 | stdout=subprocess.PIPE,
86 | stderr=subprocess.PIPE,
87 | universal_newlines=True)
88 |
89 | # display output of "stdout" and "stderr" (if any)
90 | for pipe_output in proc.communicate():
91 | if pipe_output:
92 | print(pipe_output.strip())
93 | print()
94 |
95 |
96 | # define directories to be ignored
97 | def exclude_directories(path):
98 | if path.startswith('src/faust/main-svg'):
99 | return True
100 | else:
101 | return False
102 |
103 |
104 | if __name__ == '__main__':
105 | # directory that should be monitored
106 | directory_to_watch = 'src/faust/'
107 |
108 | # command to be run on payload. "unbuffer" pretends a TTY, thus
109 | # keeping escape sequences
110 | payload_command = 'make faust-clean && make faust'
111 |
112 | # create an instance of "pyinotify"
113 | watchmanager = pyinotify.WatchManager()
114 |
115 | # add a watch (will trigger on completed writes)
116 | watchmanager.add_watch(directory_to_watch,
117 | pyinotify.IN_CLOSE_WRITE,
118 | rec=True,
119 | auto_add=True,
120 | exclude_filter=exclude_directories)
121 |
122 | # create an instance of our file processor
123 | watchhandler = OnWriteHandler(payload_command)
124 |
125 | # connect to our file processor to "pyinotify"
126 | watchnotifier = pyinotify.Notifier(watchmanager,
127 | default_proc_fun=watchhandler)
128 |
129 | # keep monitoring
130 | watchnotifier.loop()
131 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ProtoFaust
2 |
3 | DSP prototyping in Faust for VCV Rack
4 |
5 | 
6 |
7 |
8 | ## Installation
9 |
10 | These are the instructions for Linux, but it should be relatively
11 | simple to modify them for use on Windows or MacOS:
12 |
13 | 1. clone this repository: `git clone
14 | https://github.com/mzuther/ProtoFaust.git`
15 | 1. [download and install][SDK Rack] the latest VCV Rack SDK – the
16 | Makefile defaults to `../Rack-SDK` but respects the `RACK_DIR`
17 | shell variable
18 | 1. install Faust (I recommend using a [recent version][Faust
19 | compiler])
20 | 1. `make run` will compile and install your module; Rack is run if it
21 | is found in your path
22 |
23 |
24 | ## Prototype your own DSP
25 |
26 | The default Faust process is a simple three-oscillator synth with
27 | resonant filter. Simply edit `src/faust/main.dsp` to change this.
28 | The main process is
29 |
30 | ```
31 | process(in1 , in2 , in3 , in4 , in5 , in6 , in7 , in8) = internal_processor
32 | with
33 | {
34 | internal_processor = ... ;
35 | };
36 | ```
37 |
38 | You can simply put your mono DSP process in there:
39 |
40 | ```
41 | internal_processor = (in1 : gui_attacher) :
42 | your_mono_process :
43 | _ , in2 , in3 , in4 , in5 , in6 , in7 , in8 :
44 | si.bus(8);
45 | ```
46 |
47 | Or in stereo:
48 |
49 | ```
50 | internal_processor = (in1 : gui_attacher) , in2 :
51 | your_stereo_process :
52 | _ , _ , in3 , in4 , in5 , in6 , in7 , in8 :
53 | si.bus(8);
54 | ```
55 |
56 | Just make sure that you add `gui_attacher` somewhere -- this will
57 | attach the GUI parameters and simply copy any mono input signal to its
58 | output. If you fail to do so, the ` ProtoFaust` module will not find
59 | any of the knobs, buttons and LEDs (they will be thought as
60 | superfluous and optimized out) and probably crash.
61 |
62 | Enjoy!
63 |
64 |
65 | ## Signal ranges
66 |
67 | Input signals from VCV Rack are divided by `5.0`. Conversely, output
68 | signals are multiplied by `5.0` to bring them back in range. This
69 | keeps values in the usual range of DSP processing (`-1.0 .. +1.0`) and
70 | should help when porting algorithms to VCV Rack. All signals are
71 | full-range, so you have to apply any input or output saturation
72 | yourself.
73 |
74 | Knobs have a range of `0.0 .. 1.0`; the center position is located at
75 | `0.5`. Toggle switches take on values of `0.0` and `1.0`, whereas
76 | three-way switches add a third state of `0.5`.
77 |
78 |
79 | ## Ideas and bug fixes
80 |
81 | This module is very new and experimental. So please send problems,
82 | bug reports, fixes and any ideas that come to your mind. Thanks!
83 |
84 |
85 | ## Contributors
86 |
87 | - [Martin Zuther][]: maintainer; code and GUI design
88 |
89 | - [Stéphane Letz](https://github.com/sletz): improved readability of
90 | Faust code (`src/faust/rack.dsp`)
91 |
92 |
93 | ## Code of conduct
94 |
95 | Please read the [code of conduct][COC] before asking for help, filing
96 | bug reports or contributing to this project. Thanks!
97 |
98 |
99 | ## License
100 |
101 | Copyright (c) 2019-2020 [Martin Zuther][] and contributors
102 |
103 | This program is free software: you can redistribute it and/or modify
104 | it under the terms of the GNU General Public License as published by
105 | the Free Software Foundation, either version 3 of the License, or
106 | (at your option) any later version.
107 |
108 | This program is distributed in the hope that it will be useful,
109 | but WITHOUT ANY WARRANTY; without even the implied warranty of
110 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
111 | GNU General Public License for more details.
112 |
113 | You should have received a copy of the GNU General Public License
114 | along with this program. If not, see .
115 |
116 | Thank you for using free software!
117 |
118 |
119 | [Martin Zuther]: http://www.mzuther.de/
120 | [COC]: https://github.com/mzuther/ProtoFaust/tree/master/CODE_OF_CONDUCT.markdown
121 | [Faust compiler]: http://faust.grame.fr/doc/manual/index.html#compiling-and-installing-the-faust-compiler
122 | [SDK Rack]: https://vcvrack.com/manual/PluginDevelopmentTutorial.html
123 |
--------------------------------------------------------------------------------
/src/faust/main.dsp:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------------
2 |
3 | ProtoFaust
4 | ==========
5 | DSP prototyping in Faust for VCV Rack
6 |
7 | Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
8 | contributors
9 |
10 | This program is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program. If not, see .
22 |
23 | Thank you for using free software!
24 |
25 | ---------------------------------------------------------------------------- */
26 |
27 |
28 | import("stdfaust.lib");
29 | import("gui.dsp");
30 |
31 | rack = component("rack.dsp");
32 |
33 |
34 | vca(i_cv , in) = internal_vca
35 | with
36 | {
37 | gain = max(0 , i_cv);
38 |
39 | internal_vca = gain * in;
40 | };
41 |
42 |
43 | vco(i_cv_pitch , btn) = internal_vco
44 | with
45 | {
46 | freq = i_cv_pitch :
47 | rack.i_cv_pitch2freq;
48 |
49 | internal_vco = freq <:
50 | os.saw2 , os.square , os.triangle :
51 | ba.selectn(3 , btn);
52 | };
53 |
54 |
55 | vcf(i_cv_cutoff , i_cv_resonance , btn , in) = internal_vcf
56 | with
57 | {
58 | cutoff = i_cv_cutoff * 1.5 - 0.5 :
59 | rack.i_cv_pitch2freq;
60 | cutoff_limited = max(10 , min(cutoff , 20000));
61 | resonance = max(i_cv_resonance * 5 , 0.1);
62 | gain = 1;
63 |
64 | internal_vcf = cutoff_limited , resonance , gain , in <:
65 | fi.resonhp , fi.resonlp :
66 | ba.selectn(2 , btn);
67 | };
68 |
69 |
70 | voice(i_cv_pitch , volume, knob_coarse , knob_fine, btn_waveform) = internal_voice
71 | with
72 | {
73 | i_cv_pitch_coarse = int(knob_coarse * 48 - 12) / 60;
74 | i_cv_pitch_fine = (knob_fine - 0.5) / 30;
75 | i_cv_pitch_final = i_cv_pitch + (i_cv_pitch_coarse + i_cv_pitch_fine : si.smooth(1e-3));
76 |
77 | internal_voice = i_cv_pitch_final , btn_waveform :
78 | volume , vco :
79 | vca;
80 | };
81 |
82 |
83 | voices(i_cv_pitch , i_cv_cutoff , i_cv_resonance) = internal_voices
84 | with
85 | {
86 | volume = -18 : ba.db2linear;
87 |
88 | voice_1 = voice(i_cv_pitch , volume , knob_1 , knob_2 , button_1 * 2);
89 | voice_2 = voice(i_cv_pitch , volume , knob_3 , knob_4 , button_2 * 2);
90 | voice_3 = voice(i_cv_pitch , volume , knob_5 , knob_6 , button_3 * 2 + 1);
91 |
92 | i_cv_cutoff_final = i_cv_cutoff + (knob_7 : si.smooth(1e-3));
93 | i_cv_resonance_final = i_cv_resonance + (knob_8 : si.smooth(1e-3));
94 |
95 | internal_voices = voice_1 + voice_2 + voice_3 :
96 | i_cv_cutoff_final , i_cv_resonance_final , button_4 * 2 , _ : vcf :
97 | 0.3 , 0.1 , _ : ef.cubicnl :
98 | fi.dcblocker;
99 | };
100 |
101 |
102 | process(in1 , in2 , in3 , in4 , in5 , in6 , in7 , in8) = internal_processor
103 | with
104 | {
105 | lfo_1 = (os.osccos(0.5) + 1) / 2;
106 | lfo_2 = 1 - lfo_1;
107 |
108 | gui_attacher = _ :
109 | attach(_ , button_1) :
110 | attach(_ , button_2) :
111 | attach(_ , button_3) :
112 | attach(_ , button_4) :
113 | attach(_ , button_5) :
114 | attach(_ , button_6) :
115 | attach(_ , button_7) :
116 | attach(_ , button_8) :
117 |
118 | attach(_ , knob_1) :
119 | attach(_ , knob_2) :
120 | attach(_ , knob_3) :
121 | attach(_ , knob_4) :
122 | attach(_ , knob_5) :
123 | attach(_ , knob_6) :
124 | attach(_ , knob_7) :
125 | attach(_ , knob_8) :
126 |
127 | attach(_ , lfo_1 : led_1_r) :
128 | attach(_ , 0 : led_1_g) :
129 | attach(_ , 0 : led_1_b) :
130 |
131 | attach(_ , 0 : led_2_r) :
132 | attach(_ , lfo_2 : led_2_g) :
133 | attach(_ , 0 : led_2_b) :
134 |
135 | attach(_ , 0 : led_3_r) :
136 | attach(_ , 0 : led_3_g) :
137 | attach(_ , lfo_1 : led_3_b) :
138 |
139 | attach(_ , lfo_2 : led_4_r) :
140 | attach(_ , lfo_2 : led_4_g) :
141 | attach(_ , lfo_2 : led_4_b) :
142 |
143 | attach(_ , lfo_1 : led_5_r) :
144 | attach(_ , lfo_1 : led_5_g) :
145 | attach(_ , lfo_1 : led_5_b) :
146 |
147 | attach(_ , lfo_1 : led_6_r) :
148 | attach(_ , lfo_2 : led_6_g) :
149 | attach(_ , 0 : led_6_b) :
150 |
151 | attach(_ , 0 : led_7_r) :
152 | attach(_ , lfo_1 : led_7_g) :
153 | attach(_ , lfo_2 : led_7_b) :
154 |
155 | attach(_ , lfo_1 : led_8_r) :
156 | attach(_ , 0 : led_8_g) :
157 | attach(_ , lfo_2 : led_8_b) :
158 | _;
159 |
160 | internal_processor = (in1 : gui_attacher) , in2 , in3 :
161 | voices :
162 | _ , in2 , in3 , in4 , in5 , in6 , in7 , in8 :
163 | si.bus(8);
164 | };
165 |
--------------------------------------------------------------------------------
/src/ProtoFaust.cpp:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------------
2 |
3 | ProtoFaust
4 | ==========
5 | DSP prototyping in Faust for VCV Rack
6 |
7 | Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
8 | contributors
9 |
10 | This program is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program. If not, see .
22 |
23 | Thank you for using free software!
24 |
25 | ---------------------------------------------------------------------------- */
26 |
27 | #include "Amalgamated.hpp"
28 |
29 |
30 | ProtoFaust::ProtoFaust()
31 | {
32 | config( ProtoFaustWidget::NUM_PARAMS,
33 | ProtoFaustWidget::NUM_INPUTS,
34 | ProtoFaustWidget::NUM_OUTPUTS,
35 | ProtoFaustWidget::NUM_LED_PINS );
36 |
37 | FaustDSP.buildUserInterface( &FaustUI );
38 | }
39 |
40 |
41 | void ProtoFaust::onAdd()
42 | {
43 | // initialize Faust using default sample rate; see
44 | // ProtoFaust::process()
45 | FaustDSP.init( 44100 );
46 | }
47 |
48 |
49 | void ProtoFaust::process( const ProcessArgs& args )
50 | {
51 | // update Faust DSP on sample rate changes
52 | //
53 | // running this check in *every* module and for *every* single
54 | // sample seems like a *huge* amount of overhead; however, this is
55 | // the current expected behaviour of VCV Rack modules; see
56 | // https://github.com/mzuther/ProtoFaust/pull/2
57 | if ( args.sampleRate != FaustDSP.getSampleRate() ) {
58 | FaustDSP.init( args.sampleRate );
59 | }
60 |
61 | // cppcheck-suppress allocaCalled ; Stéphane knows what he is doing ...
62 | FAUSTFLOAT* temporaryInputs = ( FAUSTFLOAT* ) alloca( numberOfChannels *
63 | sizeof( FAUSTFLOAT ) );
64 |
65 | // cppcheck-suppress allocaCalled
66 | FAUSTFLOAT* temporaryOutputs = ( FAUSTFLOAT* ) alloca( numberOfChannels *
67 | sizeof( FAUSTFLOAT ) );
68 |
69 | // read from module's inputs; scale voltages from Rack to usual
70 | // range in DSP processing (-1.0 to +1.0) so you don't have to
71 | // adjust algorithms when porting them to VCV Rack
72 | for ( auto channel = 0; channel < numberOfChannels; channel++ ) {
73 | FAUSTFLOAT input = inputs[ProtoFaustWidget::IN_1_INPUT + channel].getVoltage();
74 | temporaryInputs[channel] = input / voltageScaling;
75 |
76 | // protect your ears in case of misbehaviour
77 | temporaryOutputs[channel] = 0.0;
78 | }
79 |
80 | // get widget values and update Faust parameters
81 | for ( auto& widget : activeWidgets ) {
82 | updateParameterIn( widget );
83 | }
84 |
85 | // update Faust controls
86 | int int_control[FaustDSP.getNumIntControls()];
87 | FAUSTFLOAT real_control[FaustDSP.getNumRealControls()];
88 | FaustDSP.control( int_control, real_control );
89 |
90 | // process one sample in Faust
91 | FaustDSP.compute( temporaryInputs,
92 | temporaryOutputs,
93 | int_control,
94 | real_control );
95 |
96 | // write to module's outputs; scale voltages from DSP processing
97 | // back to Rack voltages (-5.0 to +5.0)
98 | for ( auto channel = 0; channel < numberOfChannels; channel++ ) {
99 | FAUSTFLOAT output = temporaryOutputs[channel];
100 | outputs[ProtoFaustWidget::OUT_1_OUTPUT + channel].setVoltage( output * voltageScaling );
101 | }
102 |
103 | // get widget values and update Faust parameters
104 | for ( auto& widget : passiveWidgets ) {
105 | updateParameterOut( widget );
106 | }
107 | }
108 |
109 |
110 | void ProtoFaust::addParameter( int widgetType,
111 | int parameterId,
112 | const std::string& faustStringId )
113 | {
114 | std::vector* widgets;
115 |
116 | if ( widgetType == ProtoFaustWidget::LED_RGB ) {
117 | widgets = &passiveWidgets;
118 | } else {
119 | widgets = &activeWidgets;
120 | }
121 |
122 | // prepare controller zone 'set' and 'get' functions
123 | FAUSTFLOAT* zone = FaustUI.getParamZone( faustStringId );
124 |
125 | WidgetAccess::setFunction setFun = [ = ]( FAUSTFLOAT value ) {
126 | *zone = value;
127 | };
128 |
129 | WidgetAccess::getFunction getFun = [ = ]() {
130 | return *zone;
131 | };
132 |
133 | switch ( widgetType ) {
134 | case ProtoFaustWidget::TOGGLE_SWITCH:
135 | case ProtoFaustWidget::PUSH_BUTTON:
136 |
137 | // values: 0.0, 1.0
138 | // default: 0.0 (off)
139 | configParam( parameterId,
140 | 0.0f,
141 | 1.0f,
142 | 0.0f,
143 | "" );
144 | break;
145 |
146 | case ProtoFaustWidget::THREE_WAY_SWITCH:
147 |
148 | // values: 0.0, 1.0, 2.0; scaled in ProtoFaust::updateParameter()
149 | // default: 0.0 (bottom)
150 | configParam( parameterId,
151 | 0.0f,
152 | 2.0f,
153 | 0.0f,
154 | "" );
155 |
156 | // special 'set' version
157 | setFun = [ = ]( FAUSTFLOAT value ) {
158 | *zone = value / FAUSTFLOAT( 2.0 );
159 | };
160 | break;
161 |
162 | case ProtoFaustWidget::KNOB_WHITE:
163 | case ProtoFaustWidget::KNOB_RED:
164 |
165 | // range: 0.0 to 1.0
166 | // default: 0.5 (centered)
167 | configParam( parameterId,
168 | 0.0f,
169 | 1.0f,
170 | 0.5f,
171 | "" );
172 | break;
173 | }
174 |
175 | widgets->push_back( WidgetAccess ( widgetType,
176 | parameterId,
177 | setFun,
178 | getFun ) );
179 | }
180 |
181 |
182 | void ProtoFaust::addParameterLed( int widgetType,
183 | int parameterId,
184 | const std::string& faustStringId )
185 | {
186 | // add a parameter for each virtual LED pin
187 | // (red, green and blue)
188 |
189 | addParameter( widgetType,
190 | parameterId,
191 | faustStringId + "_Red" );
192 |
193 | addParameter( widgetType,
194 | parameterId + 1,
195 | faustStringId + "_Green" );
196 |
197 | addParameter( widgetType,
198 | parameterId + 2,
199 | faustStringId + "_Blue" );
200 |
201 | }
202 |
203 |
204 | void ProtoFaust::updateParameterIn( WidgetAccess& widget )
205 | {
206 | widget.faustSet( params[widget.parameterId].getValue() );
207 | }
208 |
209 |
210 | void ProtoFaust::updateParameterOut( WidgetAccess& widget )
211 | {
212 | lights[widget.parameterId].setBrightness( widget.faustGet() );
213 | }
214 |
215 |
216 | Model* modelProtoFaust = createModel(
217 | "ProtoFaust" );
218 |
--------------------------------------------------------------------------------
/src/ProtoFaustWidget.cpp:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------------
2 |
3 | ProtoFaust
4 | ==========
5 | DSP prototyping in Faust for VCV Rack
6 |
7 | Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
8 | contributors
9 |
10 | This program is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program. If not, see .
22 |
23 | Thank you for using free software!
24 |
25 | ---------------------------------------------------------------------------- */
26 |
27 | #include "Amalgamated.hpp"
28 |
29 |
30 | // "repetitive" takes on a whole new meaning in this file ...
31 |
32 | ProtoFaustWidget::ProtoFaustWidget( ProtoFaust* currentModule ) :
33 | _module( currentModule )
34 | {
35 | setModule( _module );
36 | setPanel( APP->window->loadSvg(
37 | asset::plugin( pluginInstance, "res/ProtoFaust.svg" ) ) );
38 |
39 | // sorry for the following cruft -- I'd give my right arm for
40 | // LISP-like macros in C++ ...
41 |
42 | // ------ screws ------
43 |
44 | addWidget( ProtoFaustWidget::SCREW,
45 | ProtoFaustWidget::GENERIC_SCREW,
46 | RACK_GRID_WIDTH,
47 | 0 );
48 |
49 | addWidget( ProtoFaustWidget::SCREW,
50 | ProtoFaustWidget::GENERIC_SCREW,
51 | box.size.x - 2 * RACK_GRID_WIDTH,
52 | 0 );
53 |
54 | addWidget( ProtoFaustWidget::SCREW,
55 | ProtoFaustWidget::GENERIC_SCREW,
56 | RACK_GRID_WIDTH,
57 | RACK_GRID_HEIGHT - RACK_GRID_WIDTH );
58 |
59 | addWidget( ProtoFaustWidget::SCREW,
60 | ProtoFaustWidget::GENERIC_SCREW,
61 | box.size.x - 2 * RACK_GRID_WIDTH,
62 | RACK_GRID_HEIGHT - RACK_GRID_WIDTH );
63 |
64 | // ------ switches ------
65 |
66 | addWidgetAndParameter( ProtoFaustWidget::THREE_WAY_SWITCH,
67 | ProtoFaustWidget::BUTTON_1_PARAM,
68 | "/ProtoFaust/Buttons/1",
69 | 31.75,
70 | 21.82 );
71 |
72 | addWidgetAndParameter( ProtoFaustWidget::THREE_WAY_SWITCH,
73 | ProtoFaustWidget::BUTTON_2_PARAM,
74 | "/ProtoFaust/Buttons/2",
75 | 31.75,
76 | 34.52 );
77 |
78 | addWidgetAndParameter( ProtoFaustWidget::TOGGLE_SWITCH,
79 | ProtoFaustWidget::BUTTON_3_PARAM,
80 | "/ProtoFaust/Buttons/3",
81 | 31.75,
82 | 49.76 );
83 |
84 | addWidgetAndParameter( ProtoFaustWidget::TOGGLE_SWITCH,
85 | ProtoFaustWidget::BUTTON_4_PARAM,
86 | "/ProtoFaust/Buttons/4",
87 | 31.75,
88 | 62.46 );
89 |
90 | // ------ buttons ------
91 |
92 | addWidgetAndParameter( ProtoFaustWidget::PUSH_BUTTON,
93 | ProtoFaustWidget::BUTTON_5_PARAM,
94 | "/ProtoFaust/Buttons/5",
95 | 31.75,
96 | 77.7 );
97 |
98 | addWidgetAndParameter( ProtoFaustWidget::PUSH_BUTTON,
99 | ProtoFaustWidget::BUTTON_6_PARAM,
100 | "/ProtoFaust/Buttons/6",
101 | 31.75,
102 | 90.4 );
103 |
104 | addWidgetAndParameter( ProtoFaustWidget::PUSH_BUTTON,
105 | ProtoFaustWidget::BUTTON_7_PARAM,
106 | "/ProtoFaust/Buttons/7",
107 | 31.75,
108 | 105.64 );
109 |
110 | addWidgetAndParameter( ProtoFaustWidget::PUSH_BUTTON,
111 | ProtoFaustWidget::BUTTON_8_PARAM,
112 | "/ProtoFaust/Buttons/8",
113 | 31.75,
114 | 118.34 );
115 |
116 | // ------ knobs ------
117 |
118 | addWidgetAndParameter( ProtoFaustWidget::KNOB_WHITE,
119 | ProtoFaustWidget::KNOB_1_PARAM,
120 | "/ProtoFaust/Knobs/1",
121 | 53.34,
122 | 28.17 );
123 |
124 | addWidgetAndParameter( ProtoFaustWidget::KNOB_RED,
125 | ProtoFaustWidget::KNOB_2_PARAM,
126 | "/ProtoFaust/Knobs/2",
127 | 78.74,
128 | 28.17 );
129 |
130 | addWidgetAndParameter( ProtoFaustWidget::KNOB_WHITE,
131 | ProtoFaustWidget::KNOB_3_PARAM,
132 | "/ProtoFaust/Knobs/3",
133 | 53.34,
134 | 56.11 );
135 |
136 | addWidgetAndParameter( ProtoFaustWidget::KNOB_RED,
137 | ProtoFaustWidget::KNOB_4_PARAM,
138 | "/ProtoFaust/Knobs/4",
139 | 78.74,
140 | 56.11 );
141 |
142 | addWidgetAndParameter( ProtoFaustWidget::KNOB_WHITE,
143 | ProtoFaustWidget::KNOB_5_PARAM,
144 | "/ProtoFaust/Knobs/5",
145 | 53.34,
146 | 84.05 );
147 |
148 | addWidgetAndParameter( ProtoFaustWidget::KNOB_RED,
149 | ProtoFaustWidget::KNOB_6_PARAM,
150 | "/ProtoFaust/Knobs/6",
151 | 78.74,
152 | 84.05 );
153 |
154 | addWidgetAndParameter( ProtoFaustWidget::KNOB_WHITE,
155 | ProtoFaustWidget::KNOB_7_PARAM,
156 | "/ProtoFaust/Knobs/7",
157 | 53.34,
158 | 111.99 );
159 |
160 | addWidgetAndParameter( ProtoFaustWidget::KNOB_RED,
161 | ProtoFaustWidget::KNOB_8_PARAM,
162 | "/ProtoFaust/Knobs/8",
163 | 78.74,
164 | 111.99 );
165 |
166 | // ------ input ports ------
167 |
168 | addWidget( ProtoFaustWidget::PORT_INPUT,
169 | ProtoFaustWidget::IN_1_INPUT,
170 | 17.78,
171 | 21.82 );
172 |
173 | addWidget( ProtoFaustWidget::PORT_INPUT,
174 | ProtoFaustWidget::IN_2_INPUT,
175 | 17.78,
176 | 34.52 );
177 |
178 | addWidget( ProtoFaustWidget::PORT_INPUT,
179 | ProtoFaustWidget::IN_3_INPUT,
180 | 17.78,
181 | 49.76 );
182 |
183 | addWidget( ProtoFaustWidget::PORT_INPUT,
184 | ProtoFaustWidget::IN_4_INPUT,
185 | 17.78,
186 | 62.46 );
187 |
188 | addWidget( ProtoFaustWidget::PORT_INPUT,
189 | ProtoFaustWidget::IN_5_INPUT,
190 | 17.78,
191 | 77.7 );
192 |
193 | addWidget( ProtoFaustWidget::PORT_INPUT,
194 | ProtoFaustWidget::IN_6_INPUT,
195 | 17.78,
196 | 90.4 );
197 |
198 | addWidget( ProtoFaustWidget::PORT_INPUT,
199 | ProtoFaustWidget::IN_7_INPUT,
200 | 17.78,
201 | 105.64 );
202 |
203 | addWidget( ProtoFaustWidget::PORT_INPUT,
204 | ProtoFaustWidget::IN_8_INPUT,
205 | 17.78,
206 | 118.34 );
207 |
208 | // ------ output ports ------
209 |
210 | addWidget( ProtoFaustWidget::PORT_OUTPUT,
211 | ProtoFaustWidget::OUT_1_OUTPUT,
212 | 114.3,
213 | 21.82 );
214 |
215 | addWidget( ProtoFaustWidget::PORT_OUTPUT,
216 | ProtoFaustWidget::OUT_2_OUTPUT,
217 | 114.3,
218 | 34.52 );
219 |
220 | addWidget( ProtoFaustWidget::PORT_OUTPUT,
221 | ProtoFaustWidget::OUT_3_OUTPUT,
222 | 114.3,
223 | 49.76 );
224 |
225 | addWidget( ProtoFaustWidget::PORT_OUTPUT,
226 | ProtoFaustWidget::OUT_4_OUTPUT,
227 | 114.3,
228 | 62.46 );
229 |
230 | addWidget( ProtoFaustWidget::PORT_OUTPUT,
231 | ProtoFaustWidget::OUT_5_OUTPUT,
232 | 114.3,
233 | 77.7 );
234 |
235 | addWidget( ProtoFaustWidget::PORT_OUTPUT,
236 | ProtoFaustWidget::OUT_6_OUTPUT,
237 | 114.3,
238 | 90.4 );
239 |
240 | addWidget( ProtoFaustWidget::PORT_OUTPUT,
241 | ProtoFaustWidget::OUT_7_OUTPUT,
242 | 114.3,
243 | 105.64 );
244 |
245 | addWidget( ProtoFaustWidget::PORT_OUTPUT,
246 | ProtoFaustWidget::OUT_8_OUTPUT,
247 | 114.3,
248 | 118.34 );
249 |
250 | // ------ RGB LEDs ------
251 |
252 | addWidgetAndParameter( ProtoFaustWidget::LED_RGB,
253 | ProtoFaustWidget::LED_1,
254 | "/ProtoFaust/Lights/1",
255 | 99.06,
256 | 21.82 );
257 |
258 | addWidgetAndParameter( ProtoFaustWidget::LED_RGB,
259 | ProtoFaustWidget::LED_2,
260 | "/ProtoFaust/Lights/2",
261 | 99.06,
262 | 34.52 );
263 |
264 | addWidgetAndParameter( ProtoFaustWidget::LED_RGB,
265 | ProtoFaustWidget::LED_3,
266 | "/ProtoFaust/Lights/3",
267 | 99.06,
268 | 49.76 );
269 |
270 | addWidgetAndParameter( ProtoFaustWidget::LED_RGB,
271 | ProtoFaustWidget::LED_4,
272 | "/ProtoFaust/Lights/4",
273 | 99.06,
274 | 62.46 );
275 |
276 | addWidgetAndParameter( ProtoFaustWidget::LED_RGB,
277 | ProtoFaustWidget::LED_5,
278 | "/ProtoFaust/Lights/5",
279 | 99.06,
280 | 77.7 );
281 |
282 | addWidgetAndParameter( ProtoFaustWidget::LED_RGB,
283 | ProtoFaustWidget::LED_6,
284 | "/ProtoFaust/Lights/6",
285 | 99.06,
286 | 90.4 );
287 |
288 | addWidgetAndParameter( ProtoFaustWidget::LED_RGB,
289 | ProtoFaustWidget::LED_7,
290 | "/ProtoFaust/Lights/7",
291 | 99.06,
292 | 105.64 );
293 |
294 | addWidgetAndParameter( ProtoFaustWidget::LED_RGB,
295 | ProtoFaustWidget::LED_8,
296 | "/ProtoFaust/Lights/8",
297 | 99.06,
298 | 118.34 );
299 | }
300 |
301 |
302 | void ProtoFaustWidget::addWidget( int widgetType,
303 | int parameterId,
304 | float x,
305 | float y )
306 | {
307 | math::Vec pos = math::Vec( x, y );
308 | math::Vec pos_converted = mm2px( pos );
309 |
310 | switch ( widgetType ) {
311 | case TOGGLE_SWITCH:
312 |
313 | addParam( createParamCentered(
314 | pos_converted, _module, parameterId ) );
315 | break;
316 |
317 | case THREE_WAY_SWITCH:
318 |
319 | addParam( createParamCentered(
320 | pos_converted, _module, parameterId ) );
321 | break;
322 |
323 | case PUSH_BUTTON:
324 |
325 | addParam( createParamCentered(
326 | pos_converted, _module, parameterId ) );
327 | break;
328 |
329 | case KNOB_WHITE:
330 |
331 | addParam( createParamCentered(
332 | pos_converted, _module, parameterId ) );
333 | break;
334 |
335 | case KNOB_RED:
336 |
337 | addParam( createParamCentered(
338 | pos_converted, _module, parameterId ) );
339 | break;
340 |
341 | case PORT_INPUT:
342 |
343 | addInput( createInputCentered(
344 | pos_converted, _module, parameterId ) );
345 | break;
346 |
347 | case PORT_OUTPUT:
348 |
349 | addOutput( createOutputCentered(
350 | pos_converted, _module, parameterId ) );
351 | break;
352 |
353 | case LED_RGB:
354 |
355 | addChild( createLightCentered>(
356 | pos_converted, _module, parameterId ) );
357 | break;
358 |
359 | case SCREW:
360 |
361 | addChild( createWidget(
362 | pos ) );
363 | break;
364 | }
365 | }
366 |
367 |
368 | void ProtoFaustWidget::addWidgetAndParameter( int widgetType,
369 | int parameterId,
370 | const std::string& faustStringId,
371 | float x,
372 | float y )
373 | {
374 | if ( _module ) {
375 | if ( widgetType == ProtoFaustWidget::LED_RGB ) {
376 | _module->addParameterLed( widgetType, parameterId, faustStringId );
377 | } else {
378 | _module->addParameter( widgetType, parameterId, faustStringId );
379 | }
380 | }
381 |
382 | addWidget( widgetType, parameterId, x, y );
383 | }
384 |
--------------------------------------------------------------------------------
/helper.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | # this file has been copied and adapted from VCV Rack SDK:
4 | #
5 | # - change tabs to spaces (PEP 8)
6 | # - sort components by name
7 | # - this comment :)
8 |
9 | import sys
10 | import os
11 | import re
12 | import json
13 | import xml.etree.ElementTree
14 |
15 |
16 | # Version check
17 | f"Python 3.6+ is required"
18 |
19 |
20 | class UserException(Exception):
21 | pass
22 |
23 |
24 | def find(f, array):
25 | for a in array:
26 | if f(a):
27 | return f
28 |
29 | def input_default(prompt, default=""):
30 | str = input(f"{prompt} [{default}]: ")
31 | if str == "":
32 | return default
33 | return str
34 |
35 |
36 | def is_valid_slug(slug):
37 | return re.match(r'^[a-zA-Z0-9_\-]+$', slug) != None
38 |
39 |
40 | def slug_to_identifier(slug):
41 | if len(slug) == 0 or slug[0].isdigit():
42 | slug = "_" + slug
43 | slug = slug[0].upper() + slug[1:]
44 | slug = slug.replace('-', '_')
45 | return slug
46 |
47 |
48 | def create_plugin(slug, plugin_dir=None):
49 | # Check slug
50 | if not is_valid_slug(slug):
51 | raise UserException("Slug must only contain ASCII letters, numbers, '-', and '_'.")
52 |
53 | if not plugin_dir:
54 | plugin_dir = os.path.join(slug, '')
55 |
56 | # Check if plugin directory exists
57 | if os.path.exists(plugin_dir):
58 | raise UserException(f"Directory {plugin_dir} already exists")
59 |
60 | # Create plugin directory
61 | os.mkdir(plugin_dir)
62 |
63 | # Create manifest
64 | try:
65 | create_manifest(slug, plugin_dir)
66 | except Exception as e:
67 | os.rmdir(plugin_dir)
68 | raise e
69 |
70 | # Create subdirectories
71 | os.mkdir(os.path.join(plugin_dir, "src"))
72 | os.mkdir(os.path.join(plugin_dir, "res"))
73 |
74 | # Create Makefile
75 | makefile = """# If RACK_DIR is not defined when calling the Makefile, default to two directories above
76 | RACK_DIR ?= ../..
77 |
78 | # FLAGS will be passed to both the C and C++ compiler
79 | FLAGS +=
80 | CFLAGS +=
81 | CXXFLAGS +=
82 |
83 | # Careful about linking to shared libraries, since you can't assume much about the user's environment and library search path.
84 | # Static libraries are fine, but they should be added to this plugin's build system.
85 | LDFLAGS +=
86 |
87 | # Add .cpp files to the build
88 | SOURCES += $(wildcard src/*.cpp)
89 |
90 | # Add files to the ZIP package when running `make dist`
91 | # The compiled plugin and "plugin.json" are automatically added.
92 | DISTRIBUTABLES += res
93 | DISTRIBUTABLES += $(wildcard LICENSE*)
94 |
95 | # Include the Rack plugin Makefile framework
96 | include $(RACK_DIR)/plugin.mk
97 | """
98 | with open(os.path.join(plugin_dir, "Makefile"), "w") as f:
99 | f.write(makefile)
100 |
101 | # Create plugin.hpp
102 | plugin_hpp = """#pragma once
103 | #include
104 |
105 |
106 | using namespace rack;
107 |
108 | // Declare the Plugin, defined in plugin.cpp
109 | extern Plugin *pluginInstance;
110 |
111 | // Declare each Model, defined in each module source file
112 | // extern Model *modelMyModule;
113 | """
114 | with open(os.path.join(plugin_dir, "src/plugin.hpp"), "w") as f:
115 | f.write(plugin_hpp)
116 |
117 | # Create plugin.cpp
118 | plugin_cpp = """#include "plugin.hpp"
119 |
120 |
121 | Plugin *pluginInstance;
122 |
123 |
124 | void init(Plugin *p) {
125 | pluginInstance = p;
126 |
127 | // Add modules here
128 | // p->addModel(modelMyModule);
129 |
130 | // Any other plugin initialization may go here.
131 | // As an alternative, consider lazy-loading assets and lookup tables when your module is created to reduce startup times of Rack.
132 | }
133 | """
134 | with open(os.path.join(plugin_dir, "src/plugin.cpp"), "w") as f:
135 | f.write(plugin_cpp)
136 |
137 | git_ignore = """/build
138 | /dist
139 | /plugin.so
140 | /plugin.dylib
141 | /plugin.dll
142 | .DS_Store
143 | """
144 | with open(os.path.join(plugin_dir, ".gitignore"), "w") as f:
145 | f.write(git_ignore)
146 |
147 | print(f"Created template plugin in {plugin_dir}")
148 | os.system(f"cd {plugin_dir} && git init")
149 | print(f"You may use `make`, `make clean`, `make dist`, `make install`, etc in the {plugin_dir} directory.")
150 |
151 |
152 | def create_manifest(slug, plugin_dir="."):
153 | # Default manifest
154 | manifest = {
155 | 'slug': slug,
156 | }
157 |
158 | # Try to load existing manifest file
159 | manifest_filename = os.path.join(plugin_dir, 'plugin.json')
160 | try:
161 | with open(manifest_filename, "r") as f:
162 | manifest = json.load(f)
163 | except:
164 | pass
165 |
166 | # Query manifest information
167 | manifest['name'] = input_default("Plugin name", manifest.get('name', slug))
168 | manifest['version'] = input_default("Version", manifest.get('version', "1.0.0"))
169 | manifest['license'] = input_default("License (if open-source, use license identifier from https://spdx.org/licenses/)", manifest.get('license', "proprietary"))
170 | manifest['brand'] = input_default("Brand (prefix for all module names)", manifest.get('brand', manifest['name']))
171 | manifest['author'] = input_default("Author", manifest.get('author', ""))
172 | manifest['authorEmail'] = input_default("Author email (optional)", manifest.get('authorEmail', ""))
173 | manifest['authorUrl'] = input_default("Author website URL (optional)", manifest.get('authorUrl', ""))
174 | manifest['pluginUrl'] = input_default("Plugin website URL (optional)", manifest.get('pluginUrl', ""))
175 | manifest['manualUrl'] = input_default("Manual website URL (optional)", manifest.get('manualUrl', ""))
176 | manifest['sourceUrl'] = input_default("Source code URL (optional)", manifest.get('sourceUrl', ""))
177 | manifest['donateUrl'] = input_default("Donate URL (optional)", manifest.get('donateUrl', ""))
178 |
179 | if 'modules' not in manifest:
180 | manifest['modules'] = []
181 |
182 | # Dump JSON
183 | with open(manifest_filename, "w") as f:
184 | json.dump(manifest, f, indent=" ")
185 | print(f"Manifest written to {manifest_filename}")
186 |
187 |
188 | def create_module(slug, panel_filename=None, source_filename=None):
189 | # Check slug
190 | if not is_valid_slug(slug):
191 | raise UserException("Slug must only contain ASCII letters, numbers, '-', and '_'.")
192 |
193 | # Read manifest
194 | manifest_filename = 'plugin.json'
195 | with open(manifest_filename, "r") as f:
196 | manifest = json.load(f)
197 |
198 | # Check if module manifest exists
199 | module_manifest = find(lambda m: m['slug'] == slug, manifest['modules'])
200 | if module_manifest:
201 | print(f"Module {slug} already exists in plugin.json. Edit this file to modify the module manifest.")
202 |
203 | else:
204 | # Add module to manifest
205 | module_manifest = {}
206 | module_manifest['slug'] = slug
207 | module_manifest['name'] = input_default("Module name", slug)
208 | module_manifest['description'] = input_default("One-line description (optional)")
209 | tags = input_default("Tags (comma-separated, case-insensitive, see https://github.com/VCVRack/Rack/blob/v1/src/tag.cpp for list)")
210 | tags = tags.split(",")
211 | tags = [tag.strip() for tag in tags]
212 | if len(tags) == 1 and tags[0] == "":
213 | tags = []
214 | module_manifest['tags'] = tags
215 |
216 | manifest['modules'].append(module_manifest)
217 |
218 | # Write manifest
219 | with open(manifest_filename, "w") as f:
220 | json.dump(manifest, f, indent=" ")
221 |
222 | print(f"Added {slug} to {manifest_filename}")
223 |
224 | # Check filenames
225 | if panel_filename and source_filename:
226 | if not os.path.exists(panel_filename):
227 | raise UserException(f"Panel not found at {panel_filename}.")
228 |
229 | print(f"Panel found at {panel_filename}. Generating source file.")
230 |
231 | if os.path.exists(source_filename):
232 | if input_default(f"{source_filename} already exists. Overwrite?", "n").lower() != "y":
233 | return
234 |
235 | # Read SVG XML
236 | tree = xml.etree.ElementTree.parse(panel_filename)
237 |
238 | components = panel_to_components(tree)
239 | print(f"Components extracted from {panel_filename}")
240 |
241 | # Write source
242 | source = components_to_source(components, slug)
243 |
244 | with open(source_filename, "w") as f:
245 | f.write(source)
246 | print(f"Source file generated at {source_filename}")
247 |
248 | # Append model to plugin.hpp
249 | identifier = slug_to_identifier(slug)
250 |
251 | # Tell user to add model to plugin.hpp and plugin.cpp
252 | print(f"""
253 | To enable the module, add
254 | extern Model *model{identifier};
255 | to plugin.hpp, and add
256 | p->addModel(model{identifier});
257 | to the init() function in plugin.cpp.""")
258 |
259 |
260 | def panel_to_components(tree):
261 | ns = {
262 | "svg": "http://www.w3.org/2000/svg",
263 | "inkscape": "http://www.inkscape.org/namespaces/inkscape",
264 | }
265 |
266 | # Get components layer
267 | root = tree.getroot()
268 | groups = root.findall(".//svg:g[@inkscape:label='components']", ns)
269 | # Illustrator uses `id` for the group name.
270 | if len(groups) < 1:
271 | groups = root.findall(".//svg:g[@id='components']", ns)
272 | if len(groups) < 1:
273 | raise UserException("Could not find \"components\" layer on panel")
274 |
275 | # Get circles and rects
276 | components_group = groups[0]
277 | circles = components_group.findall(".//svg:circle", ns)
278 | rects = components_group.findall(".//svg:rect", ns)
279 |
280 | components = {}
281 | components['params'] = []
282 | components['inputs'] = []
283 | components['outputs'] = []
284 | components['lights'] = []
285 | components['widgets'] = []
286 |
287 | for el in circles + rects:
288 | c = {}
289 | # Get name
290 | name = el.get('{http://www.inkscape.org/namespaces/inkscape}label')
291 | if name is None:
292 | name = el.get('id')
293 | name = slug_to_identifier(name).upper()
294 | c['name'] = name
295 |
296 | # Get color
297 | style = el.get('style')
298 | color_match = re.search(r'fill:\S*#(.{6});', style)
299 | color = color_match.group(1).lower()
300 | c['color'] = color
301 |
302 | # Get position
303 | if el.tag == "{http://www.w3.org/2000/svg}rect":
304 | x = float(el.get('x'))
305 | y = float(el.get('y'))
306 | width = float(el.get('width'))
307 | height = float(el.get('height'))
308 | c['x'] = round(x, 3)
309 | c['y'] = round(y, 3)
310 | c['width'] = round(width, 3)
311 | c['height'] = round(height, 3)
312 | c['cx'] = round(x + width / 2, 3)
313 | c['cy'] = round(y + height / 2, 3)
314 | elif el.tag == "{http://www.w3.org/2000/svg}circle":
315 | cx = float(el.get('cx'))
316 | cy = float(el.get('cy'))
317 | c['cx'] = round(cx, 3)
318 | c['cy'] = round(cy, 3)
319 |
320 | if color == 'ff0000':
321 | components['params'].append(c)
322 | if color == '00ff00':
323 | components['inputs'].append(c)
324 | if color == '0000ff':
325 | components['outputs'].append(c)
326 | if color == 'ff00ff':
327 | components['lights'].append(c)
328 | if color == 'ffff00':
329 | components['widgets'].append(c)
330 |
331 | # Sort components
332 | top_left_sort = lambda w: (w['cy'], w['cx'])
333 | name_sort = lambda w: w['name']
334 | components['params'] = sorted(components['params'], key=name_sort)
335 | components['inputs'] = sorted(components['inputs'], key=name_sort)
336 | components['outputs'] = sorted(components['outputs'], key=name_sort)
337 | components['lights'] = sorted(components['lights'], key=name_sort)
338 | components['widgets'] = sorted(components['widgets'], key=name_sort)
339 |
340 | print(f"Found {len(components['params'])} params, {len(components['inputs'])} inputs, {len(components['outputs'])} outputs, {len(components['lights'])} lights, and {len(components['widgets'])} custom widgets.")
341 | return components
342 |
343 |
344 | def components_to_source(components, slug):
345 | identifier = slug_to_identifier(slug)
346 | source = ""
347 |
348 | source += f"""#include "plugin.hpp"
349 |
350 |
351 | struct {identifier} : Module {{"""
352 |
353 | # Params
354 | source += """
355 | enum ParamIds {"""
356 | for c in components['params']:
357 | source += f"""
358 | {c['name']}_PARAM,"""
359 | source += """
360 | NUM_PARAMS
361 | };"""
362 |
363 | # Inputs
364 | source += """
365 | enum InputIds {"""
366 | for c in components['inputs']:
367 | source += f"""
368 | {c['name']}_INPUT,"""
369 | source += """
370 | NUM_INPUTS
371 | };"""
372 |
373 | # Outputs
374 | source += """
375 | enum OutputIds {"""
376 | for c in components['outputs']:
377 | source += f"""
378 | {c['name']}_OUTPUT,"""
379 | source += """
380 | NUM_OUTPUTS
381 | };"""
382 |
383 | # Lights
384 | source += """
385 | enum LightIds {"""
386 | for c in components['lights']:
387 | source += f"""
388 | {c['name']}_LIGHT,"""
389 | source += """
390 | NUM_LIGHTS
391 | };"""
392 |
393 |
394 | source += f"""
395 |
396 | {identifier}() {{
397 | config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);"""
398 |
399 | for c in components['params']:
400 | source += f"""
401 | configParam({c['name']}_PARAM, 0.f, 1.f, 0.f, "");"""
402 |
403 | source += """
404 | }
405 |
406 | void process(const ProcessArgs &args) override {
407 | }
408 | };"""
409 |
410 | source += f"""
411 |
412 |
413 | struct {identifier}Widget : ModuleWidget {{
414 | {identifier}Widget({identifier} *module) {{
415 | setModule(module);
416 | setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/{slug}.svg")));
417 |
418 | addChild(createWidget(Vec(RACK_GRID_WIDTH, 0)));
419 | addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
420 | addChild(createWidget(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
421 | addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));"""
422 |
423 |
424 | # Params
425 | if len(components['params']) > 0:
426 | source += "\n"
427 | for c in components['params']:
428 | if 'x' in c:
429 | source += f"""
430 | addParam(createParam(mm2px(Vec({c['x']}, {c['y']})), module, {identifier}::{c['name']}_PARAM));"""
431 | else:
432 | source += f"""
433 | addParam(createParamCentered(mm2px(Vec({c['cx']}, {c['cy']})), module, {identifier}::{c['name']}_PARAM));"""
434 |
435 | # Inputs
436 | if len(components['inputs']) > 0:
437 | source += "\n"
438 | for c in components['inputs']:
439 | if 'x' in c:
440 | source += f"""
441 | addInput(createInput(mm2px(Vec({c['x']}, {c['y']})), module, {identifier}::{c['name']}_INPUT));"""
442 | else:
443 | source += f"""
444 | addInput(createInputCentered(mm2px(Vec({c['cx']}, {c['cy']})), module, {identifier}::{c['name']}_INPUT));"""
445 |
446 | # Outputs
447 | if len(components['outputs']) > 0:
448 | source += "\n"
449 | for c in components['outputs']:
450 | if 'x' in c:
451 | source += f"""
452 | addOutput(createOutput(mm2px(Vec({c['x']}, {c['y']})), module, {identifier}::{c['name']}_OUTPUT));"""
453 | else:
454 | source += f"""
455 | addOutput(createOutputCentered(mm2px(Vec({c['cx']}, {c['cy']})), module, {identifier}::{c['name']}_OUTPUT));"""
456 |
457 | # Lights
458 | if len(components['lights']) > 0:
459 | source += "\n"
460 | for c in components['lights']:
461 | if 'x' in c:
462 | source += f"""
463 | addChild(createLight>(mm2px(Vec({c['x']}, {c['y']})), module, {identifier}::{c['name']}_LIGHT));"""
464 | else:
465 | source += f"""
466 | addChild(createLightCentered>(mm2px(Vec({c['cx']}, {c['cy']})), module, {identifier}::{c['name']}_LIGHT));"""
467 |
468 | # Widgets
469 | if len(components['widgets']) > 0:
470 | source += "\n"
471 | for c in components['widgets']:
472 | if 'x' in c:
473 | source += f"""
474 | // mm2px(Vec({c['width']}, {c['height']}))
475 | addChild(createWidget(mm2px(Vec({c['x']}, {c['y']}))));"""
476 | else:
477 | source += f"""
478 | addChild(createWidgetCentered(mm2px(Vec({c['cx']}, {c['cy']}))));"""
479 |
480 | source += f"""
481 | }}
482 | }};
483 |
484 |
485 | Model *model{identifier} = createModel<{identifier}, {identifier}Widget>("{slug}");"""
486 |
487 | return source
488 |
489 |
490 | def usage(script):
491 | text = f"""VCV Rack Plugin Helper Utility
492 |
493 | Usage: {script} ...
494 | Commands:
495 |
496 | createplugin [plugin dir]
497 |
498 | A directory will be created and initialized with a minimal plugin template.
499 | If no plugin directory is given, the slug is used.
500 |
501 | createmanifest [plugin dir]
502 |
503 | Creates a `plugin.json` manifest file in an existing plugin directory.
504 | If no plugin directory is given, the current directory is used.
505 |
506 | createmodule [panel file] [source file]
507 |
508 | Adds a new module to the plugin manifest in the current directory.
509 | If a panel and source file are given, generates a template source file initialized with components from a panel file.
510 | Example:
511 | {script} createmodule MyModule res/MyModule.svg src/MyModule.cpp
512 |
513 | See https://vcvrack.com/manual/PanelTutorial.html for creating SVG panel files.
514 | """
515 | print(text)
516 |
517 |
518 | def parse_args(args):
519 | script = args.pop(0)
520 | if len(args) == 0:
521 | usage(script)
522 | return
523 |
524 | cmd = args.pop(0)
525 | if cmd == 'createplugin':
526 | create_plugin(*args)
527 | elif cmd == 'createmodule':
528 | create_module(*args)
529 | elif cmd == 'createmanifest':
530 | create_manifest(*args)
531 | else:
532 | print(f"Command not found: {cmd}")
533 |
534 |
535 | if __name__ == "__main__":
536 | try:
537 | parse_args(sys.argv)
538 | except KeyboardInterrupt:
539 | pass
540 | except UserException as e:
541 | print(e)
542 | sys.exit(1)
543 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------