├── .appveyor.yml
├── .gitignore
├── .travis.yml
├── CMakeLists.txt
├── LICENSE
├── README.md
├── cmake_modules
├── SuperColliderCompilerConfig.cmake
└── SuperColliderServerPlugin.cmake
├── plugins
└── HouvilainenFilter
│ ├── .DS_Store
│ ├── Decimator.h
│ ├── FilterBp24db.h
│ ├── FilterHandler.h
│ ├── FilterHp24db.h
│ ├── FilterLp06db.h
│ ├── FilterLp12db.h
│ ├── FilterLp18db.h
│ ├── FilterLp24db.h
│ ├── FilterN24db.h
│ ├── HelpSource
│ └── Classes
│ │ └── HouvilainenFilter.schelp
│ ├── HouvilainenFilter.cpp
│ ├── HouvilainenFilter.hpp
│ ├── HouvilainenFilter.sc
│ ├── Interpolatorlinear.h
│ └── OscNoise.h
├── regenerate
├── testing 2.scd
└── testing.scd
/.appveyor.yml:
--------------------------------------------------------------------------------
1 | version: '{build}'
2 |
3 | clone_depth: 5
4 |
5 | # https://www.appveyor.com/docs/build-environment/#build-worker-images
6 | image: Visual Studio 2017
7 |
8 | test: off
9 |
10 | environment:
11 | CMAKE_CONFIGURATION: Release
12 |
13 | matrix:
14 | - CMAKE_GENERATOR: "Visual Studio 15 2017"
15 | ARCH: "x86"
16 | # https://www.appveyor.com/docs/lang/cpp/
17 | VCVARS_SCRIPT: "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvars32.bat"
18 |
19 | - CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
20 | ARCH: "x64"
21 | VCVARS_SCRIPT: "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvars64.bat"
22 |
23 | install:
24 | # Load command-line tools (lib.exe)
25 | - cmd: call "%VCVARS_SCRIPT%"
26 |
27 | - cmd: echo "Get SuperCollider"
28 | - cmd: git clone --recursive --depth 1 https://github.com/supercollider/supercollider ../supercollider
29 |
30 | before_build:
31 | - mkdir build
32 | - cd build
33 |
34 | build_script:
35 | - cmake -G "%CMAKE_GENERATOR%" -DSC_PATH=../supercollider -DCMAKE_INSTALL_PREFIX=_install ..
36 | - cmake --build . --target install --config %CMAKE_CONFIGURATION%
37 |
38 | artifacts:
39 | - path: build\_install
40 | name: houvilainenfilter-windows-$(ARCH)-$(APPVEYOR_REPO_TAG_NAME)
41 |
42 | # deploy:
43 | # - provider: GitHub
44 | # description: Port of filter described by Antti Houvilainen in text "Non linear digital implementation of the moog ladder filter" - Release $(APPVEYOR_REPO_TAG_NAME)
45 | # artifact: houvilainenfilter-windows-$(ARCH)-$(APPVEYOR_REPO_TAG_NAME)
46 | # auth_token:
47 | # secure: YOUR_TOKEN_HERE
48 | # on:
49 | # appveyor_repo_tag: true
50 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .vimrc
2 |
3 | build*
4 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: cpp
2 |
3 | matrix:
4 | include:
5 | - os: linux
6 | sudo: required
7 | dist: trusty
8 | - os: osx
9 |
10 | before_install:
11 | - git clone --recursive --depth 1 https://github.com/supercollider/supercollider.git ../supercollider
12 |
13 | before_script:
14 | - mkdir build
15 | - cd build
16 | - cmake -DCMAKE_INSTALL_PREFIX=_install -DCMAKE_BUILD_TYPE=Release -DCMAKE_PATH=../supercollider ..
17 |
18 | script:
19 | - cmake --build . --target install
20 |
21 | before_deploy:
22 | - mkdir -p $HOME/artifacts
23 | - cd $TRAVIS_BUILD_DIR/build/_install
24 | - zip -r --symlinks $HOME/artifacts/houvilainenfilter-$TRAVIS_OS_NAME-$TRAVIS_TAG.zip *
25 |
26 | deploy:
27 | # github releases - only tags
28 | - provider: releases
29 | api_key: $GITHUB_TOKEN
30 | file: $HOME/artifacts/houvilainenfilter-$TRAVIS_OS_NAME-$TRAVIS_TAG.zip
31 | skip_cleanup: true
32 | on:
33 | condition: -n "$GITHUB_TOKEN"
34 | tags: true
35 | all_branches: true
36 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ####################################################################################################
2 | # CMakeLists file for HouvilainenFilter
3 | # Generated by Eric Sluyter
4 | # 2019-06-04
5 | ####################################################################################################
6 |
7 | ####################################################################################################
8 | # basic project config
9 | cmake_minimum_required(VERSION 3.5)
10 | set(project_name "HouvilainenFilter")
11 | set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules ${CMAKE_MODULE_PATH})
12 | set(CMAKE_CXX_STANDARD 11)
13 |
14 | ####################################################################################################
15 | # load modules
16 | include(SuperColliderServerPlugin RESULT_VARIABLE server_plugin_found)
17 | if(NOT server_plugin_found)
18 | message(FATAL_ERROR "Could not find server plugin functions module")
19 | endif()
20 |
21 | include(SuperColliderCompilerConfig RESULT_VARIABLE compiler_config_found)
22 | if(NOT compiler_config_found)
23 | message(FATAL_ERROR "Could not find compiler config module")
24 | endif()
25 |
26 | # Windows - puts redistributable DLLs in install directory
27 | include(InstallRequiredSystemLibraries)
28 |
29 | sc_check_sc_path("${SC_PATH}")
30 | message(STATUS "Found SuperCollider: ${SC_PATH}")
31 | set(SC_PATH "${SC_PATH}" CACHE PATH
32 | "Path to SuperCollider source. Relative paths are treated as relative to this script")
33 |
34 | include("${SC_PATH}/SCVersion.txt")
35 | set(SC_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}${PROJECT_VERSION_PATCH}")
36 | message(STATUS "Building plugins for SuperCollider version: ${SC_VERSION}")
37 |
38 | # set project here to avoid SCVersion.txt clobbering our version info
39 | project(${project_name})
40 | sc_do_initial_compiler_config() # do after setting project so compiler ID is available
41 |
42 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX)
43 | message(WARNING "No install prefix provided, defaulting to $BUILD_DIR/install")
44 | set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Install prefix" FORCE)
45 | endif()
46 |
47 | message(STATUS "Install directory set to: ${CMAKE_INSTALL_PREFIX}")
48 |
49 | ####################################################################################################
50 | # options
51 | option(SUPERNOVA "Build plugins for supernova" ON)
52 | option(SCSYNTH "Build plugins for scsynth" ON)
53 | option(NATIVE "Optimize for native architecture" OFF)
54 | option(STRICT "Use strict warning flags" OFF)
55 |
56 | ####################################################################################################
57 | # Begin target HouvilainenFilter
58 |
59 | set(HouvilainenFilter_cpp_files
60 | plugins/HouvilainenFilter/HouvilainenFilter.cpp
61 | plugins/HouvilainenFilter/HouvilainenFilter.hpp
62 | )
63 | set(HouvilainenFilter_sc_files
64 | plugins/HouvilainenFilter/HouvilainenFilter.sc
65 | )
66 | set(HouvilainenFilter_schelp_files
67 | plugins/HouvilainenFilter/HouvilainenFilter.schelp
68 | )
69 |
70 | sc_add_server_plugin(
71 | "HouvilainenFilter/HouvilainenFilter" # desination directory
72 | "HouvilainenFilter" # target name
73 | "${HouvilainenFilter_cpp_files}"
74 | "${HouvilainenFilter_sc_files}"
75 | "${HouvilainenFilter_schelp_files}"
76 | )
77 |
78 | # End target HouvilainenFilter
79 | ####################################################################################################
80 |
81 | ####################################################################################################
82 | # END PLUGIN TARGET DEFINITION
83 | ####################################################################################################
84 |
85 | message(STATUS "Generating plugin targets done")
86 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # HouvilainenFilter
2 |
3 | Author: Eric Sluyter
4 |
5 | Port of filter described by Antti Houvilainen in text "Non linear digital implementation of the moog ladder filter"
6 |
7 | ### Requirements
8 |
9 | - CMake >= 3.5
10 | - SuperCollider source code
11 |
12 | ### Building
13 |
14 | Clone the project, then use CMake to configure and build it. If you start from a directory that
15 | contains the directory where you cloned SuperCollider, the following commands will work.
16 |
17 | git clone https://esluyter/houvilainenfilter
18 | cd houvilainenfilter
19 | mkdir build
20 | cd build
21 |
22 | Then, depending on your toolchain:
23 |
24 | # Linux + make
25 | cmake .. -DCMAKE_BUILD_TYPE=Release
26 | make -j
27 | make install
28 |
29 | # macOS + Xcode
30 | cmake .. -GXcode -DSC_PATH=/path/to/supercollider
31 | cmake --build . --config Release
32 |
33 | # Windows + VS 2017
34 | cmake .. -G"Visual Studio 15 2017 Win64"
35 | cmake --build . --config Release
36 | cmake --build . --config Release --target Install
37 |
38 | You may want to manually specify the install location in the first step to point it at your
39 | SuperCollider extensions directory: add the option `-DCMAKE_INSTALL_PREFIX=/path/to/extensions`.
40 |
41 | ### Developing
42 |
43 | Use the command in `regenerate` to update CMakeLists.txt when you add or remove files from the
44 | project. You don't need to run it if you only change the contents of existing files. You may need to
45 | edit the command if you add, remove, or rename plugins, to match the new plugin paths. Run the
46 | script with `--help` to see all available options.
47 |
--------------------------------------------------------------------------------
/cmake_modules/SuperColliderCompilerConfig.cmake:
--------------------------------------------------------------------------------
1 | # Brian Heim
2 | # 2018-08-26
3 | #
4 | # Compiler configuration help for server plugins
5 |
6 | function(sc_do_initial_compiler_config)
7 | # assume we are not mixing C and C++ compiler vendors
8 | if(CMAKE_VERSION VERSION_LESS 3.10)
9 | # slower/more complicated way
10 | include(CheckCCompilerFlag)
11 | include(CheckCXXCompilerFlag)
12 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU")
13 | CHECK_CXX_COMPILER_FLAG(-msse has_sse)
14 | CHECK_CXX_COMPILER_FLAG(-msse2 has_sse2)
15 | CHECK_CXX_COMPILER_FLAG(-mfpmath=sse has_sse_fp)
16 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
17 | CHECK_CXX_COMPILER_FLAG(/arch:SSE has_sse)
18 | CHECK_CXX_COMPILER_FLAG(/arch:SSE2 has_sse2)
19 | else()
20 | message(WARNING "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}. You may want to modify SuperColliderCompilerConfig.cmake to add checks for SIMD flags and other optimizations.")
21 | endif()
22 | else()
23 | cmake_host_system_information(RESULT has_sse QUERY HAS_SSE)
24 | cmake_host_system_information(RESULT has_sse2 QUERY HAS_SSE2)
25 | cmake_host_system_information(RESULT has_sse_fp QUERY HAS_SSE_FP)
26 | endif()
27 | endfunction()
28 |
29 | function(sc_config_compiler_flags target)
30 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU")
31 | target_compile_options(${target} PUBLIC
32 | $<$:-msse>
33 | $<$:-msse2>
34 | $<$:-mfpmath=sse>
35 | $<$:-march=native>
36 | $<$:-Wall -Wextra -Werror -Wpedantic>
37 | )
38 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
39 | # these options only apply if we're doing a 32-bit build, otherwise they cause a diagnostic
40 | # https://stackoverflow.com/questions/1067630/sse2-option-in-visual-c-x64
41 | if(CMAKE_SIZEOF_VOID_P EQUAL 4)
42 | target_compile_options(${target} PUBLIC
43 | $<$:/arch:SSE>
44 | $<$:/arch:SSE2>
45 | )
46 | endif()
47 | if(NATIVE)
48 | message(WARNING "-DNATIVE is not supported with MSVC")
49 | endif()
50 | # C4514: inline function not used
51 | # C4625: copy ctor implicitly deleted
52 | # C4626: copy assign implicitly deleted
53 | # C4820: padding added after member
54 | # C5026: move ctor implicitly deleted
55 | # C5027: move assign implicitly deleted
56 | target_compile_options(${target} PUBLIC
57 | $<$:-Wall -WX -wd4820 -wd4514 -wd5026 -wd5027 -wd4626 -wd4625>
58 | )
59 | else()
60 | message(WARNING "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}. You may want to modify SuperColliderCompilerConfig.cmake to add checks for SIMD flags and other optimizations.")
61 | endif()
62 | endfunction()
63 |
--------------------------------------------------------------------------------
/cmake_modules/SuperColliderServerPlugin.cmake:
--------------------------------------------------------------------------------
1 | # Brian Heim
2 | # 2018-08-26
3 | # Functions for configuring SuperCollider server plugins
4 |
5 | include(SuperColliderCompilerConfig)
6 |
7 | function(sc_check_sc_path path)
8 | if(NOT path)
9 | set(sc_path_default "../supercollider")
10 | message(WARNING "No SC_PATH specified, defaulting to '${sc_path_default}'.")
11 | set(path "${sc_path_default}")
12 | endif()
13 |
14 | get_filename_component(full_path "${path}" ABSOLUTE BASE_DIR "${CMAKE_SOURCE_DIR}")
15 |
16 | # check main paths
17 | if(NOT EXISTS "${full_path}/include/plugin_interface/SC_PlugIn.h")
18 | set(msg_end "\nPlease set SC_PATH to the root folder of the SuperCollider project relative to the folder containing this CMakeLists.txt file")
19 | message(FATAL_ERROR "Could not find SuperCollider3 headers at '${full_path}'.${msg_end}")
20 | endif()
21 |
22 | # check supernova paths
23 | if (SUPERNOVA)
24 | if (NOT EXISTS ${full_path}/external_libraries/nova-tt/CMakeLists.txt)
25 | message(FATAL_ERROR "The nova-tt submodule in the SuperCollider repository is missing (required for SuperNova plugins). This probably means you forgot to clone submodules. To fix this, run `git submodule update --init` from the root folder of the SuperCollider repository")
26 | endif()
27 | endif()
28 |
29 | set(SC_PATH ${full_path} PARENT_SCOPE)
30 | endfunction()
31 |
32 | function(sc_add_server_plugin_properties target is_supernova)
33 | set_target_properties(${target} PROPERTIES
34 | CXX_VISIBILITY_PRESET hidden
35 | PREFIX ""
36 | )
37 |
38 | if(APPLE OR WIN32)
39 | set_target_properties(${target} PROPERTIES SUFFIX ".scx")
40 | endif()
41 |
42 | target_include_directories(${target} PUBLIC
43 | ${SC_PATH}/include/plugin_interface
44 | ${SC_PATH}/include/common
45 | ${SC_PATH}/common
46 | )
47 |
48 | # from CompilerConfig module
49 | sc_config_compiler_flags(${target})
50 |
51 | target_compile_definitions(${target} PRIVATE $<$:SUPERNOVA>)
52 |
53 | list(APPEND all_sc_server_plugins ${target})
54 | set(all_sc_server_plugins ${all_sc_server_plugins} PARENT_SCOPE)
55 | endfunction()
56 |
57 | function(sc_add_server_plugin dest_dir name cpp sc schelp)
58 | if(SCSYNTH)
59 | set(sy_name "${name}_scsynth")
60 | add_library(${sy_name} MODULE "${cpp}")
61 | install(TARGETS ${sy_name} LIBRARY DESTINATION ${dest_dir})
62 | sc_add_server_plugin_properties(${sy_name} FALSE)
63 | message(STATUS "Added server plugin target ${sy_name}")
64 | endif()
65 |
66 | if(SUPERNOVA)
67 | set(sn_name "${name}_supernova")
68 | add_library(${sn_name} MODULE "${cpp}")
69 | # install scsynth/supernova targets to same dir
70 | install(TARGETS ${sn_name} LIBRARY DESTINATION ${dest_dir})
71 | sc_add_server_plugin_properties(${sn_name} TRUE)
72 | message(STATUS "Added server plugin target ${sn_name}")
73 | endif()
74 |
75 | if(sc)
76 | install(FILES "${sc}" DESTINATION ${dest_dir}/Classes)
77 | endif()
78 | if(schelp)
79 | install(FILES "${schelp}" DESTINATION ${dest_dir}/Help)
80 | endif()
81 | endfunction()
82 |
83 | set(all_sc_server_plugins)
84 |
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/esluyter/houvilainenfilter/2037d8503ea42ecddc15a656cbadd3594e1f33e9/plugins/HouvilainenFilter/.DS_Store
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/Decimator.h:
--------------------------------------------------------------------------------
1 | class Upsample
2 | {
3 | private:
4 | float b0, b1, b2, b3;
5 |
6 | float returnValues[4];
7 |
8 | public:
9 | Upsample()
10 | {
11 | b0= b1= b2= b3= 0.0f;
12 | }
13 |
14 | // TODO: http://www.dspguru.com/dsp/faqs/multirate/interpolation
15 |
16 | float* Calc(const float sample)
17 | {
18 | // Queue with real values
19 | b3 = b2;
20 | b2 = b1;
21 | b1 = b0;
22 | b0 = sample;
23 |
24 | // Get interpolated values between b1 and b2
25 | returnValues[0] = b1;
26 | returnValues[1] = hermite2(0.25f, b0, b1, b2, b3);
27 | returnValues[2] = hermite2(0.50f, b0, b1, b2, b3);
28 | returnValues[3] = hermite2(0.75f, b0, b1, b2, b3);
29 |
30 | return returnValues;
31 | }
32 |
33 | inline float hermite2(const float x, const float y0, const float y1, const float y2, const float y3)
34 | {
35 | // 4-point, 3rd-order Hermite (x-form)
36 | float c0 = y1;
37 | float c1 = 0.5f * (y2 - y0);
38 | float c3 = 1.5f * (y1 - y2) + 0.5f * (y3 - y0);
39 | float c2 = y0 - y1 + c1 - c3;
40 |
41 | return ((c3 * x + c2) * x + c1) * x + c0;
42 | }
43 | };
44 |
45 | //Filtres d�cimateurs
46 | // T.Rochebois
47 | // Based on
48 | //Traitement num�rique du signal, 5eme edition, M Bellanger, Masson pp. 339-346
49 | class Decimator5
50 | {
51 | private:
52 | float R1,R2,R3,R4,R5;
53 | const float h0;
54 | const float h1;
55 | const float h3;
56 | const float h5;
57 |
58 |
59 | public:
60 | Decimator5():h0(346/692.0f),h1(208/692.0f),h3(-44/692.0f),h5(9/692.0f)
61 | {
62 | R1=R2=R3=R4=R5=0.0f;
63 | }
64 | float Calc(const float x0,const float x1)
65 | {
66 | float h5x0=h5*x0;
67 | float h3x0=h3*x0;
68 | float h1x0=h1*x0;
69 | float R6=R5+h5x0;
70 | R5=R4+h3x0;
71 | R4=R3+h1x0;
72 | R3=R2+h1x0+h0*x1;
73 | R2=R1+h3x0;
74 | R1=h5x0;
75 | return R6;
76 | }
77 | };
78 | class Decimator7
79 | {
80 | private:
81 | float R1,R2,R3,R4,R5,R6,R7;
82 | const float h0,h1,h3,h5,h7;
83 | public:
84 | Decimator7():h0(802/1604.0f),h1(490/1604.0f),h3(-116/1604.0f),h5(33/1604.0f),h7(-6/1604.0f)
85 | {
86 | R1=R2=R3=R4=R5=R6=R7=0.0f;
87 | }
88 | float Calc(const float x0,const float x1)
89 | {
90 | float h7x0=h7*x0;
91 | float h5x0=h5*x0;
92 | float h3x0=h3*x0;
93 | float h1x0=h1*x0;
94 | float R8=R7+h7x0;
95 | R7=R6+h5x0;
96 | R6=R5+h3x0;
97 | R5=R4+h1x0;
98 | R4=R3+h1x0+h0*x1;
99 | R3=R2+h3x0;
100 | R2=R1+h5x0;
101 | R1=h7x0;
102 | return R8;
103 | }
104 | };
105 | class Decimator9
106 | {
107 | private:
108 | float R1,R2,R3,R4,R5,R6,R7,R8,R9;
109 | const float h0,h1,h3,h5,h7,h9;
110 |
111 | float h9x0;
112 | float h7x0;
113 | float h5x0;
114 | float h3x0;
115 | float h1x0;
116 | float R10;
117 |
118 | public:
119 | Decimator9():h0(8192/16384.0f),h1(5042/16384.0f),h3(-1277/16384.0f),h5(429/16384.0f),h7(-116/16384.0f),h9(18/16384.0f)
120 | {
121 | Initialize();
122 | }
123 |
124 | inline void Initialize()
125 | {
126 | R1=R2=R3=R4=R5=R6=R7=R8=R9=0.0f;
127 | }
128 |
129 | inline float Calc(const float x0,const float x1)
130 | {
131 | h9x0=h9*x0;
132 | h7x0=h7*x0;
133 | h5x0=h5*x0;
134 | h3x0=h3*x0;
135 | h1x0=h1*x0;
136 | R10=R9+h9x0;
137 | R9=R8+h7x0;
138 | R8=R7+h5x0;
139 | R7=R6+h3x0;
140 | R6=R5+h1x0;
141 | R5=R4+h1x0+h0*x1;
142 | R4=R3+h3x0;
143 | R3=R2+h5x0;
144 | R2=R1+h7x0;
145 | R1=h9x0;
146 | return R10;
147 | }
148 | };
149 |
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/FilterBp24db.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 | This file is part of Tal-NoiseMaker by Patrick Kunz.
4 |
5 | Copyright(c) 2005-2010 Patrick Kunz, TAL
6 | Togu Audio Line, Inc.
7 | http://kunz.corrupt.ch
8 |
9 | This file may be licensed under the terms of of the
10 | GNU General Public License Version 2 (the ``GPL'').
11 |
12 | Software distributed under the License is distributed
13 | on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14 | express or implied. See the GPL for the specific language
15 | governing rights and limitations.
16 |
17 | You should have received a copy of the GPL along with this
18 | program. If not, go to http://www.gnu.org/licenses/gpl.html
19 | or write to the Free Software Foundation, Inc.,
20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 | ==============================================================================
22 | */
23 |
24 | #ifndef __FilterBp24db_h_
25 | #define __FilterBp24db_h_
26 |
27 | #include "OscNoise.h"
28 |
29 | class FilterBp24db
30 | {
31 | public:
32 | private:
33 | float pi;
34 | float v2, iv2;
35 | float ay1, ay2, ay3, ay4, amf;
36 | float az1, az2, az3, az4;
37 | float at1, at2, at3, at4;
38 |
39 | float kfc, kfcr, kacr, k2vg, k2vgNoisy;
40 |
41 | // temporary variables
42 | float tmp;
43 | float sampleRateFactor, cutoffInOld;
44 |
45 | float resonanceInOld;
46 | float resonanceCorrPre;
47 | float resonanceCorrPost;
48 |
49 | OscNoise *oscNoise;
50 |
51 | public:
52 | FilterBp24db(float sampleRate)
53 | {
54 | pi= 3.1415926535f;
55 | v2= 2.0f; // twice the 'thermal voltage of a transistor'
56 | iv2= 1.0f/v2;
57 | cutoffInOld = -1.0f;
58 | resonanceInOld = -1.0f;
59 |
60 | sampleRateFactor= 44100.0f/sampleRate;
61 | if (sampleRateFactor > 1.0f)
62 | {
63 | sampleRateFactor= 1.0f;
64 | }
65 |
66 | oscNoise = new OscNoise(sampleRate);
67 | reset();
68 | }
69 |
70 | public:
71 | void reset()
72 | {
73 | az1= az2= az3= az4= ay1= ay2= ay3= ay4= amf= 0.4f;
74 | at1= at2= at3 = at4 = 0.0f;
75 | }
76 |
77 | inline void process(float *input, const float cutoffIn, const float resonance, const bool calcCeff)
78 | {
79 | // Filter based on the text "Non linear digital implementation of the moog ladder filter" by Antti Houvilainen
80 | // Adopted from Csound code at http://www.kunstmusik.com/udo/cache/moogladder.udo
81 |
82 | if (resonanceInOld != resonance)
83 | {
84 | resonanceInOld = resonance;
85 | float resonanceInverted = 1.0f - resonance;
86 | float invertedSquare = resonanceInverted * resonanceInverted;
87 | resonanceCorrPre = 1.0f + (1.0f - invertedSquare) * 1.0f;
88 | resonanceCorrPost = 1.0f + resonance * 1.1f;
89 | }
90 |
91 | //*input *= resonanceCorrPre;
92 | *input *= 4.0f;
93 |
94 | // Resonance [0..1]
95 | // Cutoff from 0 (0Hz) to 1 (nyquist)
96 | if (calcCeff && cutoffIn != cutoffInOld)
97 | {
98 | cutoffInOld = cutoffIn;
99 | kfc = cutoffIn * sampleRateFactor * 0.5f; // ~sr/2 + tanh approximation correction
100 |
101 | // Frequency & amplitude correction
102 | kfcr = 1.8730f*(kfc*kfc*kfc) + 0.4955f*(kfc*kfc) - 0.6490f*kfc + 0.9988f;
103 | kacr = 1.0f + 1.0f * cutoffIn;
104 |
105 | tmp = - 2.0f * pi * kfcr * kfc; // Filter Tuning
106 | k2vg = (1.0f-(1.0f+tmp+tmp*tmp*0.5f+tmp*tmp*tmp*0.16666667f+tmp*tmp*tmp*tmp*0.0416666667f+tmp*tmp*tmp*tmp*tmp*0.00833333333f));
107 | }
108 |
109 | float rnd1 = 0.001f * oscNoise->getNextSamplePositive() * (1.0f -cutoffIn);
110 |
111 | k2vgNoisy = k2vg + rnd1 * cutoffIn;
112 |
113 | float inWithRes = *input - 4.2f * resonance * amf * kacr;
114 |
115 | ay1 = az1 + k2vgNoisy * (rnd1 + inWithRes - at1);
116 | at1 = tanhApp(ay1);
117 |
118 | ay2 = az2 + k2vgNoisy * (at1-at2);
119 | at2 = tanhApp(ay2);
120 |
121 | ay3 = az3 + k2vgNoisy * (at2-at3);
122 | at3 = tanhApp(ay3);
123 |
124 | ay4 = az4 + k2vgNoisy * (at3-at4);
125 | at4 = tanhApp(ay4);
126 |
127 | az1 = ay1;
128 | az2 = ay2;
129 | az3 = ay3;
130 | az4 = ay4;
131 |
132 | // 1/2-sample delay for phase compensation
133 | amf = ay4; // * 0.625f + az4 * 0.375f;
134 |
135 | amf = tanhClipper(amf);
136 |
137 | if (amf > 0.0f)
138 | {
139 | amf *= 0.99f;
140 | }
141 |
142 | // See Oberheim xpander manual http://www.synthi.se/oberheim/
143 | float ci = 0.f; // R = 100 Ohm, thus ci = 1.f
144 | float c1 = 0.f; // 50 Ohm
145 | float c2 = 2.0f; // 100 Ohm
146 | float c3 = 4.0f; // Pole 3 is not connected
147 | float c4 = 2.0f; // Pole 4 isn't connected either
148 |
149 | float output = ci * inWithRes - c1 * at1 + c2 * at2 - c3 * at3 + c4 * at4;
150 |
151 | *input = output * (resonanceCorrPost + cutoffIn * resonance * 1.0f);
152 | }
153 |
154 | inline float tanhApp(const float x)
155 | {
156 | return x;
157 | }
158 |
159 | inline float tanhClipper(float x)
160 | {
161 | // return tanh(x);
162 | x *= 2.0f;
163 | float a = fabs(x);
164 | float b = 6.0f+a*(3.0f+a);
165 | return (x*b)/(a*b+12.0f);
166 | }
167 | };
168 | #endif
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/FilterHandler.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 | This file is part of Tal-NoiseMaker by Patrick Kunz.
4 |
5 | Copyright(c) 2005-2010 Patrick Kunz, TAL
6 | Togu Audio Line, Inc.
7 | http://kunz.corrupt.ch
8 |
9 | This file may be licensed under the terms of of the
10 | GNU General Public License Version 2 (the ``GPL'').
11 |
12 | Software distributed under the License is distributed
13 | on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14 | express or implied. See the GPL for the specific language
15 | governing rights and limitations.
16 |
17 | You should have received a copy of the GPL along with this
18 | program. If not, go to http://www.gnu.org/licenses/gpl.html
19 | or write to the Free Software Foundation, Inc.,
20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 | ==============================================================================
22 | */
23 |
24 | #ifndef __FilterHandler_h_
25 | #define __FilterHandler_h_
26 |
27 |
28 | #include "Decimator.h"
29 | #include "InterpolatorLinear.h"
30 | #include "FilterLp24db.h"
31 | #include "FilterLp18db.h"
32 | #include "FilterLp12db.h"
33 | #include "FilterLp06db.h"
34 | #include "FilterHp24db.h"
35 | #include "FilterBp24db.h"
36 | #include "FilterN24db.h"
37 |
38 | class FilterHandler
39 | {
40 | private:
41 | Decimator9 *decimator;
42 | Decimator9 *decimator2;
43 | Upsample *upsample;
44 | InterpolatorLinear *interpolatorLinear;
45 |
46 | FilterLp24db *filterLp24db;
47 | FilterLp18db *filterLp18db;
48 | FilterLp12db *filterLp12db;
49 | FilterLp06db *filterLp06db;
50 |
51 | FilterHp24db *filterHp24db;
52 | FilterBp24db *filterBp24db;
53 | FilterN24db *filterN24db;
54 |
55 | int filtertype;
56 | float *upsampledValues;
57 |
58 |
59 | public:
60 | FilterHandler(float sampleRate)
61 | {
62 | upsample = new Upsample();
63 | decimator = new Decimator9();
64 | decimator2 = new Decimator9();
65 | interpolatorLinear = new InterpolatorLinear();
66 | upsampledValues = new float[4];
67 |
68 | filterLp24db = new FilterLp24db(sampleRate * 4.0f);
69 | filterLp18db = new FilterLp18db(sampleRate * 4.0f);
70 | filterLp12db = new FilterLp12db(sampleRate * 4.0f);
71 | filterLp06db = new FilterLp06db(sampleRate * 4.0f);
72 | filterHp24db = new FilterHp24db(sampleRate * 4.0f);
73 | filterBp24db = new FilterBp24db(sampleRate * 4.0f);
74 | filterN24db = new FilterN24db(sampleRate * 4.0f);
75 |
76 | filtertype = 0;
77 | }
78 |
79 | ~FilterHandler()
80 | {
81 | delete decimator;
82 | delete decimator2;
83 | delete upsample;
84 | delete interpolatorLinear;
85 | delete filterLp24db;
86 | delete filterLp18db;
87 | delete filterLp12db;
88 | delete filterLp06db;
89 | delete filterHp24db;
90 | delete filterBp24db;
91 | delete filterN24db;
92 | delete upsampledValues;
93 | }
94 |
95 | void setFiltertype(float value)
96 | {
97 | this->filtertype = (int)value;
98 | }
99 |
100 | void reset()
101 | {
102 | decimator->Initialize();
103 | decimator2->Initialize();
104 | filterLp24db->reset();
105 | filterLp18db->reset();
106 | filterLp12db->reset();
107 | filterLp06db->reset();
108 | filterHp24db->reset();
109 | filterBp24db->reset();
110 | filterN24db->reset();
111 | }
112 |
113 | inline float process(float input, float cutoff, float resonance)
114 | {
115 | interpolatorLinear->process4x(input, upsampledValues);
116 |
117 | // Do oversampled stuff here
118 | switch (filtertype)
119 | {
120 | case 1:
121 | filterLp24db->process(&upsampledValues[0], cutoff, resonance, true);
122 | filterLp24db->process(&upsampledValues[1], cutoff, resonance, false);
123 | filterLp24db->process(&upsampledValues[2], cutoff, resonance, false);
124 | filterLp24db->process(&upsampledValues[3], cutoff, resonance, false);
125 | break;
126 | case 2:
127 | filterLp18db->process(&upsampledValues[0], cutoff, resonance, true);
128 | filterLp18db->process(&upsampledValues[1], cutoff, resonance, false);
129 | filterLp18db->process(&upsampledValues[2], cutoff, resonance, false);
130 | filterLp18db->process(&upsampledValues[3], cutoff, resonance, false);
131 | break;
132 | case 3:
133 | filterLp12db->process(&upsampledValues[0], cutoff, resonance, true);
134 | filterLp12db->process(&upsampledValues[1], cutoff, resonance, false);
135 | filterLp12db->process(&upsampledValues[2], cutoff, resonance, false);
136 | filterLp12db->process(&upsampledValues[3], cutoff, resonance, false);
137 | break;
138 | case 4:
139 | filterLp06db->process(&upsampledValues[0], cutoff, resonance, true);
140 | filterLp06db->process(&upsampledValues[1], cutoff, resonance, false);
141 | filterLp06db->process(&upsampledValues[2], cutoff, resonance, false);
142 | filterLp06db->process(&upsampledValues[3], cutoff, resonance, false);
143 | break;
144 | case 5:
145 | filterHp24db->process(&upsampledValues[0], cutoff, resonance, true);
146 | filterHp24db->process(&upsampledValues[1], cutoff, resonance, false);
147 | filterHp24db->process(&upsampledValues[2], cutoff, resonance, false);
148 | filterHp24db->process(&upsampledValues[3], cutoff, resonance, false);
149 | break;
150 | case 6:
151 | filterBp24db->process(&upsampledValues[0], cutoff, resonance, true);
152 | filterBp24db->process(&upsampledValues[1], cutoff, resonance, false);
153 | filterBp24db->process(&upsampledValues[2], cutoff, resonance, false);
154 | filterBp24db->process(&upsampledValues[3], cutoff, resonance, false);
155 | break;
156 | case 7:
157 | filterN24db->process(&upsampledValues[0], cutoff, resonance, true);
158 | filterN24db->process(&upsampledValues[1], cutoff, resonance, false);
159 | filterN24db->process(&upsampledValues[2], cutoff, resonance, false);
160 | filterN24db->process(&upsampledValues[3], cutoff, resonance, false);
161 | break;
162 | }
163 |
164 | //return upsampledValues[0];
165 |
166 | float decimated1 = decimator->Calc(upsampledValues[0], upsampledValues[1]);
167 | float decimated2 = decimator->Calc(upsampledValues[2], upsampledValues[3]);
168 | //*input = decimator2->Calc(decimated1, decimated2);
169 | return decimator2->Calc(decimated1, decimated2);
170 | }
171 | };
172 | #endif
173 |
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/FilterHp24db.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 | This file is part of Tal-NoiseMaker by Patrick Kunz.
4 |
5 | Copyright(c) 2005-2010 Patrick Kunz, TAL
6 | Togu Audio Line, Inc.
7 | http://kunz.corrupt.ch
8 |
9 | This file may be licensed under the terms of of the
10 | GNU General Public License Version 2 (the ``GPL'').
11 |
12 | Software distributed under the License is distributed
13 | on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14 | express or implied. See the GPL for the specific language
15 | governing rights and limitations.
16 |
17 | You should have received a copy of the GPL along with this
18 | program. If not, go to http://www.gnu.org/licenses/gpl.html
19 | or write to the Free Software Foundation, Inc.,
20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 | ==============================================================================
22 | */
23 |
24 | #ifndef __FilterHp24db_h_
25 | #define __FilterHp24db_h_
26 |
27 | #include "OscNoise.h"
28 |
29 | class FilterHp24db
30 | {
31 | public:
32 | private:
33 | float pi;
34 | float v2, iv2;
35 | float ay1, ay2, ay3, ay4, amf;
36 | float az1, az2, az3, az4;
37 | float at1, at2, at3, at4;
38 |
39 | float kfc, kfcr, kacr, k2vg, k2vgNoisy;
40 |
41 | // temporary variables
42 | float tmp;
43 | float sampleRateFactor, cutoffInOld;
44 |
45 | float resonanceInOld;
46 |
47 | OscNoise *oscNoise;
48 |
49 | public:
50 | FilterHp24db(float sampleRate)
51 | {
52 | pi= 3.1415926535f;
53 | v2= 2.0f; // twice the 'thermal voltage of a transistor'
54 | iv2= 1.0f/v2;
55 | cutoffInOld = -1.0f;
56 | resonanceInOld = -1.0f;
57 |
58 | sampleRateFactor= 44100.0f/sampleRate;
59 | if (sampleRateFactor > 1.0f)
60 | {
61 | sampleRateFactor= 1.0f;
62 | }
63 |
64 | oscNoise = new OscNoise(sampleRate);
65 | reset();
66 | }
67 |
68 | public:
69 | void reset()
70 | {
71 | az1= az2= az3= az4= ay1= ay2= ay3= ay4= amf= 0.4f;
72 | at1= at2= at3 = at4 = 0.0f;
73 | }
74 |
75 | inline void process(float *input, const float cutoffIn, const float resonance, const bool calcCeff)
76 | {
77 | // Filter based on the text "Non linear digital implementation of the moog ladder filter" by Antti Houvilainen
78 | // Adopted from Csound code at http://www.kunstmusik.com/udo/cache/moogladder.udo
79 |
80 | // Resonance [0..1]
81 | // Cutoff from 0 (0Hz) to 1 (nyquist)
82 | if (calcCeff && cutoffIn != cutoffInOld)
83 | {
84 | cutoffInOld = cutoffIn;
85 | kfc = cutoffIn * sampleRateFactor * 0.5f; // ~sr/2 + tanh approximation correction
86 |
87 | // Frequency & amplitude correction
88 | kfcr = 1.8730f*(kfc*kfc*kfc) + 0.4955f*(kfc*kfc) - 0.6490f*kfc + 0.9988f;
89 | kacr = 1.0f + 1.0f * cutoffIn;
90 |
91 | tmp = - 2.0f * pi * kfcr * kfc; // Filter Tuning
92 | k2vg = (1.0f-(1.0f+tmp+tmp*tmp*0.5f+tmp*tmp*tmp*0.16666667f+tmp*tmp*tmp*tmp*0.0416666667f+tmp*tmp*tmp*tmp*tmp*0.00833333333f));
93 | }
94 |
95 | float rnd1 = 0.001f * oscNoise->getNextSamplePositive() * (1.0f -cutoffIn);
96 |
97 | k2vgNoisy = k2vg + rnd1 * cutoffIn;
98 |
99 | float inWithRes = *input - 4.2f * resonance * amf * kacr;
100 |
101 | ay1 = az1 + k2vgNoisy * (rnd1 + inWithRes - at1);
102 | at1 = tanhApp(ay1);
103 |
104 | ay2 = az2 + k2vgNoisy * (at1-at2);
105 | at2 = tanhApp(ay2);
106 |
107 | ay3 = az3 + k2vgNoisy * (at2-at3);
108 | at3 = tanhApp(ay3);
109 |
110 | ay4 = az4 + k2vgNoisy * (at3-at4);
111 | at4 = tanhApp(ay4);
112 |
113 | az1 = ay1;
114 | az2 = ay2;
115 | az3 = ay3;
116 | az4 = ay4;
117 |
118 | // 1/2-sample delay for phase compensation
119 | amf = ay4; // * 0.625f + az4 * 0.375f;
120 |
121 | amf = tanhClipper(amf);
122 |
123 | if (amf > 0.0f)
124 | {
125 | amf *= 0.99999999f;
126 | }
127 |
128 | // See Oberheim xpander manual http://www.synthi.se/oberheim/
129 | //float ci = 1.f; // R = 100 Ohm, thus ci = 1.f
130 | //float c1 = 4.f; // 50 Ohm
131 | //float c2 = 6.f; // 100 Ohm
132 | //float c3 = 4.f; // Pole 3 is not connected
133 | //float c4 = 1.f; // Pole 4 isn't connected either
134 |
135 | float ci = 1.f; // R = 100 Ohm, thus ci = 1.f
136 | float c1 = 2.f; // 50 Ohm
137 | float c2 = 1.f; // 100 Ohm
138 | float c3 = 0.f; // Pole 3 is not connected
139 | float c4 = 0.f; // Pole 4 isn't connected either
140 |
141 | float output = ci * inWithRes - c1 * at1 + c2 * at2 - c3 * at3 + c4 * at4;
142 |
143 | *input = output;
144 | }
145 |
146 | inline float tanhApp(const float x)
147 | {
148 | return x;
149 | }
150 |
151 | inline float tanhClipper(float x)
152 | {
153 | // return tanh(x);
154 | x *= 2.0f;
155 | float a = fabs(x);
156 | float b = 6.0f+a*(3.0f+a);
157 | return (x*b)/(a*b+12.0f);
158 | }
159 | };
160 | #endif
161 |
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/FilterLp06db.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 | This file is part of Tal-NoiseMaker by Patrick Kunz.
4 |
5 | Copyright(c) 2005-2010 Patrick Kunz, TAL
6 | Togu Audio Line, Inc.
7 | http://kunz.corrupt.ch
8 |
9 | This file may be licensed under the terms of of the
10 | GNU General Public License Version 2 (the ``GPL'').
11 |
12 | Software distributed under the License is distributed
13 | on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14 | express or implied. See the GPL for the specific language
15 | governing rights and limitations.
16 |
17 | You should have received a copy of the GPL along with this
18 | program. If not, go to http://www.gnu.org/licenses/gpl.html
19 | or write to the Free Software Foundation, Inc.,
20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 | ==============================================================================
22 | */
23 |
24 | #ifndef __FilterLp06db_h_
25 | #define __FilterLp06db_h_
26 |
27 | #include "OscNoise.h"
28 |
29 | class FilterLp06db
30 | {
31 | public:
32 | private:
33 | float pi;
34 | float v2, iv2;
35 | float ay1, ay2, ay3, ay4, amf;
36 | float az1, az2, az3, az4;
37 | float at1, at2, at3, at4;
38 |
39 | float kfc, kfcr, kacr, k2vg, k2vgNoisy;
40 |
41 | // temporary variables
42 | float tmp;
43 | float sampleRateFactor, cutoffInOld;
44 |
45 | float resonanceInOld;
46 | float resonanceCorrPre;
47 | float resonanceCorrPost;
48 |
49 | OscNoise *oscNoise;
50 |
51 | public:
52 | FilterLp06db(float sampleRate)
53 | {
54 | pi= 3.1415926535f;
55 | v2= 2.0f; // twice the 'thermal voltage of a transistor'
56 | iv2= 1.0f/v2;
57 | cutoffInOld = -1.0f;
58 | resonanceInOld = -1.0f;
59 |
60 | sampleRateFactor= 44100.0f/sampleRate;
61 | if (sampleRateFactor > 1.0f)
62 | {
63 | sampleRateFactor= 1.0f;
64 | }
65 |
66 | oscNoise = new OscNoise(sampleRate);
67 | reset();
68 | }
69 |
70 | public:
71 | void reset()
72 | {
73 | az1= az2= az3= az4= ay1= ay2= ay3= ay4= amf= 0.4f;
74 | at1= at2= at3 = at4 = 0.0f;
75 | }
76 |
77 | inline void process(float *input, const float cutoffIn, const float resonance, const bool calcCeff)
78 | {
79 | // Filter based on the text "Non linear digital implementation of the moog ladder filter" by Antti Houvilainen
80 | // Adopted from Csound code at http://www.kunstmusik.com/udo/cache/moogladder.udo
81 |
82 | if (resonanceInOld != resonance)
83 | {
84 | resonanceInOld = resonance;
85 | float resonanceInverted = 1.0f - resonance;
86 | float invertedSquare = resonanceInverted * resonanceInverted;
87 | resonanceCorrPre = 1.0f + (1.0f - invertedSquare) * 1.0f;
88 | resonanceCorrPost = 1.0f + resonance * 1.1f;
89 | }
90 |
91 | *input *= resonanceCorrPre;
92 |
93 | // Resonance [0..1]
94 | // Cutoff from 0 (0Hz) to 1 (nyquist)
95 | if (calcCeff && cutoffIn != cutoffInOld)
96 | {
97 | cutoffInOld = cutoffIn;
98 | kfc = cutoffIn * sampleRateFactor * 0.5f; // ~sr/2 + tanh approximation correction
99 |
100 | // Frequency & amplitude correction
101 | kfcr = 1.8730f*(kfc*kfc*kfc) + 0.4955f*(kfc*kfc) - 0.6490f*kfc + 0.9988f;
102 | kacr = 1.0f + 0.8f * cutoffIn;
103 |
104 | tmp = - 2.0f * pi * kfcr * kfc; // Filter Tuning
105 | k2vg = (1.0f-(1.0f+tmp+tmp*tmp*0.5f+tmp*tmp*tmp*0.16666667f+tmp*tmp*tmp*tmp*0.0416666667f+tmp*tmp*tmp*tmp*tmp*0.00833333333f));
106 | }
107 |
108 | float rnd1 = 0.001f * oscNoise->getNextSamplePositive() * (1.0f -cutoffIn);
109 |
110 | k2vgNoisy = k2vg + rnd1 * cutoffIn;
111 |
112 | float inWithRes = *input - 4.2f * resonance * amf * kacr;
113 |
114 | ay1 = az1 + k2vgNoisy * (rnd1 + inWithRes - at1);
115 | at1 = ay1;
116 |
117 | ay2 = az2 + k2vgNoisy * (at1-at2);
118 | at2 = ay2;
119 |
120 | ay3 = az3 + k2vgNoisy * (at2-at3);
121 | at3 = ay3;
122 |
123 | ay4 = az4 + k2vgNoisy * (at3-at4);
124 | at4 = ay4;
125 |
126 | az1 = ay1;
127 | az2 = ay2;
128 | az3 = ay3;
129 | az4 = ay4;
130 |
131 | // 1/2-sample delay for phase compensation
132 | amf = ay4; // * 0.625f + az4 * 0.375f;
133 |
134 | amf = tanhClipper(amf);
135 |
136 | if (amf > 0.0f)
137 | {
138 | amf *= 0.99f;
139 | }
140 |
141 | *input = tanhClipper(at1) * (resonanceCorrPost + cutoffIn * resonance * 1.5f);
142 | }
143 |
144 | inline float tanhApp(const float x)
145 | {
146 | return x;
147 | }
148 |
149 | inline float tanhClipper(float x)
150 | {
151 | // return tanh(x);
152 | x *= 2.0f;
153 | float a = fabs(x);
154 | float b = 6.0f+a*(3.0f+a);
155 | return (x*b)/(a*b+12.0f);
156 | }
157 | };
158 | #endif
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/FilterLp12db.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 | This file is part of Tal-NoiseMaker by Patrick Kunz.
4 |
5 | Copyright(c) 2005-2010 Patrick Kunz, TAL
6 | Togu Audio Line, Inc.
7 | http://kunz.corrupt.ch
8 |
9 | This file may be licensed under the terms of of the
10 | GNU General Public License Version 2 (the ``GPL'').
11 |
12 | Software distributed under the License is distributed
13 | on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14 | express or implied. See the GPL for the specific language
15 | governing rights and limitations.
16 |
17 | You should have received a copy of the GPL along with this
18 | program. If not, go to http://www.gnu.org/licenses/gpl.html
19 | or write to the Free Software Foundation, Inc.,
20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 | ==============================================================================
22 | */
23 |
24 | #ifndef __FilterLp12db_h_
25 | #define __FilterLp12db_h_
26 |
27 | #include "OscNoise.h"
28 |
29 | class FilterLp12db
30 | {
31 | public:
32 | private:
33 | float pi;
34 | float v2, iv2;
35 | float ay1, ay2, ay3, ay4, amf;
36 | float az1, az2, az3, az4;
37 | float at1, at2, at3, at4;
38 |
39 | float kfc, kfcr, kacr, k2vg, k2vgNoisy;
40 |
41 | // temporary variables
42 | float tmp;
43 | float sampleRateFactor, cutoffInOld;
44 |
45 | float resonanceInOld;
46 | float resonanceCorrPre;
47 | float resonanceCorrPost;
48 |
49 | OscNoise *oscNoise;
50 |
51 | public:
52 | FilterLp12db(float sampleRate)
53 | {
54 | pi= 3.1415926535f;
55 | v2= 2.0f; // twice the 'thermal voltage of a transistor'
56 | iv2= 1.0f/v2;
57 | cutoffInOld = -1.0f;
58 | resonanceInOld = -1.0f;
59 |
60 | sampleRateFactor= 44100.0f/sampleRate;
61 | if (sampleRateFactor > 1.0f)
62 | {
63 | sampleRateFactor= 1.0f;
64 | }
65 |
66 | oscNoise = new OscNoise(sampleRate);
67 | reset();
68 | }
69 |
70 | public:
71 | void reset()
72 | {
73 | az1= az2= az3= az4= ay1= ay2= ay3= ay4= amf= 0.4f;
74 | at1= at2= at3 = at4 = 0.0f;
75 | }
76 |
77 | inline void process(float *input, const float cutoffIn, const float resonance, const bool calcCeff)
78 | {
79 | // Filter based on the text "Non linear digital implementation of the moog ladder filter" by Antti Houvilainen
80 | // Adopted from Csound code at http://www.kunstmusik.com/udo/cache/moogladder.udo
81 |
82 | if (resonanceInOld != resonance)
83 | {
84 | resonanceInOld = resonance;
85 | float resonanceInverted = 1.0f - resonance;
86 | float invertedSquare = resonanceInverted * resonanceInverted;
87 | resonanceCorrPre = 1.0f + (1.0f - invertedSquare) * 1.0f;
88 | resonanceCorrPost = 1.0f + resonance * 1.1f;
89 | }
90 |
91 | *input *= resonanceCorrPre;
92 |
93 | // Resonance [0..1]
94 | // Cutoff from 0 (0Hz) to 1 (nyquist)
95 | if (calcCeff && cutoffIn != cutoffInOld)
96 | {
97 | cutoffInOld = cutoffIn;
98 | kfc = cutoffIn * sampleRateFactor * 0.5f; // ~sr/2 + tanh approximation correction
99 |
100 | // Frequency & amplitude correction
101 | kfcr = 1.8730f*(kfc*kfc*kfc) + 0.4955f*(kfc*kfc) - 0.6490f*kfc + 0.9988f;
102 | kacr = 1.0f + 0.9f * cutoffIn;
103 |
104 | tmp = - 2.0f * pi * kfcr * kfc; // Filter Tuning
105 | k2vg = (1.0f-(1.0f+tmp+tmp*tmp*0.5f+tmp*tmp*tmp*0.16666667f+tmp*tmp*tmp*tmp*0.0416666667f+tmp*tmp*tmp*tmp*tmp*0.00833333333f));
106 | }
107 |
108 | float rnd1 = 0.001f * oscNoise->getNextSamplePositive() * (1.0f -cutoffIn);
109 |
110 | k2vgNoisy = k2vg + rnd1 * cutoffIn;
111 |
112 | float inWithRes = *input - 4.2f * resonance * amf * kacr;
113 |
114 | ay1 = az1 + k2vgNoisy * (rnd1 + inWithRes - at1);
115 | at1 = ay1;
116 |
117 | ay2 = az2 + k2vgNoisy * (at1-at2);
118 | at2 = ay2;
119 |
120 | ay3 = az3 + k2vgNoisy * (at2-at3);
121 | at3 = ay3;
122 |
123 | ay4 = az4 + k2vgNoisy * (at3-at4);
124 | at4 = ay4;
125 |
126 | az1 = ay1;
127 | az2 = ay2;
128 | az3 = ay3;
129 | az4 = ay4;
130 |
131 | // 1/2-sample delay for phase compensation
132 | amf = ay4; // * 0.625f + az4 * 0.375f;
133 |
134 | amf = tanhClipper(amf);
135 |
136 | if (amf > 0.0f)
137 | {
138 | amf *= 0.99f;
139 | }
140 |
141 | *input = tanhClipper(at2) * (resonanceCorrPost + cutoffIn * resonance * 1.5f);
142 | }
143 |
144 | inline float tanhApp(const float x)
145 | {
146 | return x;
147 | }
148 |
149 | inline float tanhClipper(float x)
150 | {
151 | // return tanh(x);
152 | x *= 2.0f;
153 | float a = fabs(x);
154 | float b = 6.0f+a*(3.0f+a);
155 | return (x*b)/(a*b+12.0f);
156 | }
157 | };
158 | #endif
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/FilterLp18db.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 | This file is part of Tal-NoiseMaker by Patrick Kunz.
4 |
5 | Copyright(c) 2005-2010 Patrick Kunz, TAL
6 | Togu Audio Line, Inc.
7 | http://kunz.corrupt.ch
8 |
9 | This file may be licensed under the terms of of the
10 | GNU General Public License Version 2 (the ``GPL'').
11 |
12 | Software distributed under the License is distributed
13 | on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14 | express or implied. See the GPL for the specific language
15 | governing rights and limitations.
16 |
17 | You should have received a copy of the GPL along with this
18 | program. If not, go to http://www.gnu.org/licenses/gpl.html
19 | or write to the Free Software Foundation, Inc.,
20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 | ==============================================================================
22 | */
23 |
24 | #ifndef __FilterLp18db_h_
25 | #define __FilterLp18db_h_
26 |
27 | #include "OscNoise.h"
28 |
29 | class FilterLp18db
30 | {
31 | public:
32 | private:
33 | float pi;
34 | float v2, iv2;
35 | float ay1, ay2, ay3, ay4, amf;
36 | float az1, az2, az3, az4;
37 | float at1, at2, at3, at4;
38 |
39 | float kfc, kfcr, kacr, k2vg, k2vgNoisy;
40 |
41 | // temporary variables
42 | float tmp;
43 | float sampleRateFactor, cutoffInOld;
44 |
45 | float resonanceInOld;
46 | float resonanceCorrPre;
47 | float resonanceCorrPost;
48 |
49 | OscNoise *oscNoise;
50 |
51 | public:
52 | FilterLp18db(float sampleRate)
53 | {
54 | pi= 3.1415926535f;
55 | v2= 2.0f; // twice the 'thermal voltage of a transistor'
56 | iv2= 1.0f/v2;
57 | cutoffInOld = -1.0f;
58 | resonanceInOld = -1.0f;
59 |
60 | sampleRateFactor= 44100.0f/sampleRate;
61 | if (sampleRateFactor > 1.0f)
62 | {
63 | sampleRateFactor= 1.0f;
64 | }
65 |
66 | oscNoise = new OscNoise(sampleRate);
67 | reset();
68 | }
69 |
70 | public:
71 | void reset()
72 | {
73 | az1= az2= az3= az4= ay1= ay2= ay3= ay4= amf= 0.4f;
74 | at1= at2= at3 = at4 = 0.0f;
75 | }
76 |
77 | inline void process(float *input, const float cutoffIn, const float resonance, const bool calcCeff)
78 | {
79 | // Filter based on the text "Non linear digital implementation of the moog ladder filter" by Antti Houvilainen
80 | // Adopted from Csound code at http://www.kunstmusik.com/udo/cache/moogladder.udo
81 |
82 | if (resonanceInOld != resonance)
83 | {
84 | resonanceInOld = resonance;
85 | float resonanceInverted = 1.0f - resonance;
86 | float invertedSquare = resonanceInverted * resonanceInverted * resonanceInverted * resonanceInverted;
87 | resonanceCorrPre = 1.0f + (1.0f - invertedSquare) * 1.0f;
88 | resonanceCorrPost = 1.0f + resonance * 1.1f;
89 | }
90 |
91 | *input *= resonanceCorrPre;
92 |
93 | // Resonance [0..1]
94 | // Cutoff from 0 (0Hz) to 1 (nyquist)
95 | if (calcCeff && cutoffIn != cutoffInOld)
96 | {
97 | cutoffInOld = cutoffIn;
98 | kfc = cutoffIn * sampleRateFactor * 0.5f; // ~sr/2 + tanh approximation correction
99 |
100 | // Frequency & amplitude correction
101 | kfcr = 1.8730f*(kfc*kfc*kfc) + 0.4955f*(kfc*kfc) - 0.6490f*kfc + 0.9988f;
102 | kacr = 1.0f + 1.0f * cutoffIn;
103 |
104 | tmp = - 2.0f * pi * kfcr * kfc; // Filter Tuning
105 | k2vg = (1.0f-(1.0f+tmp+tmp*tmp*0.5f+tmp*tmp*tmp*0.16666667f+tmp*tmp*tmp*tmp*0.0416666667f+tmp*tmp*tmp*tmp*tmp*0.00833333333f));
106 | }
107 |
108 | float rnd1 = 0.001f * oscNoise->getNextSamplePositive() * (1.0f -cutoffIn);
109 |
110 | k2vgNoisy = k2vg + rnd1 * cutoffIn;
111 |
112 | float inWithRes = *input - 4.2f * resonance * amf * kacr;
113 |
114 | ay1 = az1 + k2vgNoisy * (rnd1 + inWithRes - at1);
115 | at1 = ay1;
116 |
117 | ay2 = az2 + k2vgNoisy * (at1-at2);
118 | at2 = ay2;
119 |
120 | ay3 = az3 + k2vgNoisy * (at2-at3);
121 | at3 = ay3;
122 |
123 | ay4 = az4 + k2vgNoisy * (at3-at4);
124 | at4 = ay4;
125 |
126 | az1 = ay1;
127 | az2 = ay2;
128 | az3 = ay3;
129 | az4 = ay4;
130 |
131 | // 1/2-sample delay for phase compensation
132 | amf = ay4; // * 0.625f + az4 * 0.375f;
133 |
134 | amf = tanhClipper(amf);
135 |
136 | if (amf > 0.0f)
137 | {
138 | amf *= 0.99f;
139 | }
140 |
141 | *input = tanhClipper(at3) * (resonanceCorrPost + cutoffIn * resonance * 1.5f);
142 | }
143 |
144 | inline float tanhApp(const float x)
145 | {
146 | return x;
147 | }
148 |
149 | inline float tanhClipper(float x)
150 | {
151 | // return tanh(x);
152 | x *= 2.0f;
153 | float a = fabs(x);
154 | float b = 6.0f+a*(3.0f+a);
155 | return (x*b)/(a*b+12.0f);
156 | }
157 | };
158 | #endif
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/FilterLp24db.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 | This file is part of Tal-NoiseMaker by Patrick Kunz.
4 |
5 | Copyright(c) 2005-2010 Patrick Kunz, TAL
6 | Togu Audio Line, Inc.
7 | http://kunz.corrupt.ch
8 |
9 | This file may be licensed under the terms of of the
10 | GNU General Public License Version 2 (the ``GPL'').
11 |
12 | Software distributed under the License is distributed
13 | on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14 | express or implied. See the GPL for the specific language
15 | governing rights and limitations.
16 |
17 | You should have received a copy of the GPL along with this
18 | program. If not, go to http://www.gnu.org/licenses/gpl.html
19 | or write to the Free Software Foundation, Inc.,
20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 | ==============================================================================
22 | */
23 |
24 | #ifndef __FilterLp24db_h_
25 | #define __FilterLp24db_h_
26 |
27 | #include "OscNoise.h"
28 |
29 | class FilterLp24db
30 | {
31 | public:
32 | private:
33 | float pi;
34 | float v2, iv2;
35 | float ay1, ay2, ay3, ay4, amf;
36 | float az1, az2, az3, az4;
37 | float at1, at2, at3, at4;
38 |
39 | float kfc, kfcr, kacr, k2vg, k2vgNoisy;
40 |
41 | // temporary variables
42 | float tmp;
43 | float sampleRateFactor, cutoffInOld;
44 |
45 | float resonanceInOld;
46 | float resonanceCorrPre;
47 | float resonanceCorrPost;
48 |
49 | OscNoise *oscNoise;
50 |
51 | public:
52 | FilterLp24db(float sampleRate)
53 | {
54 | pi= 3.1415926535f;
55 | v2= 2.0f; // twice the 'thermal voltage of a transistor'
56 | iv2= 1.0f/v2;
57 | cutoffInOld = -1.0f;
58 | resonanceInOld = -1.0f;
59 |
60 | sampleRateFactor= 44100.0f/sampleRate;
61 | if (sampleRateFactor > 1.0f)
62 | {
63 | sampleRateFactor= 1.0f;
64 | }
65 |
66 | oscNoise = new OscNoise(sampleRate);
67 | reset();
68 | }
69 |
70 | public:
71 | void reset()
72 | {
73 | az1= az2= az3= az4= ay1= ay2= ay3= ay4= amf= 0.4f;
74 | at1= at2= at3 = at4 = 0.0f;
75 | }
76 |
77 | inline void process(float *input, const float cutoffIn, const float resonance, const bool calcCeff)
78 | {
79 | // Filter based on the text "Non linear digital implementation of the moog ladder filter" by Antti Houvilainen
80 | // Adopted from Csound code at http://www.kunstmusik.com/udo/cache/moogladder.udo
81 |
82 | if (resonanceInOld != resonance)
83 | {
84 | resonanceInOld = resonance;
85 | float resonanceInverted = 1.0f - resonance;
86 | float invertedSquare = resonanceInverted * resonanceInverted;
87 | resonanceCorrPre = 1.0f + (1.0f - invertedSquare) * 1.0f;
88 | resonanceCorrPost = 1.0f + resonance * 1.1f;
89 | }
90 |
91 |
92 | *input *= resonanceCorrPre;
93 |
94 | // Resonance [0..1]
95 | // Cutoff from 0 (0Hz) to 1 (nyquist)
96 | if (calcCeff && cutoffIn != cutoffInOld)
97 | {
98 | cutoffInOld = cutoffIn; // 1000
99 | // 114.843750
100 | kfc = cutoffIn * sampleRateFactor * 0.5f; // ~sr/2 + tanh approximation correction
101 |
102 | // Frequency & amplitude correction
103 | kfcr = 1.8730f*(kfc*kfc*kfc) + 0.4955f*(kfc*kfc) - 0.6490f*kfc + 1.4f; // 2843466
104 | kacr = 1.0f + 1.8f * cutoffIn; // 1801
105 |
106 | tmp = - 2.0f * pi * kfcr * kfc; // Filter Tuning
107 |
108 | k2vg = (1.0f-(1.0f+tmp+tmp*tmp*0.5f+tmp*tmp*tmp*0.16666667f+tmp*tmp*tmp*tmp*0.0416666667f+tmp*tmp*tmp*tmp*tmp*0.00833333333f));
109 | }
110 |
111 |
112 | float rnd1 = 0.001f * oscNoise->getNextSamplePositive() * (1.0f -cutoffIn);
113 |
114 | k2vgNoisy = k2vg + rnd1 * cutoffIn;
115 |
116 | float inWithRes = *input - 4.2f * resonance * amf * kacr;
117 |
118 | ay1 = az1 + k2vgNoisy * (rnd1 + inWithRes - at1);
119 | at1 = ay1;
120 |
121 | ay2 = az2 + k2vgNoisy * (at1-at2);
122 | at2 = ay2;
123 |
124 | ay3 = az3 + k2vgNoisy * (at2-at3);
125 | at3 = ay3;
126 |
127 | ay4 = az4 + k2vgNoisy * (at3-at4);
128 | at4 = ay4;
129 |
130 | az1 = ay1;
131 | az2 = ay2;
132 | az3 = ay3;
133 | az4 = ay4;
134 |
135 | // 1/2-sample delay for phase compensation
136 | amf = ay4; // * 0.625f + az4 * 0.375f;
137 |
138 | amf = tanhClipper(amf);
139 |
140 | if (amf > 0.0f)
141 | {
142 | amf *= 0.99f;
143 | }
144 |
145 | *input = amf * (resonanceCorrPost + cutoffIn * resonance * 3.5f);
146 | }
147 |
148 | inline float tanhApp(const float x)
149 | {
150 | return x;
151 | }
152 |
153 | inline float tanhClipper(float x)
154 | {
155 | // return tanh(x);
156 | x *= 2.0f;
157 | float a = fabs(x);
158 | float b = 6.0f+a*(3.0f+a);
159 | return (x*b)/(a*b+12.0f);
160 | }
161 | };
162 | #endif
163 |
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/FilterN24db.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 | This file is part of Tal-NoiseMaker by Patrick Kunz.
4 |
5 | Copyright(c) 2005-2010 Patrick Kunz, TAL
6 | Togu Audio Line, Inc.
7 | http://kunz.corrupt.ch
8 |
9 | This file may be licensed under the terms of of the
10 | GNU General Public License Version 2 (the ``GPL'').
11 |
12 | Software distributed under the License is distributed
13 | on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14 | express or implied. See the GPL for the specific language
15 | governing rights and limitations.
16 |
17 | You should have received a copy of the GPL along with this
18 | program. If not, go to http://www.gnu.org/licenses/gpl.html
19 | or write to the Free Software Foundation, Inc.,
20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 | ==============================================================================
22 | */
23 |
24 | #ifndef __FilterN24db_h_
25 | #define __FilterN24db_h_
26 |
27 | #include "OscNoise.h"
28 |
29 | class FilterN24db
30 | {
31 | public:
32 | private:
33 | float pi;
34 | float v2, iv2;
35 | float ay1, ay2, ay3, ay4, amf;
36 | float az1, az2, az3, az4;
37 | float at1, at2, at3, at4;
38 |
39 | float kfc, kfcr, kacr, k2vg, k2vgNoisy;
40 |
41 | // temporary variables
42 | float tmp;
43 | float sampleRateFactor, cutoffInOld;
44 |
45 | float resonanceInOld;
46 | float resonanceCorrPre;
47 | float resonanceCorrPost;
48 |
49 | OscNoise *oscNoise;
50 |
51 | public:
52 | FilterN24db(float sampleRate)
53 | {
54 | pi= 3.1415926535f;
55 | v2= 2.0f; // twice the 'thermal voltage of a transistor'
56 | iv2= 1.0f/v2;
57 | cutoffInOld = -1.0f;
58 | resonanceInOld = -1.0f;
59 |
60 | sampleRateFactor= 44100.0f/sampleRate;
61 | if (sampleRateFactor > 1.0f)
62 | {
63 | sampleRateFactor= 1.0f;
64 | }
65 |
66 | oscNoise = new OscNoise(sampleRate);
67 | reset();
68 | }
69 |
70 | public:
71 | void reset()
72 | {
73 | az1= az2= az3= az4= ay1= ay2= ay3= ay4= amf= 0.4f;
74 | at1= at2= at3 = at4 = 0.0f;
75 | }
76 |
77 | inline void process(float *input, const float cutoffIn, const float resonance, const bool calcCeff)
78 | {
79 | // Filter based on the text "Non linear digital implementation of the moog ladder filter" by Antti Houvilainen
80 | // Adopted from Csound code at http://www.kunstmusik.com/udo/cache/moogladder.udo
81 |
82 | if (resonanceInOld != resonance)
83 | {
84 | resonanceInOld = resonance;
85 | float resonanceInverted = 1.0f - resonance;
86 | float invertedSquare = resonanceInverted * resonanceInverted;
87 | resonanceCorrPre = 1.0f + (1.0f - invertedSquare) * 1.0f;
88 | resonanceCorrPost = 1.0f + resonance * 1.1f;
89 | }
90 |
91 | *input *= resonanceCorrPre;
92 |
93 | // Resonance [0..1]
94 | // Cutoff from 0 (0Hz) to 1 (nyquist)
95 | if (calcCeff && cutoffIn != cutoffInOld)
96 | {
97 | cutoffInOld = cutoffIn;
98 | kfc = cutoffIn * sampleRateFactor * 0.5f; // ~sr/2 + tanh approximation correction
99 |
100 | // Frequency & amplitude correction
101 | kfcr = 1.8730f*(kfc*kfc*kfc) + 0.4955f*(kfc*kfc) - 0.6490f*kfc + 0.9988f;
102 | kacr = 1.0f + 1.0f * cutoffIn;
103 |
104 | tmp = - 2.0f * pi * kfcr * kfc; // Filter Tuning
105 | k2vg = (1.0f-(1.0f+tmp+tmp*tmp*0.5f+tmp*tmp*tmp*0.16666667f+tmp*tmp*tmp*tmp*0.0416666667f+tmp*tmp*tmp*tmp*tmp*0.00833333333f));
106 | }
107 |
108 | float rnd1 = 0.001f * oscNoise->getNextSamplePositive() * (1.0f -cutoffIn);
109 |
110 | k2vgNoisy = k2vg + rnd1 * cutoffIn;
111 |
112 | float inWithRes = *input - 4.2f * resonance * amf * kacr;
113 |
114 | ay1 = az1 + k2vgNoisy * (rnd1 + inWithRes - at1);
115 | at1 = tanhApp(ay1);
116 |
117 | ay2 = az2 + k2vgNoisy * (at1-at2);
118 | at2 = tanhApp(ay2);
119 |
120 | ay3 = az3 + k2vgNoisy * (at2-at3);
121 | at3 = tanhApp(ay3);
122 |
123 | ay4 = az4 + k2vgNoisy * (at3-at4);
124 | at4 = tanhApp(ay4);
125 |
126 | az1 = ay1;
127 | az2 = ay2;
128 | az3 = ay3;
129 | az4 = ay4;
130 |
131 | // 1/2-sample delay for phase compensation
132 | amf = ay4; // * 0.625f + az4 * 0.375f;
133 |
134 | amf = tanhClipper(amf);
135 |
136 | if (amf > 0.0f)
137 | {
138 | amf *= 0.99f;
139 | }
140 |
141 | //// See Oberheim xpander manual http://www.synthi.se/oberheim/
142 | //float ci = 1.f;
143 | //float c1 = 1.f;
144 | //float c2 = 2.0f;
145 | //float c3 = 0.f;
146 | //float c4 = 1.0f;
147 |
148 | float ci = 1.0f;
149 | float c1 = 2.0f;
150 | float c2 = 4.0f;
151 | float c3 = 4.0f;
152 | float c4 = 0.0f;
153 |
154 | float output = ci * inWithRes - c1 * at1 + c2 * at2 - c3 * at3 + c4 * at4;
155 |
156 | *input = output * (resonanceCorrPost + cutoffIn * resonance * 1.0f);
157 | }
158 |
159 | inline float tanhApp(const float x)
160 | {
161 | return x;
162 | }
163 |
164 | inline float tanhClipper(float x)
165 | {
166 | // return tanh(x);
167 | x *= 2.0f;
168 | float a = fabs(x);
169 | float b = 6.0f+a*(3.0f+a);
170 | return (x*b)/(a*b+12.0f);
171 | }
172 | };
173 | #endif
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/HelpSource/Classes/HouvilainenFilter.schelp:
--------------------------------------------------------------------------------
1 | class:: HouvilainenFilter
2 | summary:: Port of filter described by Antti Houvilainen in text "Non linear digital implementation of the moog ladder filter"
3 | related:: Classes/RLPF, Classes/MoogFF, Classes/SVF, Classes/DFM1
4 | categories:: UGens>Filters
5 |
6 | description::
7 |
8 | Port of filter described by Antti Houvilainen in text "Non linear digital implementation of the moog ladder filter", implemented as the Csound moogladder opcode (https://github.com/csound) and modified as part of Tal-NoiseMaker by Patrick Kunz (https://github.com/Nexbit/tal-noisemaker).
9 |
10 | Features 4x upsampling and audio-rate cutoff modulation.
11 |
12 |
13 | classmethods::
14 |
15 | method::ar
16 |
17 | argument::in
18 | audio rate input signal
19 |
20 | argument::freq
21 | filter cutoff frequency in hz, this is modulatable at audio rate
22 |
23 | argument::res
24 | filter resonance gain, between 0 and 1
25 |
26 | argument::filtertype
27 | selects between the various flavors of filter:
28 | table::
29 | ## 0 || Bypass
30 | ## 1 || LP 24db
31 | ## 2 || LP 18db
32 | ## 3 || LP 12db
33 | ## 4 || LP 6db
34 | ## 5 || HP 24db
35 | ## 6 || BP 24db
36 | ## 7 || N 24db
37 | ::
38 |
39 |
40 | examples::
41 |
42 | Basic example of all filter types on various sources:
43 | code::
44 | (
45 | Ndef(\src, { PinkNoise.ar(0.1 ! 2) });
46 | Ndef(\type, 1);
47 | Ndef(\freq, { MouseX.kr(100, 12000, \exponential) });
48 | Ndef(\res, { MouseY.kr });
49 | Ndef(\filtered, {
50 | Limiter.ar(
51 | HouvilainenFilter.ar(Ndef.ar(\src), Ndef.kr(\freq), Ndef.kr(\res), Ndef.kr(\type)),
52 | 0.2
53 | );
54 | }).play;
55 | )
56 |
57 | Ndef(\type, 1); // LP 24 db
58 | Ndef(\type, 2); // LP 18 db
59 | Ndef(\type, 3); // LP 12 db
60 | Ndef(\type, 4); // LP 6 db
61 | Ndef(\type, 5); // HP 24 db
62 | Ndef(\type, 6); // BP 24 db
63 | Ndef(\type, 7); // N 24 db
64 |
65 | Ndef(\src, { PinkNoise.ar(0.1 ! 2) });
66 | Ndef(\src, { Saw.ar(75, 0.1) ! 2 });
67 | Ndef(\src, { Saw.ar(303, 0.1) ! 2});
68 | Ndef(\src, { Saw.ar(SinOsc.ar(0.1).range(5, 15), 0.1) ! 2 });
69 | Ndef(\src, { Pulse.ar(75, SinOsc.ar(1).range(0.1, 0.9), 0.1) ! 2 });
70 |
71 | b.free; b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01-44_1.aiff");
72 | b.free; b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");
73 | Ndef(\src, { HPF.ar(PlayBuf.ar(1, b, BufRateScale.kr(b), loop: 1), 400) ! 2});
74 |
75 | Ndef(\filtered).stop;
76 | Ndef.all.do(_.free); b.free;
77 | ::
78 |
79 |
80 | An example using control- and audio-rate cutoff modulation on a monophonic synth bass:
81 | code::
82 | (
83 | {
84 | var freq = Lag2.ar(Demand.ar(Impulse.ar(LFNoise0.kr(0.5).range(0.1, 1)), 0, Dseq([100, 66.666, 50, 75], inf)), 0.1);
85 | var sig = Saw.ar(freq) * 0.1;
86 | sig = sig + (Saw.ar(freq + 1) * 0.1);
87 | sig = sig + (Pulse.ar(freq / 2) * 0.05);
88 | sig = HouvilainenFilter.ar(sig, Lag2.ar(LFNoise0.ar(3.6).exprange(25, 22000), 0.05) + (SinOsc.ar(150).range(-150, 150) * LFNoise1.kr(0.5).range(0, 1)), LFNoise2.kr(LFNoise1.kr(0.5).exprange(0.1, 10)).range(0.5, 0.93), 3);
89 | sig = Limiter.ar(sig, 0.2);
90 | sig = LeakDC.ar(sig);
91 | sig = sig + AllpassC.ar(sig, 0.2777, [0.17, 0.2777], 10, 0.1);
92 | sig = sig + AllpassC.ar(sig, 1.0, [0.2777 * 2, 0.27777 * 3], 10, 0.2);
93 | }.play
94 | )
95 | ::
96 |
97 |
98 | A polyphonic example where each note has different filter parameters, also including audio-rate cutoff modulation:
99 | code::
100 | ( // first add synthdef
101 | SynthDef(\filterdemo, { |out, res = 0.8, gate = 1, amp = 0.1, filtrange = 10, noiseamt = 0.5, type = 1, subamt = 0.5, ampmod = 0, audiomod = 0|
102 | var pan = \pan.kr(0) + SinOsc.kr(LFNoise1.kr(0.5).exprange(0.1, 1), 0, \panmod.kr(0));
103 | var freq = \freq.kr(440) * LFNoise2.kr(LFNoise1.kr(0.5).exprange(0.3, 0.9)).range(0.99, 1.01);
104 | var sig = Splay.ar(Saw.ar([freq, freq + 1]) + HPF.ar(PinkNoise.ar(noiseamt!2), freq), 0.4, center: pan) + Pan2.ar(Pulse.ar(freq / 2, 0.5, subamt), pan / 3);
105 | var cutoff = Env.adsr(5, 7, 0.5, 5).kr(0, gate).linexp(0, 1, freq, freq * filtrange);
106 | amp = Env.adsr(7, 10, 0.2, 10).kr(1, gate, levelScale: amp) * SinOsc.ar(LFNoise1.kr(0.5).range(3, 6)).range(1, 1 - ampmod);
107 | sig = HouvilainenFilter.ar(sig, cutoff + (SinOsc.ar(LFNoise2.kr(LFNoise1.kr(1).range(0.5, 5)).exprange(0.001, 1000)).range(-100, 100) * audiomod), res, type) * amp;
108 | Out.ar(out, sig);
109 | }).add;
110 | )
111 |
112 | ( // then start pattern
113 | x = {
114 | var sig = In.ar(0, 2) * 0.1;
115 | sig = sig + LPF.ar(AllpassC.ar(sig, 0.2, [0.17, 0.2], 10, 0.2), 8000);
116 | sig = sig + LPF.ar(AllpassC.ar(sig, 1.0, [1.0, 0.7], 10, 0.3), 5000);
117 | ReplaceOut.ar(0, sig);
118 | }.play;
119 |
120 | Pbind(
121 | \instrument, \filterdemo,
122 | \midinote, Prand([38, 50, 57, 62, 64, 66, 68, 69, 72, 74], inf),
123 | \dur, Pwhite(0.5, 8),
124 | \legato, Pwhite(1.0, 5.0),
125 | \res, Pwhite(0, 0.95),
126 | \db, Pkey(\midinote).linlin(38, 66, -6, -12) + Pwhite(-3.0, 3.0),
127 | \filtrange, Pkey(\midinote).linlin(38, 66, 15, 6) + Pwhite(-5, 5),
128 | \noiseamt, Pwhite(0.0, 1.0),
129 | \type, Pwhite(1, 4),
130 | \pan, Pwhite(-1.0, 1.0),
131 | \subamt, Pkey(\midinote).linlin(38, 74, 0.8, 0.2) + Pwhite(-0.2, 0.4),
132 | \ampmod, Pwhite(0.0, 1).linexp(0, 1, 0.001, 1) * Pkey(\midinote).linlin(38, 66, 0.1, 1),
133 | \audiomod, (Pbrown(0.0, 1.0, 0.5) + Pwhite(-0.2, 0.2)).linexp(0, 1, 0.01, 2),
134 | \panmod, Pwhite(0.0, 1.0) * Pkey(\midinote).linexp(38, 74, 0.1, 1)
135 | ).play
136 | )
137 | ::
138 |
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/HouvilainenFilter.cpp:
--------------------------------------------------------------------------------
1 | // PluginHouvilainenFilter.cpp
2 | // Eric Sluyter (wondersluyter@gmail.com)
3 |
4 | #include "SC_PlugIn.hpp"
5 | #include "FilterHandler.h"
6 | #include "HouvilainenFilter.hpp"
7 |
8 | static InterfaceTable *ft;
9 |
10 | namespace HouvilainenFilter {
11 |
12 | HouvilainenFilter::HouvilainenFilter()
13 | {
14 | filterType = in0(3);
15 | filterHandler = new FilterHandler(sampleRate());
16 | filterHandler->setFiltertype(filterType);
17 | filterHandler->reset();
18 |
19 | if (isAudioRateIn(1)) {
20 | set_calc_function();
21 | } else {
22 | set_calc_function();
23 | }
24 | // set_calc_function already calculates sample
25 | //next(1);
26 | }
27 |
28 | HouvilainenFilter::~HouvilainenFilter()
29 | {
30 | delete filterHandler;
31 | }
32 |
33 | void HouvilainenFilter::next_a(int nSamples)
34 | {
35 | const float * input = in(0);
36 | const float * cutoff = in(1);
37 | const float resonance = in0(2);
38 | const float filterTypeIn = in0(3);
39 | float * outbuf = out(0);
40 |
41 | if (filterTypeIn != filterType) {
42 | filterType = filterTypeIn;
43 | filterHandler->setFiltertype(filterType);
44 | }
45 |
46 | for (int i = 0; i < nSamples; ++i) {
47 | outbuf[i] = filterHandler->process(input[i], cutoff[i], resonance);
48 | }
49 | }
50 |
51 | void HouvilainenFilter::next_k(int nSamples)
52 | {
53 | const float * input = in(0);
54 | const float cutoff = in0(1);
55 | const float resonance = in0(2);
56 | const float filterTypeIn = in0(3);
57 | float * outbuf = out(0);
58 |
59 | if (filterTypeIn != filterType) {
60 | filterType = filterTypeIn;
61 | filterHandler->setFiltertype(filterType);
62 | }
63 |
64 | for (int i = 0; i < nSamples; ++i) {
65 | outbuf[i] = filterHandler->process(input[i], cutoff, resonance);
66 | }
67 | }
68 |
69 | } // namespace HouvilainenFilter
70 |
71 | PluginLoad(HouvilainenFilterUGens) {
72 | // Plugin magic
73 | ft = inTable;
74 | registerUnit(ft, "HouvilainenFilter");
75 | }
76 |
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/HouvilainenFilter.hpp:
--------------------------------------------------------------------------------
1 | // PluginHouvilainenFilter.hpp
2 | // Eric Sluyter (wondersluyter@gmail.com)
3 |
4 | #pragma once
5 |
6 | #include "SC_PlugIn.hpp"
7 | #include "FilterHandler.h"
8 |
9 | namespace HouvilainenFilter {
10 |
11 | class HouvilainenFilter : public SCUnit
12 | {
13 | public:
14 | HouvilainenFilter();
15 |
16 | // Destructor
17 | ~HouvilainenFilter();
18 |
19 | private:
20 | // Calc function
21 | void next_a(int nSamples);
22 | void next_k(int nSamples);
23 |
24 | // Member variables
25 | FilterHandler *filterHandler;
26 | float filterType;
27 | };
28 |
29 | } // namespace HouvilainenFilter
30 |
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/HouvilainenFilter.sc:
--------------------------------------------------------------------------------
1 | HouvilainenFilter : Filter {
2 | *ar { |in, freq = 1000, res = 0, filtertype = 1|
3 | freq = freq.expexp(25, 22000, 0.001, 0.588);
4 | ^this.multiNew('audio', in, freq, res, filtertype);
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/Interpolatorlinear.h:
--------------------------------------------------------------------------------
1 | #ifndef __LIN_INTERPOLATOR_H_
2 | #define __LIN_INTERPOLATOR_H_
3 |
4 | /************************************************************************
5 | * Linear interpolator class *
6 | ************************************************************************/
7 |
8 | class InterpolatorLinear
9 | {
10 | public:
11 | InterpolatorLinear() {
12 | reset_hist();
13 | }
14 |
15 | // reset history
16 | void reset_hist() {
17 | d1 = 0.f;
18 | }
19 |
20 | // 2x interpolator
21 | // out: pointer to float[2]
22 | inline void process2x(float const in, float *out) {
23 | out[0] = d1 + 0.5f*(in-d1); // interpolate
24 | out[1] = in;
25 | d1 = in; // store delay
26 | }
27 |
28 | // 4x interpolator
29 | // out: pointer to float[4]
30 | inline void process4x(float const in, float *out) {
31 | float y = in-d1;
32 | out[0] = d1 + 0.25f*y; // interpolate
33 | out[1] = d1 + 0.5f*y;
34 | out[2] = d1 + 0.75f*y;
35 | out[3] = in;
36 | d1 = in; // store delay
37 | }
38 |
39 | // 8x interpolator
40 | // out: pointer to float[8]
41 | inline void process8x(float const in, float *out) {
42 | float y = in-d1;
43 | out[0] = d1 + 0.125f*y; // interpolate
44 | out[1] = d1 + 0.25f*y;
45 | out[2] = d1 + 0.375f*y;
46 | out[3] = d1 + 0.5f*y;
47 | out[4] = d1 + 0.625f*y;
48 | out[5] = d1 + 0.75f*y;
49 | out[6] = d1 + 0.875f*y;
50 | out[7] = in;
51 | d1 = in; // store delay
52 | }
53 |
54 | // 16x interpolator
55 | // out: pointer to float[16]
56 | inline void process16x(float const in, float *out) {
57 | float y = in-d1;
58 | out[0] = d1 + (1.0f/16.0f)*y; // interpolate
59 | out[1] = d1 + (2.0f/16.0f)*y;
60 | out[2] = d1 + (3.0f/16.0f)*y;
61 | out[3] = d1 + (4.0f/16.0f)*y;
62 | out[4] = d1 + (5.0f/16.0f)*y;
63 | out[5] = d1 + (6.0f/16.0f)*y;
64 | out[6] = d1 + (7.0f/16.0f)*y;
65 | out[7] = d1 + (8.0f/16.0f)*y;
66 | out[8] = d1 + (9.0f/16.0f)*y;
67 | out[9] = d1 + (10.0f/16.0f)*y;
68 | out[10] = d1 + (11.0f/16.0f)*y;
69 | out[11] = d1 + (12.0f/16.0f)*y;
70 | out[12] = d1 + (13.0f/16.0f)*y;
71 | out[13] = d1 + (14.0f/16.0f)*y;
72 | out[14] = d1 + (15.0f/16.0f)*y;
73 | out[15] = in;
74 | d1 = in; // store delay
75 | }
76 |
77 | // 32x interpolator
78 | // out: pointer to float[32]
79 | inline void process32x(float const in, float *out) {
80 | float y = in-d1;
81 | out[0] = d1 + (1.0f/32.0f)*y; // interpolate
82 | out[1] = d1 + (2.0f/32.0f)*y;
83 | out[2] = d1 + (3.0f/32.0f)*y;
84 | out[3] = d1 + (4.0f/32.0f)*y;
85 | out[4] = d1 + (5.0f/32.0f)*y;
86 | out[5] = d1 + (6.0f/32.0f)*y;
87 | out[6] = d1 + (7.0f/32.0f)*y;
88 | out[7] = d1 + (8.0f/32.0f)*y;
89 | out[8] = d1 + (9.0f/32.0f)*y;
90 | out[9] = d1 + (10.0f/32.0f)*y;
91 | out[10] = d1 + (11.0f/32.0f)*y;
92 | out[11] = d1 + (12.0f/32.0f)*y;
93 | out[12] = d1 + (13.0f/32.0f)*y;
94 | out[13] = d1 + (14.0f/32.0f)*y;
95 | out[14] = d1 + (15.0f/32.0f)*y;
96 | out[15] = d1 + (16.0f/32.0f)*y;
97 | out[16] = d1 + (17.0f/32.0f)*y;
98 | out[17] = d1 + (18.0f/32.0f)*y;
99 | out[18] = d1 + (19.0f/32.0f)*y;
100 | out[19] = d1 + (20.0f/32.0f)*y;
101 | out[20] = d1 + (21.0f/32.0f)*y;
102 | out[21] = d1 + (22.0f/32.0f)*y;
103 | out[22] = d1 + (23.0f/32.0f)*y;
104 | out[23] = d1 + (24.0f/32.0f)*y;
105 | out[24] = d1 + (25.0f/32.0f)*y;
106 | out[25] = d1 + (26.0f/32.0f)*y;
107 | out[26] = d1 + (27.0f/32.0f)*y;
108 | out[27] = d1 + (28.0f/32.0f)*y;
109 | out[28] = d1 + (29.0f/32.0f)*y;
110 | out[29] = d1 + (30.0f/32.0f)*y;
111 | out[30] = d1 + (31.0f/32.0f)*y;
112 | out[31] = in;
113 | d1 = in; // store delay
114 | }
115 |
116 | private:
117 | float d1; // previous input
118 | };
119 |
120 | #endif
--------------------------------------------------------------------------------
/plugins/HouvilainenFilter/OscNoise.h:
--------------------------------------------------------------------------------
1 | #ifndef OscNoise_H
2 | #define OscNoise_H
3 |
4 | #include "Math.h"
5 |
6 | /*
7 | ==============================================================================
8 | This file is part of Tal-NoiseMaker by Patrick Kunz.
9 |
10 | Copyright(c) 2005-2010 Patrick Kunz, TAL
11 | Togu Audio Line, Inc.
12 | http://kunz.corrupt.ch
13 |
14 | This file may be licensed under the terms of of the
15 | GNU General Public License Version 2 (the ``GPL'').
16 |
17 | Software distributed under the License is distributed
18 | on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
19 | express or implied. See the GPL for the specific language
20 | governing rights and limitations.
21 |
22 | You should have received a copy of the GPL along with this
23 | program. If not, go to http://www.gnu.org/licenses/gpl.html
24 | or write to the Free Software Foundation, Inc.,
25 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 | ==============================================================================
27 | */
28 |
29 | #include
30 |
31 | class OscNoise
32 | {
33 | public:
34 | int randSeed;
35 |
36 | OscNoise(float sampleRate)
37 | {
38 | resetOsc();
39 | }
40 |
41 | void resetOsc()
42 | {
43 | randSeed = 1;
44 | }
45 |
46 | inline float getNextSample()
47 | {
48 | randSeed *= 16807;
49 | //return (float)(randSeed & 0x7FFFFFFF) * 4.6566129e-010f; // 0..1
50 | return (float)randSeed * 4.6566129e-010f;
51 | }
52 |
53 | inline float getNextSamplePositive()
54 | {
55 | randSeed *= 16807;
56 | return (float)(randSeed & 0x7FFFFFFF) * 4.6566129e-010f;
57 | }
58 | };
59 | #endif
--------------------------------------------------------------------------------
/regenerate:
--------------------------------------------------------------------------------
1 | python /Users/roomba/supercollider/tools/cmake_gen/generate_server_plugin_cmake.py -P "HouvilainenFilter" -p "plugins/HouvilainenFilter" -a "Eric Sluyter"
2 |
--------------------------------------------------------------------------------
/testing 2.scd:
--------------------------------------------------------------------------------
1 |
2 | (
3 | x = { |type = 1, portamento = 0.2, audioMod = 0|
4 | var sig, baseFreq;
5 | var freq = \freq.kr(100, portamento);
6 | freq = freq + LFNoise2.kr(LFNoise1.kr(1).exprange(0.2, 2)).range(freq * 0.98, freq * 1.02);
7 | baseFreq = freq;
8 | sig = DC.ar(0);
9 | [1, 2, 3, 5, 8].do { |n|
10 | freq = baseFreq * n;
11 | sig = sig + Splay.ar(Saw.ar({ LFNoise2.kr(0.5).range(freq - 1, freq + 1) } ! 2), 0.2)
12 | + Pulse.ar(freq / 2, 0.5, LFNoise2.kr(0.5).exprange(0.01, 1));
13 | };
14 | HouvilainenFilter.ar(
15 | sig,
16 | MouseX.kr(100, 10000, \exponential)
17 | + (SinOsc.ar(LFNoise2.kr(LFNoise1.kr(1).range(0.5, 5)).exprange(0.001, 5000)).range(-100, 100) * audioMod),
18 | MouseY.kr,
19 | type
20 | );
21 | }.play
22 | )
23 | s.options.outDevice = "Built-in Output"
24 | s.options.inDevice = "Aggregate Device"
25 | s.options.sampleRate = nil
26 | s.reboot
27 | x.set(\type, 3)
28 | x.set(\freq, 25);
29 | x.set(\audioMod, 1)
30 |
31 | SCDoc.indexAllDocuments(true)
32 |
33 |
34 | (
35 | SynthDef(\filterdemo, { |out, res = 0.8, gate = 1, amp = 0.1, filtrange = 10, noiseamt = 0.5, type = 1, subamt = 0.5, ampmod = 0, audiomod = 0|
36 | var pan = \pan.kr(0) + SinOsc.kr(LFNoise1.kr(0.5).exprange(0.1, 1), 0, \panmod.kr(0));
37 | var freq = \freq.kr(440) * LFNoise2.kr(LFNoise1.kr(0.5).exprange(0.3, 0.9)).range(0.99, 1.01);
38 | var sig = Splay.ar(Saw.ar([freq, freq + 1]) + HPF.ar(PinkNoise.ar(noiseamt!2), freq), 0.4, center: pan) + Pan2.ar(Pulse.ar(freq / 2, 0.5, subamt), pan / 3);
39 | var cutoff = Env.adsr(5, 7, 0.5, 5).kr(0, gate).linexp(0, 1, freq, freq * filtrange);
40 | amp = Env.adsr(7, 10, 0.2, 10).kr(1, gate, levelScale: amp) * SinOsc.ar(LFNoise1.kr(0.5).range(3, 6)).range(1, 1 - ampmod);
41 | sig = HouvilainenFilter.ar(sig, cutoff + (SinOsc.ar(LFNoise2.kr(LFNoise1.kr(1).range(0.5, 5)).exprange(0.001, 1000)).range(-100, 100) * audiomod), res, type) * amp;
42 | Out.ar(out, sig);
43 | }).add;
44 | )
45 |
46 | (
47 | x = {
48 | var sig = In.ar(0, 2);
49 | sig = sig + LPF.ar(AllpassC.ar(sig, 0.2, [0.17, 0.2], 10, 0.2), 8000);
50 | sig = sig + LPF.ar(AllpassC.ar(sig, 1.0, [1.0, 0.7], 10, 0.3), 5000);
51 | ReplaceOut.ar(0, sig);
52 | }.play;
53 |
54 | Pbind(
55 | \instrument, \filterdemo,
56 | \midinote, Prand([38, 50, 57, 62, 64, 66, 68, 69, 72, 74], inf),
57 | \dur, Pwhite(0.5, 8),
58 | \legato, Pwhite(1.0, 5.0),
59 | \res, Pwhite(0, 0.95),
60 | \db, Pkey(\midinote).linlin(38, 66, -6, -12) + Pwhite(-3.0, 3.0),
61 | \filtrange, Pkey(\midinote).linlin(38, 66, 15, 6) + Pwhite(-5, 5),
62 | \noiseamt, Pwhite(0.0, 1.0),
63 | \type, Pwhite(1, 4),
64 | \pan, Pwhite(-1.0, 1.0),
65 | \subamt, Pkey(\midinote).linlin(38, 74, 0.8, 0.2) + Pwhite(-0.2, 0.4),
66 | \ampmod, Pwhite(0.0, 1).linexp(0, 1, 0.001, 1) * Pkey(\midinote).linlin(38, 66, 0.1, 1),
67 | \audiomod, (Pbrown(0.0, 1.0, 0.5) + Pwhite(-0.2, 0.2)).linexp(0, 1, 0.01, 2).trace,
68 | \panmod, Pwhite(0.0, 1.0) * Pkey(\midinote).linexp(38, 74, 0.1, 1)
69 | ).play
70 | )
--------------------------------------------------------------------------------
/testing.scd:
--------------------------------------------------------------------------------
1 | (
2 | {
3 | var freq = Lag2.ar(Demand.ar(Impulse.ar(LFNoise0.kr(0.5).range(0.1, 1)), 0, Dseq([100, 66.666, 50, 75], inf)), 0.1);
4 | var sig = Saw.ar(freq) * 0.1;
5 | sig = sig + (Saw.ar(freq + 1) * 0.1);
6 | sig = sig + (Pulse.ar(freq / 2) * 0.05);
7 | //sig = PinkNoise.ar(0.6);
8 | sig = HouvilainenFilter.ar(sig, Lag2.ar(LFNoise0.ar(3.6).exprange(25, 22000), 0.05) + (SinOsc.ar(150).range(-150, 150) * LFNoise1.kr(0.5).range(0, 1)), LFNoise2.kr(LFNoise1.kr(0.5).exprange(0.1, 10)).range(0.5, 0.93), 3);
9 | sig = Limiter.ar(sig, 0.2);
10 | sig = LeakDC.ar(sig);
11 | sig = sig + AllpassC.ar(sig, 0.2777, [0.17, 0.2777], 10, 0.1);
12 | sig = sig + AllpassC.ar(sig, 1.0, [0.2777 * 2, 0.27777 * 3], 10, 0.2);
13 | //sig = sig + SinOsc.ar(MouseX.kr(25, 22000, \exponential), 0, 0.1);
14 | }.play
15 | )
16 | s.reboot
17 |
18 | s.sampleRate
19 |
20 | 2843465.5661095 * (-2) * pi * 1801
21 | 1.873 * (114.84375.pow(3)) + (0.4955 * (114.84375.squared)) - (0.649 * 114.84375) + 1.4
22 | 1000 * (44100 / 192000) * 0.5
23 | 48000 * 4
24 |
25 | {SampleRate.ir.poll}.play
26 |
27 |
28 | (
29 | ~oscs = { |freq, slop, pw = 0.5|
30 | var rate = freq + LFNoise1.ar(LFNoise1.kr(1).range(0.2, 0.3), mul: slop * (freq / 1000));
31 | var phase = Phasor.ar(0, rate, 0, SampleRate.ir) * 2pi / SampleRate.ir;
32 | var duty = (pw - 0.5).sign * (pw - 0.5).abs.lincurve(0, 0.5, 0, 0.5, 5);
33 | var dutyPhase = phase.lincurve(0, 2pi, 0, 2pi, duty.linlin(-0.5, 0.5, -85, 85));
34 | var k = 12000 * (SampleRate.ir/44100) / (freq * log10(freq));
35 | var sinSig = SinOsc.ar(0, phase);
36 | var dutySinSig = SinOsc.ar(0, dutyPhase);
37 | var cosSig = SinOsc.ar(0, phase + (pi/2));
38 | var sqSig = tanh(sinSig * k);
39 | var dutySqSig = tanh(dutySinSig * k);
40 | var sawSig = dutySqSig * (cosSig + 1) * 0.5;
41 | var sawPw = (pw - 0.5).abs.lincurve(0, 0.5, 0, 0.5, 2);
42 | var triSig = VarSaw.ar(rate, 0, sawPw);
43 | var dutySawSig = LinSelectX.ar(sawPw.lincurve(0, 0.5, 0, 1, -7), [sawSig + Saw.ar(rate), triSig * 1.5]);
44 | [dutySawSig, dutySqSig * 1.5, dutySinSig + VarSaw.ar(rate, 0.25, 0.5)];
45 | };
46 |
47 | x = { |freq = 100, slop = 0.01, portamento = 0.2|
48 | var sigs, sig;
49 | freq = Lag2.kr(freq, portamento);
50 | freq = freq * LFNoise2.kr(0.5).range(0.995, 1.005);
51 | freq = freq * VarSaw.kr(LFNoise2.kr(0.5).range(4, 7)).range(0.995, 1.005);
52 | sigs = ~oscs.(freq, slop);
53 | sig = sigs[0] * 0.05;
54 | sigs = ~oscs.(freq / 2, slop, 0.5);
55 | sig = sig + (sigs[2] * 0.05);
56 | sigs = ~oscs.(freq + 1, slop);
57 | sig = sig + (sigs[0] * 0.02);
58 | //var sig = Saw.ar(100) * 0.1;
59 | //sig = sig + (Saw.ar(101) * 0.1);
60 | //sig = sig + (Pulse.ar(50) * 0.05);
61 | //sig = PinkNoise.ar(0.6);
62 | sig = HouvilainenFilter.ar(sig, K2A.ar(MouseX.kr(25, 22000, \exponential)) + Saw.ar(freq).range(-1 * freq, freq), K2A.ar(MouseY.kr(0, 1).lincurve(0, 1, 0, 1, -2).poll), 1);
63 | sig = LeakDC.ar(sig);
64 | sig = sig + AllpassC.ar(sig, 0.2, [0.17, 0.2], 10, 0.1);
65 | sig = sig + AllpassC.ar(sig, 1.0, [1.0, 0.7], 10, 0.2);
66 | //sig = sig + SinOsc.ar(MouseX.kr(25, 22000, \exponential), 0, 0.1);
67 | }.play
68 | )
69 |
70 | (
71 | MIDIClient.init;
72 | MIDIIn.connectAll;
73 |
74 | k = MIDIIn.findPort("microKEY2", "KEYBOARD");
75 | MIDIdef.noteOn(\korgOn, { |vel, num|
76 | x.set(\freq, num.midicps);
77 | }, srcID: k.uid);
78 | MIDIdef.noteOff(\korgOff, { |vel, num|
79 | }, srcID: k.uid);
80 | MIDIdef.cc(\korgCC, { |val, num|
81 | if (num == 1) {
82 | x.set(\portamento, val.linexp(0, 127, 0.01, 5));
83 | };
84 | }, srcID: k.uid);
85 | MIDIdef.bend(\korgBend, { |val|
86 | }, srcID: k.uid);
87 | )
88 |
--------------------------------------------------------------------------------