| @@ -0,0 +1,16 @@ | |||
| *.a | |||
| *.d | |||
| *.o | |||
| *.exe | |||
| *.dll | |||
| *.dylib | |||
| *.so | |||
| *.zip | |||
| .kdev_include_paths | |||
| .kdev4/ | |||
| bin/*-dssi/ | |||
| bin/*.lv2/ | |||
| bin/Ma* | |||
| @@ -0,0 +1,165 @@ | |||
| GNU LESSER GENERAL PUBLIC LICENSE | |||
| Version 3, 29 June 2007 | |||
| Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> | |||
| Everyone is permitted to copy and distribute verbatim copies | |||
| of this license document, but changing it is not allowed. | |||
| This version of the GNU Lesser General Public License incorporates | |||
| the terms and conditions of version 3 of the GNU General Public | |||
| License, supplemented by the additional permissions listed below. | |||
| 0. Additional Definitions. | |||
| As used herein, "this License" refers to version 3 of the GNU Lesser | |||
| General Public License, and the "GNU GPL" refers to version 3 of the GNU | |||
| General Public License. | |||
| "The Library" refers to a covered work governed by this License, | |||
| other than an Application or a Combined Work as defined below. | |||
| An "Application" is any work that makes use of an interface provided | |||
| by the Library, but which is not otherwise based on the Library. | |||
| Defining a subclass of a class defined by the Library is deemed a mode | |||
| of using an interface provided by the Library. | |||
| A "Combined Work" is a work produced by combining or linking an | |||
| Application with the Library. The particular version of the Library | |||
| with which the Combined Work was made is also called the "Linked | |||
| Version". | |||
| The "Minimal Corresponding Source" for a Combined Work means the | |||
| Corresponding Source for the Combined Work, excluding any source code | |||
| for portions of the Combined Work that, considered in isolation, are | |||
| based on the Application, and not on the Linked Version. | |||
| The "Corresponding Application Code" for a Combined Work means the | |||
| object code and/or source code for the Application, including any data | |||
| and utility programs needed for reproducing the Combined Work from the | |||
| Application, but excluding the System Libraries of the Combined Work. | |||
| 1. Exception to Section 3 of the GNU GPL. | |||
| You may convey a covered work under sections 3 and 4 of this License | |||
| without being bound by section 3 of the GNU GPL. | |||
| 2. Conveying Modified Versions. | |||
| If you modify a copy of the Library, and, in your modifications, a | |||
| facility refers to a function or data to be supplied by an Application | |||
| that uses the facility (other than as an argument passed when the | |||
| facility is invoked), then you may convey a copy of the modified | |||
| version: | |||
| a) under this License, provided that you make a good faith effort to | |||
| ensure that, in the event an Application does not supply the | |||
| function or data, the facility still operates, and performs | |||
| whatever part of its purpose remains meaningful, or | |||
| b) under the GNU GPL, with none of the additional permissions of | |||
| this License applicable to that copy. | |||
| 3. Object Code Incorporating Material from Library Header Files. | |||
| The object code form of an Application may incorporate material from | |||
| a header file that is part of the Library. You may convey such object | |||
| code under terms of your choice, provided that, if the incorporated | |||
| material is not limited to numerical parameters, data structure | |||
| layouts and accessors, or small macros, inline functions and templates | |||
| (ten or fewer lines in length), you do both of the following: | |||
| a) Give prominent notice with each copy of the object code that the | |||
| Library is used in it and that the Library and its use are | |||
| covered by this License. | |||
| b) Accompany the object code with a copy of the GNU GPL and this license | |||
| document. | |||
| 4. Combined Works. | |||
| You may convey a Combined Work under terms of your choice that, | |||
| taken together, effectively do not restrict modification of the | |||
| portions of the Library contained in the Combined Work and reverse | |||
| engineering for debugging such modifications, if you also do each of | |||
| the following: | |||
| a) Give prominent notice with each copy of the Combined Work that | |||
| the Library is used in it and that the Library and its use are | |||
| covered by this License. | |||
| b) Accompany the Combined Work with a copy of the GNU GPL and this license | |||
| document. | |||
| c) For a Combined Work that displays copyright notices during | |||
| execution, include the copyright notice for the Library among | |||
| these notices, as well as a reference directing the user to the | |||
| copies of the GNU GPL and this license document. | |||
| d) Do one of the following: | |||
| 0) Convey the Minimal Corresponding Source under the terms of this | |||
| License, and the Corresponding Application Code in a form | |||
| suitable for, and under terms that permit, the user to | |||
| recombine or relink the Application with a modified version of | |||
| the Linked Version to produce a modified Combined Work, in the | |||
| manner specified by section 6 of the GNU GPL for conveying | |||
| Corresponding Source. | |||
| 1) Use a suitable shared library mechanism for linking with the | |||
| Library. A suitable mechanism is one that (a) uses at run time | |||
| a copy of the Library already present on the user's computer | |||
| system, and (b) will operate properly with a modified version | |||
| of the Library that is interface-compatible with the Linked | |||
| Version. | |||
| e) Provide Installation Information, but only if you would otherwise | |||
| be required to provide such information under section 6 of the | |||
| GNU GPL, and only to the extent that such information is | |||
| necessary to install and execute a modified version of the | |||
| Combined Work produced by recombining or relinking the | |||
| Application with a modified version of the Linked Version. (If | |||
| you use option 4d0, the Installation Information must accompany | |||
| the Minimal Corresponding Source and Corresponding Application | |||
| Code. If you use option 4d1, you must provide the Installation | |||
| Information in the manner specified by section 6 of the GNU GPL | |||
| for conveying Corresponding Source.) | |||
| 5. Combined Libraries. | |||
| You may place library facilities that are a work based on the | |||
| Library side by side in a single library together with other library | |||
| facilities that are not Applications and are not covered by this | |||
| License, and convey such a combined library under terms of your | |||
| choice, if you do both of the following: | |||
| a) Accompany the combined library with a copy of the same work based | |||
| on the Library, uncombined with any other library facilities, | |||
| conveyed under the terms of this License. | |||
| b) Give prominent notice with the combined library that part of it | |||
| is a work based on the Library, and explaining where to find the | |||
| accompanying uncombined form of the same work. | |||
| 6. Revised Versions of the GNU Lesser General Public License. | |||
| The Free Software Foundation may publish revised and/or new versions | |||
| of the GNU Lesser General Public License from time to time. Such new | |||
| versions will be similar in spirit to the present version, but may | |||
| differ in detail to address new problems or concerns. | |||
| Each version is given a distinguishing version number. If the | |||
| Library as you received it specifies that a certain numbered version | |||
| of the GNU Lesser General Public License "or any later version" | |||
| applies to it, you have the option of following the terms and | |||
| conditions either of that published version or of any later version | |||
| published by the Free Software Foundation. If the Library as you | |||
| received it does not specify a version number of the GNU Lesser | |||
| General Public License, you may choose any version of the GNU Lesser | |||
| General Public License ever published by the Free Software Foundation. | |||
| If the Library as you received it specifies that a proxy can decide | |||
| whether future versions of the GNU Lesser General Public License shall | |||
| apply, that proxy's public statement of acceptance of any version is | |||
| permanent authorization for you to choose that version for the | |||
| Library. | |||
| @@ -0,0 +1,35 @@ | |||
| #!/usr/bin/make -f | |||
| # Makefile for DISTRHO Plugins # | |||
| # ---------------------------- # | |||
| # Created by falkTX | |||
| # | |||
| include Makefile.mk | |||
| all: plugins gen | |||
| # -------------------------------------------------------------- | |||
| plugins: | |||
| $(MAKE) all -C plugins/BitCrusher | |||
| $(MAKE) all -C plugins/Freeverb | |||
| gen: plugins dpf/utils/lv2_ttl_generator | |||
| @$(CURDIR)/dpf/utils/generate-ttl.sh | |||
| ifeq ($(MACOS),true) | |||
| @$(CURDIR)/dpf/utils/generate-vst-bundles.sh | |||
| endif | |||
| dpf/utils/lv2_ttl_generator: | |||
| $(MAKE) -C dpf/utils/lv2-ttl-generator | |||
| # -------------------------------------------------------------- | |||
| clean: | |||
| $(MAKE) clean -C dpf/utils/lv2-ttl-generator | |||
| $(MAKE) clean -C plugins/BitCrusher | |||
| $(MAKE) clean -C plugins/Freeverb | |||
| # -------------------------------------------------------------- | |||
| .PHONY: plugins | |||
| @@ -0,0 +1,147 @@ | |||
| #!/usr/bin/make -f | |||
| # Makefile for DISTRHO Plugins # | |||
| # ---------------------------- # | |||
| # Created by falkTX | |||
| # | |||
| AR ?= ar | |||
| CC ?= gcc | |||
| CXX ?= g++ | |||
| # -------------------------------------------------------------- | |||
| # Fallback to Linux if no other OS defined | |||
| ifneq ($(HAIKU),true) | |||
| ifneq ($(MACOS),true) | |||
| ifneq ($(WIN32),true) | |||
| LINUX=true | |||
| endif | |||
| endif | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| # Set build and link flags | |||
| BASE_FLAGS = -Wall -Wextra -pipe | |||
| BASE_OPTS = -O2 -ffast-math -mtune=generic -msse -msse2 -fdata-sections -ffunction-sections | |||
| ifneq ($(MACOS),true) | |||
| # MacOS doesn't support this | |||
| BASE_OPTS += -mfpmath=sse | |||
| endif | |||
| ifeq ($(MACOS),true) | |||
| # MacOS linker flags | |||
| LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs | |||
| else | |||
| # Common linker flags | |||
| LINK_OPTS = -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-O1 -Wl,--as-needed -Wl,--strip-all | |||
| endif | |||
| ifeq ($(RASPPI),true) | |||
| # Raspberry-Pi optimization flags | |||
| BASE_OPTS = -O2 -ffast-math -march=armv6 -mfpu=vfp -mfloat-abi=hard | |||
| LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all | |||
| endif | |||
| ifeq ($(PANDORA),true) | |||
| # OpenPandora optimization flags | |||
| BASE_OPTS = -O2 -ffast-math -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp | |||
| LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all | |||
| endif | |||
| ifeq ($(NOOPT),true) | |||
| # No optimization flags | |||
| BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections | |||
| endif | |||
| ifneq ($(WIN32),true) | |||
| # not needed for Windows | |||
| BASE_FLAGS += -fPIC -DPIC | |||
| endif | |||
| ifeq ($(DEBUG),true) | |||
| BASE_FLAGS += -DDEBUG -O0 -g | |||
| LINK_OPTS = | |||
| else | |||
| BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden | |||
| CXXFLAGS += -fvisibility-inlines-hidden | |||
| endif | |||
| BUILD_C_FLAGS = $(BASE_FLAGS) -std=c99 -std=gnu99 $(CFLAGS) | |||
| BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=c++0x -std=gnu++0x $(CXXFLAGS) $(CPPFLAGS) | |||
| LINK_FLAGS = $(LINK_OPTS) -Wl,--no-undefined $(LDFLAGS) | |||
| ifeq ($(MACOS),true) | |||
| # No C++11 support | |||
| BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) $(CPPFLAGS) | |||
| LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS) | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| # Check for optional libs | |||
| ifeq ($(LINUX),true) | |||
| HAVE_DGL = $(shell pkg-config --exists gl x11 && echo true) | |||
| HAVE_JACK = $(shell pkg-config --exists jack && echo true) | |||
| HAVE_LIBLO = $(shell pkg-config --exists liblo && echo true) | |||
| endif | |||
| ifeq ($(MACOS),true) | |||
| HAVE_DGL = true | |||
| endif | |||
| ifeq ($(WIN32),true) | |||
| HAVE_DGL = true | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| # Set libs stuff | |||
| ifeq ($(HAVE_DGL),true) | |||
| ifeq ($(LINUX),true) | |||
| DGL_FLAGS = $(shell pkg-config --cflags gl x11) | |||
| DGL_LIBS = $(shell pkg-config --libs gl x11) | |||
| endif | |||
| ifeq ($(MACOS),true) | |||
| DGL_LIBS = -framework OpenGL -framework Cocoa | |||
| endif | |||
| ifeq ($(WIN32),true) | |||
| DGL_LIBS = -lopengl32 -lgdi32 | |||
| endif | |||
| endif # HAVE_DGL | |||
| # -------------------------------------------------------------- | |||
| # Set app extension | |||
| ifeq ($(WIN32),true) | |||
| APP_EXT = .exe | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| # Set shared lib extension | |||
| LIB_EXT = .so | |||
| ifeq ($(MACOS),true) | |||
| LIB_EXT = .dylib | |||
| endif | |||
| ifeq ($(WIN32),true) | |||
| LIB_EXT = .dll | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| # Set shared library CLI arg | |||
| SHARED = -shared | |||
| ifeq ($(MACOS),true) | |||
| SHARED = -dynamiclib | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| @@ -0,0 +1,5 @@ | |||
| # DPF-Max-Gen | |||
| An experiment with Max generated code and DPF. | |||
| Based on https://github.com/Cycling74/gen-plugin-export. | |||
| @@ -0,0 +1,3 @@ | |||
| All final plugin builds will be placed in this folder. | |||
| There is no "make install" process, simply copy those files to their appropriate place. | |||
| @@ -0,0 +1,30 @@ | |||
| /* | |||
| * DPF Max Gen | |||
| * Copyright (C) 2015 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
| * or without fee is hereby granted, provided that the above copyright notice and this | |||
| * permission notice appear in all copies. | |||
| * | |||
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
| * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
| * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
| * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
| * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| #ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED | |||
| #define DISTRHO_PLUGIN_INFO_H_INCLUDED | |||
| #define DISTRHO_PLUGIN_NAME "MaBitCrush" | |||
| #define DISTRHO_PLUGIN_URI "http://distrho.sf.net/plugins/MaBitCrush" | |||
| #define DISTRHO_PLUGIN_HAS_UI 0 | |||
| #define DISTRHO_PLUGIN_IS_RT_SAFE 0 | |||
| #define DISTRHO_PLUGIN_NUM_INPUTS 1 | |||
| #define DISTRHO_PLUGIN_NUM_OUTPUTS 2 | |||
| //#define DISTRHO_PLUGIN_LV2_CATEGORY "lv2:EQPlugin" | |||
| #endif // DISTRHO_PLUGIN_INFO_H_INCLUDED | |||
| @@ -0,0 +1 @@ | |||
| ../common/DistrhoPluginMaxGen.cpp | |||
| @@ -0,0 +1,40 @@ | |||
| #!/usr/bin/make -f | |||
| # Makefile for DISTRHO Plugins # | |||
| # ---------------------------- # | |||
| # Created by falkTX | |||
| # | |||
| # -------------------------------------------------------------- | |||
| # Project name, used for binaries | |||
| NAME = MaBitCrush | |||
| # -------------------------------------------------------------- | |||
| # Files to build | |||
| OBJS_DSP = \ | |||
| DistrhoPluginMaxGen.cpp.o \ | |||
| gen_exported.cpp.o | |||
| # -------------------------------------------------------------- | |||
| # Do some magic | |||
| include ../Makefile.mk | |||
| # -------------------------------------------------------------- | |||
| # Enable all possible plugin types | |||
| ifeq ($(HAVE_JACK),true) | |||
| TARGETS += jack | |||
| endif | |||
| ifeq ($(LINUX),true) | |||
| TARGETS += ladspa | |||
| endif | |||
| TARGETS += lv2_dsp | |||
| TARGETS += vst | |||
| all: $(TARGETS) | |||
| # -------------------------------------------------------------- | |||
| @@ -0,0 +1,184 @@ | |||
| #include "gen_exported.h" | |||
| namespace gen_exported { | |||
| /******************************************************************************************************************* | |||
| Copyright (c) 2012 Cycling '74 | |||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software | |||
| and associated documentation files (the "Software"), to deal in the Software without restriction, | |||
| including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
| and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | |||
| subject to the following conditions: | |||
| The above copyright notice and this permission notice shall be included in all copies | |||
| or substantial portions of the Software. | |||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
| INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |||
| WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
| OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
| *******************************************************************************************************************/ | |||
| // global noise generator | |||
| Noise noise; | |||
| static const int GENLIB_LOOPCOUNT_BAIL = 100000; | |||
| // The State struct contains all the state and procedures for the gendsp kernel | |||
| typedef struct State { | |||
| CommonState __commonstate; | |||
| double m_resolution_1; | |||
| double samplerate; | |||
| int vectorsize; | |||
| int __exception; | |||
| // re-initialize all member variables; | |||
| inline void reset(double __sr, int __vs) { | |||
| __exception = 0; | |||
| vectorsize = __vs; | |||
| samplerate = __sr; | |||
| m_resolution_1 = 6; | |||
| genlib_reset_complete(this); | |||
| }; | |||
| // the signal processing routine; | |||
| inline int perform(t_sample ** __ins, t_sample ** __outs, int __n) { | |||
| vectorsize = __n; | |||
| const t_sample * __in1 = __ins[0]; | |||
| t_sample * __out1 = __outs[0]; | |||
| t_sample * __out2 = __outs[1]; | |||
| if (__exception) { | |||
| return __exception; | |||
| } else if (( (__in1 == 0) || (__out1 == 0) || (__out2 == 0) )) { | |||
| __exception = GENLIB_ERR_NULL_BUFFER; | |||
| return __exception; | |||
| }; | |||
| // the main sample loop; | |||
| while ((__n--)) { | |||
| const double in1 = (*(__in1++)); | |||
| double mul_50 = (in1 * m_resolution_1); | |||
| double ceil_49 = ceil(mul_50); | |||
| double div_48 = safediv(ceil_49, m_resolution_1); | |||
| double out1 = div_48; | |||
| double add_45 = (mul_50 + 0.5); | |||
| double floor_46 = floor(add_45); | |||
| double sub_44 = (floor_46 - 0.5); | |||
| double div_47 = safediv(sub_44, m_resolution_1); | |||
| double out2 = div_47; | |||
| // assign results to output buffer; | |||
| (*(__out1++)) = out1; | |||
| (*(__out2++)) = out2; | |||
| }; | |||
| return __exception; | |||
| }; | |||
| inline void set_resolution(double _value) { | |||
| m_resolution_1 = _value; | |||
| }; | |||
| } State; | |||
| /// | |||
| /// Configuration for the genlib API | |||
| /// | |||
| /// Number of signal inputs and outputs | |||
| int gen_kernel_numins = 1; | |||
| int gen_kernel_numouts = 2; | |||
| int num_inputs() { return gen_kernel_numins; } | |||
| int num_outputs() { return gen_kernel_numouts; } | |||
| int num_params() { return 1; } | |||
| /// Assistive lables for the signal inputs and outputs | |||
| const char * gen_kernel_innames[] = { "in1" }; | |||
| const char * gen_kernel_outnames[] = { "out1", "out2" }; | |||
| /// Invoke the signal process of a State object | |||
| int perform(CommonState *cself, t_sample **ins, long numins, t_sample **outs, long numouts, long n) { | |||
| State * self = (State *)cself; | |||
| return self->perform(ins, outs, n); | |||
| } | |||
| /// Reset all parameters and stateful operators of a State object | |||
| void reset(CommonState *cself) { | |||
| State * self = (State *)cself; | |||
| self->reset(cself->sr, cself->vs); | |||
| } | |||
| /// Set a parameter of a State object | |||
| void setparameter(CommonState *cself, long index, double value, void *ref) { | |||
| State * self = (State *)cself; | |||
| switch (index) { | |||
| case 0: self->set_resolution(value); break; | |||
| default: break; | |||
| } | |||
| } | |||
| /// Get the value of a parameter of a State object | |||
| void getparameter(CommonState *cself, long index, double *value) { | |||
| State *self = (State *)cself; | |||
| switch (index) { | |||
| case 0: *value = self->m_resolution_1; break; | |||
| default: break; | |||
| } | |||
| } | |||
| /// Allocate and configure a new State object and it's internal CommonState: | |||
| void * create(double sr, long vs) { | |||
| State *self = new State; | |||
| self->reset(sr, vs); | |||
| ParamInfo *pi; | |||
| self->__commonstate.inputnames = gen_kernel_innames; | |||
| self->__commonstate.outputnames = gen_kernel_outnames; | |||
| self->__commonstate.numins = gen_kernel_numins; | |||
| self->__commonstate.numouts = gen_kernel_numouts; | |||
| self->__commonstate.sr = sr; | |||
| self->__commonstate.vs = vs; | |||
| self->__commonstate.params = (ParamInfo *)genlib_sysmem_newptr(1 * sizeof(ParamInfo)); | |||
| self->__commonstate.numparams = 1; | |||
| // initialize parameter 0 ("m_resolution_1") | |||
| pi = self->__commonstate.params + 0; | |||
| pi->name = "resolution"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_resolution_1; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| pi->inputmax = 1; | |||
| pi->hasminmax = true; | |||
| pi->outputmin = 1; | |||
| pi->outputmax = 32; | |||
| pi->exp = 0; | |||
| pi->units = "bits"; // no units defined | |||
| return self; | |||
| } | |||
| /// Release all resources and memory used by a State object: | |||
| void destroy(CommonState *cself) { | |||
| State * self = (State *)cself; | |||
| genlib_sysmem_freeptr(cself->params); | |||
| delete self; | |||
| } | |||
| } // gen_exported:: | |||
| @@ -0,0 +1,37 @@ | |||
| /******************************************************************************************************************* | |||
| Copyright (c) 2012 Cycling '74 | |||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software | |||
| and associated documentation files (the "Software"), to deal in the Software without restriction, | |||
| including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
| and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | |||
| subject to the following conditions: | |||
| The above copyright notice and this permission notice shall be included in all copies | |||
| or substantial portions of the Software. | |||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
| INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |||
| WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
| OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
| *******************************************************************************************************************/ | |||
| #include "genlib.h" | |||
| #include "genlib_exportfunctions.h" | |||
| #include "genlib_ops.h" | |||
| namespace gen_exported { | |||
| int num_inputs(); | |||
| int num_outputs(); | |||
| int num_params(); | |||
| int perform(CommonState *cself, t_sample **ins, long numins, t_sample **outs, long numouts, long n); | |||
| void reset(CommonState *cself); | |||
| void setparameter(CommonState *cself, long index, double value, void *ref); | |||
| void getparameter(CommonState *cself, long index, double *value); | |||
| void * create(double sr, long vs); | |||
| void destroy(CommonState *cself); | |||
| } // gen_exported:: | |||
| @@ -0,0 +1,30 @@ | |||
| /* | |||
| * DPF Max Gen | |||
| * Copyright (C) 2015 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
| * or without fee is hereby granted, provided that the above copyright notice and this | |||
| * permission notice appear in all copies. | |||
| * | |||
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
| * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
| * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
| * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
| * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| #ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED | |||
| #define DISTRHO_PLUGIN_INFO_H_INCLUDED | |||
| #define DISTRHO_PLUGIN_NAME "MaFreeverb" | |||
| #define DISTRHO_PLUGIN_URI "http://distrho.sf.net/plugins/MaFreeverb" | |||
| #define DISTRHO_PLUGIN_HAS_UI 0 | |||
| #define DISTRHO_PLUGIN_IS_RT_SAFE 0 | |||
| #define DISTRHO_PLUGIN_NUM_INPUTS 1 | |||
| #define DISTRHO_PLUGIN_NUM_OUTPUTS 1 | |||
| //#define DISTRHO_PLUGIN_LV2_CATEGORY "lv2:EQPlugin" | |||
| #endif // DISTRHO_PLUGIN_INFO_H_INCLUDED | |||
| @@ -0,0 +1 @@ | |||
| ../common/DistrhoPluginMaxGen.cpp | |||
| @@ -0,0 +1,40 @@ | |||
| #!/usr/bin/make -f | |||
| # Makefile for DISTRHO Plugins # | |||
| # ---------------------------- # | |||
| # Created by falkTX | |||
| # | |||
| # -------------------------------------------------------------- | |||
| # Project name, used for binaries | |||
| NAME = MaFreeverb | |||
| # -------------------------------------------------------------- | |||
| # Files to build | |||
| OBJS_DSP = \ | |||
| DistrhoPluginMaxGen.cpp.o \ | |||
| gen_exported.cpp.o | |||
| # -------------------------------------------------------------- | |||
| # Do some magic | |||
| include ../Makefile.mk | |||
| # -------------------------------------------------------------- | |||
| # Enable all possible plugin types | |||
| ifeq ($(HAVE_JACK),true) | |||
| TARGETS += jack | |||
| endif | |||
| ifeq ($(LINUX),true) | |||
| TARGETS += ladspa | |||
| endif | |||
| TARGETS += lv2_dsp | |||
| TARGETS += vst | |||
| all: $(TARGETS) | |||
| # -------------------------------------------------------------- | |||
| @@ -0,0 +1,420 @@ | |||
| #include "gen_exported.h" | |||
| namespace gen_exported { | |||
| /******************************************************************************************************************* | |||
| Copyright (c) 2012 Cycling '74 | |||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software | |||
| and associated documentation files (the "Software"), to deal in the Software without restriction, | |||
| including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
| and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | |||
| subject to the following conditions: | |||
| The above copyright notice and this permission notice shall be included in all copies | |||
| or substantial portions of the Software. | |||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
| INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |||
| WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
| OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
| *******************************************************************************************************************/ | |||
| // global noise generator | |||
| Noise noise; | |||
| static const int GENLIB_LOOPCOUNT_BAIL = 100000; | |||
| // The State struct contains all the state and procedures for the gendsp kernel | |||
| typedef struct State { | |||
| CommonState __commonstate; | |||
| Delay m_delay_24; | |||
| Delay m_delay_15; | |||
| Delay m_delay_13; | |||
| Delay m_delay_23; | |||
| Delay m_delay_9; | |||
| Delay m_delay_17; | |||
| Delay m_delay_21; | |||
| Delay m_delay_19; | |||
| Delay m_delay_22; | |||
| Delay m_delay_7; | |||
| Delay m_delay_11; | |||
| Delay m_delay_5; | |||
| double m_history_6; | |||
| double m_history_18; | |||
| double m_spread_1; | |||
| double m_history_20; | |||
| double samplerate; | |||
| double m_fb_2; | |||
| double m_history_8; | |||
| double m_history_16; | |||
| double m_history_14; | |||
| double m_damp_3; | |||
| double m_history_12; | |||
| double m_history_10; | |||
| double m_fb_4; | |||
| int vectorsize; | |||
| int __exception; | |||
| // re-initialize all member variables; | |||
| inline void reset(double __sr, int __vs) { | |||
| __exception = 0; | |||
| vectorsize = __vs; | |||
| samplerate = __sr; | |||
| m_spread_1 = 0; | |||
| m_fb_2 = 0.9; | |||
| m_damp_3 = 0.5; | |||
| m_fb_4 = 0.5; | |||
| m_delay_5.reset("m_delay_5", 2000); | |||
| m_history_6 = 0; | |||
| m_delay_7.reset("m_delay_7", 2000); | |||
| m_history_8 = 0; | |||
| m_delay_9.reset("m_delay_9", 2000); | |||
| m_history_10 = 0; | |||
| m_delay_11.reset("m_delay_11", 2000); | |||
| m_history_12 = 0; | |||
| m_delay_13.reset("m_delay_13", 2000); | |||
| m_history_14 = 0; | |||
| m_delay_15.reset("m_delay_15", 2000); | |||
| m_history_16 = 0; | |||
| m_delay_17.reset("m_delay_17", 2000); | |||
| m_history_18 = 0; | |||
| m_delay_19.reset("m_delay_19", 2000); | |||
| m_history_20 = 0; | |||
| m_delay_21.reset("m_delay_21", 2000); | |||
| m_delay_22.reset("m_delay_22", 2000); | |||
| m_delay_23.reset("m_delay_23", 2000); | |||
| m_delay_24.reset("m_delay_24", 2000); | |||
| genlib_reset_complete(this); | |||
| }; | |||
| // the signal processing routine; | |||
| inline int perform(t_sample ** __ins, t_sample ** __outs, int __n) { | |||
| vectorsize = __n; | |||
| const t_sample * __in1 = __ins[0]; | |||
| t_sample * __out1 = __outs[0]; | |||
| if (__exception) { | |||
| return __exception; | |||
| } else if (( (__in1 == 0) || (__out1 == 0) )) { | |||
| __exception = GENLIB_ERR_NULL_BUFFER; | |||
| return __exception; | |||
| }; | |||
| double mul_498 = (m_fb_4 * 0.5); | |||
| double add_474 = (225 + m_spread_1); | |||
| double add_481 = (341 + m_spread_1); | |||
| double add_496 = (441 + m_spread_1); | |||
| double add_467 = (556 + m_spread_1); | |||
| double damp_379 = m_damp_3; | |||
| double damp_377 = damp_379; | |||
| double damp_376 = damp_379; | |||
| double damp_378 = damp_379; | |||
| double damp_380 = damp_379; | |||
| double damp_381 = damp_379; | |||
| double damp_382 = damp_379; | |||
| double damp_383 = damp_379; | |||
| double add_489 = (1557 + m_spread_1); | |||
| double rsub_72 = (1 - damp_377); | |||
| double add_488 = (1617 + m_spread_1); | |||
| double rsub_510 = (1 - damp_376); | |||
| double add_490 = (1491 + m_spread_1); | |||
| double rsub_522 = (1 - damp_378); | |||
| double add_491 = (1422 + m_spread_1); | |||
| double rsub_537 = (1 - damp_379); | |||
| double add_492 = (1356 + m_spread_1); | |||
| double rsub_548 = (1 - damp_380); | |||
| double add_493 = (1277 + m_spread_1); | |||
| double rsub_561 = (1 - damp_381); | |||
| double add_494 = (1188 + m_spread_1); | |||
| double rsub_576 = (1 - damp_382); | |||
| double add_495 = (1116 + m_spread_1); | |||
| double rsub_585 = (1 - damp_383); | |||
| // the main sample loop; | |||
| while ((__n--)) { | |||
| const double in1 = (*(__in1++)); | |||
| double mul_509 = (in1 * 0.015); | |||
| double tap_79 = m_delay_5.read_linear(add_489); | |||
| double gen_460 = tap_79; | |||
| double mul_77 = (tap_79 * damp_377); | |||
| double mul_75 = (m_history_6 * rsub_72); | |||
| double add_76 = (mul_77 + mul_75); | |||
| double mul_73 = (add_76 * m_fb_2); | |||
| double add_80 = (mul_509 + mul_73); | |||
| double history_74_next_81 = add_76; | |||
| double tap_514 = m_delay_7.read_linear(add_488); | |||
| double gen_508 = tap_514; | |||
| double mul_518 = (tap_514 * damp_376); | |||
| double mul_512 = (m_history_8 * rsub_510); | |||
| double add_513 = (mul_518 + mul_512); | |||
| double mul_515 = (add_513 * m_fb_2); | |||
| double add_517 = (mul_509 + mul_515); | |||
| double history_74_next_516 = add_513; | |||
| double tap_526 = m_delay_9.read_linear(add_490); | |||
| double gen_449 = tap_526; | |||
| double mul_530 = (tap_526 * damp_378); | |||
| double mul_524 = (m_history_10 * rsub_522); | |||
| double add_525 = (mul_530 + mul_524); | |||
| double mul_527 = (add_525 * m_fb_2); | |||
| double add_529 = (mul_509 + mul_527); | |||
| double history_74_next_528 = add_525; | |||
| double tap_539 = m_delay_11.read_linear(add_491); | |||
| double gen_438 = tap_539; | |||
| double mul_536 = (tap_539 * damp_379); | |||
| double mul_535 = (m_history_12 * rsub_537); | |||
| double add_538 = (mul_536 + mul_535); | |||
| double mul_540 = (add_538 * m_fb_2); | |||
| double add_541 = (mul_509 + mul_540); | |||
| double history_74_next_543 = add_538; | |||
| double tap_550 = m_delay_13.read_linear(add_492); | |||
| double gen_427 = tap_550; | |||
| double mul_547 = (tap_550 * damp_380); | |||
| double mul_546 = (m_history_14 * rsub_548); | |||
| double add_549 = (mul_547 + mul_546); | |||
| double mul_551 = (add_549 * m_fb_2); | |||
| double add_553 = (mul_509 + mul_551); | |||
| double history_74_next_555 = add_549; | |||
| double tap_563 = m_delay_15.read_linear(add_493); | |||
| double gen_416 = tap_563; | |||
| double mul_560 = (tap_563 * damp_381); | |||
| double mul_559 = (m_history_16 * rsub_561); | |||
| double add_562 = (mul_560 + mul_559); | |||
| double mul_564 = (add_562 * m_fb_2); | |||
| double add_565 = (mul_509 + mul_564); | |||
| double history_74_next_566 = add_562; | |||
| double tap_574 = m_delay_17.read_linear(add_494); | |||
| double gen_405 = tap_574; | |||
| double mul_572 = (tap_574 * damp_382); | |||
| double mul_571 = (m_history_18 * rsub_576); | |||
| double add_573 = (mul_572 + mul_571); | |||
| double mul_575 = (add_573 * m_fb_2); | |||
| double add_577 = (mul_509 + mul_575); | |||
| double history_74_next_579 = add_573; | |||
| double tap_587 = m_delay_19.read_linear(add_495); | |||
| double gen_394 = tap_587; | |||
| double mul_584 = (tap_587 * damp_383); | |||
| double mul_583 = (m_history_20 * rsub_585); | |||
| double add_586 = (mul_584 + mul_583); | |||
| double mul_588 = (add_586 * m_fb_2); | |||
| double add_589 = (mul_509 + mul_588); | |||
| double history_74_next_591 = add_586; | |||
| double add_497 = ((((((((gen_394 + gen_405) + gen_416) + gen_427) + gen_438) + gen_449) + gen_508) + gen_460) + 0); | |||
| double tap_60 = m_delay_21.read_linear(add_467); | |||
| double sub_56 = (add_497 - tap_60); | |||
| double mul_58 = (tap_60 * mul_498); | |||
| double add_57 = (add_497 + mul_58); | |||
| double tap_597 = m_delay_22.read_linear(add_496); | |||
| double sub_594 = (sub_56 - tap_597); | |||
| double mul_596 = (tap_597 * mul_498); | |||
| double add_598 = (sub_56 + mul_596); | |||
| double tap_603 = m_delay_23.read_linear(add_481); | |||
| double sub_600 = (sub_594 - tap_603); | |||
| double mul_602 = (tap_603 * mul_498); | |||
| double add_604 = (sub_594 + mul_602); | |||
| double tap_608 = m_delay_24.read_linear(add_474); | |||
| double sub_606 = (sub_600 - tap_608); | |||
| double mul_609 = (tap_608 * mul_498); | |||
| double add_610 = (sub_600 + mul_609); | |||
| double out1 = sub_606; | |||
| m_delay_5.write(add_80); | |||
| m_delay_24.write(add_610); | |||
| m_delay_23.write(add_604); | |||
| m_delay_22.write(add_598); | |||
| m_delay_21.write(add_57); | |||
| m_history_20 = history_74_next_591; | |||
| m_delay_19.write(add_589); | |||
| m_history_18 = history_74_next_579; | |||
| m_delay_17.write(add_577); | |||
| m_history_16 = history_74_next_566; | |||
| m_delay_15.write(add_565); | |||
| m_history_14 = history_74_next_555; | |||
| m_delay_13.write(add_553); | |||
| m_history_12 = history_74_next_543; | |||
| m_delay_11.write(add_541); | |||
| m_history_10 = history_74_next_528; | |||
| m_delay_9.write(add_529); | |||
| m_history_8 = history_74_next_516; | |||
| m_delay_7.write(add_517); | |||
| m_history_6 = history_74_next_81; | |||
| m_delay_5.step(); | |||
| m_delay_7.step(); | |||
| m_delay_9.step(); | |||
| m_delay_11.step(); | |||
| m_delay_13.step(); | |||
| m_delay_15.step(); | |||
| m_delay_17.step(); | |||
| m_delay_19.step(); | |||
| m_delay_21.step(); | |||
| m_delay_22.step(); | |||
| m_delay_23.step(); | |||
| m_delay_24.step(); | |||
| // assign results to output buffer; | |||
| (*(__out1++)) = out1; | |||
| }; | |||
| return __exception; | |||
| }; | |||
| inline void set_spread(double _value) { | |||
| m_spread_1 = (_value < 0 ? 0 : (_value > 400 ? 400 : _value)); | |||
| }; | |||
| inline void set_fb1(double _value) { | |||
| m_fb_2 = (_value < 0 ? 0 : (_value > 1 ? 1 : _value)); | |||
| }; | |||
| inline void set_damp(double _value) { | |||
| m_damp_3 = (_value < 0 ? 0 : (_value > 1 ? 1 : _value)); | |||
| }; | |||
| inline void set_fb2(double _value) { | |||
| m_fb_4 = (_value < 0 ? 0 : (_value > 1 ? 1 : _value)); | |||
| }; | |||
| } State; | |||
| /// | |||
| /// Configuration for the genlib API | |||
| /// | |||
| /// Number of signal inputs and outputs | |||
| int gen_kernel_numins = 1; | |||
| int gen_kernel_numouts = 1; | |||
| int num_inputs() { return gen_kernel_numins; } | |||
| int num_outputs() { return gen_kernel_numouts; } | |||
| int num_params() { return 4; } | |||
| /// Assistive lables for the signal inputs and outputs | |||
| const char * gen_kernel_innames[] = { "in1" }; | |||
| const char * gen_kernel_outnames[] = { "out1" }; | |||
| /// Invoke the signal process of a State object | |||
| int perform(CommonState *cself, t_sample **ins, long numins, t_sample **outs, long numouts, long n) { | |||
| State * self = (State *)cself; | |||
| return self->perform(ins, outs, n); | |||
| } | |||
| /// Reset all parameters and stateful operators of a State object | |||
| void reset(CommonState *cself) { | |||
| State * self = (State *)cself; | |||
| self->reset(cself->sr, cself->vs); | |||
| } | |||
| /// Set a parameter of a State object | |||
| void setparameter(CommonState *cself, long index, double value, void *ref) { | |||
| State * self = (State *)cself; | |||
| switch (index) { | |||
| case 0: self->set_spread(value); break; | |||
| case 1: self->set_fb1(value); break; | |||
| case 2: self->set_damp(value); break; | |||
| case 3: self->set_fb2(value); break; | |||
| default: break; | |||
| } | |||
| } | |||
| /// Get the value of a parameter of a State object | |||
| void getparameter(CommonState *cself, long index, double *value) { | |||
| State *self = (State *)cself; | |||
| switch (index) { | |||
| case 0: *value = self->m_spread_1; break; | |||
| case 1: *value = self->m_fb_2; break; | |||
| case 2: *value = self->m_damp_3; break; | |||
| case 3: *value = self->m_fb_4; break; | |||
| default: break; | |||
| } | |||
| } | |||
| /// Allocate and configure a new State object and it's internal CommonState: | |||
| void * create(double sr, long vs) { | |||
| State *self = new State; | |||
| self->reset(sr, vs); | |||
| ParamInfo *pi; | |||
| self->__commonstate.inputnames = gen_kernel_innames; | |||
| self->__commonstate.outputnames = gen_kernel_outnames; | |||
| self->__commonstate.numins = gen_kernel_numins; | |||
| self->__commonstate.numouts = gen_kernel_numouts; | |||
| self->__commonstate.sr = sr; | |||
| self->__commonstate.vs = vs; | |||
| self->__commonstate.params = (ParamInfo *)genlib_sysmem_newptr(4 * sizeof(ParamInfo)); | |||
| self->__commonstate.numparams = 4; | |||
| // initialize parameter 0 ("m_spread_1") | |||
| pi = self->__commonstate.params + 0; | |||
| pi->name = "spread"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_spread_1; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| pi->inputmax = 1; | |||
| pi->hasminmax = true; | |||
| pi->outputmin = 0; | |||
| pi->outputmax = 400; | |||
| pi->exp = 0; | |||
| pi->units = ""; // no units defined | |||
| // initialize parameter 1 ("m_fb_2") | |||
| pi = self->__commonstate.params + 1; | |||
| pi->name = "fb1"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_fb_2; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| pi->inputmax = 1; | |||
| pi->hasminmax = true; | |||
| pi->outputmin = 0; | |||
| pi->outputmax = 1; | |||
| pi->exp = 0; | |||
| pi->units = ""; // no units defined | |||
| // initialize parameter 2 ("m_damp_3") | |||
| pi = self->__commonstate.params + 2; | |||
| pi->name = "damp"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_damp_3; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| pi->inputmax = 1; | |||
| pi->hasminmax = true; | |||
| pi->outputmin = 0; | |||
| pi->outputmax = 1; | |||
| pi->exp = 0; | |||
| pi->units = ""; // no units defined | |||
| // initialize parameter 3 ("m_fb_4") | |||
| pi = self->__commonstate.params + 3; | |||
| pi->name = "fb2"; | |||
| pi->paramtype = GENLIB_PARAMTYPE_FLOAT; | |||
| pi->defaultvalue = self->m_fb_4; | |||
| pi->defaultref = 0; | |||
| pi->hasinputminmax = false; | |||
| pi->inputmin = 0; | |||
| pi->inputmax = 1; | |||
| pi->hasminmax = true; | |||
| pi->outputmin = 0; | |||
| pi->outputmax = 1; | |||
| pi->exp = 0; | |||
| pi->units = ""; // no units defined | |||
| return self; | |||
| } | |||
| /// Release all resources and memory used by a State object: | |||
| void destroy(CommonState *cself) { | |||
| State * self = (State *)cself; | |||
| genlib_sysmem_freeptr(cself->params); | |||
| delete self; | |||
| } | |||
| } // freeverb:: | |||
| @@ -0,0 +1,37 @@ | |||
| /******************************************************************************************************************* | |||
| Copyright (c) 2012 Cycling '74 | |||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software | |||
| and associated documentation files (the "Software"), to deal in the Software without restriction, | |||
| including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
| and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | |||
| subject to the following conditions: | |||
| The above copyright notice and this permission notice shall be included in all copies | |||
| or substantial portions of the Software. | |||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
| INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |||
| WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
| OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
| *******************************************************************************************************************/ | |||
| #include "genlib.h" | |||
| #include "genlib_exportfunctions.h" | |||
| #include "genlib_ops.h" | |||
| namespace gen_exported { | |||
| int num_inputs(); | |||
| int num_outputs(); | |||
| int num_params(); | |||
| int perform(CommonState *cself, t_sample **ins, long numins, t_sample **outs, long numouts, long n); | |||
| void reset(CommonState *cself); | |||
| void setparameter(CommonState *cself, long index, double value, void *ref); | |||
| void getparameter(CommonState *cself, long index, double *value); | |||
| void * create(double sr, long vs); | |||
| void destroy(CommonState *cself); | |||
| } // gen_exported:: | |||
| @@ -0,0 +1,153 @@ | |||
| #!/usr/bin/make -f | |||
| # Makefile for DISTRHO Plugins # | |||
| # ---------------------------- # | |||
| # Created by falkTX | |||
| # | |||
| # NAME, OBJS_DSP and OBJS_UI have been defined before | |||
| include ../../Makefile.mk | |||
| ifeq ($(OBJS_UI),) | |||
| HAVE_DGL = false | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| # Basic setup | |||
| TARGET_DIR = ../../bin | |||
| BUILD_C_FLAGS += -I. | |||
| BUILD_CXX_FLAGS += -I. -I../common -I../common/gen_dsp -I../../dpf/distrho -I../../dpf/dgl | |||
| ifeq ($(HAVE_DGL),true) | |||
| BASE_FLAGS += -DHAVE_DGL | |||
| endif | |||
| ifeq ($(HAVE_JACK),true) | |||
| BASE_FLAGS += -DHAVE_JACK | |||
| endif | |||
| ifeq ($(HAVE_LIBLO),true) | |||
| BASE_FLAGS += -DHAVE_LIBLO | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| # Set plugin binary file targets | |||
| jack = $(TARGET_DIR)/$(NAME)$(APP_EXT) | |||
| ladspa_dsp = $(TARGET_DIR)/$(NAME)-ladspa$(LIB_EXT) | |||
| dssi_dsp = $(TARGET_DIR)/$(NAME)-dssi$(LIB_EXT) | |||
| dssi_ui = $(TARGET_DIR)/$(NAME)-dssi/$(NAME)_ui$(APP_EXT) | |||
| lv2 = $(TARGET_DIR)/$(NAME).lv2/$(NAME)$(LIB_EXT) | |||
| lv2_dsp = $(TARGET_DIR)/$(NAME).lv2/$(NAME)_dsp$(LIB_EXT) | |||
| lv2_ui = $(TARGET_DIR)/$(NAME).lv2/$(NAME)_ui$(LIB_EXT) | |||
| vst = $(TARGET_DIR)/$(NAME)-vst$(LIB_EXT) | |||
| # -------------------------------------------------------------- | |||
| # Set distrho code files | |||
| DISTRHO_PLUGIN_FILES = ../../dpf/distrho/DistrhoPluginMain.cpp | |||
| ifeq ($(HAVE_DGL),true) | |||
| DISTRHO_UI_FILES = ../../dpf/distrho/DistrhoUIMain.cpp ../../dpf/libdgl.a | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| # Handle plugins without UI | |||
| ifneq ($(HAVE_DGL),true) | |||
| dssi_ui = | |||
| lv2_ui = | |||
| DISTRHO_UI_FILES = | |||
| DGL_LIBS = | |||
| OBJS_UI = | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| # all needs to be first | |||
| all: | |||
| # -------------------------------------------------------------- | |||
| # Common | |||
| %.c.o: %.c | |||
| $(CC) $< $(BUILD_C_FLAGS) -MD -MP -c -o $@ | |||
| %.cpp.o: %.cpp | |||
| $(CXX) $< $(BUILD_CXX_FLAGS) -MD -MP -c -o $@ | |||
| clean: | |||
| rm -f *.d *.o | |||
| rm -rf $(TARGET_DIR)/$(NAME) $(TARGET_DIR)/$(NAME)-* $(TARGET_DIR)/$(NAME).lv2/ | |||
| # -------------------------------------------------------------- | |||
| # JACK | |||
| jack: $(jack) | |||
| $(jack): $(OBJS_DSP) $(OBJS_UI) $(DISTRHO_PLUGIN_FILES) $(DISTRHO_UI_FILES) | |||
| mkdir -p $(shell dirname $@) | |||
| $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell pkg-config --cflags --libs jack) -DDISTRHO_PLUGIN_TARGET_JACK -o $@ | |||
| # -------------------------------------------------------------- | |||
| # LADSPA | |||
| ladspa: $(ladspa_dsp) | |||
| $(ladspa_dsp): $(OBJS_DSP) $(DISTRHO_PLUGIN_FILES) | |||
| mkdir -p $(shell dirname $@) | |||
| $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -DDISTRHO_PLUGIN_TARGET_LADSPA -o $@ | |||
| # -------------------------------------------------------------- | |||
| # DSSI | |||
| dssi: $(dssi_dsp) $(dssi_ui) | |||
| dssi_dsp: $(dssi_dsp) | |||
| dssi_ui: $(dssi_ui) | |||
| $(dssi_dsp): $(OBJS_DSP) $(DISTRHO_PLUGIN_FILES) | |||
| mkdir -p $(shell dirname $@) | |||
| $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -DDISTRHO_PLUGIN_TARGET_DSSI -o $@ | |||
| $(dssi_ui): $(OBJS_UI) $(DISTRHO_UI_FILES) | |||
| mkdir -p $(shell dirname $@) | |||
| $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell pkg-config --cflags --libs liblo) -DDISTRHO_PLUGIN_TARGET_DSSI -o $@ | |||
| # -------------------------------------------------------------- | |||
| # LV2 | |||
| lv2_one: $(lv2) | |||
| lv2_dsp: $(lv2_dsp) | |||
| lv2_sep: $(lv2_dsp) $(lv2_ui) | |||
| $(lv2): $(OBJS_DSP) $(OBJS_UI) $(DISTRHO_PLUGIN_FILES) $(DISTRHO_UI_FILES) | |||
| mkdir -p $(shell dirname $@) | |||
| $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -DDISTRHO_PLUGIN_TARGET_LV2 -o $@ | |||
| $(lv2_dsp): $(OBJS_DSP) $(DISTRHO_PLUGIN_FILES) | |||
| mkdir -p $(shell dirname $@) | |||
| $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -DDISTRHO_PLUGIN_TARGET_LV2 -o $@ | |||
| $(lv2_ui): $(OBJS_UI) $(DISTRHO_UI_FILES) | |||
| mkdir -p $(shell dirname $@) | |||
| $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -DDISTRHO_PLUGIN_TARGET_LV2 -o $@ | |||
| # -------------------------------------------------------------- | |||
| # VST | |||
| vst: $(vst) | |||
| $(vst): $(OBJS_DSP) $(OBJS_UI) $(DISTRHO_PLUGIN_FILES) $(DISTRHO_UI_FILES) | |||
| mkdir -p $(shell dirname $@) | |||
| $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -DDISTRHO_PLUGIN_TARGET_VST -o $@ | |||
| # -------------------------------------------------------------- | |||
| -include $(OBJS_DSP:%.o=%.d) | |||
| ifeq ($(HAVE_DGL),true) | |||
| -include $(OBJS_UI:%.o=%.d) | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| @@ -0,0 +1,89 @@ | |||
| /* | |||
| * DPF Max Gen | |||
| * Copyright (C) 2015 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
| * or without fee is hereby granted, provided that the above copyright notice and this | |||
| * permission notice appear in all copies. | |||
| * | |||
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
| * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
| * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
| * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
| * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| #include "DistrhoPluginMaxGen.hpp" | |||
| #include "gen_exported.h" | |||
| namespace gen = gen_exported; | |||
| START_NAMESPACE_DISTRHO | |||
| // ----------------------------------------------------------------------- | |||
| DistrhoPluginMaxGen::DistrhoPluginMaxGen() | |||
| : Plugin(gen::num_params(), 0, 0), // 0 programs, 0 states | |||
| fGenState((CommonState*)gen::create(getSampleRate(), getBufferSize())) | |||
| { | |||
| gen::reset(fGenState); | |||
| } | |||
| DistrhoPluginMaxGen::~DistrhoPluginMaxGen() | |||
| { | |||
| gen::destroy(fGenState); | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| // Init | |||
| void DistrhoPluginMaxGen::initParameter(uint32_t index, Parameter& parameter) | |||
| { | |||
| ParamInfo& info(fGenState->params[index]); | |||
| parameter.hints = kParameterIsAutomable; | |||
| parameter.name = info.name; | |||
| parameter.symbol = info.name; | |||
| parameter.unit = info.units; | |||
| parameter.ranges.def = info.defaultvalue; | |||
| parameter.ranges.min = info.outputmin; | |||
| parameter.ranges.max = info.outputmax; | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| // Internal data | |||
| float DistrhoPluginMaxGen::getParameterValue(uint32_t index) const | |||
| { | |||
| double value = 0.0; | |||
| gen::getparameter(fGenState, index, &value); | |||
| return value; | |||
| } | |||
| void DistrhoPluginMaxGen::setParameterValue(uint32_t index, float value) | |||
| { | |||
| gen::setparameter(fGenState, index, value, nullptr); | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| // Process | |||
| void DistrhoPluginMaxGen::run(const float** inputs, float** outputs, uint32_t frames) | |||
| { | |||
| gen::perform(fGenState, (float**)inputs, DISTRHO_PLUGIN_NUM_INPUTS, outputs, DISTRHO_PLUGIN_NUM_OUTPUTS, frames); | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| Plugin* createPlugin() | |||
| { | |||
| return new DistrhoPluginMaxGen(); | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| END_NAMESPACE_DISTRHO | |||
| #include "gen_dsp/genlib.cpp" | |||
| @@ -0,0 +1,90 @@ | |||
| /* | |||
| * DPF Max Gen | |||
| * Copyright (C) 2015 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
| * or without fee is hereby granted, provided that the above copyright notice and this | |||
| * permission notice appear in all copies. | |||
| * | |||
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
| * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
| * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
| * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
| * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| #ifndef DISTRHO_PLUGIN_MAX_GEN_HPP_INCLUDED | |||
| #define DISTRHO_PLUGIN_MAX_GEN_HPP_INCLUDED | |||
| #include "DistrhoPlugin.hpp" | |||
| #include "genlib.h" | |||
| START_NAMESPACE_DISTRHO | |||
| // ----------------------------------------------------------------------- | |||
| class DistrhoPluginMaxGen : public Plugin | |||
| { | |||
| public: | |||
| DistrhoPluginMaxGen(); | |||
| ~DistrhoPluginMaxGen() override; | |||
| protected: | |||
| // ------------------------------------------------------------------- | |||
| // Information | |||
| const char* getLabel() const noexcept override | |||
| { | |||
| return DISTRHO_PLUGIN_NAME; | |||
| } | |||
| const char* getMaker() const noexcept override | |||
| { | |||
| return "DISTRHO"; | |||
| } | |||
| const char* getLicense() const noexcept override | |||
| { | |||
| return "LGPL"; | |||
| } | |||
| uint32_t getVersion() const noexcept override | |||
| { | |||
| return 0x1000; | |||
| } | |||
| int64_t getUniqueId() const noexcept override | |||
| { | |||
| return d_cconst('D', '3', 'E', 'Q'); | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| // Init | |||
| void initParameter(uint32_t index, Parameter& parameter) override; | |||
| // ------------------------------------------------------------------- | |||
| // Internal data | |||
| float getParameterValue(uint32_t index) const override; | |||
| void setParameterValue(uint32_t index, float value) override; | |||
| // ------------------------------------------------------------------- | |||
| // Process | |||
| void run(const float** inputs, float** outputs, uint32_t frames) override; | |||
| // ------------------------------------------------------------------- | |||
| private: | |||
| CommonState* fGenState; | |||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoPluginMaxGen) | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| END_NAMESPACE_DISTRHO | |||
| #endif // DISTRHO_PLUGIN_MAX_GEN_HPP_INCLUDED | |||
| @@ -0,0 +1,354 @@ | |||
| /******************************************************************************************************************* | |||
| Copyright (c) 2012 Cycling '74 | |||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software | |||
| and associated documentation files (the "Software"), to deal in the Software without restriction, | |||
| including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
| and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | |||
| subject to the following conditions: | |||
| The above copyright notice and this permission notice shall be included in all copies | |||
| or substantial portions of the Software. | |||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
| INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |||
| WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
| OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
| *******************************************************************************************************************/ | |||
| #include "genlib.h" | |||
| #include "genlib_exportfunctions.h" | |||
| #include "stdlib.h" | |||
| #include "stdio.h" | |||
| #include "string.h" | |||
| #ifdef pow | |||
| #undef pow | |||
| #endif | |||
| #include <cmath> | |||
| #include <malloc.h> | |||
| #define malloc_size malloc_usable_size | |||
| // DATA_MAXIMUM_ELEMENTS * 8 bytes = 256 mb limit | |||
| #define DATA_MAXIMUM_ELEMENTS (33554432) | |||
| //////////// export_genlib.cpp //////////// | |||
| // export version | |||
| void my_memset(void *p, int c, long size); | |||
| void my_memcpy(void *dst, const void *src, long size); | |||
| t_ptr sysmem_newptr(t_ptr_size size) | |||
| { | |||
| return (t_ptr)malloc(size); | |||
| } | |||
| t_ptr sysmem_newptrclear(t_ptr_size size) | |||
| { | |||
| t_ptr p = (t_ptr)malloc(size); | |||
| if (p) | |||
| my_memset(p, 0, size); | |||
| return p; | |||
| } | |||
| t_ptr sysmem_resizeptr(void *ptr, t_ptr_size newsize) | |||
| { | |||
| return (t_ptr)realloc(ptr, newsize); | |||
| } | |||
| t_ptr sysmem_resizeptrclear(void *ptr, t_ptr_size newsize) | |||
| { | |||
| long oldsize = malloc_size(ptr); | |||
| t_ptr p = (t_ptr)realloc(ptr, newsize); | |||
| if (p) { | |||
| if (newsize > oldsize) | |||
| my_memset((char *)p + oldsize, 0, newsize - oldsize); | |||
| } | |||
| return p; | |||
| } | |||
| t_ptr_size sysmem_ptrsize(void *ptr) | |||
| { | |||
| return malloc_size(ptr); | |||
| } | |||
| void sysmem_freeptr(void *ptr) | |||
| { | |||
| free(ptr); | |||
| } | |||
| void sysmem_copyptr(const void *src, void *dst, t_ptr_size bytes) | |||
| { | |||
| my_memcpy(dst, src, bytes); | |||
| } | |||
| void my_memset(void *p, int c, long size) | |||
| { | |||
| char *p2 = (char *)p; | |||
| int i; | |||
| for (i = 0; i < size; i++, p2++) | |||
| *p2 = c; | |||
| } | |||
| void my_memcpy(void *dst, const void *src, long size) | |||
| { | |||
| char *s2 = (char *)src; | |||
| char *d2 = (char *)dst; | |||
| int i; | |||
| for (i = 0; i < size; i++, s2++, d2++) | |||
| *d2 = *s2; | |||
| } | |||
| void set_zero64(t_sample *memory, long size) | |||
| { | |||
| long i; | |||
| for (i = 0; i < size; i++, memory++) { | |||
| *memory = 0.; | |||
| } | |||
| } | |||
| void genlib_report_error(const char *s) | |||
| { | |||
| fprintf(stderr, "%s\n", s); | |||
| } | |||
| void genlib_report_message(const char *s) | |||
| { | |||
| fprintf(stdout, "%s\n", s); | |||
| } | |||
| unsigned long systime_ticks(void) | |||
| { | |||
| return 0; // Gen code can deal with this | |||
| } | |||
| void * genlib_obtain_reference_from_string(const char * name) { | |||
| return 0; // to be implemented | |||
| } | |||
| // the rest is stuff to isolate gensym, attrs, atoms, buffers etc. | |||
| t_genlib_buffer * genlib_obtain_buffer_from_reference(void *ref) | |||
| { | |||
| return 0; // to be implemented | |||
| } | |||
| t_genlib_err genlib_buffer_edit_begin(t_genlib_buffer *b) | |||
| { | |||
| return 0; // to be implemented | |||
| } | |||
| t_genlib_err genlib_buffer_edit_end(t_genlib_buffer *b, long valid) | |||
| { | |||
| return 0; // to be implemented | |||
| } | |||
| t_genlib_err genlib_buffer_getinfo(t_genlib_buffer *b, t_genlib_buffer_info *info) | |||
| { | |||
| return 0; // to be implemented | |||
| } | |||
| char *genlib_reference_getname(void *ref) | |||
| { | |||
| return 0; // to be implemented | |||
| } | |||
| void genlib_buffer_dirty(t_genlib_buffer *b) | |||
| { | |||
| // to be implemented | |||
| } | |||
| t_genlib_err genlib_buffer_perform_begin(t_genlib_buffer *b) | |||
| { | |||
| return 0; // to be implemented | |||
| } | |||
| void genlib_buffer_perform_end(t_genlib_buffer *b) | |||
| { | |||
| // to be implemented | |||
| } | |||
| t_sample gen_msp_pow(t_sample value, t_sample power) | |||
| { | |||
| return pow(value, power); | |||
| } | |||
| void genlib_data_setbuffer(t_genlib_data *b, void *ref) { | |||
| genlib_report_error("not supported for export targets\n"); | |||
| } | |||
| typedef struct { | |||
| t_genlib_data_info info; | |||
| t_sample cursor; // used by Delay | |||
| //t_symbol * name; | |||
| } t_dsp_gen_data; | |||
| t_genlib_data * genlib_obtain_data_from_reference(void *ref) | |||
| { | |||
| t_dsp_gen_data * self = (t_dsp_gen_data *)malloc(sizeof(t_dsp_gen_data)); | |||
| self->info.dim = 0; | |||
| self->info.channels = 0; | |||
| self->info.data = 0; | |||
| self->cursor = 0; | |||
| return (t_genlib_data *)self; | |||
| } | |||
| t_genlib_err genlib_data_getinfo(t_genlib_data *b, t_genlib_data_info *info) { | |||
| t_dsp_gen_data * self = (t_dsp_gen_data *)b; | |||
| info->dim = self->info.dim; | |||
| info->channels = self->info.channels; | |||
| info->data = self->info.data; | |||
| return GENLIB_ERR_NONE; | |||
| } | |||
| void genlib_data_release(t_genlib_data *b) { | |||
| t_dsp_gen_data * self = (t_dsp_gen_data *)b; | |||
| if (self->info.data) { | |||
| genlib_sysmem_freeptr(self->info.data); | |||
| self->info.data = 0; | |||
| } | |||
| } | |||
| long genlib_data_getcursor(t_genlib_data *b) { | |||
| t_dsp_gen_data * self = (t_dsp_gen_data *)b; | |||
| return self->cursor; | |||
| } | |||
| void genlib_data_setcursor(t_genlib_data *b, long cursor) { | |||
| t_dsp_gen_data * self = (t_dsp_gen_data *)b; | |||
| self->cursor = cursor; | |||
| } | |||
| void genlib_data_resize(t_genlib_data *b, long s, long c) { | |||
| t_dsp_gen_data * self = (t_dsp_gen_data *)b; | |||
| size_t sz, oldsz, copysz; | |||
| t_sample * old = 0; | |||
| t_sample * replaced = 0; | |||
| int i, j, copydim, copychannels, olddim, oldchannels; | |||
| //printf("data resize %d %d\n", s, c); | |||
| // cache old for copying: | |||
| old = self->info.data; | |||
| olddim = self->info.dim; | |||
| oldchannels = self->info.channels; | |||
| // limit [data] size: | |||
| if (s * c > DATA_MAXIMUM_ELEMENTS) { | |||
| s = DATA_MAXIMUM_ELEMENTS/c; | |||
| genlib_report_message("warning: constraining [data] to < 256MB"); | |||
| } | |||
| // bytes required: | |||
| sz = sizeof(t_sample) * s * c; | |||
| oldsz = sizeof(t_sample) * olddim * oldchannels; | |||
| if (old && sz == oldsz) { | |||
| // no need to re-allocate, just resize | |||
| // careful, audio thread may still be using it: | |||
| if (s > olddim) { | |||
| self->info.channels = c; | |||
| self->info.dim = s; | |||
| } else { | |||
| self->info.dim = s; | |||
| self->info.channels = c; | |||
| } | |||
| set_zero64(self->info.data, s * c); | |||
| return; | |||
| } else { | |||
| // allocate new: | |||
| replaced = (t_sample *)sysmem_newptr(sz); | |||
| // check allocation: | |||
| if (replaced == 0) { | |||
| genlib_report_error("allocating [data]: out of memory"); | |||
| // try to reallocate with a default/minimal size instead: | |||
| if (s > 512 || c > 1) { | |||
| genlib_data_resize((t_genlib_data *)self, 512, 1); | |||
| } else { | |||
| // if this fails, then Max is kaput anyway... | |||
| genlib_data_resize((t_genlib_data *)self, 4, 1); | |||
| } | |||
| return; | |||
| } | |||
| // fill with zeroes: | |||
| set_zero64(replaced, s * c); | |||
| // copy in old data: | |||
| if (old) { | |||
| // frames to copy: | |||
| // clamped: | |||
| copydim = olddim > s ? s : olddim; | |||
| // use memcpy if channels haven't changed: | |||
| if (c == oldchannels) { | |||
| copysz = sizeof(t_sample) * copydim * c; | |||
| //post("reset resize (same channels) %p %p, %d", self->info.data, old, copysz); | |||
| memcpy(replaced, old, copysz); | |||
| } else { | |||
| // memcpy won't work if channels have changed, | |||
| // because data is interleaved. | |||
| // clamp channels copied: | |||
| copychannels = oldchannels > c ? c : oldchannels; | |||
| //post("reset resize (different channels) %p %p, %d %d", self->info.data, old, copydim, copychannels); | |||
| for (i = 0; i<copydim; i++) { | |||
| for (j = 0; j<copychannels; j++) { | |||
| replaced[j + i*c] = old[j + i*oldchannels]; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| // now update info: | |||
| if (old == 0) { | |||
| self->info.data = replaced; | |||
| self->info.dim = s; | |||
| self->info.channels = c; | |||
| } else { | |||
| // need to be careful; the audio thread may still be using it | |||
| // since dsp_gen_data is preserved through edits | |||
| // the order of resizing has to be carefully done | |||
| // to prevent indexing out of bounds | |||
| // (or maybe I'm being too paranoid here...) | |||
| if (oldsz > sz) { | |||
| // shrink size first | |||
| if (s > olddim) { | |||
| self->info.channels = c; | |||
| self->info.dim = s; | |||
| } else { | |||
| self->info.dim = s; | |||
| self->info.channels = c; | |||
| } | |||
| self->info.data = replaced; | |||
| } else { | |||
| // shrink size after | |||
| self->info.data = replaced; | |||
| if (s > olddim) { | |||
| self->info.channels = c; | |||
| self->info.dim = s; | |||
| } else { | |||
| self->info.dim = s; | |||
| self->info.channels = c; | |||
| } | |||
| } | |||
| // done with old: | |||
| sysmem_freeptr(old); | |||
| } | |||
| } | |||
| } | |||
| void genlib_reset_complete(void *data) {} | |||
| @@ -0,0 +1,120 @@ | |||
| /******************************************************************************************************************* | |||
| Copyright (c) 2012 Cycling '74 | |||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software | |||
| and associated documentation files (the "Software"), to deal in the Software without restriction, | |||
| including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
| and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | |||
| subject to the following conditions: | |||
| The above copyright notice and this permission notice shall be included in all copies | |||
| or substantial portions of the Software. | |||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
| INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |||
| WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
| OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
| *******************************************************************************************************************/ | |||
| #ifndef GENLIB_H | |||
| #define GENLIB_H 1 | |||
| #include "genlib_common.h" | |||
| //////////// genlib.h //////////// | |||
| // genlib.h -- max (gen~) version | |||
| #ifndef GEN_WINDOWS | |||
| #ifndef _SIZE_T | |||
| #define _SIZE_T | |||
| typedef __typeof__(sizeof(int)) size_t; | |||
| #endif | |||
| #endif | |||
| #ifndef __INT32_TYPE__ | |||
| #define __INT32_TYPE__ int | |||
| #endif | |||
| #ifdef MSP_ON_CLANG | |||
| // gen~ hosted: | |||
| typedef unsigned __INT32_TYPE__ uint32_t; | |||
| typedef unsigned __INT64_TYPE__ uint64_t; | |||
| #else | |||
| #ifdef __GNUC__ | |||
| #include <stdint.h> | |||
| #endif | |||
| #endif | |||
| #define inf (__DBL_MAX__) | |||
| #define GEN_UINT_MAX (4294967295) | |||
| #define TWO_TO_32 (4294967296.0) | |||
| #define C74_CONST const | |||
| // max_types.h: | |||
| // #ifdef C74_X64 | |||
| // typedef unsigned long long t_ptr_uint; | |||
| // typedef long long t_ptr_int; | |||
| // typedef double t_atom_float; | |||
| // typedef t_ptr_uint t_getbytes_size; | |||
| // #else | |||
| typedef unsigned long t_ptr_uint; | |||
| typedef long t_ptr_int; | |||
| typedef float t_atom_float; | |||
| typedef short t_getbytes_size; | |||
| // #endif | |||
| typedef uint32_t t_uint32; | |||
| typedef t_ptr_int t_atom_long; // the type that is an A_LONG in an atom | |||
| typedef t_ptr_int t_int; ///< an integer @ingroup misc | |||
| typedef t_ptr_uint t_ptr_size; ///< unsigned pointer-sized value for counting (like size_t) @ingroup misc | |||
| typedef t_ptr_int t_atom_long; ///< the type that is an A_LONG in a #t_atom @ingroup misc | |||
| typedef t_atom_long t_max_err; ///< an integer value suitable to be returned as an error code @ingroup misc | |||
| extern "C" { | |||
| // string reference handling: | |||
| void * genlib_obtain_reference_from_string(const char * name); | |||
| char *genlib_reference_getname(void *ref); | |||
| // buffer handling: | |||
| t_genlib_buffer *genlib_obtain_buffer_from_reference(void *ref); | |||
| t_genlib_err genlib_buffer_edit_begin(t_genlib_buffer *b); | |||
| t_genlib_err genlib_buffer_edit_end(t_genlib_buffer *b, long valid); | |||
| t_genlib_err genlib_buffer_getinfo(t_genlib_buffer *b, t_genlib_buffer_info *info); | |||
| void genlib_buffer_dirty(t_genlib_buffer *b); | |||
| t_genlib_err genlib_buffer_perform_begin(t_genlib_buffer *b); | |||
| void genlib_buffer_perform_end(t_genlib_buffer *b); | |||
| // data handling: | |||
| t_genlib_data *genlib_obtain_data_from_reference(void *ref); | |||
| t_genlib_err genlib_data_getinfo(t_genlib_data *b, t_genlib_data_info *info); | |||
| void genlib_data_resize(t_genlib_data *b, long dim, long channels); | |||
| void genlib_data_setbuffer(t_genlib_data *b, void *ref); | |||
| void genlib_data_release(t_genlib_data *b); | |||
| void genlib_data_setcursor(t_genlib_data *b, long cursor); | |||
| long genlib_data_getcursor(t_genlib_data *b); | |||
| // other notification: | |||
| void genlib_reset_complete(void *data); | |||
| // get/set state of parameters | |||
| size_t genlib_getstatesize(CommonState *cself, getparameter_method getmethod); | |||
| short genlib_getstate(CommonState *cself, char *state, getparameter_method getmethod); | |||
| short genlib_setstate(CommonState *cself, const char *state, setparameter_method setmethod); | |||
| }; // extern "C" | |||
| #define genlib_sysmem_newptr(s) sysmem_newptr(s) | |||
| #define genlib_sysmem_newptrclear(s) sysmem_newptrclear(s) | |||
| #define genlib_sysmem_resizeptr(p, s) sysmem_resizeptr(p, s) | |||
| #define genlib_sysmem_resizeptrclear(p, s) sysmem_resizeptrclear(p, s) | |||
| #define genlib_sysmem_ptrsize(p) sysmem_ptrsize(p) | |||
| #define genlib_sysmem_freeptr(p) sysmem_freeptr(p) | |||
| #define genlib_sysmem_copyptr(s, d, b) sysmem_copyptr(s, d, b) | |||
| #define genlib_set_zero64(d, n) set_zero64(d, n) | |||
| #define genlib_ticks systime_ticks | |||
| #endif // GENLIB_H | |||
| @@ -0,0 +1,108 @@ | |||
| /******************************************************************************************************************* | |||
| Copyright (c) 2012 Cycling '74 | |||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software | |||
| and associated documentation files (the "Software"), to deal in the Software without restriction, | |||
| including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
| and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | |||
| subject to the following conditions: | |||
| The above copyright notice and this permission notice shall be included in all copies | |||
| or substantial portions of the Software. | |||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
| INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |||
| WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
| OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
| *******************************************************************************************************************/ | |||
| #ifndef GENLIB_COMMON_H | |||
| #define GENLIB_COMMON_H 1 | |||
| #include "genlib_common_win.h" | |||
| //////////// genlib_common.h //////////// | |||
| // common data structure header file -- this is the stuff required by the | |||
| // common code and accessed by the export and max code | |||
| #define DSP_GEN_MAX_SIGNALS 16 | |||
| typedef float t_sample; | |||
| typedef float t_param; | |||
| typedef char *t_ptr; | |||
| typedef long t_genlib_err; | |||
| typedef enum { | |||
| GENLIB_ERR_NONE = 0, ///< No error | |||
| GENLIB_ERR_GENERIC = -1, ///< Generic error | |||
| GENLIB_ERR_INVALID_PTR = -2, ///< Invalid Pointer | |||
| GENLIB_ERR_DUPLICATE = -3, ///< Duplicate | |||
| GENLIB_ERR_OUT_OF_MEM = -4, ///< Out of memory | |||
| GENLIB_ERR_LOOP_OVERFLOW = 100, // too many iterations of loops in perform() | |||
| GENLIB_ERR_NULL_BUFFER = 101 // missing signal data in perform() | |||
| } e_genlib_errorcodes; | |||
| typedef enum { | |||
| GENLIB_PARAMTYPE_FLOAT = 0, | |||
| GENLIB_PARAMTYPE_SYM = 1 | |||
| } e_genlib_paramtypes; | |||
| struct ParamInfo | |||
| { | |||
| t_param defaultvalue; | |||
| void * defaultref; | |||
| char hasinputminmax; | |||
| char hasminmax; | |||
| t_param inputmin, inputmax; | |||
| t_param outputmin, outputmax; | |||
| const char *name; | |||
| const char *units; | |||
| int paramtype; // 0 -> float64, 1 -> symbol (table name) | |||
| t_param exp; // future, for scaling | |||
| }; | |||
| struct CommonState | |||
| { | |||
| t_sample sr; | |||
| int vs; | |||
| int numins; | |||
| int numouts; | |||
| const char **inputnames; | |||
| const char **outputnames; | |||
| int numparams; | |||
| ParamInfo *params; | |||
| void * parammap; // implementation-dependent | |||
| void * api; // implementation-dependent | |||
| }; | |||
| // opaque interface to float32 buffer: | |||
| typedef struct _genlib_buffer t_genlib_buffer; | |||
| typedef struct { | |||
| char b_name[256]; ///< name of the buffer | |||
| float *b_samples; ///< stored with interleaved channels if multi-channel | |||
| long b_frames; ///< number of sample frames (each one is sizeof(float) * b_nchans bytes) | |||
| long b_nchans; ///< number of channels | |||
| long b_size; ///< size of buffer in floats | |||
| float b_sr; ///< sampling rate of the buffer | |||
| long b_modtime; ///< last modified time ("dirty" method) | |||
| long b_rfu[57]; ///< reserved for future use | |||
| } t_genlib_buffer_info; | |||
| // opaque interface to float64 buffer: | |||
| typedef struct _genlib_data t_genlib_data; | |||
| typedef struct { | |||
| int dim, channels; | |||
| t_sample * data; | |||
| } t_genlib_data_info; | |||
| typedef void (*setparameter_method) (CommonState *, long, t_param, void *); | |||
| typedef void (*getparameter_method) (CommonState *, long, t_param *); | |||
| #endif // GENLIB_COMMON_H | |||
| @@ -0,0 +1,43 @@ | |||
| /******************************************************************************************************************* | |||
| Copyright (c) 2012 Cycling '74 | |||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software | |||
| and associated documentation files (the "Software"), to deal in the Software without restriction, | |||
| including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
| and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | |||
| subject to the following conditions: | |||
| The above copyright notice and this permission notice shall be included in all copies | |||
| or substantial portions of the Software. | |||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
| INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |||
| WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
| OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
| *******************************************************************************************************************/ | |||
| #ifndef GENLIB_COMMON_WIN_H | |||
| #define GENLIB_COMMON_WIN_H | |||
| #ifdef _MSC_VER | |||
| #define GEN_WINDOWS | |||
| #endif | |||
| #ifdef GEN_WINDOWS | |||
| #include <malloc.h> | |||
| #include <limits> | |||
| typedef __int32 int32_t; | |||
| typedef unsigned __int32 uint32_t; | |||
| typedef __int64 int64_t; | |||
| typedef unsigned __int64 uint64_t; | |||
| #define malloc_size _msize | |||
| #define __DBL_EPSILON__ (DBL_EPSILON) | |||
| #endif | |||
| #endif | |||
| @@ -0,0 +1,38 @@ | |||
| /******************************************************************************************************************* | |||
| Copyright (c) 2012 Cycling '74 | |||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software | |||
| and associated documentation files (the "Software"), to deal in the Software without restriction, | |||
| including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
| and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | |||
| subject to the following conditions: | |||
| The above copyright notice and this permission notice shall be included in all copies | |||
| or substantial portions of the Software. | |||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
| INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |||
| WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
| OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
| *******************************************************************************************************************/ | |||
| #ifndef GENLIB_EXPORT_FUNCTIONS_H | |||
| #define GENLIB_EXPORT_FUNCTIONS_H 1 | |||
| typedef char *t_ptr; | |||
| t_ptr sysmem_newptr(t_ptr_size size); | |||
| t_ptr sysmem_newptrclear(t_ptr_size size); | |||
| t_ptr sysmem_resizeptr(void *ptr, t_ptr_size newsize); | |||
| t_ptr sysmem_resizeptrclear(void *ptr, t_ptr_size newsize); | |||
| t_ptr_size sysmem_ptrsize(void *ptr); | |||
| void sysmem_freeptr(void *ptr); | |||
| void sysmem_copyptr(const void *src, void *dst, t_ptr_size bytes); | |||
| unsigned long systime_ticks(void); | |||
| void genlib_report_error(const char *s); | |||
| void genlib_report_message(const char *s); | |||
| void set_zero64(t_sample *mem, long size); | |||
| #endif // GENLIB_EXPORT_FUNCTIONS_H | |||