├── .gitignore
├── .gitmodules
├── CHANGELOG.md
├── LICENSE
├── Makefile
├── README.md
├── designs
├── Logistiker.gvdesign
├── Nosering.gvdesign
└── Radio.gvdesign
├── modular80.png
├── plugin.json
├── res
├── Logistiker.svg
├── Nosering.svg
└── Radio.svg
└── src
├── Logistiker.cpp
├── Nosering.cpp
├── RadioMusic.cpp
├── modular80.cpp
└── modular80.hpp
/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | plugin.dll
3 | plugin.so
4 | plugin.dylib
5 | dist/
6 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "src/dep/dr_libs"]
2 | path = src/dep/dr_libs
3 | url = https://github.com/mackron/dr_libs.git
4 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ### 2.0.1 (2022-01-07)
2 | - Fix playback behavior in Radio Music to keep playing when station is changed (match hardware).
3 |
4 | ### 2.0.0 (2021-10-18)
5 |
6 | - Update to Rack v2
7 | - Add root directory location to context menu
8 | - Add Pitch Mode (available via context menu)
9 | - Add Stereo Mode option to allow stereo output (polyphonic cable) - default to Mono mode to preserve compatibility
10 | - Add option to clear current bank and stop playback to context menu
11 | - Change bank size limit from file size to memory limit (2GB in RAM per bank)
12 | - Allow current pool of audio files in root directory to continue to play while new pool of audio files is loaded (by loading and background and swapping)
13 | - Set different default values and labels for Start knob in Pitch mode
14 | - Allow saving of current **bank** of audio files to be saved to Patch Storage.
15 |
16 | ### 1.0.3 (2021-05-13)
17 |
18 | - Fix crash when loading RAW files
19 |
20 | ### 1.0.2 (2020-11-29)
21 |
22 | - Fix WAV file playback
23 |
24 | ### 1.0.1 (2020-03-02)
25 |
26 | - Relicense source code to GPLv3
27 | - Update module description for Radio Music
28 | - Add Hardware Clone tag
29 |
30 | ### 1.0.0 (2019-06-03)
31 |
32 | - Initial release for Rack v1
33 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # If RACK_DIR is not defined when calling the Makefile, default to two directories above
2 | RACK_DIR ?= ../..
3 |
4 | # FLAGS will be passed to both the C and C++ compiler
5 | FLAGS +=
6 | CFLAGS +=
7 | CXXFLAGS +=
8 |
9 | # Careful about linking to shared libraries, since you can't assume much about the user's environment and library search path.
10 | # Static libraries are fine, but they should be added to this plugin's build system.
11 | LDFLAGS +=
12 |
13 | # Add .cpp files to the build
14 | SOURCES += $(wildcard src/*.cpp)
15 |
16 | # Add files to the ZIP package when running `make dist`
17 | # The compiled plugin and "plugin.json" are automatically added.
18 | DISTRIBUTABLES += res
19 | DISTRIBUTABLES += $(wildcard LICENSE*)
20 | DISTRIBUTABLES += $(wildcard CHANGELOG*)
21 |
22 | # Include the VCV Rack plugin Makefile framework
23 | include $(RACK_DIR)/plugin.mk
24 |
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # A collection of modules for VCV Rack
2 |
3 | This repository contains a collection of modules for [VCV Rack](https://vcvrack.com/),
4 | the open-source virtual modular synthesizer.
5 |
6 | The minimum supported VCV Rack version is **2.0.0**.
7 |
8 | # Overview of modules
9 |
10 | 
11 |
12 | ## Logistiker
13 |
14 | The `Logistiker` module is based on the [Logistic Map](https://en.wikipedia.org/wiki/Logistic_map),
15 | a non-linear dynamic equation, which for certain input parameters exhibits [chaotic behavior](https://en.wikipedia.org/wiki/Chaos_theory).
16 |
17 | The **RATE** knob controls the update rate of the internal clock. It has no function, if an
18 | external clock signal is connected to the **EXT CLOCK** input.
19 |
20 | The **R** knob, and the corresponding input, controls the **R** variable of the equation.
21 | The [Wikipedia page](https://en.wikipedia.org/wiki/Logistic_map) has a good overview of the effect
22 | of different **R** values. The default value corresponds to the onset of *Chaos* in the system.
23 |
24 | The **X0** knob sets the initial starting value for the **X** variable of the equation.
25 |
26 | If the **RESET** button is pressed, or a positive edge arrives at the **RESET** input,
27 | the model starts over from the value set by the **X0** knob. The reset takes effect at the
28 | next rising edge of the (internal or external) clock signal.
29 |
30 | [YouTube Module Demo](https://youtu.be/xGSvLBChjzk)
31 |
32 | ## Nosering
33 |
34 | The `Nosering` module is inspired by Grant Richter's [Noisering](https://malekkoheavyindustry.com/product/richter-noisering/) module. It does not implement all of
35 | the Noisering functionality, but enough to be useful and fun.
36 |
37 | See [this page](https://www.infinitesimal.eu/modules/index.php?title=Malekko_Noisering) for more
38 | information on theory of operation of the original *Noisering* module.
39 |
40 | The **RATE** knob controls the update rate of the internal clock. It has no function, if an
41 | external clock signal is connected to the **EXT CLOCK** input.
42 |
43 | The **CHANGE** knob controls the probability that **new data** is introduced into the system.
44 | All the way CCW means only new data is feed into the shift register. All the way CW means only
45 | old data is recycled in the shift register, i.e. the shift register content is looping.
46 | The corresponding input provides CV contol of the **CHANGE** parameter.
47 |
48 | The **CHANCE** knob controls the probability of introducing either a **0** (all the way CCW) or
49 | a **1** (all the way CW) into the system. The corresponding input provides CV control of the **CHANCE** parameter.
50 |
51 | The **INV OLD** switch will cause the last bit pushed out of the shift register to be **inverted**
52 | before feeding it back into the shift register input. The corresponding input provides CV control over
53 | the **INV OLD** parameter.
54 |
55 | The **EXT CHANCE** input switches the internal signal used with the Chance and Change comparators
56 | from internally generated White Noise to the external signal connected to the **EXT CHANCE** input.
57 |
58 | The **NOISE OUT** output carries the internal White Noise signal of the module.
59 |
60 | The **n+1** output produces **n+1** or 9 levels, the **2^n** output produces **2^n** or 256 levels.
61 | This is comparable the functionality of the [Buchla 266 Source Of Uncertainty](https://modularsynthesis.com/roman/buchla_266/266sou.htm).
62 |
63 | ## Radio Music
64 |
65 | The `Radio Music` module is an **official port** of the hardware module by [Music Thing Modular](http://musicthing.co.uk/).
66 |
67 | Tom Whitwell of `Music Thing Modular` has blessed this port and graciously provided the panel artwork.
68 |
69 | Be sure to support Tom and `Music Thing Modular` by buying their excellent kits and/or modules!
70 |
71 | The Rack version of the module does not use any of the hardware module's firmware code, but instead implements the module's
72 | fundamental functionality in the context of Rack.
73 |
74 | Not all advanced options and modes of the original module are currently implemented, but may be added in future versions.
75 |
76 | For more information on the module see the [official documentation](https://github.com/TomWhitwell/RadioMusic/wiki/How-to-use-the-Radio-Music-module).
77 |
78 | A collection of sample packs to load can be found on Tom Whitwell's [GitHub page](https://github.com/TomWhitwell/RadioMusic/wiki/Audio-packs-for-the-Radio-Music-module).
79 |
80 | [YouTube Module Demo](https://youtu.be/cdk8DFG7_-U)
81 |
82 | ### Rack module features
83 |
84 | - Playback of `.raw` (44.1 kHz, 16 bit, headerless PCM) and `.wav` files (all formats)
85 | - Supports up to 16 banks (subfolders) with a maximum bank size of 2GB per bank (size in memory!)
86 | - Pitch Mode (available via the context menu)
87 |
88 | ### Notable differences to hardware version
89 |
90 | - `Root folder` is selected via the context menu (instead of the settings file).
91 | - `Bank Selection Mode` is accessed via the context menu (instead of pressing and holding the reset button).
92 | - `Clear Current Bank` option via context menu to clear the currently playing bank and stop playback.
93 | - Visual indicator (flashing LEDs) to indicate files are being loaded (all LEDs blink slow) and an error occurred during file loading (all LEDs blink fast).
94 | - All implemented options are available via the context menu (instead of a settings file).
95 | - `Stereo Mode` is accessed via context menu and enables stereo output for stereo files (dual mono for mono files) via a polyphonic cable.
96 | - Allow saving of current bank to Rack Patch Storage.
97 |
98 | # Build instructions
99 |
100 | Set up build environment by either compiling from within the `plugin` directory or using the `RACK_DIR` environment variable.
101 |
102 | ```
103 | git submodule update --init --recursive
104 | make
105 | ```
106 |
107 | # Licenses
108 |
109 | All source code in this repository is copyright © 2021 Christoph Scholtes and is licensed under the [GNU General Public License v3.0](LICENSE).
110 | All **graphics** for `Logistiker` and `Nosering` in the `res` directory are copyright © 2021 Christoph Scholtes and licensed under [CC BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
111 |
112 | All `Radio Music` hardware and software design in the original project is Creative Commons licensed by Tom Whitwell:
113 | [CC-BY-SA: Attribution / ShareAlike](https://creativecommons.org/licenses/by-sa/3.0/).
114 |
115 | [`dr_wav`](https://mackron.github.io/dr_wav) source code is placed into public domain by the author.
116 |
--------------------------------------------------------------------------------
/designs/Logistiker.gvdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cschol/modular80/6020017f6df74d61bb0ccfa7c814257dccf4d853/designs/Logistiker.gvdesign
--------------------------------------------------------------------------------
/designs/Nosering.gvdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cschol/modular80/6020017f6df74d61bb0ccfa7c814257dccf4d853/designs/Nosering.gvdesign
--------------------------------------------------------------------------------
/designs/Radio.gvdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cschol/modular80/6020017f6df74d61bb0ccfa7c814257dccf4d853/designs/Radio.gvdesign
--------------------------------------------------------------------------------
/modular80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cschol/modular80/6020017f6df74d61bb0ccfa7c814257dccf4d853/modular80.png
--------------------------------------------------------------------------------
/plugin.json:
--------------------------------------------------------------------------------
1 | {
2 | "slug": "modular80",
3 | "name": "modular80",
4 | "author": "cschol",
5 | "license": "GPL-3.0-or-later",
6 | "authorEmail": "modular80@gmail.com",
7 | "authorUrl": "",
8 | "brand": "modular80",
9 | "pluginUrl": "https://github.com/cschol/modular80/blob/master/README.md",
10 | "manualUrl": "https://github.com/cschol/modular80/blob/master/README.md",
11 | "sourceUrl": "https://github.com/cschol/modular80.git",
12 | "changelogUrl": "https://github.com/cschol/modular80/blob/v1/CHANGELOG.md",
13 | "donateUrl": "",
14 | "version": "2.0.1",
15 | "modules": [
16 | {
17 | "slug": "Logistiker",
18 | "name": "Logistiker",
19 | "description": "Chaotic CV generator based on Logistics equation",
20 | "manualUrl": "https://github.com/cschol/modular80/blob/v2/README.md#logistiker",
21 | "tags": [
22 | "Random",
23 | "Sample and hold"
24 | ]
25 | },
26 | {
27 | "slug": "RadioMusic",
28 | "name": "Radio Music",
29 | "description": "The Music Thing Modular Radio Music is a sampler pretending to be a radio",
30 | "manualUrl": "https://github.com/cschol/modular80/blob/v2/README.md#radio-music",
31 | "modularGridUrl": "https://www.modulargrid.net/e/music-thing-modular-radio-music",
32 | "tags": [
33 | "Sampler",
34 | "Hardware clone"
35 | ]
36 | },
37 | {
38 | "slug": "Nosering",
39 | "name": "Nosering",
40 | "description": "Interpretation of Grant Richter's Noisering design",
41 | "manualUrl": "https://github.com/cschol/modular80/blob/v2/README.md#nosering",
42 | "tags": [
43 | "Noise",
44 | "Random",
45 | "Sample and hold"
46 | ]
47 | }
48 | ]
49 | }
50 |
--------------------------------------------------------------------------------
/res/Logistiker.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/res/Nosering.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/Logistiker.cpp:
--------------------------------------------------------------------------------
1 | #include "modular80.hpp"
2 |
3 | struct Logistiker : Module {
4 | enum ParamIds {
5 | RATE_PARAM,
6 | R_PARAM,
7 | X_PARAM,
8 | RESET_PARAM,
9 | NUM_PARAMS
10 | };
11 | enum InputIds {
12 | CLK_INPUT,
13 | RST_INPUT,
14 | R_INPUT,
15 | NUM_INPUTS
16 | };
17 | enum OutputIds {
18 | X_OUTPUT,
19 | NUM_OUTPUTS
20 | };
21 | enum LightIds {
22 | NUM_LIGHTS
23 | };
24 |
25 | Logistiker() : x(0.0f),
26 | phase(0.0f)
27 | {
28 | config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
29 |
30 | configParam(RATE_PARAM, -2.0f, 6.0f, 2.0f, "Rate", " Hz"); // 0.25..64 Hz
31 | configParam(R_PARAM, 0.0f, 8.0f, 3.56995f, "R"); // default value = onset of chaos
32 | configParam(X_PARAM, 0.0f, 0.5f, 0.0f, "X");
33 | configButton(RESET_PARAM, "Reset");
34 |
35 | configInput(CLK_INPUT, "Clock");
36 | configInput(RST_INPUT, "Reset");
37 | configInput(R_INPUT, "R");
38 |
39 | configOutput(X_OUTPUT, "X");
40 | }
41 |
42 | void process(const ProcessArgs &args) override;
43 | void onReset() override;
44 |
45 | private:
46 | float logistic(const float x, const float r);
47 |
48 | dsp::SchmittTrigger rstButtonTrigger;
49 | dsp::SchmittTrigger rstInputTrigger;
50 | dsp::SchmittTrigger clkTrigger;
51 |
52 | float x;
53 | float phase;
54 | };
55 |
56 | void Logistiker::onReset() {
57 | x = 0.0f;
58 | phase = 0.0f;
59 | }
60 |
61 | float Logistiker::logistic(const float x, const float r) {
62 | return(r * x * (1.0f - x));
63 | }
64 |
65 | void Logistiker::process(const ProcessArgs &args) {
66 | if (!outputs[X_OUTPUT].isConnected()) {
67 | return;
68 | }
69 |
70 | static bool doReset(false);
71 |
72 | if (rstButtonTrigger.process(params[RESET_PARAM].getValue()) ||
73 | (inputs[RST_INPUT].isConnected() && rstInputTrigger.process(inputs[RST_INPUT].getVoltage())))
74 | {
75 | doReset = true;
76 | }
77 |
78 | bool doStep(false);
79 |
80 | // External clock
81 | if (inputs[CLK_INPUT].isConnected()) {
82 | if (clkTrigger.process(inputs[CLK_INPUT].getVoltage())) {
83 | phase = 0.0f;
84 | doStep = true;
85 | }
86 | }
87 | else {
88 | // Internal clock
89 | phase += pow(2.0f, params[RATE_PARAM].getValue()) * args.sampleTime;
90 | if (phase >= 1.0f) {
91 | phase = 0.0f;
92 | doStep = true;
93 | }
94 | }
95 |
96 | if (doStep) {
97 |
98 | // Synchronize resetting x with steps.
99 | if (doReset) {
100 | x = params[X_PARAM].getValue();
101 | doReset = false;
102 | }
103 |
104 | const float r = clamp(params[R_PARAM].getValue() + inputs[R_INPUT].getVoltage(), 0.0f, 8.0f);
105 |
106 | // Don't let population die!
107 | x = clamp(logistic(x, r), 0.00001f, 1.0f);
108 | }
109 |
110 | outputs[X_OUTPUT].setVoltage(clamp(x * 10.0f, -10.0f, 10.0f));
111 | }
112 |
113 | struct LogistikerWidget : ModuleWidget {
114 | LogistikerWidget(Logistiker *module);
115 | };
116 |
117 | LogistikerWidget::LogistikerWidget(Logistiker *module) {
118 | setModule(module);
119 | setPanel(createPanel(asset::plugin(pluginInstance, "res/Logistiker.svg")));
120 |
121 | addChild(createWidget(Vec(RACK_GRID_WIDTH, 0)));
122 | addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
123 |
124 | addParam(createParam(Vec(18, 62), module, Logistiker::RATE_PARAM));
125 | addParam(createParam(Vec(49, 140), module, Logistiker::R_PARAM));
126 | addParam(createParam(Vec(49, 206), module, Logistiker::X_PARAM));
127 |
128 | addInput(createInput(Vec(11, 146), module, Logistiker::R_INPUT));
129 |
130 | addParam(createParam(Vec(15, 217), module, Logistiker::RESET_PARAM));
131 |
132 | addInput(createInput(Vec(54, 276), module, Logistiker::CLK_INPUT));
133 | addInput(createInput(Vec(11, 276), module, Logistiker::RST_INPUT));
134 |
135 | addOutput(createOutput(Vec(33, 319), module, Logistiker::X_OUTPUT));
136 |
137 | addChild(createWidget(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
138 | addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
139 | }
140 |
141 | Model *modelLogistiker = createModel("Logistiker");
142 |
--------------------------------------------------------------------------------
/src/Nosering.cpp:
--------------------------------------------------------------------------------
1 | #include "modular80.hpp"
2 |
3 | //#define DEBUG_MODE
4 |
5 | #define SR_SIZE 8
6 | #define MAX_FREQ 10000.0f
7 |
8 | // Resistor ladder values for Digital-to-Analog conversion
9 | const float DAC_MULT1[SR_SIZE] = {1.28f, 1.28f, 1.28f, 1.28f, 1.28f, 1.28f, 1.28f, 1.28f};
10 | const float DAC_MULT2[SR_SIZE] = {5.0f, 2.5f, 1.25f, 0.625f, 0.3125f, 0.1525f, 0.078125f, 0.0390625f};
11 |
12 | struct Nosering : Module {
13 | enum ParamIds {
14 | CHANGE_PARAM,
15 | CHANCE_PARAM,
16 | INT_RATE_PARAM,
17 | INVERT_OLD_DATA_PARAM,
18 | NUM_PARAMS
19 | };
20 | enum InputIds {
21 | CHANGE_INPUT,
22 | CHANCE_INPUT,
23 | EXT_RATE_INPUT,
24 | EXT_CHANCE_INPUT,
25 | INV_OUT_INPUT,
26 | NUM_INPUTS
27 | };
28 | enum OutputIds {
29 | N_PLUS_1_OUTPUT,
30 | TWO_POW_N_OUTPUT,
31 | NOISE_OUTPUT,
32 | NUM_OUTPUTS
33 | };
34 | enum LightIds {
35 | NUM_LIGHTS
36 | };
37 |
38 | Nosering()
39 | {
40 | config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
41 |
42 | configParam(INT_RATE_PARAM, 0.0f, 14.0f, 0.0f, "Clock Rate", " Hz");
43 | configParam(CHANGE_PARAM, -10.0f, 10.0f, -10.0f, "Change");
44 | configParam(CHANCE_PARAM, -10.0f, 10.0f, -10.0f, "Chance");
45 | configSwitch(INVERT_OLD_DATA_PARAM, 0.0f, 1.0f, 0.0f, "Invert Old Data", {"Normal", "Inverted"});
46 |
47 | configInput(CHANGE_INPUT, "Change");
48 | configInput(CHANCE_INPUT, "Chance");
49 | configInput(EXT_RATE_INPUT, "External Clock Rate");
50 | configInput(EXT_CHANCE_INPUT, "External Chance");
51 | configInput(INV_OUT_INPUT, "Invert Old Data");
52 |
53 | configOutput(N_PLUS_1_OUTPUT, "n+1");
54 | configOutput(TWO_POW_N_OUTPUT, "2^n");
55 | configOutput(NOISE_OUTPUT, "Noise");
56 | }
57 |
58 | void process(const ProcessArgs &args) override;
59 | void onReset() override;
60 |
61 | private:
62 |
63 | float phase;
64 |
65 | dsp::SchmittTrigger clkTrigger;
66 |
67 | unsigned int shiftRegister[SR_SIZE] = {0,0,0,0,0,0,0,0};
68 | };
69 |
70 | void Nosering::onReset() {
71 | phase = 0.0f;
72 |
73 | for (unsigned int &val : shiftRegister) {
74 | val = 0;
75 | }
76 | }
77 |
78 | void Nosering::process(const ProcessArgs &args) {
79 |
80 | bool doStep(false);
81 |
82 | // Inputs
83 | const float change = clamp((params[CHANGE_PARAM].getValue() + inputs[CHANGE_INPUT].getVoltage()), -10.0f, 10.0f);
84 | const float chance = clamp((params[CHANCE_PARAM].getValue() + inputs[CHANCE_INPUT].getVoltage()), -10.0f, 10.0f);
85 |
86 | // Generate White noise sample
87 | const float noiseSample = clamp((random::uniform() * 20.0f - 10.0f), -10.0f, 10.0f);
88 |
89 | // Either use Chance input to sample data for Chance comparator or White Noise.
90 | float sample(0.0f);
91 | if (inputs[EXT_CHANCE_INPUT].isConnected()) {
92 | sample = inputs[EXT_CHANCE_INPUT].getVoltage();
93 | } else {
94 | sample = noiseSample;
95 | }
96 |
97 | // External clock
98 | if (inputs[EXT_RATE_INPUT].isConnected()) {
99 | if (clkTrigger.process(inputs[EXT_RATE_INPUT].getVoltage())) {
100 | phase = 0.0f;
101 | doStep = true;
102 | }
103 | }
104 | else { // Internal clock
105 | float freq = powf(2.0f, params[INT_RATE_PARAM].getValue());
106 |
107 | // Limit internal rate.
108 | if (freq > MAX_FREQ) {
109 | freq = MAX_FREQ;
110 | }
111 |
112 | phase += freq * args.sampleTime;
113 | if (phase >= 1.0f) {
114 | phase = 0.0f;
115 | doStep = true;
116 | }
117 | }
118 |
119 | if (doStep) {
120 | bool selectNewData = (noiseSample > change); // Always compare against White Noise
121 |
122 | unsigned int newData = (sample > chance) ? 0 : 1;
123 | unsigned int oldData = shiftRegister[SR_SIZE - 1];
124 |
125 | const bool invertOldData = (params[INVERT_OLD_DATA_PARAM].getValue() != 0.0f) ||
126 | (inputs[INV_OUT_INPUT].getVoltage() != 0.0f);
127 | if (invertOldData) {
128 | oldData = (oldData == 1) ? 0 : 1;
129 | }
130 |
131 | unsigned int sum(0);
132 |
133 | // Advance shift register
134 | for (size_t i = SR_SIZE-1; i > 0; i--) {
135 | sum += shiftRegister[i];
136 | shiftRegister[i] = shiftRegister[i - 1];
137 | }
138 |
139 | sum += shiftRegister[0];
140 |
141 | // Only do stale data detection if we are not inverting old data.invertOldData
142 | // If we are, the shift register should never be stale.
143 | if (!invertOldData) {
144 | // Stale data detection (either all 0s or all 1s in the shift register).
145 | if (sum == 0) {
146 | selectNewData = true;
147 | newData = 1;
148 | } else if (sum == 8) {
149 | selectNewData = true;
150 | newData = 0;
151 | }
152 | }
153 |
154 | // Move data into shift register
155 | shiftRegister[0] = (selectNewData) ? newData : oldData;
156 |
157 | #ifdef DEBUG_MODE
158 | for (size_t i = 0; i < SR_SIZE; ++i) {
159 | debug("%d %d", i, shiftRegister[i]);
160 | }
161 | #endif
162 | }
163 |
164 | // DAC
165 | float TwoPowNOutput(0.0f);
166 | float nPlus1Output(0.0f);
167 | for (size_t i = 0; i < SR_SIZE; ++i) {
168 | nPlus1Output += (static_cast(shiftRegister[i]) * DAC_MULT1[i]);
169 | TwoPowNOutput += (static_cast(shiftRegister[i]) * DAC_MULT2[i]);
170 | }
171 |
172 | // Outputs
173 | outputs[N_PLUS_1_OUTPUT].setVoltage(clamp(nPlus1Output, 0.0f, 10.0f));
174 | outputs[TWO_POW_N_OUTPUT].setVoltage(clamp(TwoPowNOutput, 0.0f, 10.0f));
175 | outputs[NOISE_OUTPUT].setVoltage(noiseSample);
176 | }
177 |
178 | struct NoseringWidget : ModuleWidget {
179 | NoseringWidget(Nosering *module);
180 | };
181 |
182 | NoseringWidget::NoseringWidget(Nosering *module) {
183 | setModule(module);
184 | setPanel(createPanel(asset::plugin(pluginInstance, "res/Nosering.svg")));
185 |
186 | addChild(createWidget(Vec(RACK_GRID_WIDTH, 0)));
187 | addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
188 |
189 | addParam(createParam(Vec(49, 52), module, Nosering::INT_RATE_PARAM));
190 | addParam(createParam(Vec(49, 109), module, Nosering::CHANGE_PARAM));
191 | addParam(createParam(Vec(49, 166), module, Nosering::CHANCE_PARAM));
192 | addParam(createParam(Vec(60, 224), module, Nosering::INVERT_OLD_DATA_PARAM));
193 |
194 | addInput(createInput(Vec(11, 58), module, Nosering::EXT_RATE_INPUT));
195 | addInput(createInput(Vec(11, 115), module, Nosering::CHANGE_INPUT));
196 | addInput(createInput(Vec(11, 172), module, Nosering::CHANCE_INPUT));
197 | addInput(createInput(Vec(11, 221), module, Nosering::INV_OUT_INPUT));
198 | addInput(createInput(Vec(11, 275), module, Nosering::EXT_CHANCE_INPUT));
199 |
200 | addOutput(createOutput(Vec(56, 275), module, Nosering::NOISE_OUTPUT));
201 | addOutput(createOutput(Vec(11, 319), module, Nosering::N_PLUS_1_OUTPUT));
202 | addOutput(createOutput(Vec(56, 319), module, Nosering::TWO_POW_N_OUTPUT));
203 |
204 | addChild(createWidget(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
205 | addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
206 | }
207 |
208 | Model *modelNosering = createModel("Nosering");
209 |
--------------------------------------------------------------------------------
/src/RadioMusic.cpp:
--------------------------------------------------------------------------------
1 | #include "modular80.hpp"
2 |
3 | #include
4 | #include
5 |
6 | #include "osdialog.h"
7 |
8 | #define DR_WAV_IMPLEMENTATION
9 | #include "dep/dr_libs/dr_wav.h"
10 |
11 | #define MAX_BANK_SIZE 2147483648l // 2GB max per bank (in memory!)
12 | #define MAX_NUM_BANKS 16
13 | #define MAX_DIR_DEPTH 1
14 |
15 | #define PITCH_MODE_DEFAULT 0.5f
16 | #define NORMAL_MODE_DEFAULT 0.0f
17 |
18 |
19 | class FileScanner {
20 |
21 | public:
22 |
23 | FileScanner() :
24 | scanDepth(0)
25 | {}
26 | ~FileScanner() {};
27 |
28 | void reset() {
29 | scanDepth = 0;
30 | banks.clear();
31 | }
32 |
33 | static bool isSupportedAudioFormat(std::string& path) {
34 | const std::string tmpF = string::lowercase(path);
35 | return (string::endsWith(tmpF, ".wav") ||
36 | string::endsWith(tmpF, ".raw"));
37 | }
38 |
39 | void scan(std::string& root, const bool sort = false, const bool filter = true) {
40 |
41 | std::vector files;
42 | std::vector entries;
43 |
44 | entries = system::getEntries(root);
45 |
46 | if (sort) {
47 | std::sort(entries.begin(), entries.end());
48 | }
49 |
50 | for (std::string &entry : entries) {
51 | if (system::isDirectory(entry)) {
52 | if (string::startsWith(entry, "SPOTL") ||
53 | string::startsWith(entry, "TRASH") ||
54 | string::startsWith(entry, "__MACOSX")) {
55 | continue;
56 | }
57 |
58 | if (banks.size() > MAX_NUM_BANKS) {
59 | WARN("Max number of banks reached. Ignoring subdirectories.");
60 | return;
61 | }
62 |
63 | if (scanDepth++ > MAX_DIR_DEPTH) {
64 | WARN("Directory has too many subdirectories: %s", entry.c_str());
65 | continue;
66 | };
67 |
68 | scan(entry, sort, filter);
69 |
70 | } else {
71 | files.push_back(entry);
72 | }
73 | }
74 |
75 | if (filter) {
76 | for (std::vector::iterator it = files.begin(); it != files.end(); /* */) {
77 | if (!isSupportedAudioFormat(*it)) it = files.erase(it);
78 | else ++it;
79 | }
80 | }
81 |
82 | if (!files.empty()) {
83 | banks.push_back(files);
84 | }
85 | scanDepth--;
86 | }
87 |
88 | int scanDepth;
89 | std::vector< std::vector > banks;
90 |
91 | };
92 |
93 |
94 | // Base class
95 | class AudioObject {
96 |
97 | public:
98 |
99 | AudioObject() :
100 | filePath(),
101 | currentPos(0.0f),
102 | channels(0),
103 | sampleRate(0),
104 | bytesPerSample(2),
105 | totalSamples(0),
106 | samples(nullptr),
107 | peak(0.0f) {};
108 |
109 | virtual ~AudioObject() {};
110 |
111 | virtual bool load(const std::string &path) = 0;
112 |
113 | std::string filePath;
114 | float currentPos;
115 | unsigned int channels;
116 | unsigned int sampleRate;
117 | unsigned int bytesPerSample;
118 | drwav_uint64 totalSamples;
119 | float *samples;
120 | float peak;
121 |
122 | };
123 |
124 |
125 | class WavAudioObject : public AudioObject {
126 |
127 | public:
128 |
129 | WavAudioObject() : AudioObject() {
130 | bytesPerSample = 4;
131 | };
132 | ~WavAudioObject() {
133 | if (samples) {
134 | drwav_free(samples, nullptr);
135 | }
136 | };
137 |
138 | bool load(const std::string &path) override {
139 | drwav_uint64 totalFrames(0);
140 |
141 | filePath = path;
142 | samples = drwav_open_file_and_read_pcm_frames_f32(
143 | filePath.c_str(), &channels, &sampleRate, &totalFrames, nullptr
144 | );
145 |
146 | totalSamples = totalFrames * channels;
147 |
148 | if (samples) {
149 | for (size_t i = 0; i < totalSamples; ++i) {
150 | if (samples[i] > peak) peak = samples[i];
151 | }
152 | }
153 |
154 | return (samples != nullptr);
155 | }
156 | };
157 |
158 |
159 | class RawAudioObject : public AudioObject {
160 |
161 | public:
162 |
163 | RawAudioObject() : AudioObject() {
164 | channels = 1;
165 | sampleRate = 44100;
166 | bytesPerSample = 2;
167 | };
168 | ~RawAudioObject() {
169 | if (samples) {
170 | free(samples);
171 | }
172 | }
173 |
174 | bool load(const std::string &path) override {
175 | filePath = path;
176 |
177 | FILE *wav = fopen(filePath.c_str(), "rb");
178 |
179 | if (wav) {
180 | fseek(wav, 0, SEEK_END);
181 | const long fsize = ftell(wav);
182 | rewind(wav);
183 |
184 | int16_t *rawSamples = (int16_t*)malloc(sizeof(int16_t) * fsize/bytesPerSample);
185 | if (rawSamples) {
186 | const long samplesRead = fread(rawSamples, (size_t)sizeof(int16_t), fsize/bytesPerSample, wav);
187 | fclose(wav);
188 | if (samplesRead != fsize/(int)bytesPerSample) { WARN("Failed to read entire file"); }
189 | totalSamples = samplesRead;
190 |
191 | samples = (float*)malloc(sizeof(float) * totalSamples);
192 | for (size_t i = 0; i < totalSamples; ++i) {
193 | samples[i] = static_cast(rawSamples[i]);
194 | if (samples[i] > peak) peak = samples[i];
195 | }
196 | } else {
197 | FATAL("Failed to allocate memory");
198 | }
199 |
200 | free(rawSamples);
201 |
202 | } else {
203 | FATAL("Failed to load file: %s", filePath.c_str());
204 | }
205 |
206 | return (samples != nullptr);
207 | }
208 |
209 | };
210 |
211 |
212 | class AudioPlayer {
213 |
214 | public:
215 | AudioPlayer() :
216 | startPos(0.0f),
217 | playbackSpeed(1.0f)
218 | {};
219 | ~AudioPlayer() {};
220 |
221 | void load(std::shared_ptr object) {
222 | audio = std::move(object);
223 | }
224 |
225 | void skipTo(float pos) {
226 | if (audio) {
227 | audio->currentPos = pos;
228 | }
229 | }
230 |
231 | float play(unsigned int channel) {
232 | float sample(0.0f);
233 |
234 | if (audio) {
235 | if (channel < audio->channels) {
236 | if ((audio->currentPos + channel) < audio->totalSamples) {
237 | const unsigned int pos = static_cast(audio->currentPos + channel);
238 | const float delta = (audio->currentPos + channel) - pos;
239 | sample = crossfade(audio->samples[pos],
240 | audio->samples[std::min(pos+1, (unsigned int)audio->totalSamples-1)],
241 | delta);
242 | }
243 | }
244 | }
245 |
246 | return sample;
247 | }
248 |
249 | void advance(bool repeat, bool pitchMode) {
250 | if (audio) {
251 |
252 | float nextPos;
253 | if (pitchMode) {
254 | const float speed = playbackSpeed;
255 | nextPos = audio->currentPos + speed * static_cast(audio->channels);
256 | } else {
257 | nextPos = audio->currentPos + audio->channels;
258 | }
259 |
260 | float const maxPos = static_cast(audio->totalSamples);
261 | if (nextPos >= maxPos) {
262 | if (repeat) {
263 | audio->currentPos = startPos;
264 | } else {
265 | audio->currentPos = maxPos;
266 | }
267 | } else {
268 | audio->currentPos = nextPos;
269 | }
270 | }
271 | }
272 |
273 | void resetTo(float pos) {
274 | if (audio) {
275 | startPos = pos;
276 | audio->currentPos = startPos;
277 | }
278 | }
279 |
280 | bool ready() {
281 | if (audio) {
282 | return audio->totalSamples > 0;
283 | } else {
284 | return false;
285 | }
286 | }
287 |
288 | void reset() {
289 | if (audio) {
290 | audio.reset();
291 | }
292 | }
293 |
294 | void setPlaybackSpeed(const float speed) {
295 | playbackSpeed = speed;
296 | }
297 |
298 | std::shared_ptr object() {
299 | return audio;
300 | }
301 |
302 | private:
303 |
304 | std::shared_ptr audio;
305 | float startPos;
306 | float playbackSpeed;
307 |
308 | };
309 |
310 |
311 | struct AudioObjectPool {
312 | unsigned long memoryUsage = 0;
313 | std::vector> objects;
314 |
315 | void clear() {
316 | objects.clear();
317 | memoryUsage = 0;
318 | }
319 | };
320 |
321 |
322 | struct MsTimer : dsp::TTimer {
323 | void process() {
324 | dsp::TTimer::process(1);
325 | }
326 |
327 | unsigned long elapsedTime() {
328 | return time;
329 | }
330 | };
331 |
332 |
333 | struct RadioMusic : Module {
334 | enum ParamIds {
335 | STATION_PARAM,
336 | START_PARAM,
337 | RESET_PARAM,
338 | NUM_PARAMS
339 | };
340 | enum InputIds {
341 | STATION_INPUT,
342 | START_INPUT,
343 | RESET_INPUT,
344 | NUM_INPUTS
345 | };
346 | enum OutputIds {
347 | OUT_OUTPUT,
348 | NUM_OUTPUTS
349 | };
350 | enum LightIds {
351 | RESET_LIGHT,
352 | ENUMS(LED_LIGHT, 4),
353 | NUM_LIGHTS
354 | };
355 |
356 | RadioMusic();
357 | ~RadioMusic();
358 |
359 | void process(const ProcessArgs &args) override;
360 | void onReset(const ResetEvent& e) override;
361 | void onAdd(const AddEvent& e) override;
362 |
363 | void clearCurrentBank();
364 | void saveCurrentBankToPatchStorage();
365 | void removeAudioPoolFromPatchStorage();
366 |
367 | size_t getNumBanks() const {
368 | return scanner.banks.size();
369 | };
370 | size_t getCurrentObjectPoolSize() const {
371 | return currentObjectPool->objects.size();
372 | };
373 |
374 | // Context menu
375 | bool loadFiles;
376 | bool scanFiles;
377 | bool selectBank;
378 | std::string audioPoolLocation;
379 |
380 | // Settings
381 | bool stereoOutputMode;
382 | bool pitchMode;
383 | bool loopingEnabled;
384 | bool crossfadeEnabled;
385 | bool sortFiles;
386 | bool allowAllFiles;
387 | std::string rootDir;
388 | int currentBank;
389 |
390 | json_t *dataToJson() override {
391 | json_t *rootJ = json_object();
392 |
393 | // Option: Stereo Output Mode
394 | json_t *stereoOutputModeJ = json_boolean(stereoOutputMode);
395 | json_object_set_new(rootJ, "stereoOutputMode", stereoOutputModeJ);
396 |
397 | // Option: Pitch Mode
398 | json_t *pitchModeJ = json_boolean(pitchMode);
399 | json_object_set_new(rootJ, "pitchMode", pitchModeJ);
400 |
401 | // Option: Loop Samples
402 | json_t *loopingJ = json_boolean(loopingEnabled);
403 | json_object_set_new(rootJ, "loopingEnabled", loopingJ);
404 |
405 | // Option: Enable Crossfade
406 | json_t *crossfadeJ = json_boolean(crossfadeEnabled);
407 | json_object_set_new(rootJ, "crossfadeEnabled", crossfadeJ);
408 |
409 | // Option: Sort Files
410 | json_t *sortJ = json_boolean(sortFiles);
411 | json_object_set_new(rootJ, "sortFiles", sortJ);
412 |
413 | // Option: Allow All Files
414 | json_t *filesJ = json_boolean(allowAllFiles);
415 | json_object_set_new(rootJ, "allowAllFiles", filesJ);
416 |
417 | // Internal state: rootDir
418 | json_t *rootDirJ = json_string(rootDir.c_str());
419 | json_object_set_new(rootJ, "rootDir", rootDirJ);
420 |
421 | // Internal state: currentBank
422 | json_t *bankJ = json_integer(currentBank);
423 | json_object_set_new(rootJ, "currentBank", bankJ);
424 |
425 | return rootJ;
426 | }
427 |
428 | void dataFromJson(json_t *rootJ) override {
429 | // Option: Stereo Output Mode
430 | json_t *stereoOutputModeJ = json_object_get(rootJ, "stereoOutputMode");
431 | if (stereoOutputModeJ) stereoOutputMode = json_boolean_value(stereoOutputModeJ);
432 |
433 | // Option: Pitch Mode
434 | json_t *pitchModeJ = json_object_get(rootJ, "pitchMode");
435 | if (pitchModeJ) pitchMode = json_boolean_value(pitchModeJ);
436 |
437 | // Option: Loop Samples
438 | json_t *loopingJ = json_object_get(rootJ, "loopingEnabled");
439 | if (loopingJ) loopingEnabled = json_boolean_value(loopingJ);
440 |
441 | // Option: Enable Crossfade
442 | json_t *crossfadeJ = json_object_get(rootJ, "crossfadeEnabled");
443 | if (crossfadeJ) crossfadeEnabled = json_boolean_value(crossfadeJ);
444 |
445 | // Option: Sort Files
446 | json_t *sortJ = json_object_get(rootJ, "sortFiles");
447 | if (sortJ) sortFiles = json_boolean_value(sortJ);
448 |
449 | // Option: Allow All Files
450 | json_t *filesJ = json_object_get(rootJ, "allowAllFiles");
451 | if (filesJ) allowAllFiles = json_boolean_value(filesJ);
452 |
453 | // Internal state: rootDir
454 | json_t *rootDirJ = json_object_get(rootJ, "rootDir");
455 | if (rootDirJ) rootDir = json_string_value(rootDirJ);
456 |
457 | // Internal state: currentBank
458 | json_t *bankJ = json_object_get(rootJ, "currentBank");
459 | if (bankJ) currentBank = json_integer_value(bankJ);
460 |
461 | scanFiles = true;
462 | }
463 |
464 | private:
465 |
466 | void init();
467 | void workerThread();
468 | void threadedScan();
469 | void threadedLoad();
470 | void resetCurrentPlayer(float start);
471 |
472 | FileScanner scanner;
473 |
474 | AudioPlayer audioPlayer1;
475 | AudioPlayer audioPlayer2;
476 |
477 | AudioPlayer *currentPlayer;
478 | AudioPlayer *previousPlayer;
479 |
480 | AudioObjectPool audioContainer1;
481 | AudioObjectPool audioContainer2;
482 | AudioObjectPool* currentObjectPool;
483 | AudioObjectPool* tmpObjectPool;
484 |
485 | dsp::SchmittTrigger rstButtonTrigger;
486 | dsp::SchmittTrigger rstInputTrigger;
487 | dsp::PulseGenerator rstLedPulse;
488 |
489 | int prevIndex;
490 | unsigned long tick;
491 | bool crossfade;
492 | bool fadeout;
493 | float fadeOutGain;
494 | float xfadeGain1;
495 | float xfadeGain2;
496 | bool flashResetLed;
497 |
498 | MsTimer playTimer;
499 | MsTimer ledTimer;
500 |
501 | dsp::VuMeter2 vumeter;
502 |
503 | dsp::SampleRateConverter<2> outputSrc;
504 | dsp::DoubleRingBuffer, 256> outputBuffer;
505 |
506 | const int BLOCK_SIZE = 16;
507 |
508 | std::mutex mutex;
509 | std::condition_variable cond;
510 | std::shared_ptr worker;
511 | bool stopWorker = false;
512 | bool workerDoWork = false;
513 |
514 | std::atomic loadingFiles;
515 | std::atomic filesLoaded;
516 | std::atomic abortLoad;
517 | std::atomic scanAudioFiles;
518 | std::atomic loadAudioFiles;
519 | std::atomic showError;
520 | };
521 |
522 | // Custom ParamQuantity to handle modal behavior of Start parameter
523 | // It changes default value and label when in Pitch mode
524 | struct StartParamQuantity : ParamQuantity {
525 |
526 | float getDefaultValue() override {
527 | if (module) {
528 | rm = dynamic_cast(module);
529 | return (rm->pitchMode) ? PITCH_MODE_DEFAULT : NORMAL_MODE_DEFAULT;
530 | }
531 | return getValue();
532 | }
533 |
534 | std::string getLabel() override {
535 | if (module) {
536 | rm = dynamic_cast(module);
537 | return (rm->pitchMode) ? "Pitch" : "Start";
538 | }
539 | return "";
540 | }
541 |
542 | RadioMusic* rm = nullptr;
543 | };
544 |
545 |
546 | RadioMusic::RadioMusic() {
547 | config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
548 |
549 | configParam(STATION_PARAM, 0.0f, 1.0f, 0.0f, "Station");
550 | paramQuantities[STATION_PARAM]->displayMultiplier = 5.0f;
551 | configParam(START_PARAM, 0.0f, 1.0f, 0.0f, "Start");
552 |
553 | configButton(RESET_PARAM, "Reset");
554 |
555 | configInput(STATION_INPUT, "Station");
556 | configInput(START_INPUT, "Start");
557 | configInput(RESET_INPUT, "Reset");
558 |
559 | configOutput(OUT_OUTPUT, "Output");
560 |
561 | configLight(RESET_LIGHT, "Reset");
562 |
563 | currentPlayer = &audioPlayer1;
564 | previousPlayer = &audioPlayer2;
565 | currentObjectPool = &audioContainer1;
566 | tmpObjectPool = &audioContainer2;
567 |
568 | worker = std::make_shared(&RadioMusic::workerThread, this);
569 |
570 | init();
571 | }
572 |
573 | RadioMusic::~RadioMusic() {
574 | abortLoad = true;
575 | stopWorker = true;
576 | workerDoWork = true;
577 | cond.notify_one();
578 | worker->join();
579 | }
580 |
581 | void RadioMusic::onReset(const ResetEvent& e) {
582 | init();
583 | }
584 |
585 |
586 | void RadioMusic::onAdd(const AddEvent& e) {
587 | // Load files from audiopool as module is added to patch.
588 | const std::string audiopool = system::join(getPatchStorageDirectory(), "audiopool");
589 | if (system::exists(audiopool)) {
590 | audioPoolLocation = audiopool;
591 | rootDir = ""; // clear rootDir setting when using audiopool in Patch Storage.
592 | } else {
593 | // No patch storage. Use rootDir (if defined).
594 | audioPoolLocation = rootDir;
595 | }
596 | scanFiles = true;
597 | }
598 |
599 | void RadioMusic::init() {
600 | audioPoolLocation = "";
601 | prevIndex = -1;
602 | tick = 0;
603 | crossfade = false;
604 | fadeout = false;
605 | fadeOutGain = 1.0f;
606 | xfadeGain1 = 0.0f;
607 | xfadeGain2 = 1.0f;
608 | flashResetLed = false;
609 |
610 | selectBank = false;
611 | loadFiles = false;
612 | scanFiles = false;
613 |
614 | filesLoaded = false;
615 | loadingFiles = false;
616 | abortLoad = false;
617 | scanAudioFiles = false;
618 | loadAudioFiles = false;
619 | showError = false;
620 |
621 | // Settings
622 | stereoOutputMode = false;
623 | pitchMode = false;
624 | loopingEnabled = true;
625 | crossfadeEnabled = true;
626 | sortFiles = false;
627 | allowAllFiles = false;
628 | rootDir = "";
629 | currentBank = 0;
630 |
631 | // Internal state
632 | scanner.banks.clear();
633 |
634 | if (currentPlayer->object()) {
635 | currentPlayer->reset();
636 | }
637 | if (previousPlayer->object()) {
638 | previousPlayer->reset();
639 | }
640 |
641 | for (size_t i = 0; i < NUM_LIGHTS; i++) {
642 | lights[RESET_LIGHT + i].value = 0.0f;
643 | }
644 | }
645 |
646 | void RadioMusic::threadedScan() {
647 | if (audioPoolLocation.empty()) {
648 | WARN("No root directory defined. Scan failed.");
649 | showError = true;
650 | return;
651 | }
652 |
653 | scanner.reset();
654 | scanner.scan(audioPoolLocation, sortFiles, !allowAllFiles);
655 | if (scanner.banks.size() == 0) {
656 | return;
657 | }
658 |
659 | currentBank = clamp(currentBank, 0, (int)scanner.banks.size()-1);
660 |
661 | loadFiles = true;
662 | }
663 |
664 | // Inspired by Stoermelder-P1 thread handling.
665 | // https://github.com/stoermelder/vcvrack-packone
666 | void RadioMusic::workerThread() {
667 | while (true) {
668 | std::unique_lock lock(mutex);
669 | cond.wait(lock, std::bind(&RadioMusic::workerDoWork, this));
670 | if (stopWorker) return;
671 |
672 | if (scanAudioFiles) {
673 | threadedScan();
674 | scanAudioFiles = false;
675 | }
676 | if (loadAudioFiles) {
677 | threadedLoad();
678 | loadAudioFiles = false;
679 | }
680 |
681 | workerDoWork = false;
682 | }
683 | }
684 |
685 | void RadioMusic::threadedLoad() {
686 | if (scanner.banks.empty()) {
687 | WARN("No banks available. Failed to load audio files.");
688 | showError = true;
689 | return;
690 | }
691 |
692 | loadingFiles = true;
693 |
694 | drwav wav;
695 |
696 | currentBank = clamp(currentBank, 0, (int)scanner.banks.size()-1);
697 |
698 | const std::vector files = scanner.banks[currentBank];
699 | for (auto &f : files) {
700 | std::shared_ptr object;
701 |
702 | // Quickly determine if file is WAV file
703 | if (drwav_init_file(&wav, f.c_str(), nullptr)) {
704 | object = std::make_shared();
705 | if (drwav_uninit(&wav) != DRWAV_SUCCESS) {
706 | FATAL("Failed to uninitialize object %s", f.c_str());
707 | }
708 | } else { // if load fails, interpret as raw audio
709 | object = std::make_shared();
710 | }
711 |
712 | // Actually load files
713 | if (object->load(f)) {
714 | // Abort the current load process and release the memory.
715 | if (abortLoad) {
716 | tmpObjectPool->clear();
717 | loadingFiles = false;
718 | return;
719 | }
720 |
721 | const unsigned long memory = object->totalSamples*sizeof(float);
722 | if ((tmpObjectPool->memoryUsage + memory) < MAX_BANK_SIZE) {
723 | tmpObjectPool->objects.push_back(std::move(object));
724 | tmpObjectPool->memoryUsage += memory;
725 | } else {
726 | WARN("Bank memory limit of %ld Bytes exceeded. Aborting loading of audio objects.", (long int)MAX_BANK_SIZE);
727 | showError = true;
728 | break;
729 | }
730 | } else {
731 | WARN("Failed to load object %s", f.c_str());
732 | showError = true;
733 | }
734 | }
735 |
736 | filesLoaded = true;
737 |
738 | while(filesLoaded) {
739 | // Wait for object audio pool pointers to be swapped (in main thread).
740 | }
741 |
742 | // After swap, release memory of previous audio object pool.
743 | tmpObjectPool->clear();
744 |
745 | loadingFiles = false;
746 | }
747 |
748 | void RadioMusic::resetCurrentPlayer(float start) {
749 | const unsigned int channels = currentPlayer->object()->channels;
750 | unsigned long pos = static_cast(start * (currentPlayer->object()->totalSamples / channels));
751 | if (pos >= channels) { pos -= channels; }
752 | pos = pos % (currentPlayer->object()->totalSamples / channels);
753 | currentPlayer->resetTo(pos);
754 | }
755 |
756 | void RadioMusic::removeAudioPoolFromPatchStorage() {
757 | const std::string audiopool = system::join(getPatchStorageDirectory(), "audiopool");
758 | if (system::exists(audiopool)) {
759 | if (!system::removeRecursively(audiopool)) {
760 | WARN("Failed to remove audiopool: %s", audiopool.c_str());
761 | showError = true;
762 | }
763 | }
764 | }
765 |
766 | void RadioMusic::clearCurrentBank() {
767 | if (currentObjectPool) currentObjectPool->clear();
768 | if (tmpObjectPool) tmpObjectPool->clear();
769 | if (previousPlayer) previousPlayer->reset();
770 | if (currentPlayer) currentPlayer->reset();
771 |
772 | // Delete audio pool from patch storage if it exists.
773 | removeAudioPoolFromPatchStorage();
774 |
775 | audioPoolLocation = "";
776 | rootDir = "";
777 |
778 | for (int i = 0; i < 4; i++) {
779 | lights[LED_LIGHT+i].value = 0.0f;
780 | }
781 | }
782 |
783 | void RadioMusic::saveCurrentBankToPatchStorage() {
784 | if (scanner.banks.size() == 0) return;
785 |
786 | std::string audiopool = system::join(getPatchStorageDirectory(), "audiopool");
787 | if (system::exists(audiopool)) {
788 | if (!system::removeRecursively(audiopool)) {
789 | WARN("Failed to remove existing audiopool: %s", audiopool.c_str());
790 | showError = true;
791 | return;
792 | }
793 | }
794 | audiopool = system::join(createPatchStorageDirectory(), "audiopool");
795 | if (!system::createDirectory(audiopool)) {
796 | WARN("Creating audiopool failed: %s", audiopool.c_str());
797 | showError = true;
798 | return;
799 | };
800 |
801 | for (auto& f : scanner.banks[currentBank]) {
802 | if (!system::copy(f, audiopool)) {
803 | WARN("Failed to copy file: %s", f.c_str());
804 | showError = true;
805 | }
806 | }
807 |
808 | // Point root directory to audio pool in Patch Storage and rescan.
809 | audioPoolLocation = audiopool;
810 | rootDir = "";
811 | scanFiles = true;
812 | }
813 |
814 | void RadioMusic::process(const ProcessArgs &args) {
815 |
816 | if (audioPoolLocation.empty()) {
817 | // No files loaded yet. Idle.
818 | return;
819 | }
820 |
821 | if (scanFiles) {
822 | scanAudioFiles = true;
823 | workerDoWork = true;
824 | cond.notify_one();
825 |
826 | scanFiles = false;
827 | }
828 |
829 | if (loadFiles) {
830 | // If we are already loading, tell the thread to abort the
831 | // current loading process.
832 | if (loadingFiles && !abortLoad) {
833 | abortLoad = true;
834 | }
835 | if (!loadingFiles) {
836 | abortLoad = false;
837 |
838 | loadAudioFiles = true;
839 | workerDoWork = true;
840 | cond.notify_one();
841 |
842 | loadFiles = false;
843 | }
844 | }
845 |
846 | if (filesLoaded) {
847 | // Swap out Audio Object Pool with newly loaded files
848 | AudioObjectPool* tmp;
849 | tmp = currentObjectPool;
850 | currentObjectPool = tmpObjectPool;
851 | tmpObjectPool = tmp;
852 | currentPlayer->reset(); // Reset current player to use new audio
853 | outputBuffer.clear(); // Clear output buffer to start fresh
854 | prevIndex = -1; // Force channel change detection upon loading files
855 | playTimer.reset(); // Reset station to beginning
856 |
857 | filesLoaded = false;
858 | }
859 |
860 | // Bank selection mode
861 | if (selectBank) {
862 | // Bank is selected via Reset button
863 | if (rstButtonTrigger.process(params[RESET_PARAM].getValue())) {
864 | currentBank++;
865 | currentBank %= getNumBanks();
866 | }
867 |
868 | // Show bank selection in LED bar
869 | for (size_t i = 0; i < 4; i++) {
870 | lights[LED_LIGHT+i].value = (1 && (currentBank & 1 << i));
871 | }
872 | }
873 |
874 | // Keep track is ms elapsed.
875 | if (tick++ % (static_cast(args.sampleRate)/1000) == 0) {
876 | playTimer.process();
877 | ledTimer.process();
878 | }
879 |
880 | // Normal mode: Start knob & input
881 | float start(0.0f);
882 | if (!pitchMode) {
883 | start = clamp(params[START_PARAM].getValue() + inputs[START_INPUT].getVoltage()/5.0f, 0.0f, 1.0f);
884 | } else {
885 | // Pitch mode: Start knob sets sample root pitch (via playback speed). Start input follows 1V/Oct.
886 | const float speed = clamp(params[START_PARAM].getValue() + inputs[START_INPUT].getVoltage()/5.0f, 0.0f, 1.0f);
887 | const float range = 8.0f;
888 | const float scaledSpeed = pow(2.0f, range*speed - range*0.5f);
889 | currentPlayer->setPlaybackSpeed(scaledSpeed);
890 | }
891 |
892 | if (getCurrentObjectPoolSize() > 0 && (rstButtonTrigger.process(params[RESET_PARAM].getValue()) ||
893 | (inputs[RESET_INPUT].isConnected() && rstInputTrigger.process(inputs[RESET_INPUT].getVoltage())))) {
894 |
895 | fadeOutGain = 1.0f;
896 |
897 | if (crossfadeEnabled) {
898 | fadeout = true;
899 | } else {
900 | resetCurrentPlayer(start);
901 | }
902 |
903 | playTimer.reset();
904 |
905 | flashResetLed = true;
906 | }
907 |
908 | // Channel knob & input
909 | const float channel = clamp(params[STATION_PARAM].getValue() + inputs[STATION_INPUT].getVoltage()/5.0f, 0.0f, 1.0f);
910 | const int index = \
911 | clamp(static_cast(rescale(channel, 0.0f, 1.0f, 0.0f, static_cast(getCurrentObjectPoolSize()))),
912 | 0, getCurrentObjectPoolSize() - 1);
913 |
914 | // Channel switch detection
915 | if (getCurrentObjectPoolSize() > 0 && index != prevIndex) {
916 | AudioPlayer *tmp;
917 | tmp = previousPlayer;
918 | previousPlayer = currentPlayer;
919 | currentPlayer = tmp;
920 |
921 | if (index < (int)getCurrentObjectPoolSize()) {
922 | currentPlayer->load(currentObjectPool->objects[index]);
923 |
924 | if (!pitchMode) {
925 | unsigned long pos = currentPlayer->object()->currentPos + \
926 | (currentPlayer->object()->channels * playTimer.elapsedTime() * currentPlayer->object()->sampleRate) / 1000;
927 | pos = pos % (currentPlayer->object()->totalSamples / currentPlayer->object()->channels);
928 | currentPlayer->skipTo(pos);
929 | } else {
930 | currentPlayer->skipTo(0);
931 | }
932 | }
933 |
934 | xfadeGain1 = 0.0f;
935 | xfadeGain2 = 1.0f;
936 |
937 | crossfade = crossfadeEnabled;
938 |
939 | if (previousPlayer->object()) {
940 | // Different number of channels while crossfading leads to audible artifacts.
941 | if (currentPlayer->object()->channels != previousPlayer->object()->channels) {
942 | crossfade = false;
943 | }
944 | }
945 |
946 | flashResetLed = true;
947 | }
948 |
949 | prevIndex = index;
950 |
951 | // Reset LED
952 | if (!selectBank && flashResetLed) {
953 | rstLedPulse.trigger(0.050f);
954 | flashResetLed = false;
955 | }
956 | lights[RESET_LIGHT].value = (rstLedPulse.process(args.sampleTime)) ? 1.0f : 0.0f;
957 |
958 | // Audio processing
959 | if (outputBuffer.empty()) {
960 | // Nothing to play if no audio objects are loaded into players.
961 | if (!currentPlayer->object() && !previousPlayer->object()) {
962 | return;
963 | }
964 |
965 | dsp::Frame<2> frame[BLOCK_SIZE];
966 |
967 | for (int i = 0; i < BLOCK_SIZE; i++) {
968 |
969 | // Crossfade?
970 | if (crossfade) {
971 |
972 | xfadeGain1 = rack::crossfade(xfadeGain1, 1.0f, 0.005); // 0.005 = ~25ms
973 | xfadeGain2 = rack::crossfade(xfadeGain2, 0.0f, 0.005); // 0.005 = ~25ms
974 |
975 | for (size_t channel = 0; channel < currentPlayer->object()->channels; channel++) {
976 | const float currSample = currentPlayer->play(channel);
977 | const float prevSample = previousPlayer->play(channel);
978 | const float out = currSample * xfadeGain1 + prevSample * xfadeGain2;
979 |
980 | frame[i].samples[channel] = 5.0f * out / currentPlayer->object()->peak;
981 | }
982 |
983 | currentPlayer->advance(loopingEnabled, pitchMode);
984 | previousPlayer->advance(loopingEnabled, pitchMode);
985 |
986 | if (isNear(xfadeGain1+0.005, 1.0f) || isNear(xfadeGain2, 0.0f)) {
987 | crossfade = false;
988 | }
989 |
990 | }
991 | // Fade out (before resetting)?
992 | else if (fadeout)
993 | {
994 |
995 | fadeOutGain = rack::crossfade(fadeOutGain, 0.0f, 0.05); // 0.05 = ~5ms
996 |
997 | for (size_t channel = 0; channel < currentPlayer->object()->channels; channel++) {
998 | const float sample = currentPlayer->play(channel);
999 | const float out = sample * fadeOutGain;
1000 |
1001 | frame[i].samples[channel] = 5.0f * out / currentPlayer->object()->peak;
1002 | }
1003 |
1004 | currentPlayer->advance(loopingEnabled, pitchMode);
1005 |
1006 | if (isNear(fadeOutGain, 0.0f)) {
1007 |
1008 | resetCurrentPlayer(start);
1009 |
1010 | fadeout = false;
1011 | }
1012 | }
1013 | else // Not fade away now!
1014 | {
1015 | for (size_t channel = 0; channel < currentPlayer->object()->channels; channel++) {
1016 | const float out = currentPlayer->play(channel);
1017 |
1018 | frame[i].samples[channel] = 5.0f * out / currentPlayer->object()->peak;
1019 | }
1020 |
1021 | currentPlayer->advance(loopingEnabled, pitchMode);
1022 | }
1023 | }
1024 |
1025 | // Sample rate conversion to match Rack engine sample rate.
1026 | outputSrc.setRates(currentPlayer->object()->sampleRate, args.sampleRate);
1027 | int inLen = BLOCK_SIZE;
1028 | int outLen = outputBuffer.capacity();
1029 |
1030 | outputSrc.process(frame, &inLen, outputBuffer.endData(), &outLen);
1031 | outputBuffer.endIncr(outLen);
1032 | }
1033 |
1034 | // Output processing & metering
1035 | if (!outputBuffer.empty()) {
1036 | outputs[OUT_OUTPUT].setChannels(stereoOutputMode ? 2 : 1);
1037 |
1038 | if (currentPlayer->object()) {
1039 |
1040 | dsp::Frame<2> frame = outputBuffer.shift();
1041 |
1042 | // Stereo mode
1043 | if (stereoOutputMode) {
1044 | if (currentPlayer->object()->channels == 2) {
1045 | for (unsigned int c = 0; c < 2; c++) {
1046 | outputs[OUT_OUTPUT].setVoltage(frame.samples[c], c);
1047 | }
1048 | } else {
1049 | // For mono audio files, duplicate mono audio across both channels.
1050 | if (currentPlayer->object()->channels == 1) {
1051 | outputs[OUT_OUTPUT].setVoltage(frame.samples[0], 0);
1052 | outputs[OUT_OUTPUT].setVoltage(frame.samples[0], 1);
1053 | }
1054 | }
1055 | // Mono mode
1056 | } else {
1057 | if (currentPlayer->object()->channels == 2) {
1058 | // L/R channels summed to mono.
1059 | outputs[OUT_OUTPUT].setVoltage((frame.samples[0] + frame.samples[1])/currentPlayer->object()->channels);
1060 | } else {
1061 | if (currentPlayer->object()->channels == 1) {
1062 | outputs[OUT_OUTPUT].setVoltage(frame.samples[0]);
1063 | }
1064 | }
1065 | }
1066 |
1067 | // Disable VU Meter in Bank Selection mode.
1068 | if (!selectBank) {
1069 | vumeter.process(args.sampleTime, frame.samples[0]/5.0f);
1070 |
1071 | if (ledTimer.elapsedTime() % 16 == 0) {
1072 | for (int i = 0; i < 4; i++){
1073 | float b = vumeter.getBrightness(-6.0f * (i+1), 0.0f * i);
1074 | lights[LED_LIGHT + 3 - i].setBrightness(b);
1075 | }
1076 | }
1077 | }
1078 | } else {
1079 | outputs[OUT_OUTPUT].setVoltage(0, 0);
1080 | outputs[OUT_OUTPUT].setVoltage(0, 1);
1081 | }
1082 | }
1083 |
1084 | // Indicator for loading audio files and errors during load.
1085 | if (loadingFiles || showError) {
1086 | static bool initTimer(true);
1087 | static unsigned long timerStart(0);
1088 | static bool toggle(false);
1089 | static int numBlinks(0);
1090 | unsigned int blinkTime(0);
1091 |
1092 | if (loadingFiles) {
1093 | blinkTime = 1000u;
1094 | }
1095 | if (showError) {
1096 | blinkTime = 200u;
1097 | }
1098 |
1099 | if (initTimer) {
1100 | timerStart = ledTimer.elapsedTime();
1101 | initTimer = false;
1102 | }
1103 |
1104 | for (int i = 0; i < 4; i++) {
1105 | lights[LED_LIGHT+i].value = toggle ? 1.0f : 0.0f;
1106 | }
1107 |
1108 | if ((ledTimer.elapsedTime() - timerStart) > blinkTime) {
1109 | initTimer = true;
1110 | toggle = !toggle;
1111 |
1112 | if (showError && ++numBlinks > 10) {
1113 | numBlinks = 0;
1114 | toggle = false;
1115 | showError = false;
1116 | }
1117 | }
1118 | }
1119 | }
1120 |
1121 | struct RadioMusicDirDialogItem : MenuItem {
1122 | RadioMusic *rm;
1123 | void onAction(const ActionEvent &e) override {
1124 |
1125 | const std::string dir = \
1126 | rm->rootDir.empty() ? asset::user("") : rm->rootDir;
1127 | char *path = osdialog_file(OSDIALOG_OPEN_DIR, dir.c_str(), NULL, NULL);
1128 | if (path) {
1129 | rm->rootDir = std::string(path);
1130 |
1131 | // New root directory selected. Scan content.
1132 | // `rootDir` is saved as a setting.
1133 | // `audioPoolLocation` defines actual location used.
1134 | rm->audioPoolLocation = rm->rootDir;
1135 | rm->scanFiles = true;
1136 |
1137 | // Remove current audiopool in Patch Storage (if it exists).
1138 | rm->removeAudioPoolFromPatchStorage();
1139 |
1140 | free(path);
1141 | }
1142 | }
1143 | };
1144 |
1145 | struct RadioMusicSelectBankItem : MenuItem {
1146 | RadioMusic *rm;
1147 | int currentBank;
1148 | void onAction(const ActionEvent &e) override {
1149 | rm->selectBank = !rm->selectBank;
1150 | if (rm->selectBank == false) {
1151 | if (currentBank != rm->currentBank) {
1152 | // Remove current audiopool in Patch Storage (if it exists).
1153 | rm->removeAudioPoolFromPatchStorage();
1154 |
1155 | rm->loadFiles = true;
1156 | }
1157 | } else {
1158 | // When entering bank selection mode, store current bank to detect bank changes.
1159 | currentBank = rm->currentBank;
1160 | }
1161 | }
1162 | void step() override {
1163 | text = (rm->selectBank != true) ? "Enter Bank Select Mode" : "Exit Bank Select Mode";
1164 | rightText = CHECKMARK(rm->selectBank);
1165 | }
1166 | };
1167 |
1168 |
1169 | struct RadioMusicWidget : ModuleWidget {
1170 | RadioMusicWidget(RadioMusic *module) {
1171 | setModule(module);
1172 | setPanel(createPanel(asset::plugin(pluginInstance, "res/Radio.svg")));
1173 |
1174 | addChild(createWidget(Vec(14, 0)));
1175 |
1176 | addChild(createLight>(Vec(6, 33), module, RadioMusic::LED_LIGHT));
1177 | addChild(createLight>(Vec(19, 33), module, RadioMusic::LED_LIGHT + 1));
1178 | addChild(createLight>(Vec(32, 33), module, RadioMusic::LED_LIGHT + 2));
1179 | addChild(createLight>(Vec(45, 33), module, RadioMusic::LED_LIGHT + 3));
1180 |
1181 | addParam(createParam(Vec(12, 49), module, RadioMusic::STATION_PARAM));
1182 | addParam(createParam(Vec(12, 131), module, RadioMusic::START_PARAM));
1183 |
1184 | addChild(createLight>(Vec(44, 188), module, RadioMusic::RESET_LIGHT));
1185 | addParam(createParam(Vec(25, 202), module, RadioMusic::RESET_PARAM));
1186 |
1187 | addInput(createInput(Vec(3, 274), module, RadioMusic::STATION_INPUT));
1188 | addInput(createInput(Vec(32, 274), module, RadioMusic::START_INPUT));
1189 |
1190 | addInput(createInput(Vec(3, 318), module, RadioMusic::RESET_INPUT));
1191 | addOutput(createOutput(Vec(32, 318), module, RadioMusic::OUT_OUTPUT));
1192 |
1193 | addChild(createWidget(Vec(14, 365)));
1194 | };
1195 |
1196 | void appendContextMenu(Menu *menu) override {
1197 | RadioMusic *module = dynamic_cast(this->module);
1198 |
1199 | menu->addChild(new MenuSeparator);
1200 |
1201 | RadioMusicDirDialogItem *audioPoolLocationItem = new RadioMusicDirDialogItem;
1202 | std::stringstream audioPoolLocationText, audioPoolLocation;
1203 | if (module->audioPoolLocation.empty()) {
1204 | audioPoolLocation << "";
1205 | } else {
1206 | if (system::getFilename(module->audioPoolLocation) == "audiopool") {
1207 | audioPoolLocation << "Patch Storage (" << module->audioPoolLocation << ")";
1208 | } else {
1209 | audioPoolLocation << module->audioPoolLocation;
1210 | }
1211 | }
1212 | audioPoolLocationText << "Root Directory: " << audioPoolLocation.str();
1213 | audioPoolLocationItem->text = audioPoolLocationText.str();
1214 | audioPoolLocationItem->rm = module;
1215 | menu->addChild(audioPoolLocationItem);
1216 |
1217 | RadioMusicSelectBankItem *selectBankItem = new RadioMusicSelectBankItem;
1218 | selectBankItem->text = "";
1219 | selectBankItem->rm = module;
1220 | selectBankItem->disabled = (module->getNumBanks() < 2);
1221 | menu->addChild(selectBankItem);
1222 |
1223 | MenuItem* clearBankItem = createMenuItem("Clear current Bank", "",
1224 | [=]() {
1225 | module->clearCurrentBank();
1226 | });
1227 | clearBankItem->disabled = (module->getCurrentObjectPoolSize() == 0);
1228 | menu->addChild(clearBankItem);
1229 |
1230 | MenuItem* saveBankItem = createMenuItem("Save current Bank to Patch Storage", "",
1231 | [=]() {
1232 | module->saveCurrentBankToPatchStorage();
1233 | });
1234 | saveBankItem->disabled = (module->rootDir == "");
1235 | menu->addChild(saveBankItem);
1236 |
1237 | menu->addChild(new MenuSeparator);
1238 |
1239 | menu->addChild(createBoolPtrMenuItem("Stereo Output enabled", "", &module->stereoOutputMode));
1240 | menu->addChild(createBoolPtrMenuItem("Pitch Mode enabled", "", &module->pitchMode));
1241 | menu->addChild(createBoolPtrMenuItem("Looping enabled", "", &module->loopingEnabled));
1242 | menu->addChild(createBoolPtrMenuItem("Crossfade enabled", "", &module->crossfadeEnabled));
1243 | menu->addChild(createBoolPtrMenuItem("Files sorted", "", &module->sortFiles));
1244 | menu->addChild(createBoolPtrMenuItem("All files allowed", "", &module->allowAllFiles));
1245 | }
1246 | };
1247 |
1248 | Model *modelRadioMusic = createModel("RadioMusic");
1249 |
--------------------------------------------------------------------------------
/src/modular80.cpp:
--------------------------------------------------------------------------------
1 | #include "modular80.hpp"
2 |
3 | Plugin *pluginInstance;
4 |
5 | void init(Plugin *p) {
6 | pluginInstance = p;
7 |
8 | p->addModel(modelLogistiker);
9 | p->addModel(modelNosering);
10 | p->addModel(modelRadioMusic);
11 | }
12 |
--------------------------------------------------------------------------------
/src/modular80.hpp:
--------------------------------------------------------------------------------
1 | #include "rack.hpp"
2 | #include "componentlibrary.hpp"
3 |
4 | using namespace rack;
5 |
6 | // Declare the Plugin, defined in Template.cpp
7 | extern Plugin *pluginInstance;
8 |
9 | // Declare each Model, defined in each module source file
10 | extern Model *modelLogistiker;
11 | extern Model *modelNosering;
12 | extern Model *modelRadioMusic;
13 |
--------------------------------------------------------------------------------