Browse Source

Initial commit

grainjuice
falkTX 10 years ago
commit
6b20c178b3
100 changed files with 100662 additions and 0 deletions
  1. +19
    -0
      .gitignore
  2. +280
    -0
      LICENSE
  3. +42
    -0
      Makefile
  4. +134
    -0
      Makefile.mk
  5. +3
    -0
      README.md
  6. +3
    -0
      bin/README
  7. +130
    -0
      plugins/Makefile.mk
  8. +39
    -0
      plugins/PowerJuice/DistrhoPluginInfo.h
  9. +36
    -0
      plugins/PowerJuice/Makefile
  10. +12222
    -0
      plugins/PowerJuice/PowerJuiceArtwork.cpp
  11. +35
    -0
      plugins/PowerJuice/PowerJuiceArtwork.hpp
  12. +379
    -0
      plugins/PowerJuice/PowerJuicePlugin.cpp
  13. +212
    -0
      plugins/PowerJuice/PowerJuicePlugin.hpp
  14. +307
    -0
      plugins/PowerJuice/PowerJuiceUI.cpp
  15. +130
    -0
      plugins/PowerJuice/PowerJuiceUI.hpp
  16. BIN
      plugins/PowerJuice/artwork/about.png
  17. BIN
      plugins/PowerJuice/artwork/aboutButtonHover.png
  18. BIN
      plugins/PowerJuice/artwork/aboutButtonNormal.png
  19. BIN
      plugins/PowerJuice/artwork/artwork.xcf
  20. BIN
      plugins/PowerJuice/artwork/background.png
  21. BIN
      plugins/PowerJuice/artwork/knob.png
  22. BIN
      plugins/PowerJuice/artwork/knob.xcf
  23. +39
    -0
      plugins/PowerJuiceX2/DistrhoPluginInfo.h
  24. +36
    -0
      plugins/PowerJuiceX2/Makefile
  25. +12222
    -0
      plugins/PowerJuiceX2/PowerJuiceX2Artwork.cpp
  26. +35
    -0
      plugins/PowerJuiceX2/PowerJuiceX2Artwork.hpp
  27. +385
    -0
      plugins/PowerJuiceX2/PowerJuiceX2Plugin.cpp
  28. +212
    -0
      plugins/PowerJuiceX2/PowerJuiceX2Plugin.hpp
  29. +307
    -0
      plugins/PowerJuiceX2/PowerJuiceX2UI.cpp
  30. +130
    -0
      plugins/PowerJuiceX2/PowerJuiceX2UI.hpp
  31. BIN
      plugins/PowerJuiceX2/artwork/about.png
  32. BIN
      plugins/PowerJuiceX2/artwork/aboutButtonHover.png
  33. BIN
      plugins/PowerJuiceX2/artwork/aboutButtonNormal.png
  34. BIN
      plugins/PowerJuiceX2/artwork/artwork.xcf
  35. BIN
      plugins/PowerJuiceX2/artwork/background.png
  36. BIN
      plugins/PowerJuiceX2/artwork/knob.png
  37. BIN
      plugins/PowerJuiceX2/artwork/knob.xcf
  38. +740
    -0
      plugins/StutterJuice/CModule.hxx
  39. +36
    -0
      plugins/StutterJuice/DistrhoPluginInfo.h
  40. +36
    -0
      plugins/StutterJuice/Makefile
  41. +32814
    -0
      plugins/StutterJuice/StutterJuiceArtwork.cpp
  42. +45
    -0
      plugins/StutterJuice/StutterJuiceArtwork.hpp
  43. +199
    -0
      plugins/StutterJuice/StutterJuicePlugin.cpp
  44. +170
    -0
      plugins/StutterJuice/StutterJuicePlugin.hpp
  45. +165
    -0
      plugins/StutterJuice/StutterJuiceUI.cpp
  46. +128
    -0
      plugins/StutterJuice/StutterJuiceUI.hpp
  47. BIN
      plugins/StutterJuice/artwork/about.png
  48. BIN
      plugins/StutterJuice/artwork/about.xcf
  49. BIN
      plugins/StutterJuice/artwork/aboutButtonHover.png
  50. BIN
      plugins/StutterJuice/artwork/aboutButtonNormal.png
  51. BIN
      plugins/StutterJuice/artwork/background.png
  52. BIN
      plugins/StutterJuice/artwork/gui.xcf
  53. BIN
      plugins/StutterJuice/artwork/knob.png
  54. BIN
      plugins/StutterJuice/artwork/overlay.png
  55. BIN
      plugins/StutterJuice/artwork/slider.png
  56. +0
    -0
      plugins/StutterJuice/external/pitchshifter.cpp
  57. +71
    -0
      plugins/TriggerJuice/CStream.hxx
  58. +36
    -0
      plugins/TriggerJuice/DistrhoPluginInfo.h
  59. +36
    -0
      plugins/TriggerJuice/Makefile
  60. +7525
    -0
      plugins/TriggerJuice/TriggerJuiceArtwork.cpp
  61. +40
    -0
      plugins/TriggerJuice/TriggerJuiceArtwork.hpp
  62. +331
    -0
      plugins/TriggerJuice/TriggerJuicePlugin.cpp
  63. +118
    -0
      plugins/TriggerJuice/TriggerJuicePlugin.hpp
  64. +217
    -0
      plugins/TriggerJuice/TriggerJuiceUI.cpp
  65. +103
    -0
      plugins/TriggerJuice/TriggerJuiceUI.hpp
  66. BIN
      plugins/TriggerJuice/artwork/about.png
  67. BIN
      plugins/TriggerJuice/artwork/about.xcf
  68. BIN
      plugins/TriggerJuice/artwork/aboutButtonHover.png
  69. BIN
      plugins/TriggerJuice/artwork/aboutButtonNormal.png
  70. BIN
      plugins/TriggerJuice/artwork/background.png
  71. BIN
      plugins/TriggerJuice/artwork/gui.xcf
  72. BIN
      plugins/TriggerJuice/artwork/knob.png
  73. BIN
      plugins/TriggerJuice/artwork/slider.png
  74. +36
    -0
      plugins/VectorJuice/DistrhoPluginInfo.h
  75. +36
    -0
      plugins/VectorJuice/Makefile
  76. +18123
    -0
      plugins/VectorJuice/VectorJuiceArtwork.cpp
  77. +55
    -0
      plugins/VectorJuice/VectorJuiceArtwork.hpp
  78. +391
    -0
      plugins/VectorJuice/VectorJuicePlugin.cpp
  79. +236
    -0
      plugins/VectorJuice/VectorJuicePlugin.hpp
  80. +448
    -0
      plugins/VectorJuice/VectorJuiceUI.cpp
  81. +115
    -0
      plugins/VectorJuice/VectorJuiceUI.hpp
  82. BIN
      plugins/VectorJuice/artwork/about.png
  83. BIN
      plugins/VectorJuice/artwork/about.xcf
  84. BIN
      plugins/VectorJuice/artwork/aboutButtonHover.png
  85. BIN
      plugins/VectorJuice/artwork/aboutButtonNormal.png
  86. BIN
      plugins/VectorJuice/artwork/background.png
  87. BIN
      plugins/VectorJuice/artwork/gui.xcf
  88. BIN
      plugins/VectorJuice/artwork/knob.png
  89. BIN
      plugins/VectorJuice/artwork/orbit.png
  90. BIN
      plugins/VectorJuice/artwork/roundlet.png
  91. BIN
      plugins/VectorJuice/artwork/slider.png
  92. BIN
      plugins/VectorJuice/artwork/subOrbit.png
  93. +36
    -0
      plugins/WobbleJuice/DistrhoPluginInfo.h
  94. +36
    -0
      plugins/WobbleJuice/Makefile
  95. +10312
    -0
      plugins/WobbleJuice/WobbleJuiceArtwork.cpp
  96. +35
    -0
      plugins/WobbleJuice/WobbleJuiceArtwork.hpp
  97. +243
    -0
      plugins/WobbleJuice/WobbleJuicePlugin.cpp
  98. +142
    -0
      plugins/WobbleJuice/WobbleJuicePlugin.hpp
  99. +181
    -0
      plugins/WobbleJuice/WobbleJuiceUI.cpp
  100. +90
    -0
      plugins/WobbleJuice/WobbleJuiceUI.hpp

+ 19
- 0
.gitignore View File

@@ -0,0 +1,19 @@
*.a
*.o

*.exe
*.dll
*.dylib
*.so

.kdev_include_paths
.kdev4/

bin/*-dssi/
bin/*.lv2/
bin/PowerJuice
bin/PowerJuiceX2
bin/StutterJuice
bin/TriggerJuice
bin/VectorJuice
bin/WobbleJuice

+ 280
- 0
LICENSE View File

@@ -0,0 +1,280 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.

When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.

We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and
modification follow.

GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.

b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.

c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,

b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,

c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.

9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

+ 42
- 0
Makefile View File

@@ -0,0 +1,42 @@
#!/usr/bin/make -f
# Makefile for DISTRHO Plugins #
# ---------------------------- #
# Created by falkTX
#

all: libs plugins gen

# --------------------------------------------------------------

libs:
$(MAKE) -C dpf/dgl

plugins: libs
$(MAKE) all -C plugins/PowerJuice
$(MAKE) all -C plugins/PowerJuiceX2
$(MAKE) all -C plugins/StutterJuice
$(MAKE) all -C plugins/TriggerJuice
$(MAKE) all -C plugins/VectorJuice
$(MAKE) all -C plugins/WobbleJuice

gen: plugins dpf/utils/lv2_ttl_generator
@$(CURDIR)/dpf/utils/generate-ttl.sh

dpf/utils/lv2_ttl_generator:
$(MAKE) -C dpf/utils/lv2-ttl-generator

# --------------------------------------------------------------

clean:
$(MAKE) clean -C dpf/dgl
$(MAKE) clean -C dpf/utils/lv2-ttl-generator
$(MAKE) clean -C plugins/PowerJuice
$(MAKE) clean -C plugins/PowerJuiceX2
$(MAKE) clean -C plugins/StutterJuice
$(MAKE) clean -C plugins/TriggerJuice
$(MAKE) clean -C plugins/VectorJuice
$(MAKE) clean -C plugins/WobbleJuice

# --------------------------------------------------------------

.PHONY: plugins

+ 134
- 0
Makefile.mk View File

@@ -0,0 +1,134 @@
#!/usr/bin/make -f
# Makefile for DISTRHO Plugins #
# ---------------------------- #
# Created by falkTX
#

CC ?= gcc
CXX ?= g++

# --------------------------------------------------------------
# Fallback to Linux if no other OS defined

ifneq ($(HAIKU),true)
ifneq ($(MACOS),true)
ifneq ($(WIN32),true)
LINUX=true
endif
endif
endif

# --------------------------------------------------------------
# Common build and link flags

BASE_FLAGS = -Wall -Wextra -pipe
BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections
ifneq ($(NOOPT),true)
BASE_OPTS += -mtune=generic -msse -msse2 -mfpmath=sse
endif
LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-O1 -Wl,--as-needed -Wl,--gc-sections -Wl,--strip-all

ifeq ($(MACOS),true)
# MacOS linker flags
LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
endif

ifeq ($(RASPPI),true)
# Raspberry-Pi flags
BASE_OPTS = -O2 -ffast-math
ifneq ($(NOOPT),true)
BASE_OPTS += -march=armv6 -mfpu=vfp -mfloat-abi=hard
endif
LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
endif

ifeq ($(PANDORA),true)
# OpenPandora flags
BASE_OPTS = -O2 -ffast-math
ifneq ($(NOOPT),true)
BASE_OPTS += -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
endif
LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
endif

ifneq ($(WIN32),true)
# not needed for Windows
BASE_FLAGS += -fPIC -DPIC
endif

ifeq ($(DEBUG),true)
BASE_FLAGS += -DDEBUG -O0 -g
LINK_OPTS =
else
BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
CXXFLAGS += -fvisibility-inlines-hidden
endif

BUILD_C_FLAGS = $(BASE_FLAGS) -std=c99 -std=gnu99 $(CFLAGS)
BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=c++0x -std=gnu++0x $(CXXFLAGS) $(CPPFLAGS)
LINK_FLAGS = $(LINK_OPTS) -Wl,--no-undefined $(LDFLAGS)

ifeq ($(MACOS),true)
# No C++11 support
BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) $(CPPFLAGS)
LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
endif

# --------------------------------------------------------------
# Check for required libs

ifeq ($(LINUX),true)
ifneq ($(shell pkg-config --exists jack && echo true),true)
$(error JACK missing, cannot continue)
endif
ifneq ($(shell pkg-config --exists gl && echo true),true)
$(error OpenGL missing, cannot continue)
endif
ifneq ($(shell pkg-config --exists x11 && echo true),true)
$(error X11 missing, cannot continue)
endif
endif

ifneq ($(shell pkg-config --exists liblo && echo true),true)
$(error liblo missing, cannot continue)
endif

# --------------------------------------------------------------
# Set libs stuff

ifeq ($(LINUX),true)
DGL_FLAGS = $(shell pkg-config --cflags gl x11)
DGL_LIBS = $(shell pkg-config --libs gl x11)
endif

ifeq ($(MACOS),true)
DGL_LIBS = -framework OpenGL -framework Cocoa
endif

ifeq ($(WIN32),true)
DGL_LIBS = -lopengl32 -lgdi32
endif

# --------------------------------------------------------------
# Set extension

EXT = so

ifeq ($(MACOS),true)
EXT = dylib
endif

ifeq ($(WIN32),true)
EXT = dll
endif

# --------------------------------------------------------------
# Set shared library CLI arg

SHARED = -shared

ifeq ($(MACOS),true)
SHARED = -dynamiclib
endif

# --------------------------------------------------------------

+ 3
- 0
README.md View File

@@ -0,0 +1,3 @@
# DISTRHO Juice Plugins

TODO...

+ 3
- 0
bin/README View File

@@ -0,0 +1,3 @@
All final plugin builds will be placed in this folder.

There is no "make install" process, simply copy those files to their appropriate place.

+ 130
- 0
plugins/Makefile.mk View File

@@ -0,0 +1,130 @@
#!/usr/bin/make -f
# Makefile for DISTRHO Plugins #
# ---------------------------- #
# Created by falkTX
#

# NAME, OBJS_DSP and OBJS_UI have been defined before

include ../../Makefile.mk

# --------------------------------------------------------------
# Basic setup

TARGET_DIR = ../../bin

BUILD_C_FLAGS += -I.
BUILD_CXX_FLAGS += -I. -I../../dpf/distrho -I../../dpf/dgl

# --------------------------------------------------------------
# Set plugin binary file targets

jack = $(TARGET_DIR)/$(NAME)
ladspa_dsp = $(TARGET_DIR)/$(NAME)-ladspa.$(EXT)
dssi_dsp = $(TARGET_DIR)/$(NAME)-dssi.$(EXT)
dssi_ui = $(TARGET_DIR)/$(NAME)-dssi/$(NAME)_ui
lv2 = $(TARGET_DIR)/$(NAME).lv2/$(NAME).$(EXT)
lv2_dsp = $(TARGET_DIR)/$(NAME).lv2/$(NAME)_dsp.$(EXT)
lv2_ui = $(TARGET_DIR)/$(NAME).lv2/$(NAME)_ui.$(EXT)
vst = $(TARGET_DIR)/$(NAME)-vst.$(EXT)

ifeq ($(WIN32),true)
dssi_ui += .exe
endif

# TODO: MacOS VST bundle

# --------------------------------------------------------------
# Set distrho code files

DISTRHO_PLUGIN_FILES = ../../dpf/distrho/DistrhoPluginMain.cpp
DISTRHO_UI_FILES = ../../dpf/distrho/DistrhoUIMain.cpp ../../dpf/libdgl.a

# --------------------------------------------------------------
# Handle plugins without UI

ifeq ($(TARGET_NOUI),true)
dssi_ui =
lv2_ui =
DISTRHO_UI_FILES =
DGL_LIBS =
OBJS_UI =
endif

# --------------------------------------------------------------
# all needs to be first

all:

# --------------------------------------------------------------
# Common

%.c.o: %.c
$(CC) $< $(BUILD_C_FLAGS) -c -o $@

%.cpp.o: %.cpp
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@

clean:
rm -f *.o
rm -rf $(TARGET_DIR)/$(NAME) $(TARGET_DIR)/$(NAME)-* $(TARGET_DIR)/$(NAME).lv2/

# --------------------------------------------------------------
# JACK

jack: $(jack)

$(jack): $(OBJS_DSP) $(OBJS_UI) $(DISTRHO_PLUGIN_FILES) $(DISTRHO_UI_FILES)
mkdir -p $(shell dirname $@)
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell pkg-config --cflags --libs jack) -DDISTRHO_PLUGIN_TARGET_JACK -o $@

# --------------------------------------------------------------
# LADSPA

ladspa: $(ladspa_dsp)

$(ladspa_dsp): $(OBJS_DSP) $(DISTRHO_PLUGIN_FILES)
mkdir -p $(shell dirname $@)
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -DDISTRHO_PLUGIN_TARGET_LADSPA -o $@

# --------------------------------------------------------------
# DSSI

dssi: $(dssi_dsp) $(dssi_ui)

$(dssi_dsp): $(OBJS_DSP) $(DISTRHO_PLUGIN_FILES)
mkdir -p $(shell dirname $@)
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -DDISTRHO_PLUGIN_TARGET_DSSI -o $@

$(dssi_ui): $(OBJS_UI) $(DISTRHO_UI_FILES)
mkdir -p $(shell dirname $@)
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell pkg-config --cflags --libs liblo) -DDISTRHO_PLUGIN_TARGET_DSSI -o $@

# --------------------------------------------------------------
# LV2

lv2_one: $(lv2)
lv2_sep: $(lv2_dsp) $(lv2_ui)

$(lv2): $(OBJS_DSP) $(OBJS_UI) $(DISTRHO_PLUGIN_FILES) $(DISTRHO_UI_FILES)
mkdir -p $(shell dirname $@)
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -DDISTRHO_PLUGIN_TARGET_LV2 -o $@

$(lv2_dsp): $(OBJS_DSP) $(DISTRHO_PLUGIN_FILES)
mkdir -p $(shell dirname $@)
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -DDISTRHO_PLUGIN_TARGET_LV2 -o $@

$(lv2_ui): $(OBJS_UI) $(DISTRHO_UI_FILES)
mkdir -p $(shell dirname $@)
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -DDISTRHO_PLUGIN_TARGET_LV2 -o $@

# --------------------------------------------------------------
# VST

vst: $(vst)

$(vst): $(OBJS_DSP) $(OBJS_UI) $(DISTRHO_PLUGIN_FILES) $(DISTRHO_UI_FILES)
mkdir -p $(shell dirname $@)
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -DDISTRHO_PLUGIN_TARGET_VST -o $@

# --------------------------------------------------------------

+ 39
- 0
plugins/PowerJuice/DistrhoPluginInfo.h View File

@@ -0,0 +1,39 @@
/*
* Power Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED
#define DISTRHO_PLUGIN_INFO_H_INCLUDED

#define DISTRHO_PLUGIN_NAME "PowerJuice"

#define DISTRHO_PLUGIN_HAS_UI 1
#define DISTRHO_PLUGIN_IS_SYNTH 0

#define DISTRHO_PLUGIN_NUM_INPUTS 1
#define DISTRHO_PLUGIN_NUM_OUTPUTS 1

#define DISTRHO_PLUGIN_WANT_LATENCY 0
#define DISTRHO_PLUGIN_WANT_PROGRAMS 1
#define DISTRHO_PLUGIN_WANT_STATE 0
#define DISTRHO_PLUGIN_WANT_TIMEPOS 0

// needed for spectrum
#define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 1

#define DISTRHO_PLUGIN_URI "urn:distrho:PowerJuice"

#endif // DISTRHO_PLUGIN_INFO_H_INCLUDED

+ 36
- 0
plugins/PowerJuice/Makefile View File

@@ -0,0 +1,36 @@
#!/usr/bin/make -f
# Makefile for DISTRHO Plugins #
# ---------------------------- #
# Created by falkTX
#

# --------------------------------------------------------------
# Project name, used for binaries

NAME = PowerJuice

# --------------------------------------------------------------
# Files to build

OBJS_DSP = \
PowerJuicePlugin.cpp.o

OBJS_UI = \
PowerJuiceArtwork.cpp.o \
PowerJuiceUI.cpp.o

# --------------------------------------------------------------
# Do some magic

include ../Makefile.mk

# --------------------------------------------------------------
# Enable all possible plugin types

ifeq ($(LINUX),true)
all: jack lv2_one vst
else
all: lv2_one vst
endif

# --------------------------------------------------------------

+ 12222
- 0
plugins/PowerJuice/PowerJuiceArtwork.cpp
File diff suppressed because it is too large
View File


+ 35
- 0
plugins/PowerJuice/PowerJuiceArtwork.hpp View File

@@ -0,0 +1,35 @@
/* (Auto-generated binary data file). */

#ifndef BINARY_POWERJUICEARTWORK_HPP
#define BINARY_POWERJUICEARTWORK_HPP

namespace PowerJuiceArtwork
{
extern const char* aboutData;
const unsigned int aboutDataSize = 180000;
const unsigned int aboutWidth = 300;
const unsigned int aboutHeight = 200;

extern const char* aboutButtonHoverData;
const unsigned int aboutButtonHoverDataSize = 5888;
const unsigned int aboutButtonHoverWidth = 92;
const unsigned int aboutButtonHoverHeight = 16;

extern const char* aboutButtonNormalData;
const unsigned int aboutButtonNormalDataSize = 5888;
const unsigned int aboutButtonNormalWidth = 92;
const unsigned int aboutButtonNormalHeight = 16;

extern const char* backgroundData;
const unsigned int backgroundDataSize = 571956;
const unsigned int backgroundWidth = 619;
const unsigned int backgroundHeight = 308;

extern const char* knobData;
const unsigned int knobDataSize = 10404;
const unsigned int knobWidth = 51;
const unsigned int knobHeight = 51;
}

#endif // BINARY_POWERJUICEARTWORK_HPP


+ 379
- 0
plugins/PowerJuice/PowerJuicePlugin.cpp View File

@@ -0,0 +1,379 @@
/*
* Power Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
#include "PowerJuicePlugin.hpp"
//#include <cstring>
#include <cstdlib>
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
PowerJuicePlugin::PowerJuicePlugin()
: Plugin(paramCount, 1, 0) // 1 program, 0 states
{
// set default values
d_setProgram(0);
// reset
d_deactivate();
}
PowerJuicePlugin::~PowerJuicePlugin()
{
free(lookaheadStack.data);
free(RMSStack.data);
}
// -----------------------------------------------------------------------
// Init
void PowerJuicePlugin::d_initParameter(uint32_t index, Parameter& parameter)
{
switch (index)
{
case paramAttack:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Attack";
parameter.symbol = "att";
parameter.unit = "ms";
parameter.ranges.def = 20.0f;
parameter.ranges.min = 0.1f;
parameter.ranges.max = 1000.0f;
break;
case paramRelease:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Release";
parameter.symbol = "rel";
parameter.unit = "ms";
parameter.ranges.def = 200.0f;
parameter.ranges.min = 0.1f;
parameter.ranges.max = 1000.0f;
break;
case paramThreshold:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Threshold";
parameter.symbol = "thr";
parameter.unit = "dB";
parameter.ranges.def = 0.0f;
parameter.ranges.min = -60.0f;
parameter.ranges.max = 0.0f;
break;
case paramRatio:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Ratio";
parameter.symbol = "rat";
parameter.unit = "";
parameter.ranges.def = 1.0f;
parameter.ranges.min = 1.0f;
parameter.ranges.max = 10.0f;
break;
case paramMakeup:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Make-Up";
parameter.symbol = "mak";
parameter.unit = "";
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 20.0f;
break;
case paramMix:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Mix";
parameter.symbol = "Mix";
parameter.unit = "";
parameter.ranges.def = 1.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
}
}
void PowerJuicePlugin::d_initProgramName(uint32_t index, d_string& programName)
{
if (index != 0)
return;
programName = "Default";
}
// -----------------------------------------------------------------------
// Internal data
float PowerJuicePlugin::d_getParameterValue(uint32_t index) const
{
switch (index)
{
case paramAttack:
return attack;
case paramRelease:
return release;
case paramThreshold:
return threshold;
case paramRatio:
return ratio;
case paramMakeup:
return makeup;
case paramMix:
return mix;
default:
return 0.0f;
}
}
void PowerJuicePlugin::d_setParameterValue(uint32_t index, float value)
{
switch (index)
{
case paramAttack:
attack = value;
attackSamples = d_getSampleRate()*(attack/1000.0f);
break;
case paramRelease:
release = value;
releaseSamples = d_getSampleRate()*(release/1000.0f);
break;
case paramThreshold:
threshold = value;
break;
case paramRatio:
ratio = value;
break;
case paramMakeup:
makeup = value;
makeupFloat = fromDB(makeup);
break;
case paramMix:
mix = value;
break;
}
}
void PowerJuicePlugin::d_setProgram(uint32_t index)
{
if (index != 0)
return;
/* Default parameter values */
attack = 20.0f;
release = 200.0f;
threshold = 0.0f;
ratio = 1.0f;
makeup = 0.0f;
mix = 1.0f;
makeupFloat = fromDB(makeup);
attackSamples = d_getSampleRate()*(attack/1000.0f);
releaseSamples = d_getSampleRate()*(release/1000.0f);
w = 563; //waveform plane size, size of the plane in pixels;
w2 = 1126; //wavefowm array
h = 121; //waveform plane height
x = 27; //waveform plane positions
y = 53;
dc = 113; //0DC line y position
/* Default variable values */
averageCounter = 0;
inputMax = 0.0f;
balancer = 1.0f;
GR = 1.0f;
newRepaint = false;
input.start = 0;
rms.start = 0;
gainReduction.start = 0;
RMSStack.start = 0;
lookaheadStack.start = 0;
repaintSkip = 0;
kFloatRMSStackCount = 400.0f/44100.0f*d_getSampleRate();
RMSStack.data = (float*) calloc(kFloatRMSStackCount, sizeof(float));
kFloatLookaheadStackCount = 800.0f/44100.0f*d_getSampleRate();
lookaheadStack.data = (float*) calloc(kFloatLookaheadStackCount, sizeof(float));
refreshSkip= 300.0f/44100.0f*d_getSampleRate();
std::memset(rms.data, 0, sizeof(float)*kFloatStackCount);
std::memset(gainReduction.data, 0, sizeof(float)*kFloatStackCount);
std::memset(RMSStack.data, 0, sizeof(float)*kFloatRMSStackCount);
std::memset(lookaheadStack.data, 0, sizeof(float)*kFloatLookaheadStackCount);
for (int j=0; j < kFloatStackCount; ++j)
history.rms[j] = h +y;
for (int j=0; j < kFloatStackCount; ++j)
history.gainReduction[j] = h +y;
d_activate();
}
float PowerJuicePlugin::getRMSHistory(int n) {
return history.rms[n];
}
bool PowerJuicePlugin::repaintNeeded() {
return newRepaint;
}
float PowerJuicePlugin::getGainReductionHistory(int n) {
if (n == kFloatStackCount-1) {
newRepaint = false;
//printf("falsing!\n");
}
return history.gainReduction[n];
}
// -----------------------------------------------------------------------
// Process
void PowerJuicePlugin::d_activate()
{
}
void PowerJuicePlugin::d_deactivate()
{
// all values to zero
}
void PowerJuicePlugin::d_run(const float** inputs, float** outputs, uint32_t frames)
{
const float* in = inputs[0];
float* out = outputs[0];
float sum;
float data;
float difference;
for (uint32_t i=0; i < frames; i++) {
sum = 0.0f;
data = 0.0f;
difference = 0;
//sanitizeDenormal(in[i]); // FIXME - you cannot modify inputs
/* compute last RMS */
//store audio samples in an RMS buffer line
RMSStack.data[RMSStack.start++] = in[i];
if (RMSStack.start == kFloatRMSStackCount)
RMSStack.start = 0;
//compute RMS over last kFloatRMSStackCount samples
for (int j=0; j < kFloatRMSStackCount; ++j) {
data = RMSStack.data[(RMSStack.start+j) % kFloatRMSStackCount];
sum += data * data;
}
//root mean SQUARE
float RMS = sqrt(sum / kFloatRMSStackCount);
sanitizeDenormal(RMS);
/* compute gain reduction if needed */
float RMSDB = toDB(RMS);
if (RMSDB>threshold) {
//attack stage
float difference = (RMSDB-threshold);
//sanitizeDenormal(difference);
targetGR = difference - difference/ratio;
if (targetGR>difference/(ratio/4.0f)) {
targetGR = difference - difference/(ratio*1.5f);
//more power!
}
//
if (GR<targetGR) {
//approach targetGR at attackSamples rate
GR -= (GR-targetGR)/(attackSamples);
} else {
//approach targetGR at releaseSamples rate
GR -= (GR-targetGR)/releaseSamples;
}
sanitizeDenormal(GR);
} else {
//release stage
//approach targetGR at releaseSamples rate, targetGR = 0.0f
GR -= GR/releaseSamples;
}
//store audio in lookahead buffer
lookaheadStack.data[lookaheadStack.start++] = in[i];
//printf("rms\n");
if (lookaheadStack.start == kFloatLookaheadStackCount)
lookaheadStack.start = 0;
if (++averageCounter >= refreshSkip) {
//add relevant values to the shared memory
rms.data[rms.start++] = RMSDB;
gainReduction.data[gainReduction.start++] = GR;
//rewind stack reading heads if needed
if (rms.start == kFloatStackCount)
rms.start = 0;
if (gainReduction.start == kFloatStackCount)
gainReduction.start = 0;
//saving in gfx format, for speed
//share memory
for (int j=0; j < kFloatStackCount; ++j)
history.rms[j] = -toIEC(rms.data[(rms.start+j) % kFloatStackCount])/200*h +h +y;
for (int j=0; j < kFloatStackCount; ++j) {
history.gainReduction[j] = -toIEC(-gainReduction.data[(gainReduction.start+j) % kFloatStackCount])/200*h +h +y;
}
repaintSkip++;
if (repaintSkip>5) {
repaintSkip = 0;
newRepaint = true;
}
averageCounter = 0;
inputMax = 0.0f;
}
/* compress, mix, done. */
float compressedSignal = in[i]*fromDB(-GR);
out[i] = (compressedSignal*makeupFloat*mix)+in[i]*(1-mix);
}
}
// -----------------------------------------------------------------------
Plugin* createPlugin()
{
return new PowerJuicePlugin();
}
// -----------------------------------------------------------------------
END_NAMESPACE_DISTRHO

+ 212
- 0
plugins/PowerJuice/PowerJuicePlugin.hpp View File

@@ -0,0 +1,212 @@
/*
* Power Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
#ifndef POWERJUICEPLUGIN_HPP_INCLUDED
#define POWERJUICEPLUGIN_HPP_INCLUDED
#include "DistrhoPlugin.hpp"
#include <cmath>
static const int kFloatStackCount = 563;
struct FloatStack { //history for GUI!
int32_t start;
float data[kFloatStackCount];
};
struct FloatRMSStack { //rms, sr-dependent
int32_t start;
float* data;
};
struct LookaheadStack { //lookahead buffer, sr-dependent
int32_t start;
float* data;
};
struct SharedMemData { //history for the GUI !
float rms[kFloatStackCount];
float gainReduction[kFloatStackCount];
};
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
class PowerJuicePlugin : public Plugin
{
public:
enum Parameters
{
paramAttack = 0,
paramRelease,
paramThreshold,
paramRatio,
paramMakeup,
paramMix,
paramCount
};
PowerJuicePlugin();
~PowerJuicePlugin() override;
protected:
// -------------------------------------------------------------------
// Information
const char* d_getLabel() const noexcept override
{
return "PowerJuice";
}
const char* d_getMaker() const noexcept override
{
return "Andre Sklenar";
}
const char* d_getLicense() const noexcept override
{
return "GPL v2+";
}
uint32_t d_getVersion() const noexcept override
{
return 0x1000;
}
long d_getUniqueId() const noexcept override
{
return d_cconst('P', 'w', 'r', 'J');
}
// -------------------------------------------------------------------
// Init
void d_initParameter(uint32_t index, Parameter& parameter) override;
void d_initProgramName(uint32_t index, d_string& programName) override;
// -------------------------------------------------------------------
// Internal data
float d_getParameterValue(uint32_t index) const override;
void d_setParameterValue(uint32_t index, float value) override;
void d_setProgram(uint32_t index) override;
// -------------------------------------------------------------------
// Process
void d_activate() override;
void d_deactivate() override;
void d_run(const float** inputs, float** outputs, uint32_t frames) override;
// -------------------------------------------------------------------
private:
// params
float attack, release, threshold, ratio, makeup, mix;
float attackSamples, releaseSamples, makeupFloat;
float balancer;
float targetGR;
float GR;
SharedMemData history;
float sum;
float data;
float difference;
int w; //waveform plane size, size of the plane in pixels;
int w2; //wavefowm array
int h; //waveform plane height
int x; //waveform plane positions
int y;
int dc; //0DC line y position
int kFloatRMSStackCount;
int kFloatLookaheadStackCount;
float refreshSkip;
int averageCounter;
float inputMax;
FloatStack input, rms, gainReduction;
struct FloatRMSStack RMSStack;
struct LookaheadStack lookaheadStack;
bool newRepaint;
int repaintSkip;
float fromDB(float gdb) {
return (std::exp(gdb/20.f*std::log(10.f)));
};
float toDB(float g) {
return (20.f*std::log10(g));
}
float toIEC(float db) {
float def = 0.0f; /* Meter deflection %age */
if (db < -70.0f) {
def = 0.0f;
} else if (db < -60.0f) {
def = (db + 70.0f) * 0.25f;
} else if (db < -50.0f) {
def = (db + 60.0f) * 0.5f + 5.0f;
} else if (db < -40.0f) {
def = (db + 50.0f) * 0.75f + 7.5;
} else if (db < -30.0f) {
def = (db + 40.0f) * 1.5f + 15.0f;
} else if (db < -20.0f) {
def = (db + 30.0f) * 2.0f + 30.0f;
} else if (db < 0.0f) {
def = (db + 20.0f) * 2.5f + 50.0f;
} else {
def = 100.0f;
}
return (def * 2.0f);
}
bool isNan(float& value ) {
if (((*(uint32_t *) &value) & 0x7fffffff) > 0x7f800000) {
return true;
}
return false;
}
void sanitizeDenormal(float& value) {
if (isNan(value)) {
//std::printf("Booo!\n");
value = 0.f;
}
}
public:
//methods
float getRMSHistory(int n);
float getGainReductionHistory(int n);
bool repaintNeeded();
};
// -----------------------------------------------------------------------
END_NAMESPACE_DISTRHO
#endif // POWERJUICE_HPP_INCLUDED

+ 307
- 0
plugins/PowerJuice/PowerJuiceUI.cpp View File

@@ -0,0 +1,307 @@
/*
* Power Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#include "PowerJuiceUI.hpp"

#include <cstdlib>
#include <ctime>

using DGL::Point;

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

PowerJuiceUI::PowerJuiceUI()
: UI(),
fAboutWindow(this),
dsp((PowerJuicePlugin*)d_getPluginInstancePointer())
{
DISTRHO_SAFE_ASSERT(dsp != nullptr);

// background
fImgBackground = Image(PowerJuiceArtwork::backgroundData, PowerJuiceArtwork::backgroundWidth, PowerJuiceArtwork::backgroundHeight, GL_BGR);

// about
Image imageAbout(PowerJuiceArtwork::aboutData, PowerJuiceArtwork::aboutWidth, PowerJuiceArtwork::aboutHeight, GL_BGR);
fAboutWindow.setImage(imageAbout);

// knobs
Image knobImage(PowerJuiceArtwork::knobData, PowerJuiceArtwork::knobWidth, PowerJuiceArtwork::knobHeight);

// knob Attack
fKnobAttack = new ImageKnob(this, knobImage);
fKnobAttack->setAbsolutePos(37, 213);
fKnobAttack->setRange(0.1f, 1000.0f);
fKnobAttack->setStep(0.1f);
fKnobAttack->setValue(20.0f);
fKnobAttack->setRotationAngle(270);
fKnobAttack->setCallback(this);

// knob Release
fKnobRelease = new ImageKnob(this, knobImage);
fKnobRelease->setAbsolutePos(136, 213);
fKnobRelease->setRange(0.1f, 1000.0f);
fKnobRelease->setValue(0.1f);
fKnobRelease->setRotationAngle(270);
fKnobRelease->setCallback(this);

// knob Threshold
fKnobThreshold = new ImageKnob(this, knobImage);
fKnobThreshold->setAbsolutePos(235, 213);
fKnobThreshold->setRange(-60.0f, 0.0f);
fKnobThreshold->setValue(0.0f);
fKnobThreshold->setRotationAngle(270);
fKnobThreshold->setCallback(this);

// knob Ratio
fKnobRatio = new ImageKnob(this, knobImage);
fKnobRatio->setAbsolutePos(334, 213);
fKnobRatio->setRange(1.0f, 10.0f);
fKnobRatio->setValue(1.0f);
fKnobRatio->setRotationAngle(270);
fKnobRatio->setCallback(this);

// knob Make-Up
fKnobMakeup = new ImageKnob(this, knobImage);
fKnobMakeup->setAbsolutePos(433, 213);
fKnobMakeup->setRange(0.0f, 20.0f);
fKnobMakeup->setValue(0.0f);
fKnobMakeup->setRotationAngle(270);
fKnobMakeup->setCallback(this);

// knob Mix
fKnobMix = new ImageKnob(this, knobImage);
fKnobMix->setAbsolutePos(532, 213);
fKnobMix->setRange(0.0f, 1.0f);
fKnobMix->setValue(1.0f);
fKnobMix->setRotationAngle(270);
fKnobMix->setCallback(this);

// about button
Image aboutImageNormal(PowerJuiceArtwork::aboutButtonNormalData, PowerJuiceArtwork::aboutButtonNormalWidth, PowerJuiceArtwork::aboutButtonNormalHeight);
Image aboutImageHover(PowerJuiceArtwork::aboutButtonHoverData, PowerJuiceArtwork::aboutButtonHoverWidth, PowerJuiceArtwork::aboutButtonHoverHeight);
fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
fButtonAbout->setAbsolutePos(502, 17);
fButtonAbout->setCallback(this);

// set default values
d_programChanged(0);
}

// -----------------------------------------------------------------------
// DSP Callbacks

void PowerJuiceUI::d_parameterChanged(uint32_t index, float value)
{
switch (index)
{
case PowerJuicePlugin::paramAttack:
fKnobAttack->setValue(value);
break;
case PowerJuicePlugin::paramRelease:
fKnobRelease->setValue(value);
break;
case PowerJuicePlugin::paramThreshold:
fKnobThreshold->setValue(value);
break;
case PowerJuicePlugin::paramRatio:
fKnobRatio->setValue(value);
break;
case PowerJuicePlugin::paramMakeup:
fKnobMakeup->setValue(value);
break;
case PowerJuicePlugin::paramMix:
fKnobMix->setValue(value);
break;
}
}

void PowerJuiceUI::d_programChanged(uint32_t index)
{
if (index != 0)
return;

// Default values
fKnobAttack->setValue(20.0f);
fKnobRelease->setValue(200.0f);
fKnobThreshold->setValue(0.0f);
fKnobRatio->setValue(1.0f);
fKnobMakeup->setValue(0.0f);
fKnobMix->setValue(1.0f);
}

// -----------------------------------------------------------------------
// Widget Callbacks

void PowerJuiceUI::imageButtonClicked(ImageButton* button, int)
{
if (button != fButtonAbout)
return;

fAboutWindow.exec();
}

void PowerJuiceUI::imageKnobDragStarted(ImageKnob* knob)
{
if (knob == fKnobAttack)
d_editParameter(PowerJuicePlugin::paramAttack, true);
else if (knob == fKnobRelease)
d_editParameter(PowerJuicePlugin::paramRelease, true);
else if (knob == fKnobThreshold)
d_editParameter(PowerJuicePlugin::paramThreshold, true);
else if (knob == fKnobRatio)
d_editParameter(PowerJuicePlugin::paramRatio, true);
else if (knob == fKnobMakeup)
d_editParameter(PowerJuicePlugin::paramMakeup, true);
else if (knob == fKnobMix)
d_editParameter(PowerJuicePlugin::paramMix, true);
}

void PowerJuiceUI::imageKnobDragFinished(ImageKnob* knob)
{
if (knob == fKnobAttack)
d_editParameter(PowerJuicePlugin::paramAttack, false);
else if (knob == fKnobRelease)
d_editParameter(PowerJuicePlugin::paramRelease, false);
else if (knob == fKnobThreshold)
d_editParameter(PowerJuicePlugin::paramThreshold, false);
else if (knob == fKnobRatio)
d_editParameter(PowerJuicePlugin::paramRatio, false);
else if (knob == fKnobMakeup)
d_editParameter(PowerJuicePlugin::paramMakeup, false);
else if (knob == fKnobMix)
d_editParameter(PowerJuicePlugin::paramMix, false);
}

void PowerJuiceUI::imageKnobValueChanged(ImageKnob* knob, float value)
{
if (knob == fKnobAttack)
d_setParameterValue(PowerJuicePlugin::paramAttack, value);
else if (knob == fKnobRelease)
d_setParameterValue(PowerJuicePlugin::paramRelease, value);
else if (knob == fKnobThreshold)
d_setParameterValue(PowerJuicePlugin::paramThreshold, value);
else if (knob == fKnobRatio)
d_setParameterValue(PowerJuicePlugin::paramRatio, value);
else if (knob == fKnobMakeup)
d_setParameterValue(PowerJuicePlugin::paramMakeup, value);
else if (knob == fKnobMix)
d_setParameterValue(PowerJuicePlugin::paramMix, value);

}

void PowerJuiceUI::d_uiIdle()
{
if (dsp != nullptr && dsp->repaintNeeded())
repaint();
}

void PowerJuiceUI::onDisplay()
{
fImgBackground.draw();

if (dsp == nullptr)
return;

int w = 563; //waveform plane size, size of the plane in pixels;
int w2 = 1126; //wavefowm array
int h = 121; //waveform plane height
int x = 27; //waveform plane positions
int y = 53;
int dc = 113; //0DC line y position


glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);



float thresholdPosition = (-toIEC(fKnobThreshold->getValue()))/200*h+h+y;

//draw waveform
/*
glColor4f(0.0f, 1.0f, 0.0f, 0.4f);
glLineWidth(1.2f);
for (int i=0; i<w; i++) {

glBegin(GL_LINES);
glVertex2i(x+i, -toIEC(shmData->input[i])/200*h+h+y);
glVertex2i(x+i, y+h);
glEnd();
}
*/
//draw RMS

glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
glLineWidth(2.0f);
glBegin(GL_LINE_STRIP);
for (int i=2; i<w; i++) {
float value = dsp->getRMSHistory(i);
if (value<thresholdPosition) {
glColor4f(0.0f, 0.5f, 0.0f, 1.0f);
} else {
glColor4f(0.0f, 0.5f, 0.2f, 1.0f);
}
glVertex2i(x+i, value);
}
glEnd();
//draw gain reduction
glColor4f(1.0f, 1.0f, 1.0f, 0.3f);
glLineWidth(3.0f);
glBegin(GL_LINES);
for (int i=2; i<w; i++) {
glColor4f(1.0f, 1.0f, 1.0f, 0.3f);
float value = dsp->getGainReductionHistory(i);
glVertex2i(x+i, value);
glVertex2i(x+i, y);

value = dsp->getRMSHistory(i);
glColor4f(0.0f, 0.5f, 0.2f, 0.1f);
glVertex2i(x+i, value);
glVertex2i(x+i, y+h);
}
glEnd();

//draw Threshold
glLineWidth(2.0f);
glColor4f(0.4f, 0.4f, 1.0f, 0.8f);
//float thresholdPosition = ((60-fKnobThreshold->getValue())/60);
glBegin(GL_LINES);
glVertex2i(x, thresholdPosition);
glVertex2i(x+w, thresholdPosition);
glEnd();

// reset color
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}

// -----------------------------------------------------------------------

UI* createUI()
{
return new PowerJuiceUI();
}

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

+ 130
- 0
plugins/PowerJuice/PowerJuiceUI.hpp View File

@@ -0,0 +1,130 @@
/*
* Power Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef POWERJUICEUI_HPP_INCLUDED
#define POWERJUICEUI_HPP_INCLUDED

#include "DistrhoUI.hpp"

#include "ImageAboutWindow.hpp"
#include "ImageButton.hpp"
#include "ImageKnob.hpp"
#include "ImageSlider.hpp"

#include "PowerJuiceArtwork.hpp"
#include "PowerJuicePlugin.hpp"

#include <cmath>

using DGL::Image;
using DGL::ImageAboutWindow;
using DGL::ImageButton;
using DGL::ImageKnob;

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

class PowerJuiceUI : public UI,
public ImageButton::Callback,
public ImageKnob::Callback
{
public:
PowerJuiceUI();

protected:
// -------------------------------------------------------------------
// Information

uint d_getWidth() const noexcept override
{
return PowerJuiceArtwork::backgroundWidth;
}

uint d_getHeight() const noexcept override
{
return PowerJuiceArtwork::backgroundHeight;
}

// -------------------------------------------------------------------
// DSP Callbacks

void d_parameterChanged(uint32_t index, float value) override;
void d_programChanged(uint32_t index) override;

// -------------------------------------------------------------------
// UI Callbacks

void d_uiIdle() override;

// -------------------------------------------------------------------
// Widget Callbacks

void imageButtonClicked(ImageButton* button, int) override;
void imageKnobDragStarted(ImageKnob* knob) override;
void imageKnobDragFinished(ImageKnob* knob) override;
void imageKnobValueChanged(ImageKnob* knob, float value) override;
void onDisplay() override;

private:
Image fImgBackground;
ImageAboutWindow fAboutWindow;

ScopedPointer<ImageKnob> fKnobAttack, fKnobRelease, fKnobThreshold;
ScopedPointer<ImageKnob> fKnobRatio, fKnobMakeup, fKnobMix;
ScopedPointer<ImageButton> fButtonAbout;

PowerJuicePlugin* const dsp;

float fromDB(float gdb) {
return (std::exp(gdb/20.f*std::log(10.f)));
};

float toDB(float g) {
return (20.f*std::log10(g));
}

float toIEC(float db) {
float def = 0.0f; /* Meter deflection %age */

if (db < -70.0f) {
def = 0.0f;
} else if (db < -60.0f) {
def = (db + 70.0f) * 0.25f;
} else if (db < -50.0f) {
def = (db + 60.0f) * 0.5f + 5.0f;
} else if (db < -40.0f) {
def = (db + 50.0f) * 0.75f + 7.5;
} else if (db < -30.0f) {
def = (db + 40.0f) * 1.5f + 15.0f;
} else if (db < -20.0f) {
def = (db + 30.0f) * 2.0f + 30.0f;
} else if (db < 0.0f) {
def = (db + 20.0f) * 2.5f + 50.0f;
} else {
def = 100.0f;
}

return (def * 2.0f);
}
};

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

#endif // POWERJUICEUI_HPP_INCLUDED

BIN
plugins/PowerJuice/artwork/about.png View File

Before After
Width: 300  |  Height: 200  |  Size: 39KB

BIN
plugins/PowerJuice/artwork/aboutButtonHover.png View File

Before After
Width: 92  |  Height: 16  |  Size: 4.0KB

BIN
plugins/PowerJuice/artwork/aboutButtonNormal.png View File

Before After
Width: 92  |  Height: 16  |  Size: 4.1KB

BIN
plugins/PowerJuice/artwork/artwork.xcf View File


BIN
plugins/PowerJuice/artwork/background.png View File

Before After
Width: 619  |  Height: 308  |  Size: 133KB

BIN
plugins/PowerJuice/artwork/knob.png View File

Before After
Width: 51  |  Height: 51  |  Size: 4.6KB

BIN
plugins/PowerJuice/artwork/knob.xcf View File


+ 39
- 0
plugins/PowerJuiceX2/DistrhoPluginInfo.h View File

@@ -0,0 +1,39 @@
/*
* Power Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED
#define DISTRHO_PLUGIN_INFO_H_INCLUDED

#define DISTRHO_PLUGIN_NAME "PowerJuiceX2"

#define DISTRHO_PLUGIN_HAS_UI 1
#define DISTRHO_PLUGIN_IS_SYNTH 0

#define DISTRHO_PLUGIN_NUM_INPUTS 2
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2

#define DISTRHO_PLUGIN_WANT_LATENCY 0
#define DISTRHO_PLUGIN_WANT_PROGRAMS 1
#define DISTRHO_PLUGIN_WANT_STATE 0
#define DISTRHO_PLUGIN_WANT_TIMEPOS 0

// needed for spectrum
#define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 1

#define DISTRHO_PLUGIN_URI "urn:distrho:PowerJuiceX2"

#endif // DISTRHO_PLUGIN_INFO_H_INCLUDED

+ 36
- 0
plugins/PowerJuiceX2/Makefile View File

@@ -0,0 +1,36 @@
#!/usr/bin/make -f
# Makefile for DISTRHO Plugins #
# ---------------------------- #
# Created by falkTX
#

# --------------------------------------------------------------
# Project name, used for binaries

NAME = PowerJuiceX2

# --------------------------------------------------------------
# Files to build

OBJS_DSP = \
PowerJuiceX2Plugin.cpp.o

OBJS_UI = \
PowerJuiceX2Artwork.cpp.o \
PowerJuiceX2UI.cpp.o

# --------------------------------------------------------------
# Do some magic

include ../Makefile.mk

# --------------------------------------------------------------
# Enable all possible plugin types

ifeq ($(LINUX),true)
all: jack lv2_one vst
else
all: lv2_one vst
endif

# --------------------------------------------------------------

+ 12222
- 0
plugins/PowerJuiceX2/PowerJuiceX2Artwork.cpp
File diff suppressed because it is too large
View File


+ 35
- 0
plugins/PowerJuiceX2/PowerJuiceX2Artwork.hpp View File

@@ -0,0 +1,35 @@
/* (Auto-generated binary data file). */

#ifndef BINARY_POWERJUICEX2ARTWORK_HPP
#define BINARY_POWERJUICEX2ARTWORK_HPP

namespace PowerJuiceX2Artwork
{
extern const char* aboutData;
const unsigned int aboutDataSize = 180000;
const unsigned int aboutWidth = 300;
const unsigned int aboutHeight = 200;

extern const char* aboutButtonHoverData;
const unsigned int aboutButtonHoverDataSize = 5888;
const unsigned int aboutButtonHoverWidth = 92;
const unsigned int aboutButtonHoverHeight = 16;

extern const char* aboutButtonNormalData;
const unsigned int aboutButtonNormalDataSize = 5888;
const unsigned int aboutButtonNormalWidth = 92;
const unsigned int aboutButtonNormalHeight = 16;

extern const char* backgroundData;
const unsigned int backgroundDataSize = 571956;
const unsigned int backgroundWidth = 619;
const unsigned int backgroundHeight = 308;

extern const char* knobData;
const unsigned int knobDataSize = 10404;
const unsigned int knobWidth = 51;
const unsigned int knobHeight = 51;
}

#endif // BINARY_POWERJUICEX2ARTWORK_HPP


+ 385
- 0
plugins/PowerJuiceX2/PowerJuiceX2Plugin.cpp View File

@@ -0,0 +1,385 @@
/*
* Power Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
#include "PowerJuiceX2Plugin.hpp"
#include <cstdlib>
#include <algorithm>
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
PowerJuiceX2Plugin::PowerJuiceX2Plugin()
: Plugin(paramCount, 1, 0) // 1 program, 0 states
{
// set default values
d_setProgram(0);
// reset
d_deactivate();
}
PowerJuiceX2Plugin::~PowerJuiceX2Plugin()
{
free(lookaheadStack.data);
free(RMSStack.data);
}
// -----------------------------------------------------------------------
// Init
void PowerJuiceX2Plugin::d_initParameter(uint32_t index, Parameter& parameter)
{
switch (index)
{
case paramAttack:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Attack";
parameter.symbol = "att";
parameter.unit = "ms";
parameter.ranges.def = 20.0f;
parameter.ranges.min = 0.1f;
parameter.ranges.max = 1000.0f;
break;
case paramRelease:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Release";
parameter.symbol = "rel";
parameter.unit = "ms";
parameter.ranges.def = 200.0f;
parameter.ranges.min = 0.1f;
parameter.ranges.max = 1000.0f;
break;
case paramThreshold:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Threshold";
parameter.symbol = "thr";
parameter.unit = "dB";
parameter.ranges.def = 0.0f;
parameter.ranges.min = -60.0f;
parameter.ranges.max = 0.0f;
break;
case paramRatio:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Ratio";
parameter.symbol = "rat";
parameter.unit = "";
parameter.ranges.def = 1.0f;
parameter.ranges.min = 1.0f;
parameter.ranges.max = 10.0f;
break;
case paramMakeup:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Make-Up";
parameter.symbol = "mak";
parameter.unit = "";
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 20.0f;
break;
case paramMix:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Mix";
parameter.symbol = "Mix";
parameter.unit = "";
parameter.ranges.def = 1.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
}
}
void PowerJuiceX2Plugin::d_initProgramName(uint32_t index, d_string& programName)
{
if (index != 0)
return;
programName = "Default";
}
// -----------------------------------------------------------------------
// Internal data
float PowerJuiceX2Plugin::d_getParameterValue(uint32_t index) const
{
switch (index)
{
case paramAttack:
return attack;
case paramRelease:
return release;
case paramThreshold:
return threshold;
case paramRatio:
return ratio;
case paramMakeup:
return makeup;
case paramMix:
return mix;
default:
return 0.0f;
}
}
void PowerJuiceX2Plugin::d_setParameterValue(uint32_t index, float value)
{
switch (index)
{
case paramAttack:
attack = value;
attackSamples = d_getSampleRate()*(attack/1000.0f);
break;
case paramRelease:
release = value;
releaseSamples = d_getSampleRate()*(release/1000.0f);
break;
case paramThreshold:
threshold = value;
break;
case paramRatio:
ratio = value;
break;
case paramMakeup:
makeup = value;
makeupFloat = fromDB(makeup);
break;
case paramMix:
mix = value;
break;
}
}
void PowerJuiceX2Plugin::d_setProgram(uint32_t index)
{
if (index != 0)
return;
/* Default parameter values */
attack = 20.0f;
release = 200.0f;
threshold = 0.0f;
ratio = 1.0f;
makeup = 0.0f;
mix = 1.0f;
makeupFloat = fromDB(makeup);
attackSamples = d_getSampleRate()*(attack/1000.0f);
releaseSamples = d_getSampleRate()*(release/1000.0f);
w = 563; //waveform plane size, size of the plane in pixels;
w2 = 1126; //wavefowm array
h = 121; //waveform plane height
x = 27; //waveform plane positions
y = 53;
dc = 113; //0DC line y position
/* Default variable values */
averageCounter = 0;
inputMax = 0.0f;
balancer = 1.0f;
GR = 1.0f;
newRepaint = false;
input.start = 0;
rms.start = 0;
gainReduction.start = 0;
RMSStack.start = 0;
lookaheadStack.start = 0;
repaintSkip = 0;
kFloatRMSStackCount = 400.0f/44100.0f*d_getSampleRate();
RMSStack.data = (float*) calloc(kFloatRMSStackCount, sizeof(float));
kFloatLookaheadStackCount = 800.0f/44100.0f*d_getSampleRate();
lookaheadStack.data = (float*) calloc(kFloatLookaheadStackCount, sizeof(float));
refreshSkip= 300.0f/44100.0f*d_getSampleRate();
std::memset(rms.data, 0, sizeof(float)*kFloatStackCount);
std::memset(gainReduction.data, 0, sizeof(float)*kFloatStackCount);
std::memset(RMSStack.data, 0, sizeof(float)*kFloatRMSStackCount);
std::memset(lookaheadStack.data, 0, sizeof(float)*kFloatLookaheadStackCount);
for (int j=0; j < kFloatStackCount; ++j)
history.rms[j] = h +y;
for (int j=0; j < kFloatStackCount; ++j)
history.gainReduction[j] = h +y;
d_activate();
}
float PowerJuiceX2Plugin::getRMSHistory(int n) {
return history.rms[n];
}
bool PowerJuiceX2Plugin::repaintNeeded() {
return newRepaint;
}
float PowerJuiceX2Plugin::getGainReductionHistory(int n) {
if (n == kFloatStackCount-1) {
newRepaint = false;
//printf("falsing!\n");
}
return history.gainReduction[n];
}
// -----------------------------------------------------------------------
// Process
void PowerJuiceX2Plugin::d_activate()
{
}
void PowerJuiceX2Plugin::d_deactivate()
{
// all values to zero
}
void PowerJuiceX2Plugin::d_run(const float** inputs, float** outputs, uint32_t frames)
{
const float* in1 = inputs[0];
const float* in2 = inputs[1];
float* out1 = outputs[0];
float* out2 = outputs[1];
float sum;
float data;
float difference;
for (uint32_t i=0; i < frames; i++) {
sum = 0.0f;
data = 0.0f;
difference = 0;
//sanitizeDenormal(in1[i]); // FIXME - you cannot modify inputs
//sanitizeDenormal(in2[i]); // FIXME - you cannot modify inputs
/* compute last RMS */
//store audio samples in an RMS buffer line
RMSStack.data[RMSStack.start++] = std::max(in1[i], in2[i]);
if (RMSStack.start == kFloatRMSStackCount)
RMSStack.start = 0;
//compute RMS over last kFloatRMSStackCount samples
for (int j=0; j < kFloatRMSStackCount; ++j) {
data = RMSStack.data[(RMSStack.start+j) % kFloatRMSStackCount];
sum += data * data;
}
//root mean SQUARE
float RMS = sqrt(sum / kFloatRMSStackCount);
sanitizeDenormal(RMS);
/* compute gain reduction if needed */
float RMSDB = toDB(RMS);
if (RMSDB>threshold) {
//attack stage
float difference = (RMSDB-threshold);
//sanitizeDenormal(difference);
targetGR = difference - difference/ratio;
if (targetGR>difference/(ratio/4.0f)) {
targetGR = difference - difference/(ratio*1.5f);
//more power!
}
//
if (GR<targetGR) {
//approach targetGR at attackSamples rate
GR -= (GR-targetGR)/(attackSamples);
} else {
//approach targetGR at releaseSamples rate
GR -= (GR-targetGR)/releaseSamples;
}
sanitizeDenormal(GR);
} else {
//release stage
//approach targetGR at releaseSamples rate, targetGR = 0.0f
GR -= GR/releaseSamples;
}
//store audio in lookahead buffer
lookaheadStack.data[lookaheadStack.start++] = std::max(in1[i], in2[i]);
//printf("rms\n");
if (lookaheadStack.start == kFloatLookaheadStackCount)
lookaheadStack.start = 0;
if (++averageCounter >= refreshSkip) {
//add relevant values to the shared memory
rms.data[rms.start++] = RMSDB;
gainReduction.data[gainReduction.start++] = GR;
//rewind stack reading heads if needed
if (rms.start == kFloatStackCount)
rms.start = 0;
if (gainReduction.start == kFloatStackCount)
gainReduction.start = 0;
//saving in gfx format, for speed
//share memory
for (int j=0; j < kFloatStackCount; ++j)
history.rms[j] = -toIEC(rms.data[(rms.start+j) % kFloatStackCount])/200*h +h +y;
for (int j=0; j < kFloatStackCount; ++j) {
history.gainReduction[j] = -toIEC(-gainReduction.data[(gainReduction.start+j) % kFloatStackCount])/200*h +h +y;
}
repaintSkip++;
if (repaintSkip>5) {
repaintSkip = 0;
newRepaint = true;
}
averageCounter = 0;
inputMax = 0.0f;
}
/* compress, mix, done. */
float realGR = fromDB(-GR);
float compressedSignal1 = in1[i]*realGR;
float compressedSignal2 = in2[i]*realGR;
out1[i] = (compressedSignal1*makeupFloat*mix)+in1[i]*(1-mix);
out2[i] = (compressedSignal2*makeupFloat*mix)+in2[i]*(1-mix);
}
}
// -----------------------------------------------------------------------
Plugin* createPlugin()
{
return new PowerJuiceX2Plugin();
}
// -----------------------------------------------------------------------
END_NAMESPACE_DISTRHO

+ 212
- 0
plugins/PowerJuiceX2/PowerJuiceX2Plugin.hpp View File

@@ -0,0 +1,212 @@
/*
* Power Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
#ifndef POWERJUICEPLUGIN_HPP_INCLUDED
#define POWERJUICEPLUGIN_HPP_INCLUDED
#include "DistrhoPlugin.hpp"
#include <cmath>
static const int kFloatStackCount = 563;
struct FloatStack { //history for GUI!
int32_t start;
float data[kFloatStackCount];
};
struct FloatRMSStack { //rms, sr-dependent
int32_t start;
float* data;
};
struct LookaheadStack { //lookahead buffer, sr-dependent
int32_t start;
float* data;
};
struct SharedMemData { //history for the GUI !
float rms[kFloatStackCount];
float gainReduction[kFloatStackCount];
};
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
class PowerJuiceX2Plugin : public Plugin
{
public:
enum Parameters
{
paramAttack = 0,
paramRelease,
paramThreshold,
paramRatio,
paramMakeup,
paramMix,
paramCount
};
PowerJuiceX2Plugin();
~PowerJuiceX2Plugin() override;
protected:
// -------------------------------------------------------------------
// Information
const char* d_getLabel() const noexcept override
{
return "PowerJuiceX2";
}
const char* d_getMaker() const noexcept override
{
return "Andre Sklenar";
}
const char* d_getLicense() const noexcept override
{
return "GPL v2+";
}
uint32_t d_getVersion() const noexcept override
{
return 0x1000;
}
long d_getUniqueId() const noexcept override
{
return d_cconst('P', 'w', 'J', 'X');
}
// -------------------------------------------------------------------
// Init
void d_initParameter(uint32_t index, Parameter& parameter) override;
void d_initProgramName(uint32_t index, d_string& programName) override;
// -------------------------------------------------------------------
// Internal data
float d_getParameterValue(uint32_t index) const override;
void d_setParameterValue(uint32_t index, float value) override;
void d_setProgram(uint32_t index) override;
// -------------------------------------------------------------------
// Process
void d_activate() override;
void d_deactivate() override;
void d_run(const float** inputs, float** outputs, uint32_t frames) override;
// -------------------------------------------------------------------
private:
// params
float attack, release, threshold, ratio, makeup, mix;
float attackSamples, releaseSamples, makeupFloat;
float balancer;
float targetGR;
float GR;
SharedMemData history;
float sum;
float data;
float difference;
int w; //waveform plane size, size of the plane in pixels;
int w2; //wavefowm array
int h; //waveform plane height
int x; //waveform plane positions
int y;
int dc; //0DC line y position
int kFloatRMSStackCount;
int kFloatLookaheadStackCount;
float refreshSkip;
int averageCounter;
float inputMax;
FloatStack input, rms, gainReduction;
struct FloatRMSStack RMSStack;
struct LookaheadStack lookaheadStack;
bool newRepaint;
int repaintSkip;
float fromDB(float gdb) {
return (std::exp(gdb/20.f*std::log(10.f)));
};
float toDB(float g) {
return (20.f*std::log10(g));
}
float toIEC(float db) {
float def = 0.0f; /* Meter deflection %age */
if (db < -70.0f) {
def = 0.0f;
} else if (db < -60.0f) {
def = (db + 70.0f) * 0.25f;
} else if (db < -50.0f) {
def = (db + 60.0f) * 0.5f + 5.0f;
} else if (db < -40.0f) {
def = (db + 50.0f) * 0.75f + 7.5;
} else if (db < -30.0f) {
def = (db + 40.0f) * 1.5f + 15.0f;
} else if (db < -20.0f) {
def = (db + 30.0f) * 2.0f + 30.0f;
} else if (db < 0.0f) {
def = (db + 20.0f) * 2.5f + 50.0f;
} else {
def = 100.0f;
}
return (def * 2.0f);
}
bool isNan(float& value ) {
if (((*(uint32_t *) &value) & 0x7fffffff) > 0x7f800000) {
return true;
}
return false;
}
void sanitizeDenormal(float& value) {
if (isNan(value)) {
//std::printf("Booo!\n");
value = 0.f;
}
}
public:
//methods
float getRMSHistory(int n);
float getGainReductionHistory(int n);
bool repaintNeeded();
};
// -----------------------------------------------------------------------
END_NAMESPACE_DISTRHO
#endif // POWERJUICE_HPP_INCLUDED

+ 307
- 0
plugins/PowerJuiceX2/PowerJuiceX2UI.cpp View File

@@ -0,0 +1,307 @@
/*
* Power Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#include "PowerJuiceX2UI.hpp"

#include <cstdlib>
#include <ctime>

using DGL::Point;

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

PowerJuiceX2UI::PowerJuiceX2UI()
: UI(),
fAboutWindow(this),
dsp((PowerJuiceX2Plugin*)d_getPluginInstancePointer())
{
DISTRHO_SAFE_ASSERT(dsp != nullptr);

// background
fImgBackground = Image(PowerJuiceX2Artwork::backgroundData, PowerJuiceX2Artwork::backgroundWidth, PowerJuiceX2Artwork::backgroundHeight, GL_BGR);

// about
Image imageAbout(PowerJuiceX2Artwork::aboutData, PowerJuiceX2Artwork::aboutWidth, PowerJuiceX2Artwork::aboutHeight, GL_BGR);
fAboutWindow.setImage(imageAbout);

// knobs
Image knobImage(PowerJuiceX2Artwork::knobData, PowerJuiceX2Artwork::knobWidth, PowerJuiceX2Artwork::knobHeight);

// knob Attack
fKnobAttack = new ImageKnob(this, knobImage);
fKnobAttack->setAbsolutePos(37, 213);
fKnobAttack->setRange(0.1f, 1000.0f);
fKnobAttack->setStep(0.1f);
fKnobAttack->setValue(20.0f);
fKnobAttack->setRotationAngle(270);
fKnobAttack->setCallback(this);

// knob Release
fKnobRelease = new ImageKnob(this, knobImage);
fKnobRelease->setAbsolutePos(136, 213);
fKnobRelease->setRange(0.1f, 1000.0f);
fKnobRelease->setValue(0.1f);
fKnobRelease->setRotationAngle(270);
fKnobRelease->setCallback(this);

// knob Threshold
fKnobThreshold = new ImageKnob(this, knobImage);
fKnobThreshold->setAbsolutePos(235, 213);
fKnobThreshold->setRange(-60.0f, 0.0f);
fKnobThreshold->setValue(0.0f);
fKnobThreshold->setRotationAngle(270);
fKnobThreshold->setCallback(this);

// knob Ratio
fKnobRatio = new ImageKnob(this, knobImage);
fKnobRatio->setAbsolutePos(334, 213);
fKnobRatio->setRange(1.0f, 10.0f);
fKnobRatio->setValue(1.0f);
fKnobRatio->setRotationAngle(270);
fKnobRatio->setCallback(this);

// knob Make-Up
fKnobMakeup = new ImageKnob(this, knobImage);
fKnobMakeup->setAbsolutePos(433, 213);
fKnobMakeup->setRange(0.0f, 20.0f);
fKnobMakeup->setValue(0.0f);
fKnobMakeup->setRotationAngle(270);
fKnobMakeup->setCallback(this);

// knob Mix
fKnobMix = new ImageKnob(this, knobImage);
fKnobMix->setAbsolutePos(532, 213);
fKnobMix->setRange(0.0f, 1.0f);
fKnobMix->setValue(1.0f);
fKnobMix->setRotationAngle(270);
fKnobMix->setCallback(this);

// about button
Image aboutImageNormal(PowerJuiceX2Artwork::aboutButtonNormalData, PowerJuiceX2Artwork::aboutButtonNormalWidth, PowerJuiceX2Artwork::aboutButtonNormalHeight);
Image aboutImageHover(PowerJuiceX2Artwork::aboutButtonHoverData, PowerJuiceX2Artwork::aboutButtonHoverWidth, PowerJuiceX2Artwork::aboutButtonHoverHeight);
fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
fButtonAbout->setAbsolutePos(502, 17);
fButtonAbout->setCallback(this);

// set default values
d_programChanged(0);
}

// -----------------------------------------------------------------------
// DSP Callbacks

void PowerJuiceX2UI::d_parameterChanged(uint32_t index, float value)
{
switch (index)
{
case PowerJuiceX2Plugin::paramAttack:
fKnobAttack->setValue(value);
break;
case PowerJuiceX2Plugin::paramRelease:
fKnobRelease->setValue(value);
break;
case PowerJuiceX2Plugin::paramThreshold:
fKnobThreshold->setValue(value);
break;
case PowerJuiceX2Plugin::paramRatio:
fKnobRatio->setValue(value);
break;
case PowerJuiceX2Plugin::paramMakeup:
fKnobMakeup->setValue(value);
break;
case PowerJuiceX2Plugin::paramMix:
fKnobMix->setValue(value);
break;
}
}

void PowerJuiceX2UI::d_programChanged(uint32_t index)
{
if (index != 0)
return;

// Default values
fKnobAttack->setValue(20.0f);
fKnobRelease->setValue(200.0f);
fKnobThreshold->setValue(0.0f);
fKnobRatio->setValue(1.0f);
fKnobMakeup->setValue(0.0f);
fKnobMix->setValue(1.0f);
}

// -----------------------------------------------------------------------
// Widget Callbacks

void PowerJuiceX2UI::imageButtonClicked(ImageButton* button, int)
{
if (button != fButtonAbout)
return;

fAboutWindow.exec();
}

void PowerJuiceX2UI::imageKnobDragStarted(ImageKnob* knob)
{
if (knob == fKnobAttack)
d_editParameter(PowerJuiceX2Plugin::paramAttack, true);
else if (knob == fKnobRelease)
d_editParameter(PowerJuiceX2Plugin::paramRelease, true);
else if (knob == fKnobThreshold)
d_editParameter(PowerJuiceX2Plugin::paramThreshold, true);
else if (knob == fKnobRatio)
d_editParameter(PowerJuiceX2Plugin::paramRatio, true);
else if (knob == fKnobMakeup)
d_editParameter(PowerJuiceX2Plugin::paramMakeup, true);
else if (knob == fKnobMix)
d_editParameter(PowerJuiceX2Plugin::paramMix, true);
}

void PowerJuiceX2UI::imageKnobDragFinished(ImageKnob* knob)
{
if (knob == fKnobAttack)
d_editParameter(PowerJuiceX2Plugin::paramAttack, false);
else if (knob == fKnobRelease)
d_editParameter(PowerJuiceX2Plugin::paramRelease, false);
else if (knob == fKnobThreshold)
d_editParameter(PowerJuiceX2Plugin::paramThreshold, false);
else if (knob == fKnobRatio)
d_editParameter(PowerJuiceX2Plugin::paramRatio, false);
else if (knob == fKnobMakeup)
d_editParameter(PowerJuiceX2Plugin::paramMakeup, false);
else if (knob == fKnobMix)
d_editParameter(PowerJuiceX2Plugin::paramMix, false);
}

void PowerJuiceX2UI::imageKnobValueChanged(ImageKnob* knob, float value)
{
if (knob == fKnobAttack)
d_setParameterValue(PowerJuiceX2Plugin::paramAttack, value);
else if (knob == fKnobRelease)
d_setParameterValue(PowerJuiceX2Plugin::paramRelease, value);
else if (knob == fKnobThreshold)
d_setParameterValue(PowerJuiceX2Plugin::paramThreshold, value);
else if (knob == fKnobRatio)
d_setParameterValue(PowerJuiceX2Plugin::paramRatio, value);
else if (knob == fKnobMakeup)
d_setParameterValue(PowerJuiceX2Plugin::paramMakeup, value);
else if (knob == fKnobMix)
d_setParameterValue(PowerJuiceX2Plugin::paramMix, value);

}

void PowerJuiceX2UI::d_uiIdle()
{
if (dsp != nullptr && dsp->repaintNeeded())
repaint();
}

void PowerJuiceX2UI::onDisplay()
{
fImgBackground.draw();

if (dsp == nullptr)
return;

int w = 563; //waveform plane size, size of the plane in pixels;
int w2 = 1126; //wavefowm array
int h = 121; //waveform plane height
int x = 27; //waveform plane positions
int y = 53;
int dc = 113; //0DC line y position


glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);



float thresholdPosition = (-toIEC(fKnobThreshold->getValue()))/200*h+h+y;

//draw waveform
/*
glColor4f(0.0f, 1.0f, 0.0f, 0.4f);
glLineWidth(1.2f);
for (int i=0; i<w; i++) {

glBegin(GL_LINES);
glVertex2i(x+i, -toIEC(shmData->input[i])/200*h+h+y);
glVertex2i(x+i, y+h);
glEnd();
}
*/
//draw RMS

glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
glLineWidth(2.0f);
glBegin(GL_LINE_STRIP);
for (int i=2; i<w; i++) {
float value = dsp->getRMSHistory(i);
if (value<thresholdPosition) {
glColor4f(0.0f, 0.5f, 0.0f, 1.0f);
} else {
glColor4f(0.0f, 0.5f, 0.2f, 1.0f);
}
glVertex2i(x+i, value);
}
glEnd();
//draw gain reduction
glColor4f(1.0f, 1.0f, 1.0f, 0.3f);
glLineWidth(3.0f);
glBegin(GL_LINES);
for (int i=2; i<w; i++) {
glColor4f(1.0f, 1.0f, 1.0f, 0.3f);
float value = dsp->getGainReductionHistory(i);
glVertex2i(x+i, value);
glVertex2i(x+i, y);

value = dsp->getRMSHistory(i);
glColor4f(0.0f, 0.5f, 0.2f, 0.1f);
glVertex2i(x+i, value);
glVertex2i(x+i, y+h);
}
glEnd();

//draw Threshold
glLineWidth(2.0f);
glColor4f(0.4f, 0.4f, 1.0f, 0.8f);
//float thresholdPosition = ((60-fKnobThreshold->getValue())/60);
glBegin(GL_LINES);
glVertex2i(x, thresholdPosition);
glVertex2i(x+w, thresholdPosition);
glEnd();

// reset color
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}

// -----------------------------------------------------------------------

UI* createUI()
{
return new PowerJuiceX2UI();
}

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

+ 130
- 0
plugins/PowerJuiceX2/PowerJuiceX2UI.hpp View File

@@ -0,0 +1,130 @@
/*
* Power Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef POWERJUICEUI_HPP_INCLUDED
#define POWERJUICEUI_HPP_INCLUDED

#include "DistrhoUI.hpp"

#include "ImageAboutWindow.hpp"
#include "ImageButton.hpp"
#include "ImageKnob.hpp"
#include "ImageSlider.hpp"

#include "PowerJuiceX2Artwork.hpp"
#include "PowerJuiceX2Plugin.hpp"

#include <cmath>

using DGL::Image;
using DGL::ImageAboutWindow;
using DGL::ImageButton;
using DGL::ImageKnob;

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

class PowerJuiceX2UI : public UI,
public ImageButton::Callback,
public ImageKnob::Callback
{
public:
PowerJuiceX2UI();

protected:
// -------------------------------------------------------------------
// Information

uint d_getWidth() const noexcept override
{
return PowerJuiceX2Artwork::backgroundWidth;
}

uint d_getHeight() const noexcept override
{
return PowerJuiceX2Artwork::backgroundHeight;
}

// -------------------------------------------------------------------
// DSP Callbacks

void d_parameterChanged(uint32_t index, float value) override;
void d_programChanged(uint32_t index) override;

// -------------------------------------------------------------------
// UI Callbacks

void d_uiIdle() override;

// -------------------------------------------------------------------
// Widget Callbacks

void imageButtonClicked(ImageButton* button, int) override;
void imageKnobDragStarted(ImageKnob* knob) override;
void imageKnobDragFinished(ImageKnob* knob) override;
void imageKnobValueChanged(ImageKnob* knob, float value) override;
void onDisplay() override;

private:
Image fImgBackground;
ImageAboutWindow fAboutWindow;

ScopedPointer<ImageKnob> fKnobAttack, fKnobRelease, fKnobThreshold;
ScopedPointer<ImageKnob> fKnobRatio, fKnobMakeup, fKnobMix;
ScopedPointer<ImageButton> fButtonAbout;

PowerJuiceX2Plugin* const dsp;

float fromDB(float gdb) {
return (std::exp(gdb/20.f*std::log(10.f)));
};

float toDB(float g) {
return (20.f*std::log10(g));
}

float toIEC(float db) {
float def = 0.0f; /* Meter deflection %age */

if (db < -70.0f) {
def = 0.0f;
} else if (db < -60.0f) {
def = (db + 70.0f) * 0.25f;
} else if (db < -50.0f) {
def = (db + 60.0f) * 0.5f + 5.0f;
} else if (db < -40.0f) {
def = (db + 50.0f) * 0.75f + 7.5;
} else if (db < -30.0f) {
def = (db + 40.0f) * 1.5f + 15.0f;
} else if (db < -20.0f) {
def = (db + 30.0f) * 2.0f + 30.0f;
} else if (db < 0.0f) {
def = (db + 20.0f) * 2.5f + 50.0f;
} else {
def = 100.0f;
}

return (def * 2.0f);
}
};

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

#endif // POWERJUICEUI_HPP_INCLUDED

BIN
plugins/PowerJuiceX2/artwork/about.png View File

Before After
Width: 300  |  Height: 200  |  Size: 39KB

BIN
plugins/PowerJuiceX2/artwork/aboutButtonHover.png View File

Before After
Width: 92  |  Height: 16  |  Size: 4.0KB

BIN
plugins/PowerJuiceX2/artwork/aboutButtonNormal.png View File

Before After
Width: 92  |  Height: 16  |  Size: 4.1KB

BIN
plugins/PowerJuiceX2/artwork/artwork.xcf View File


BIN
plugins/PowerJuiceX2/artwork/background.png View File

Before After
Width: 619  |  Height: 308  |  Size: 133KB

BIN
plugins/PowerJuiceX2/artwork/knob.png View File

Before After
Width: 51  |  Height: 51  |  Size: 4.6KB

BIN
plugins/PowerJuiceX2/artwork/knob.xcf View File


+ 740
- 0
plugins/StutterJuice/CModule.hxx View File

@@ -0,0 +1,740 @@
#ifndef CMODULE_HXX_INCLUDED
#define CMODULE_HXX_INCLUDED

#include <time.h> //rand
#include <algorithm> //min


// -----------------------------------------------------------------------
// SubModules
class LPF
{
private:
float r; // reso - 0.1 - 1.4
float f; // freq in Hz
float a1, a2, a3, b1, b2;
float in, in1, in2;
float out, out1, out2;
float c;
float sampleRate;
void compute() {
c = 1.0 / tan(M_PI * f / sampleRate);
a1 = 1.0 / (1.0 + r*c + c*c);
a2 = 2 * a1;
a3 = a1;
b1 = 2.0 * (1.0 - c*c) * a1;
b2 = (1.0 - r*c + c*c) * a1;
}
public:
LPF() {
r = 1.0f;
f = 0.0f;
a1=a2=a3=b1=b2=0.0f;
in=in1=in2=out=out1=out2=0.0f;
}
void setFreq(float nFreq) {
f = nFreq;
if (f==0) {
f=20;
}
}
void setReso(float nReso) {
r = nReso;
if (r==0) {
r = 0.1f;
}
}
void setSampleRate(float nSampleRate) {
sampleRate = nSampleRate;
}
float process(float sample) {
compute();
in = sample;
out = a1 * in + a2 * in1 + a3 * in2 - b1*out1 - b2*out2;
in2=in1;
in1=in;
out2=out1;
out1 = out;
return out;
}


};

class HPF
{
private:
float r; // reso - 0.1 - 1.4
float f; // freq in Hz
float a1, a2, a3, b1, b2;
float in, in1, in2;
float out, out1, out2;
float c;
float sampleRate;
void compute() {
c = tan(M_PI * f / sampleRate);
a1 = 1.0 / (1.0 + r*c + c*c);
a2 = -2*a1;
a3 = a1;
b1 = 2.0 * (c*c - 1.0) * a1;
b2 = (1.0 - r*c + c*c) * a1;
}
public:
HPF() {
r = 1.0f;
f = 0.0f;
a1=a2=a3=b1=b2=0.0f;
in=in1=in2=out=out1=out2=0.0f;
}
void setFreq(float nFreq) {
f = nFreq;
if (f==0) {
f=20;
}
}
void setReso(float nReso) {
r = nReso;
if (r==0) {
r = 0.1f;
}
}
void setSampleRate(float nSampleRate) {
sampleRate = nSampleRate;
}
float process(float sample) {
compute();
in = sample;
out = a1 * in + a2 * in1 + a3 * in2 - b1*out1 - b2*out2;
in2=in1;
in1=in;
out2=out1;
out1 = out;
return out;
}


};

class CSHIFT {

private:
float fVec0[65536];
float fRec0[2];
int IOTA;
float shiftAmt; //-12 .. 12 semi
float windowSize; // 50 .. 10k samples
float xfade; // 1 .. 10k samples
float sampleRate;
float output;
public:
CSHIFT() {
IOTA = 0;
for (int i = 0; i<65536; i++) {
fVec0[i] = 0.0f;
}
for (int i = 0; i<2; i++) {
fRec0[i] = 0.f;
}
shiftAmt = 0.1f;
windowSize = 200.0f;
xfade = 76.0f;
}
void setSampleRate(float nSampleRate) {
sampleRate = nSampleRate;
}
void setWindowSize(float nWindowSize) {
windowSize = nWindowSize;
}
void setXfade(float nXfade) {
xfade = nXfade;
}
void setShiftAmt(float nShiftAmt) {
shiftAmt = nShiftAmt;
}
float process(float audio) {
float input0 = audio;
float fSlow0 = windowSize;
float fSlow1 = ((1.f + fSlow0) - powf(2.f, (0.0833333f * shiftAmt)));
float fSlow2 = (1.f / xfade);
float fSlow3 = (fSlow0 - 1.f);

float fTemp0 = audio;
fVec0[(IOTA & 65535)] = fTemp0;
fRec0[0] = fmodf((fRec0[1] + fSlow1), fSlow0);
int iTemp1 = int(fRec0[0]);
int iTemp2 = (1 + iTemp1);
float fTemp3 = std::min((fSlow2 * fRec0[0]), 1.f);
float fTemp4 = (fRec0[0] + fSlow0);
int iTemp5 = int(fTemp4);
output = ((((fVec0[((IOTA - int((iTemp1 & 65535))) & 65535)] * (iTemp2 - fRec0[0])) + ((fRec0[0] - iTemp1) * fVec0[((IOTA - int((int(iTemp2) & 65535))) & 65535)])) * fTemp3) + (((fVec0[((IOTA - int((iTemp5 & 65535))) & 65535)] * (0.f - ((fRec0[0] + fSlow3) - float(iTemp5)))) + ((fTemp4 - float(iTemp5)) * fVec0[((IOTA - int((int((1 + iTemp5)) & 65535))) & 65535)])) * (1.f - fTemp3)));
IOTA = (IOTA + 1);
fRec0[1] = fRec0[0];
return output;
}

};

// -----------------------------------------------------------------------
// Modules

class CModule
{

public:
CModule() {
sampleRate = 0;
params[0] = 0.5f;
params[1] = 0.5f;
params[2] = 0.5f;
active = false;
sinePos = 0;
}
virtual void setParam(float value, int index) {
params[index] = value;
}
virtual void process(float &audioL, float &audioR) {}
virtual void initBuffers() {}
void setSampleRate(int nSR) {
sampleRate = nSR;
}
void activate() {
active = true;
}
void deactivate() {
active = false;
}
virtual void setSinePos(float nSinePos) {
sinePos = nSinePos;
}
virtual float getTempoDivider() {
return 1.0f;
}
float getSinePos() {
return sinePos;
}
float isActive() {
return active;
}
void resetSinePos() {
sinePos = 0;
}
float getOutputParam() {
return (sinePos/(2*M_PI));
}
protected:
//vars
float params[3];
int sampleRate;
bool active;//is open?
float getSinePhase(float x) {
return ((-std::cos(x)+1)/2);
}
float getSawPhase(float x) {
return (-((2/M_PI * std::atan(1/std::tan(x/2)))-1)/2);
}
float getRevSawPhase(float x) {
return (((2/M_PI * std::atan(1/std::tan(x/2)))+1)/2);
}
float getSquarePhase(float x) {
return (std::round((std::sin(x)+1)/2));
}
void debug() {
printf("Boo!\n");
}

//saw, sqr, sin, revSaw
float getBlendedPhase(float x, float wave)
{
wave = wave*3+1;
float waveBlend;
//wave = 2;
if (wave>=1 && wave<2) {
/* saw vs sqr */
waveBlend = wave-1;
return (getSawPhase(x)*(1-waveBlend) + getSquarePhase(x)*waveBlend);
} else if (wave>=2 && wave<3) {
/* sqr vs sin */
waveBlend = wave-2;
return (getSquarePhase(x)*(1-waveBlend) + getSinePhase(x)*waveBlend);
} else if (wave>=3 && wave<=4) {
/* sin vs revSaw */
waveBlend = wave-3;
return (getSinePhase(x)*(1-waveBlend) + getRevSawPhase(x)*waveBlend);
} else {
return 0.0f;
}
}
float sinePos;
float tAudioL, tAudioR;
};



class CGate: public CModule
{
public:
void process(float &audioL, float &audioR) {
tAudioL = audioL;
tAudioR = audioR;
tAudioL *= getBlendedPhase(sinePos, params[1]);
tAudioR *= getBlendedPhase(sinePos, params[1]);
if (active) {
audioL = tAudioL;
audioR = tAudioR;
}
}

};

class CReverse: public CModule
{
private:
//two buffers, one is playing (back), one is recording
struct BufferStack {
int32_t start;
float* data;
} bufferL[2], bufferR[2];
//buffer flipper
int flipState;
//buffer size
uint32_t bufferStackCount;
//flip record and play buffers
void flip() {
if (flipState==0) flipState = 1; else flipState = 0;
}
//which side is the play side
int getPlayFlip() {
if (flipState==0) return 1; else return 0;
}

public:
void process(float &audioL, float &audioR) {
tAudioL = audioL;
tAudioR = audioR;
//fill the buffer
bufferL[flipState].data[bufferL[flipState].start] = tAudioL;
bufferR[flipState].data[bufferR[flipState].start] = tAudioR;
//roll playhead forward
if (++bufferL[flipState].start>bufferStackCount) {
bufferL[flipState].start = 0;
}
if (++bufferR[flipState].start>bufferStackCount) {
bufferR[flipState].start = 0;
}
//play the buffer
//audio
tAudioL = bufferL[getPlayFlip()].data[bufferL[getPlayFlip()].start]*params[2] + tAudioL*(1-params[2]);
tAudioR = bufferR[getPlayFlip()].data[bufferR[getPlayFlip()].start]*params[2] + tAudioR*(1-params[2]);
//roll playhead backwards
if (--bufferL[getPlayFlip()].start<0) {
bufferL[getPlayFlip()].start = bufferStackCount;
}
if (--bufferR[getPlayFlip()].start<0) {
bufferR[getPlayFlip()].start = bufferStackCount;
}
if (active) {
audioL = tAudioL;
audioR = tAudioR;
}
}
//custom method, flip buffers when resetting sinePos
void setSinePos(float nSinePos) {
if (sinePos > nSinePos) {
flip();
}
sinePos = nSinePos;
}
void initBuffers() {
flipState = 0;
//set up a 10 second buffer
bufferStackCount = sampleRate*10;
for (int i=0; i<2; i++) {
//allocate
bufferL[i].data = (float*) calloc(bufferStackCount, sizeof(float));
bufferR[i].data = (float*) calloc(bufferStackCount, sizeof(float));
//clear with zeroes
std::memset(bufferL[i].data, 0, sizeof(float)*bufferStackCount);
std::memset(bufferR[i].data, 0, sizeof(float)*bufferStackCount);
//reset playhead
bufferL[i].start = 0;
bufferR[i].start = 0;
}
}

};

class CRepeat: public CModule
{
private:
//two buffers, one is playing (back), one is recording
struct BufferStack {
int32_t start;
float* data;
} bufferL[2], bufferR[2];
//buffer flipper
int flipState;
//buffer size
uint32_t bufferStackCount;
//flip record and play buffers
void flip() {
repeats++;
if (repeats==(round(params[1]*6)+1)) {
if (flipState==0) flipState = 1; else flipState = 0;
}
bufferL[getPlayFlip()].start = (bufferL[getPlayFlip()].start-lag) % bufferStackCount;
bufferR[getPlayFlip()].start = (bufferR[getPlayFlip()].start-lag) % bufferStackCount;
if (repeats==(round(params[1]*6)+1)) {
lag = 0;
repeats = 0;
}
}
//which side is the play side
int getPlayFlip() {
if (flipState==0) return 1; else return 0;
}
int repeats;
uint32_t lag;

public:
void process(float &audioL, float &audioR) {
tAudioL = audioL;
tAudioR = audioR;
//fill the buffer
bufferL[flipState].data[bufferL[flipState].start] = tAudioL;
bufferR[flipState].data[bufferR[flipState].start] = tAudioR;

//roll playhead forward
if (++bufferL[flipState].start>bufferStackCount) {
bufferL[flipState].start = 0;
}
if (++bufferR[flipState].start>bufferStackCount) {
bufferR[flipState].start = 0;
}
if (repeats == 0) {
lag++;
}
//play the buffer
//audio
tAudioL = bufferL[getPlayFlip()].data[bufferL[getPlayFlip()].start]*params[2] + tAudioL*(1-params[2]);
tAudioR = bufferR[getPlayFlip()].data[bufferR[getPlayFlip()].start]*params[2] + tAudioR*(1-params[2]);
//roll playhead forward
if (++bufferL[getPlayFlip()].start>bufferStackCount) {
bufferL[getPlayFlip()].start = 0;
}
if (++bufferR[getPlayFlip()].start>bufferStackCount) {
bufferR[getPlayFlip()].start = 0;
}
if (active) {
audioL = tAudioL;
audioR = tAudioR;
}
}
//custom method, flip buffers when resetting sinePos
void setSinePos(float nSinePos) {
if (sinePos > nSinePos) {
flip();
}
sinePos = nSinePos;
}
void setParam(float value, int index) {
params[index] = value;
repeats = 0;
}
void initBuffers() {
repeats = 0;
flipState = 0;
lag = 0;
//set up a 10 second buffer
bufferStackCount = sampleRate*10;
for (int i=0; i<2; i++) {
//allocate
bufferL[i].data = (float*) calloc(bufferStackCount, sizeof(float));
bufferR[i].data = (float*) calloc(bufferStackCount, sizeof(float));
//clear with zeroes
std::memset(bufferL[i].data, 0, sizeof(float)*bufferStackCount);
std::memset(bufferR[i].data, 0, sizeof(float)*bufferStackCount);
//reset playhead
bufferL[i].start = 0;
bufferR[i].start = 0;
}
}

};

class CSequence: public CModule
{
private:
LPF lpf[2];
HPF hpf[2];
float sequence[9][8] = {
{200.0f, 400.0f, 600.0f, 800.0f, 200.0f, 400.0f, 600.0f, 800.0f}, //1
{800.0f, 200.0f, 400.0f, 800.0f, 200.0f, 800.0f, 400.0f, 200.0f}, //2
{800.0f, 600.0f, 400.0f, 200.0f, 300.0f, 400.0f, 600.0f, 800.0f}, //3
{200.0f, 800.0f, 200.0f, 600.0f, 200.0f, 400.0f, 200.0f, 300.0f}, //4
{200.0f, 800.0f, 200.0f, 800.0f, 200.0f, 400.0f, 600.0f, 800.0f}, //5
{800.0f, 400.0f, 800.0f, 200.0f, 800.0f, 400.0f, 200.0f, 400.0f}, //6
{400.0f, 800.0f, 200.0f, 800.0f, 200.0f, 800.0f, 400.0f, 300.0f}, //7
{200.0f, 800.0f, 200.0f, 800.0f, 200.0f, 800.0f, 300.0f, 500.0f}, //8
{800.0f, 300.0f, 200.0f, 800.0f, 300.0f, 200.0f, 400.0f, 600.0f}, //9
};
int sequenceHead;
float peakFreq;

public:
void process(float &audioL, float &audioR) {
tAudioL = audioL;
tAudioR = audioR;
lpf[0].setFreq(peakFreq*2);
lpf[1].setFreq(peakFreq*2);
hpf[0].setFreq(peakFreq);
hpf[1].setFreq(peakFreq);
tAudioL = lpf[0].process(tAudioL);
tAudioR = lpf[1].process(tAudioR);
tAudioL = hpf[0].process(tAudioL);
tAudioR = hpf[1].process(tAudioR);
if (active) {
audioL = tAudioL;
audioR = tAudioR;
}
}
//custom method, move sequenceHead when needed
void setSinePos(float nSinePos) {
if (sinePos > nSinePos) {
sequenceHead++;
if (sequenceHead>7) {
sequenceHead = 0;
}
peakFreq = sequence[(int) round(params[1]*8)][sequenceHead];
peakFreq += (rand() % 400 - 200)*params[2];
peakFreq*=2;
}
sinePos = nSinePos;
}
void initBuffers() {
srand (time(NULL));
sequenceHead = 0;
peakFreq = 200.0f;
for (int i=0; i<2; i++) {
lpf[i].setSampleRate(sampleRate);
lpf[i].setReso(0.5);
hpf[i].setSampleRate(sampleRate);
hpf[i].setReso(0.5);
}
}

};

class CShift: public CModule
{
private:
CSHIFT shifter[2];
public:
void process(float &audioL, float &audioR) {
tAudioL = audioL;
tAudioR = audioR;
float range = 96*params[1];
int variation = round(params[2]*3)+1;
float shiftAmt;
switch (variation) {
case 1:
shiftAmt = (sinePos/(M_PI*2))*range-range/2;
break;
case 2:
shiftAmt = -((sinePos/(M_PI*2))*range-range/2);
break;
case 3:
shiftAmt = (sinePos/(M_PI*2))*range;
break;
case 4:
shiftAmt = -(sinePos/(M_PI*2))*range;
break;
}
//round up to one decimal point
shiftAmt = round(shiftAmt*10)/10;

for (int i=0; i<2; i++) {
shifter[i].setShiftAmt(shiftAmt);
}
//shift!
tAudioL = shifter[0].process(tAudioL);
tAudioR = shifter[1].process(tAudioR);
if (active) {
audioL = tAudioL;
audioR = tAudioR;
}
}
void initBuffers() {
for (int i=0; i<2; i++) {
shifter[i].setSampleRate(sampleRate);
}
}
float getTempoDivider() {
return 8.0f;
}

};

class CFilter: public CModule
{
private:
LPF lpf[2];
HPF hpf[2];
float peakFreq;

public:
void process(float &audioL, float &audioR) {
tAudioL = audioL;
tAudioR = audioR;
//to log scale
peakFreq = std::exp((std::log(16000)-std::log(300))*getBlendedPhase(sinePos, params[1])+std::log(300));
//peakFreq = 500.0f;
lpf[0].setFreq(peakFreq);
lpf[1].setFreq(peakFreq);
hpf[0].setFreq(peakFreq);
hpf[1].setFreq(peakFreq);
int type = params[2]*2+1;
switch (type) {
case 1:
tAudioL = lpf[0].process(tAudioL);
tAudioR = lpf[1].process(tAudioR);
//printf("type: %f\n", tAudioL);
break;
case 2:
tAudioL = lpf[0].process(tAudioL);
tAudioR = lpf[1].process(tAudioR);
tAudioL = hpf[0].process(tAudioL);
tAudioR = hpf[1].process(tAudioR);
break;
case 3:
tAudioL = hpf[0].process(tAudioL);
tAudioR = hpf[1].process(tAudioR);
break;
}
if (active) {
audioL = tAudioL;
audioR = tAudioR;
}
}
void initBuffers() {
peakFreq = 200.0f;
for (int i=0; i<2; i++) {
lpf[i].setSampleRate(sampleRate);
lpf[i].setReso(0.5);
hpf[i].setSampleRate(sampleRate);
hpf[i].setReso(0.5);
}
}
float getTempoDivider() {
return 8.0f;
}

};


#endif // CMODULE_HXX_INCLUDED

+ 36
- 0
plugins/StutterJuice/DistrhoPluginInfo.h View File

@@ -0,0 +1,36 @@
/*
* Trigger Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED
#define DISTRHO_PLUGIN_INFO_H_INCLUDED

#define DISTRHO_PLUGIN_NAME "StutterJuice"

#define DISTRHO_PLUGIN_HAS_UI 1
#define DISTRHO_PLUGIN_IS_SYNTH 1

#define DISTRHO_PLUGIN_NUM_INPUTS 2
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2

#define DISTRHO_PLUGIN_WANT_LATENCY 0
#define DISTRHO_PLUGIN_WANT_PROGRAMS 1
#define DISTRHO_PLUGIN_WANT_STATE 0
#define DISTRHO_PLUGIN_WANT_TIMEPOS 1

#define DISTRHO_PLUGIN_URI "urn:distrho:StutterJuice"

#endif // DISTRHO_PLUGIN_INFO_H_INCLUDED

+ 36
- 0
plugins/StutterJuice/Makefile View File

@@ -0,0 +1,36 @@
#!/usr/bin/make -f
# Makefile for DISTRHO Plugins #
# ---------------------------- #
# Created by falkTX
#

# --------------------------------------------------------------
# Project name, used for binaries

NAME = StutterJuice

# --------------------------------------------------------------
# Files to build

OBJS_DSP = \
StutterJuicePlugin.cpp.o

OBJS_UI = \
StutterJuiceArtwork.cpp.o \
StutterJuiceUI.cpp.o

# --------------------------------------------------------------
# Do some magic

include ../Makefile.mk

# --------------------------------------------------------------
# Enable all possible plugin types

ifeq ($(LINUX),true)
all: jack lv2_sep vst
else
all: lv2_sep vst
endif

# --------------------------------------------------------------

+ 32814
- 0
plugins/StutterJuice/StutterJuiceArtwork.cpp
File diff suppressed because it is too large
View File


+ 45
- 0
plugins/StutterJuice/StutterJuiceArtwork.hpp View File

@@ -0,0 +1,45 @@
/* (Auto-generated binary data file). */

#ifndef BINARY_STUTTERJUICEARTWORK_HPP
#define BINARY_STUTTERJUICEARTWORK_HPP

namespace StutterJuiceArtwork
{
extern const char* aboutData;
const unsigned int aboutDataSize = 240000;
const unsigned int aboutWidth = 300;
const unsigned int aboutHeight = 200;

extern const char* aboutButtonHoverData;
const unsigned int aboutButtonHoverDataSize = 5888;
const unsigned int aboutButtonHoverWidth = 92;
const unsigned int aboutButtonHoverHeight = 16;

extern const char* aboutButtonNormalData;
const unsigned int aboutButtonNormalDataSize = 5888;
const unsigned int aboutButtonNormalWidth = 92;
const unsigned int aboutButtonNormalHeight = 16;

extern const char* backgroundData;
const unsigned int backgroundDataSize = 933432;
const unsigned int backgroundWidth = 712;
const unsigned int backgroundHeight = 437;

extern const char* knobData;
const unsigned int knobDataSize = 10404;
const unsigned int knobWidth = 51;
const unsigned int knobHeight = 51;

extern const char* overlayData;
const unsigned int overlayDataSize = 1244576;
const unsigned int overlayWidth = 712;
const unsigned int overlayHeight = 437;

extern const char* sliderData;
const unsigned int sliderDataSize = 2600;
const unsigned int sliderWidth = 26;
const unsigned int sliderHeight = 25;
}

#endif // BINARY_STUTTERJUICEARTWORK_HPP


+ 199
- 0
plugins/StutterJuice/StutterJuicePlugin.cpp View File

@@ -0,0 +1,199 @@
/*
* Stutter Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
#include "StutterJuicePlugin.hpp"
#include <iostream>
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
StutterJuicePlugin::StutterJuicePlugin()
: Plugin(paramCount, 1, 0) // 1 program, 0 states
{
// set default values
d_setProgram(0);
// reset
d_deactivate();
}
// -----------------------------------------------------------------------
// Init
void StutterJuicePlugin::d_initParameter(uint32_t index, Parameter& parameter)
{
if (index<26) {
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "";
parameter.symbol = "";
parameter.unit = "";
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
} else {
parameter.hints = PARAMETER_IS_OUTPUT;
parameter.name = "";
parameter.symbol = "";
parameter.unit = "";
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
}
}
void StutterJuicePlugin::d_initProgramName(uint32_t index, d_string& programName)
{
if (index != 0)
return;
programName = "Default";
}
// -----------------------------------------------------------------------
// Internal data
float StutterJuicePlugin::d_getParameterValue(uint32_t index) const
{
if (index<26) {
int module = index/3;
int param = index%3;
return params[module][param];
} else {
return outputParams[index-26];
}
}
void StutterJuicePlugin::d_setParameterValue(uint32_t index, float value)
{
int module = index/3;
int param = index%3;
params[module][param] = value;
modules[module]->setParam(value, param);
if (param ==2) {
//modules[module]->resetSinePos();
}
}
void StutterJuicePlugin::d_setProgram(uint32_t index)
{
if (index != 0)
return;
//default params[][] values
for (int module=0; module<6; module++) {
moduleActive[module] = false;
for (int param=0; param<3; param++) {
params[module][param] = 0.5;
}
}
modules[0] = new CGate();
modules[1] = new CReverse();
modules[2] = new CRepeat();
modules[3] = new CSequence();
modules[4] = new CShift();
modules[5] = new CFilter();
for (int module=0; module<6; module++) {
modules[module]->setSampleRate(d_getSampleRate());
modules[module]->initBuffers();
}
d_activate();
}
// -----------------------------------------------------------------------
// Process
void StutterJuicePlugin::d_activate()
{
}
void StutterJuicePlugin::d_deactivate()
{
}
void StutterJuicePlugin::d_run(const float** inputs, float** outputs, uint32_t frames, const MidiEvent* midiEvents, uint32_t midiEventCount)
{
for (uint32_t i; i<frames; i++) {
float audioL = inputs[0][i];
float audioR = inputs[1][i];
rollLFOs();
prepareOutputParams();
for (int i=0; i<6; i++) {
modules[i]->process(audioL, audioR);
}
outputs[0][i] = audioL;
outputs[1][i] = audioR;
}
for (uint32_t i; i<midiEventCount; i++) {
int userNote = 48;//TODO
int range=6;
int mType = midiEvents[i].buf[0] & 0xF0;
int mChan = midiEvents[i].buf[0] & 0x0F;
int mNum = midiEvents[i].buf[1];
if (mNum>=userNote && mNum<userNote+range) {
int module = mNum-userNote;
//printf("note: %i\n", module);
if (mType == 0x90) {
//NOTE ON
moduleActive[module] = true;
modules[module]->activate();
} else if (mType == 0x80) {
//NOTE OFF
moduleActive[module] = false;
modules[module]->deactivate();
}
}
}
}
// -----------------------------------------------------------------------
Plugin* createPlugin()
{
return new StutterJuicePlugin();
}
// -----------------------------------------------------------------------
END_NAMESPACE_DISTRHO

+ 170
- 0
plugins/StutterJuice/StutterJuicePlugin.hpp View File

@@ -0,0 +1,170 @@
/*
* Stutter Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
#ifndef STUTTERJUICEPLUGIN_HPP_INCLUDED
#define STUTTERJUICEPLUGIN_HPP_INCLUDED
#include "DistrhoPlugin.hpp"
#include "CModule.hxx"
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
class StutterJuicePlugin : public Plugin
{
public:
enum Parameters
{
p1 = 0, p2, p3, p4, p5, p6, p7, p8, p9,
p11, p12, p13, p14, p15, p16, p17, p18,
p19, p20, p21, p22, p23, p24, p25, p26,
o1, o2, o3, o4, o5, o6, o7, o8, o9,
paramCount
};
void prepareOutputParams() {
for (int i=0; i<6; i++) {
if (modules[i]->isActive()) {
outputParams[i] = modules[i]->getOutputParam();
} else {
outputParams[i] = 0;
}
}
}
void rollLFOs() {
float bar, tick, tickOffset, sinePos, percentage;
for (int i=0; i<6; i++) {
sinePos = modules[i]->getSinePos();
float tempoDivider = modules[i]->getTempoDivider();
//if (i==4)
//printf("divider: %i\n", tempoDivider);
/* sample count for one bar */
const TimePos& time = d_getTimePos();
bar = ((120.0/(time.bbt.valid ? time.bbt.beatsPerMinute : 120.0))*(d_getSampleRate())); //ONE, two, three, four
tick = bar/(std::round(params[i][0]*16+2))*tempoDivider; //size of one target wob
//if (time.bbt.valid) printf("hell yeah!\n");
if (time.playing)
{
/* if rolling then sync to timepos */
tickOffset = time.frame-std::floor(time.frame/tick)*tick; //how much after last tick
if (tickOffset!=0) {
//TODO: why do we need this??
percentage = tickOffset/tick;
} else {
percentage = 0;
}
sinePos = (M_PI*2)*percentage;
if (sinePos>2*M_PI) {
//TODO: can this ever happen??
sinePos = 0;
}
}
else
{
/* else just keep on wobblin' */
sinePos += (2*M_PI)/(tick); //wtf, but works
if (sinePos>2*M_PI) {
sinePos = 0;
}
}
modules[i]->setSinePos(sinePos);
//printf("sinepos: %f\n", sinePos);
}
}
StutterJuicePlugin();
//~StutterJuicePlugin() override;
protected:
// -------------------------------------------------------------------
// Information
const char* d_getLabel() const noexcept override
{
return "StutterJuice";
}
const char* d_getMaker() const noexcept override
{
return "Andre Sklenar";
}
const char* d_getLicense() const noexcept override
{
return "GPL v2+";
}
uint32_t d_getVersion() const noexcept override
{
return 0x1000;
}
long d_getUniqueId() const noexcept override
{
return d_cconst('S', 't', 't', 'J');
}
// -------------------------------------------------------------------
// Init
void d_initParameter(uint32_t index, Parameter& parameter) override;
void d_initProgramName(uint32_t index, d_string& programName) override;
// -------------------------------------------------------------------
// Internal data
float d_getParameterValue(uint32_t index) const override;
void d_setParameterValue(uint32_t index, float value) override;
void d_setProgram(uint32_t index) override;
// -------------------------------------------------------------------
// Process
void d_activate() override;
void d_deactivate() override;
void d_run(const float** inputs, float** outputs, uint32_t frames, const MidiEvent* midiEvents, uint32_t midiEventCount) override;
// -------------------------------------------------------------------
private:
float params[9][3]; // left-> right, top->bottom
bool moduleActive[9];
float outputParams[9];
CModule* modules[9];
};
// -----------------------------------------------------------------------
END_NAMESPACE_DISTRHO
#endif // TRIGGERJUICE_HPP_INCLUDED

+ 165
- 0
plugins/StutterJuice/StutterJuiceUI.cpp View File

@@ -0,0 +1,165 @@
/*
* Stutter Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#include "StutterJuiceUI.hpp"

using DGL::Point;

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

StutterJuiceUI::StutterJuiceUI()
: UI(),
fAboutWindow(this)
{
// background
fImgBackground = Image(StutterJuiceArtwork::backgroundData, StutterJuiceArtwork::backgroundWidth, StutterJuiceArtwork::backgroundHeight, GL_BGR);

// overlay
fImgOverlay = Image(StutterJuiceArtwork::overlayData, StutterJuiceArtwork::overlayWidth, StutterJuiceArtwork::overlayHeight, GL_BGRA);

// about
Image imageAbout(StutterJuiceArtwork::aboutData, StutterJuiceArtwork::aboutWidth, StutterJuiceArtwork::aboutHeight, GL_BGRA);
fAboutWindow.setImage(imageAbout);

// about button
Image aboutImageNormal(StutterJuiceArtwork::aboutButtonNormalData, StutterJuiceArtwork::aboutButtonNormalWidth, StutterJuiceArtwork::aboutButtonNormalHeight);
Image aboutImageHover(StutterJuiceArtwork::aboutButtonHoverData, StutterJuiceArtwork::aboutButtonHoverWidth, StutterJuiceArtwork::aboutButtonHoverHeight);
fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
fButtonAbout->setAbsolutePos(358, 17);
fButtonAbout->setCallback(this);

// sliders
Image sliderImage(StutterJuiceArtwork::sliderData, StutterJuiceArtwork::sliderWidth, StutterJuiceArtwork::sliderHeight);
Point<int> sliderPosStart(293, 74);
Point<int> sliderPosEnd(293+11, 74);

int oX = 130;
int oY = 93;
int mX = 357 - oX;
int mY = 120-oY;
int mMY = 208 - oY;
int w = 235 - oX - StutterJuiceArtwork::sliderWidth;
for (int module=0; module<9; module++) {
for (int param=0; param<3; param++) {
sliderPosStart.setX(oX+(module%3)*mX);
sliderPosStart.setY(oY+(param*mY) + (int) (floor(module/3)*mMY));
sliderPosEnd.setX(sliderPosStart.getX() + w);
sliderPosEnd.setY(sliderPosStart.getY());
fSliders[module][param]= new ImageSlider(this, sliderImage);
fSliders[module][param]->setStartPos(sliderPosStart);
fSliders[module][param]->setEndPos(sliderPosEnd);
fSliders[module][param]->setRange(0.0f, 1.0f);
fSliders[module][param]->setValue(0.0f);
fSliders[module][param]->setStep(0.125f);
fSliders[module][param]->setCallback(this);
}
outputParams[module] = 0;
}

// set default values
d_programChanged(0);
}

// -----------------------------------------------------------------------
// DSP Callbacks

void StutterJuiceUI::d_parameterChanged(uint32_t index, float value)
{
if (index<26) {
int module = index/3;
int param = index%3;
fSliders[module][param]->setValue(value);
} else {
outputParams[index-26] = value;
repaint();
}
}

void StutterJuiceUI::d_programChanged(uint32_t index)
{
if (index != 0)
return;
}

// -----------------------------------------------------------------------
// Widget Callbacks

void StutterJuiceUI::imageButtonClicked(ImageButton* button, int)
{
if (button != fButtonAbout)
return;

fAboutWindow.exec();
}

void StutterJuiceUI::imageSliderDragStarted(ImageSlider* slider)
{
for (int module=0; module<9; module++) {
for (int param=0; param<3; param++) {
if (slider == fSliders[module][param]) {
d_editParameter(module*3+param, true);
}
}
}
}

void StutterJuiceUI::imageSliderDragFinished(ImageSlider* slider)
{
for (int module=0; module<9; module++) {
for (int param=0; param<3; param++) {
if (slider == fSliders[module][param]) {
d_editParameter(module*3+param, false);
}
}
}
}

void StutterJuiceUI::imageSliderValueChanged(ImageSlider* slider, float value)
{
for (int module=0; module<9; module++) {
for (int param=0; param<3; param++) {
if (slider == fSliders[module][param]) {
d_setParameterValue(module*3+param, value);
}
}
}
}

void StutterJuiceUI::onDisplay()
{
fImgBackground.draw();

drawLFOs();
fImgOverlay.draw();
}

// -----------------------------------------------------------------------

UI* createUI()
{
return new StutterJuiceUI();
}

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

+ 128
- 0
plugins/StutterJuice/StutterJuiceUI.hpp View File

@@ -0,0 +1,128 @@
/*
* Stutter Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef STUTTERJUICEUI_HPP_INCLUDED
#define STUTTERJUICEUI_HPP_INCLUDED

#include "DistrhoUI.hpp"

#include "Geometry.hpp"
#include "ImageAboutWindow.hpp"
#include "ImageButton.hpp"
#include "ImageKnob.hpp"
#include "ImageSlider.hpp"

#include "StutterJuiceArtwork.hpp"
#include "StutterJuicePlugin.hpp"

using DGL::Image;
using DGL::ImageAboutWindow;
using DGL::ImageButton;
using DGL::ImageKnob;
using DGL::ImageSlider;
using DGL::Rectangle;

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

class StutterJuiceUI : public UI,
public ImageButton::Callback,
public ImageSlider::Callback
{
public:
StutterJuiceUI();

protected:
// -------------------------------------------------------------------
// Information

uint d_getWidth() const noexcept override
{
return StutterJuiceArtwork::backgroundWidth;
}

uint d_getHeight() const noexcept override
{
return StutterJuiceArtwork::backgroundHeight;
}

// -------------------------------------------------------------------
// DSP Callbacks

void d_parameterChanged(uint32_t index, float value) override;
void d_programChanged(uint32_t index) override;

// -------------------------------------------------------------------
// Widget Callbacks

void imageButtonClicked(ImageButton* button, int) override;
void imageSliderDragStarted(ImageSlider* slider) override;
void imageSliderDragFinished(ImageSlider* slider) override;
void imageSliderValueChanged(ImageSlider* slider, float value) override;

void onDisplay() override;

private:
Image fImgBackground;
Image fImgOverlay;
ImageAboutWindow fAboutWindow;
float outputParams[9];
void drawLFOs() {
int oX = 18;
int oY = 67;
int wX = 223;
wX /=4;
int wY = 26;
int mX = 228;
int mY = 116;
wX = 221+2;
wY = 111;
// set color
for (int y=0; y<3; y++) {
for (int x=0; x<3; x++) {
if (outputParams[x+y*3]!=0) {
glColor4f(0.0f, 0.0f, 1.0f, 0.5f - outputParams[x+y*3]/2);
glBegin(GL_POLYGON);
glVertex2i(oX+x*mX, oY+y*mY);
glVertex2i(oX+x*mX, oY+y*mY+wY);
glVertex2i(oX+x*mX+wX, oY+y*mY+wY);
glVertex2i(oX+x*mX+wX, oY+y*mY);
glEnd();
}
}
}
// reset color
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}

//sliders
ScopedPointer<ImageSlider> fSliders[9][3];
ScopedPointer<ImageButton> fButtonAbout;
};

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

#endif // TRIGGERJUICEUI_HPP_INCLUDED

BIN
plugins/StutterJuice/artwork/about.png View File

Before After
Width: 300  |  Height: 200  |  Size: 44KB

BIN
plugins/StutterJuice/artwork/about.xcf View File


BIN
plugins/StutterJuice/artwork/aboutButtonHover.png View File

Before After
Width: 92  |  Height: 16  |  Size: 4.0KB

BIN
plugins/StutterJuice/artwork/aboutButtonNormal.png View File

Before After
Width: 92  |  Height: 16  |  Size: 4.1KB

BIN
plugins/StutterJuice/artwork/background.png View File

Before After
Width: 712  |  Height: 437  |  Size: 313KB

BIN
plugins/StutterJuice/artwork/gui.xcf View File


BIN
plugins/StutterJuice/artwork/knob.png View File

Before After
Width: 51  |  Height: 51  |  Size: 4.6KB

BIN
plugins/StutterJuice/artwork/overlay.png View File

Before After
Width: 712  |  Height: 437  |  Size: 37KB

BIN
plugins/StutterJuice/artwork/slider.png View File

Before After
Width: 26  |  Height: 25  |  Size: 785B

+ 0
- 0
plugins/StutterJuice/external/pitchshifter.cpp View File


+ 71
- 0
plugins/TriggerJuice/CStream.hxx View File

@@ -0,0 +1,71 @@
#ifndef CSTREAM_HXX_INCLUDED
#define CSTREAM_HXX_INCLUDED

class CStream
{

public:
CStream() {
sample = 0;
time = 0;
state = 0;
counter = 0;

}

void setSr(int sr) {
sampleRate = sr;
}

void open(float nTime) {//in samples
state = true;
if (counter<time) {
counter = time-counter;
} else {
counter = 0;
}
time = nTime*sampleRate;
}

void close(float nTime) {//in samples
state = false;
if (counter<time) {
counter = time-counter;
} else {
counter = 0;
}
time = nTime*sampleRate;
}

void update(float nSample) {
sample = nSample;
}

float run() {
if (state) {
if (counter<time) {
counter++;
sample*=(counter/time); //linear fade-in
} else {
sample*=1;
}
} else {
if (counter<time) {
counter++;
sample*=((time-counter)/time); //lineaar fade-out
} else {
sample=0;
}
}
return sample;
}

private:
//vars
float sample;
float time;
float counter;
int sampleRate;
bool state;//is open?
};
#endif // CSTREAM_HXX_INCLUDED

+ 36
- 0
plugins/TriggerJuice/DistrhoPluginInfo.h View File

@@ -0,0 +1,36 @@
/*
* Trigger Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED
#define DISTRHO_PLUGIN_INFO_H_INCLUDED

#define DISTRHO_PLUGIN_NAME "TriggerJuice"

#define DISTRHO_PLUGIN_HAS_UI 1
#define DISTRHO_PLUGIN_IS_SYNTH 1

#define DISTRHO_PLUGIN_NUM_INPUTS 2
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2

#define DISTRHO_PLUGIN_WANT_LATENCY 0
#define DISTRHO_PLUGIN_WANT_PROGRAMS 1
#define DISTRHO_PLUGIN_WANT_STATE 0
#define DISTRHO_PLUGIN_WANT_TIMEPOS 1

#define DISTRHO_PLUGIN_URI "urn:distrho:TriggerJuice"

#endif // DISTRHO_PLUGIN_INFO_H_INCLUDED

+ 36
- 0
plugins/TriggerJuice/Makefile View File

@@ -0,0 +1,36 @@
#!/usr/bin/make -f
# Makefile for DISTRHO Plugins #
# ---------------------------- #
# Created by falkTX
#

# --------------------------------------------------------------
# Project name, used for binaries

NAME = TriggerJuice

# --------------------------------------------------------------
# Files to build

OBJS_DSP = \
TriggerJuicePlugin.cpp.o

OBJS_UI = \
TriggerJuiceArtwork.cpp.o \
TriggerJuiceUI.cpp.o

# --------------------------------------------------------------
# Do some magic

include ../Makefile.mk

# --------------------------------------------------------------
# Enable all possible plugin types

ifeq ($(LINUX),true)
all: jack lv2_sep vst
else
all: lv2_sep vst
endif

# --------------------------------------------------------------

+ 7525
- 0
plugins/TriggerJuice/TriggerJuiceArtwork.cpp
File diff suppressed because it is too large
View File


+ 40
- 0
plugins/TriggerJuice/TriggerJuiceArtwork.hpp View File

@@ -0,0 +1,40 @@
/* (Auto-generated binary data file). */

#ifndef BINARY_TRIGGERJUICEARTWORK_HPP
#define BINARY_TRIGGERJUICEARTWORK_HPP

namespace TriggerJuiceArtwork
{
extern const char* aboutData;
const unsigned int aboutDataSize = 240000;
const unsigned int aboutWidth = 300;
const unsigned int aboutHeight = 200;

extern const char* aboutButtonHoverData;
const unsigned int aboutButtonHoverDataSize = 5888;
const unsigned int aboutButtonHoverWidth = 92;
const unsigned int aboutButtonHoverHeight = 16;

extern const char* aboutButtonNormalData;
const unsigned int aboutButtonNormalDataSize = 5888;
const unsigned int aboutButtonNormalWidth = 92;
const unsigned int aboutButtonNormalHeight = 16;

extern const char* backgroundData;
const unsigned int backgroundDataSize = 365156;
const unsigned int backgroundWidth = 473;
const unsigned int backgroundHeight = 193;

extern const char* knobData;
const unsigned int knobDataSize = 10404;
const unsigned int knobWidth = 51;
const unsigned int knobHeight = 51;

extern const char* sliderData;
const unsigned int sliderDataSize = 2600;
const unsigned int sliderWidth = 26;
const unsigned int sliderHeight = 25;
}

#endif // BINARY_TRIGGERJUICEARTWORK_HPP


+ 331
- 0
plugins/TriggerJuice/TriggerJuicePlugin.cpp View File

@@ -0,0 +1,331 @@
/*
* Trigger Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
#include "TriggerJuicePlugin.hpp"
#include <iostream>
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
TriggerJuicePlugin::TriggerJuicePlugin()
: Plugin(paramCount, 1, 0) // 1 program, 0 states
{
// set default values
d_setProgram(0);
// reset
d_deactivate();
}
TriggerJuicePlugin::~TriggerJuicePlugin()
{
}
// -----------------------------------------------------------------------
// Init
void TriggerJuicePlugin::d_initParameter(uint32_t index, Parameter& parameter)
{
switch (index)
{
case paramAttack:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Attack";
parameter.symbol = "att";
parameter.unit = "seconds";
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
case paramRelease:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Release";
parameter.symbol = "rel";
parameter.unit = "seconds";
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
case paramRev:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Reverse";
parameter.symbol = "rev";
parameter.unit = "";
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
case paramSplit:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Split";
parameter.symbol = "spl";
parameter.unit = "";
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
case paramMS:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "M/S";
parameter.symbol = "ms";
parameter.unit = "";
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
}
}
void TriggerJuicePlugin::d_initProgramName(uint32_t index, d_string& programName)
{
if (index != 0)
return;
programName = "Default";
}
// -----------------------------------------------------------------------
// Internal data
float TriggerJuicePlugin::d_getParameterValue(uint32_t index) const
{
switch (index)
{
case paramAttack:
return attack;
case paramRelease:
return release;
case paramSplit:
return split;
case paramRev:
return rev;
case paramMS:
return MS;
default:
return 0.0f;
}
}
void TriggerJuicePlugin::d_setParameterValue(uint32_t index, float value)
{
switch (index)
{
case paramSplit:
split = value;
break;
case paramRev:
rev = value;
if (rev<0.5) {
left.close(d_getSampleRate()/10); right.close(d_getSampleRate()/10);
} else {
left.open(d_getSampleRate()/10); right.open(d_getSampleRate()/10);
}
break;
case paramAttack:
attack = value;
break;
case paramRelease:
release = value;
break;
case paramMS:
MS = value;
break;
}
}
void TriggerJuicePlugin::d_setProgram(uint32_t index)
{
if (index != 0)
return;
/* Default parameter values */
split = 0.0f;
rev = 0.0f;
attack = 0.0f;
release = 0.0f;
MS = 0.0f;
/* Default variable values */
attack=release=0;
rev=split=MS=0;
left.setSr(d_getSampleRate());
right.setSr(d_getSampleRate());
//parameter smoothing
for (int i=0; i<2; i++) {
sA[i] = 0.99f;
sB[i] = 1.f - sA[i];
sZ[i] = 0;
}
/* reset filter values */
d_activate();
}
// -----------------------------------------------------------------------
// Process
void TriggerJuicePlugin::d_activate()
{
//sinePos = 0;
}
void TriggerJuicePlugin::d_deactivate()
{
// all values to zero
}
void TriggerJuicePlugin::d_run(const float** inputs, float** outputs, uint32_t frames, const MidiEvent* midiEvents, uint32_t midiEventCount)
{
for (uint32_t i; i<frames; i++) {
float inL = inputs[0][i];
float inR = inputs[1][i];
if (MS<0.5) {
//stereo mode
left.update(inL);
right.update(inR);
} else {
//M/S mode
left.update(inL+inR);
right.update(inL-inR);
}
float audioL = left.run();
float audioR = right.run();
if (MS>=0.5) {
// decode from MS
float mid = audioL;
float side = audioR;
audioL = (mid+side)/2;
audioR = (mid-side)/2;
}
outputs[0][i] = audioL;
outputs[1][i] = audioR;
}
int userNote = 64;//TODO
for (uint32_t i; i<midiEventCount; i++) {
int mType = midiEvents[i].buf[0] & 0xF0;
int mChan = midiEvents[i].buf[0] & 0x0F;
int mNum = midiEvents[i].buf[1];
if (mType == 0x90) {
//NOTE ON
std::cout << mNum << std::endl;
int mVelo = midiEvents[i].buf[2];
if (mNum == userNote) {
if (rev<0.5) {
if (split<0.5) {
//open both streams
left.open(attack);
right.open(attack);
} else {
//open just left stream
left.open(attack);
}
} else {
if (split<0.5) {
//close both streams
left.close(attack);
right.close(attack);
} else {
//close just left stream
left.close(attack);
}
}
}
if (split>=0.5) {
if (mNum == userNote+1) {
if (rev<0.5) {
//open right stream
right.open(attack);
} else {
//close right stream
right.close(attack);
}
}
}
} else if (mType == 0x80) {
//NOTE OFF
if (mNum == userNote) {
if (rev<0.5) {
if (split<0.5) {
//close both streams
left.close(release);
right.close(release);
} else {
//close just left stream
left.close(release);
}
} else {
if (split<0.5) {
//open both streams
left.open(release);
right.open(release);
} else {
//open just left stream
left.open(release);
}
}
}
if (split>=0.5) {
if (mNum == userNote+1) {
if (rev<0.5) {
//close right stream
right.close(release);
} else {
//open right stream
right.open(release);
}
}
}
}
}
}
// -----------------------------------------------------------------------
Plugin* createPlugin()
{
return new TriggerJuicePlugin();
}
// -----------------------------------------------------------------------
END_NAMESPACE_DISTRHO

+ 118
- 0
plugins/TriggerJuice/TriggerJuicePlugin.hpp View File

@@ -0,0 +1,118 @@
/*
* Trigger Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
#ifndef TRIGGERJUICEPLUGIN_HPP_INCLUDED
#define TRIGGERJUICEPLUGIN_HPP_INCLUDED
#include "DistrhoPlugin.hpp"
#include "CStream.hxx"
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
class TriggerJuicePlugin : public Plugin
{
public:
enum Parameters
{
paramAttack = 0,
paramRelease,
paramSplit,
paramRev,
paramMS,
paramCount
};
inline float smoothParameter(float in, int axis) {
sZ[axis] = (in * sB[axis]) + (sZ[axis] * sA[axis]); return sZ[axis];
}
TriggerJuicePlugin();
~TriggerJuicePlugin() override;
protected:
// -------------------------------------------------------------------
// Information
const char* d_getLabel() const noexcept override
{
return "TriggerJuice";
}
const char* d_getMaker() const noexcept override
{
return "Andre Sklenar";
}
const char* d_getLicense() const noexcept override
{
return "GPL v2+";
}
uint32_t d_getVersion() const noexcept override
{
return 0x1000;
}
long d_getUniqueId() const noexcept override
{
return d_cconst('T', 'r', 'g', 'J');
}
// -------------------------------------------------------------------
// Init
void d_initParameter(uint32_t index, Parameter& parameter) override;
void d_initProgramName(uint32_t index, d_string& programName) override;
// -------------------------------------------------------------------
// Internal data
float d_getParameterValue(uint32_t index) const override;
void d_setParameterValue(uint32_t index, float value) override;
void d_setProgram(uint32_t index) override;
// -------------------------------------------------------------------
// Process
void d_activate() override;
void d_deactivate() override;
void d_run(const float** inputs, float** outputs, uint32_t frames, const MidiEvent* midiEvents, uint32_t midiEventCount) override;
// -------------------------------------------------------------------
private:
CStream left, right;
float attack, release;
float rev, split, MS;
//parameter smoothing, for subOrbitX and subOrbitY
float sA[2], sB[2], sZ[2];
};
// -----------------------------------------------------------------------
END_NAMESPACE_DISTRHO
#endif // TRIGGERJUICE_HPP_INCLUDED

+ 217
- 0
plugins/TriggerJuice/TriggerJuiceUI.cpp View File

@@ -0,0 +1,217 @@
/*
* Trigger Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#include "TriggerJuiceUI.hpp"

using DGL::Point;

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

TriggerJuiceUI::TriggerJuiceUI()
: UI(),
fAboutWindow(this)
{
// background
fImgBackground = Image(TriggerJuiceArtwork::backgroundData, TriggerJuiceArtwork::backgroundWidth, TriggerJuiceArtwork::backgroundHeight, GL_BGRA);

// about
Image imageAbout(TriggerJuiceArtwork::aboutData, TriggerJuiceArtwork::aboutWidth, TriggerJuiceArtwork::aboutHeight, GL_BGRA);
fAboutWindow.setImage(imageAbout);

// about button
Image aboutImageNormal(TriggerJuiceArtwork::aboutButtonNormalData, TriggerJuiceArtwork::aboutButtonNormalWidth, TriggerJuiceArtwork::aboutButtonNormalHeight);
Image aboutImageHover(TriggerJuiceArtwork::aboutButtonHoverData, TriggerJuiceArtwork::aboutButtonHoverWidth, TriggerJuiceArtwork::aboutButtonHoverHeight);
fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
fButtonAbout->setAbsolutePos(358, 17);
fButtonAbout->setCallback(this);

// knobs
Image knobImage(TriggerJuiceArtwork::knobData, TriggerJuiceArtwork::knobWidth, TriggerJuiceArtwork::knobHeight);

// knob KnobAttack
fKnobAttack = new ImageKnob(this, knobImage);
fKnobAttack->setAbsolutePos(42, 77);
fKnobAttack->setRange(0.0f, 1.0f);
fKnobAttack->setValue(0.0f);
fKnobAttack->setRotationAngle(270);
fKnobAttack->setCallback(this);

// knob KnobRelease
fKnobRelease = new ImageKnob(this, knobImage);
fKnobRelease->setAbsolutePos(139, 77);
fKnobRelease->setRange(0.0f, 1.0f);
fKnobRelease->setValue(0.0f);
fKnobRelease->setRotationAngle(270);
fKnobRelease->setCallback(this);

// sliders
Image sliderImage(TriggerJuiceArtwork::sliderData, TriggerJuiceArtwork::sliderWidth, TriggerJuiceArtwork::sliderHeight);
Point<int> sliderPosStart(293, 74);
Point<int> sliderPosEnd(293+11, 74);

// slider Rev
fSliderRev = new ImageSlider(this, sliderImage);
fSliderRev->setStartPos(sliderPosStart);
fSliderRev->setEndPos(sliderPosEnd);
fSliderRev->setRange(0.0f, 1.0f);
fSliderRev->setValue(0.0f);
fSliderRev->setCallback(this);

// slider Split
sliderPosStart.setY(104);
sliderPosEnd.setY(104);
fSliderSplit = new ImageSlider(this, sliderImage);
fSliderSplit->setStartPos(sliderPosStart);
fSliderSplit->setEndPos(sliderPosEnd);
fSliderSplit->setRange(0.0f, 1.0f);
fSliderSplit->setValue(0.0f);
fSliderSplit->setCallback(this);

// slider MS
sliderPosStart.setY(134);
sliderPosEnd.setY(134);
fSliderMS = new ImageSlider(this, sliderImage);
fSliderMS->setStartPos(sliderPosStart);
fSliderMS->setEndPos(sliderPosEnd);
fSliderMS->setRange(0.0f, 1.0f);
fSliderMS->setValue(0.0f);
fSliderMS->setCallback(this);

// set default values
d_programChanged(0);
}

// -----------------------------------------------------------------------
// DSP Callbacks

void TriggerJuiceUI::d_parameterChanged(uint32_t index, float value)
{
switch (index)
{
case TriggerJuicePlugin::paramAttack:
fKnobAttack->setValue(value);
break;
case TriggerJuicePlugin::paramRelease:
fKnobRelease->setValue(value);
break;
case TriggerJuicePlugin::paramRev:
fSliderRev->setValue(value);
break;
case TriggerJuicePlugin::paramSplit:
fSliderSplit->setValue(value);
break;
case TriggerJuicePlugin::paramMS:
fSliderMS->setValue(value);
break;
}
}

void TriggerJuiceUI::d_programChanged(uint32_t index)
{
if (index != 0)
return;

// Default values
fKnobAttack->setValue(0.0f);
fKnobRelease->setValue(0.0f);
fSliderRev->setValue(0.0f);
fSliderSplit->setValue(0.0f);
fSliderMS->setValue(0.0f);
}

// -----------------------------------------------------------------------
// Widget Callbacks

void TriggerJuiceUI::imageButtonClicked(ImageButton* button, int)
{
if (button != fButtonAbout)
return;

fAboutWindow.exec();
}

void TriggerJuiceUI::imageKnobDragStarted(ImageKnob* knob)
{
if (knob == fKnobAttack)
d_editParameter(TriggerJuicePlugin::paramAttack, true);
else if (knob == fKnobRelease)
d_editParameter(TriggerJuicePlugin::paramRelease, true);
}

void TriggerJuiceUI::imageKnobDragFinished(ImageKnob* knob)
{
if (knob == fKnobAttack)
d_editParameter(TriggerJuicePlugin::paramAttack, false);
else if (knob == fKnobRelease)
d_editParameter(TriggerJuicePlugin::paramRelease, false);
}

void TriggerJuiceUI::imageKnobValueChanged(ImageKnob* knob, float value)
{
if (knob == fKnobAttack)
d_setParameterValue(TriggerJuicePlugin::paramAttack, value);
else if (knob == fKnobRelease)
d_setParameterValue(TriggerJuicePlugin::paramRelease, value);
}

void TriggerJuiceUI::imageSliderDragStarted(ImageSlider* slider)
{
if (slider == fSliderRev)
d_editParameter(TriggerJuicePlugin::paramRev, true);
else if (slider == fSliderSplit)
d_editParameter(TriggerJuicePlugin::paramSplit, true);
else if (slider == fSliderMS)
d_editParameter(TriggerJuicePlugin::paramMS, true);
}

void TriggerJuiceUI::imageSliderDragFinished(ImageSlider* slider)
{
if (slider == fSliderRev)
d_editParameter(TriggerJuicePlugin::paramRev, false);
else if (slider == fSliderSplit)
d_editParameter(TriggerJuicePlugin::paramSplit, false);
else if (slider == fSliderMS)
d_editParameter(TriggerJuicePlugin::paramMS, false);
}

void TriggerJuiceUI::imageSliderValueChanged(ImageSlider* slider, float value)
{
if (slider == fSliderRev)
d_setParameterValue(TriggerJuicePlugin::paramRev, value);
else if (slider == fSliderSplit)
d_setParameterValue(TriggerJuicePlugin::paramSplit, value);
else if (slider == fSliderMS)
d_setParameterValue(TriggerJuicePlugin::paramMS, value);
}

void TriggerJuiceUI::onDisplay()
{
fImgBackground.draw();
}

// -----------------------------------------------------------------------

UI* createUI()
{
return new TriggerJuiceUI();
}

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

+ 103
- 0
plugins/TriggerJuice/TriggerJuiceUI.hpp View File

@@ -0,0 +1,103 @@
/*
* Trigger Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef TRIGGERJUICEUI_HPP_INCLUDED
#define TRIGGERJUICEUI_HPP_INCLUDED

#include "DistrhoUI.hpp"

#include "Geometry.hpp"
#include "ImageAboutWindow.hpp"
#include "ImageButton.hpp"
#include "ImageKnob.hpp"
#include "ImageSlider.hpp"

#include "TriggerJuiceArtwork.hpp"
#include "TriggerJuicePlugin.hpp"

using DGL::Image;
using DGL::ImageAboutWindow;
using DGL::ImageButton;
using DGL::ImageKnob;
using DGL::ImageSlider;
using DGL::Rectangle;

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

class TriggerJuiceUI : public UI,
public ImageButton::Callback,
public ImageKnob::Callback,
public ImageSlider::Callback
{
public:
TriggerJuiceUI();

protected:
// -------------------------------------------------------------------
// Information

uint d_getWidth() const noexcept override
{
return TriggerJuiceArtwork::backgroundWidth;
}

uint d_getHeight() const noexcept override
{
return TriggerJuiceArtwork::backgroundHeight;
}

// -------------------------------------------------------------------
// DSP Callbacks

void d_parameterChanged(uint32_t index, float value) override;
void d_programChanged(uint32_t index) override;

// -------------------------------------------------------------------
// Widget Callbacks

void imageButtonClicked(ImageButton* button, int) override;
void imageKnobDragStarted(ImageKnob* knob) override;
void imageKnobDragFinished(ImageKnob* knob) override;
void imageKnobValueChanged(ImageKnob* knob, float value) override;
void imageSliderDragStarted(ImageSlider* slider) override;
void imageSliderDragFinished(ImageSlider* slider) override;
void imageSliderValueChanged(ImageSlider* slider, float value) override;

void onDisplay() override;

private:
float paramX, paramY;

Image fImgBackground;
ImageAboutWindow fAboutWindow;

ScopedPointer<ImageButton> fButtonAbout;

//knobs
ScopedPointer<ImageKnob> fKnobAttack, fKnobRelease;

//sliders
ScopedPointer<ImageSlider> fSliderRev, fSliderSplit, fSliderMS;
};

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

#endif // TRIGGERJUICEUI_HPP_INCLUDED

BIN
plugins/TriggerJuice/artwork/about.png View File

Before After
Width: 300  |  Height: 200  |  Size: 44KB

BIN
plugins/TriggerJuice/artwork/about.xcf View File


BIN
plugins/TriggerJuice/artwork/aboutButtonHover.png View File

Before After
Width: 92  |  Height: 16  |  Size: 4.0KB

BIN
plugins/TriggerJuice/artwork/aboutButtonNormal.png View File

Before After
Width: 92  |  Height: 16  |  Size: 4.1KB

BIN
plugins/TriggerJuice/artwork/background.png View File

Before After
Width: 473  |  Height: 193  |  Size: 118KB

BIN
plugins/TriggerJuice/artwork/gui.xcf View File


BIN
plugins/TriggerJuice/artwork/knob.png View File

Before After
Width: 51  |  Height: 51  |  Size: 4.6KB

BIN
plugins/TriggerJuice/artwork/slider.png View File

Before After
Width: 26  |  Height: 25  |  Size: 785B

+ 36
- 0
plugins/VectorJuice/DistrhoPluginInfo.h View File

@@ -0,0 +1,36 @@
/*
* Vector Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED
#define DISTRHO_PLUGIN_INFO_H_INCLUDED

#define DISTRHO_PLUGIN_NAME "VectorJuice"

#define DISTRHO_PLUGIN_HAS_UI 1
#define DISTRHO_PLUGIN_IS_SYNTH 0

#define DISTRHO_PLUGIN_NUM_INPUTS 8
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2

#define DISTRHO_PLUGIN_WANT_LATENCY 0
#define DISTRHO_PLUGIN_WANT_PROGRAMS 1
#define DISTRHO_PLUGIN_WANT_STATE 0
#define DISTRHO_PLUGIN_WANT_TIMEPOS 1

#define DISTRHO_PLUGIN_URI "urn:distrho:VectorJuice"

#endif // DISTRHO_PLUGIN_INFO_H_INCLUDED

+ 36
- 0
plugins/VectorJuice/Makefile View File

@@ -0,0 +1,36 @@
#!/usr/bin/make -f
# Makefile for DISTRHO Plugins #
# ---------------------------- #
# Created by falkTX
#

# --------------------------------------------------------------
# Project name, used for binaries

NAME = VectorJuice

# --------------------------------------------------------------
# Files to build

OBJS_DSP = \
VectorJuicePlugin.cpp.o

OBJS_UI = \
VectorJuiceArtwork.cpp.o \
VectorJuiceUI.cpp.o

# --------------------------------------------------------------
# Do some magic

include ../Makefile.mk

# --------------------------------------------------------------
# Enable all possible plugin types

ifeq ($(LINUX),true)
all: jack lv2_sep vst
else
all: lv2_sep vst
endif

# --------------------------------------------------------------

+ 18123
- 0
plugins/VectorJuice/VectorJuiceArtwork.cpp
File diff suppressed because it is too large
View File


+ 55
- 0
plugins/VectorJuice/VectorJuiceArtwork.hpp View File

@@ -0,0 +1,55 @@
/* (Auto-generated binary data file). */

#ifndef BINARY_VECTORJUICEARTWORK_HPP
#define BINARY_VECTORJUICEARTWORK_HPP

namespace VectorJuiceArtwork
{
extern const char* aboutData;
const unsigned int aboutDataSize = 180000;
const unsigned int aboutWidth = 300;
const unsigned int aboutHeight = 200;

extern const char* aboutButtonHoverData;
const unsigned int aboutButtonHoverDataSize = 5888;
const unsigned int aboutButtonHoverWidth = 92;
const unsigned int aboutButtonHoverHeight = 16;

extern const char* aboutButtonNormalData;
const unsigned int aboutButtonNormalDataSize = 5888;
const unsigned int aboutButtonNormalWidth = 92;
const unsigned int aboutButtonNormalHeight = 16;

extern const char* backgroundData;
const unsigned int backgroundDataSize = 933432;
const unsigned int backgroundWidth = 712;
const unsigned int backgroundHeight = 437;

extern const char* knobData;
const unsigned int knobDataSize = 10404;
const unsigned int knobWidth = 51;
const unsigned int knobHeight = 51;

extern const char* orbitData;
const unsigned int orbitDataSize = 4096;
const unsigned int orbitWidth = 32;
const unsigned int orbitHeight = 32;

extern const char* roundletData;
const unsigned int roundletDataSize = 2500;
const unsigned int roundletWidth = 25;
const unsigned int roundletHeight = 25;

extern const char* sliderData;
const unsigned int sliderDataSize = 2600;
const unsigned int sliderWidth = 26;
const unsigned int sliderHeight = 25;

extern const char* subOrbitData;
const unsigned int subOrbitDataSize = 3364;
const unsigned int subOrbitWidth = 29;
const unsigned int subOrbitHeight = 29;
}

#endif // BINARY_VECTORJUICEARTWORK_HPP


+ 391
- 0
plugins/VectorJuice/VectorJuicePlugin.cpp View File

@@ -0,0 +1,391 @@
/*
* Vector Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
#include "VectorJuicePlugin.hpp"
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
VectorJuicePlugin::VectorJuicePlugin()
: Plugin(paramCount, 1, 0) // 1 program, 0 states
{
// set default values
d_setProgram(0);
}
// -----------------------------------------------------------------------
// Init
void VectorJuicePlugin::d_initParameter(uint32_t index, Parameter& parameter)
{
switch (index)
{
case paramX:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "X";
parameter.symbol = "x";
parameter.ranges.def = 0.5f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
case paramY:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Y";
parameter.symbol = "y";
parameter.ranges.def = 0.5f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
case paramOrbitSizeX:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Orbit Size X";
parameter.symbol = "sizex";
parameter.ranges.def = 0.5f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
case paramOrbitSizeY:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Orbit Size Y";
parameter.symbol = "sizey";
parameter.ranges.def = 0.5f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
case paramOrbitSpeedX:
parameter.hints = PARAMETER_IS_AUTOMABLE|PARAMETER_IS_INTEGER;
parameter.name = "Orbit Speed X";
parameter.symbol = "speedx";
parameter.ranges.def = 4.0f;
parameter.ranges.min = 1.0f;
parameter.ranges.max = 128.0f;
break;
case paramOrbitSpeedY:
parameter.hints = PARAMETER_IS_AUTOMABLE|PARAMETER_IS_INTEGER;
parameter.name = "Orbit Speed Y";
parameter.symbol = "speedy";
parameter.ranges.def = 4.0f;
parameter.ranges.min = 1.0f;
parameter.ranges.max = 128.0f;
break;
case paramSubOrbitSize:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "SubOrbit Size";
parameter.symbol = "subsize";
parameter.ranges.def = 0.5f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
case paramSubOrbitSpeed:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "SubOrbit Speed";
parameter.symbol = "subspeed";
parameter.ranges.def = 32.0f;
parameter.ranges.min = 1.0f;
parameter.ranges.max = 128.0f;
break;
case paramSubOrbitSmooth:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "SubOrbit Wave";
parameter.symbol = "subwave";
parameter.ranges.def = 0.5f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
case paramOrbitWaveX:
parameter.hints = PARAMETER_IS_AUTOMABLE|PARAMETER_IS_INTEGER;
parameter.name = "Orbit Wave X";
parameter.symbol = "wavex";
parameter.ranges.def = 3.0f;
parameter.ranges.min = 1.0f;
parameter.ranges.max = 4.0f;
break;
case paramOrbitWaveY:
parameter.hints = PARAMETER_IS_AUTOMABLE|PARAMETER_IS_INTEGER;
parameter.name = "Orbit Wave Y";
parameter.symbol = "wavey";
parameter.ranges.def = 3.0f;
parameter.ranges.min = 1.0f;
parameter.ranges.max = 4.0f;
break;
case paramOrbitPhaseX:
parameter.hints = PARAMETER_IS_AUTOMABLE|PARAMETER_IS_INTEGER;
parameter.name = "Orbit Phase X";
parameter.symbol = "phasex";
parameter.ranges.def = 1.0f;
parameter.ranges.min = 1.0f;
parameter.ranges.max = 4.0f;
break;
case paramOrbitPhaseY:
parameter.hints = PARAMETER_IS_AUTOMABLE|PARAMETER_IS_INTEGER;
parameter.name = "Orbit Phase Y";
parameter.symbol = "phasey";
parameter.ranges.def = 1.0f;
parameter.ranges.min = 1.0f;
parameter.ranges.max = 4.0f;
break;
case paramOrbitOutX:
parameter.hints = PARAMETER_IS_OUTPUT;
parameter.name = "Orbit X";
parameter.symbol = "orx";
parameter.ranges.def = 0.5f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
case paramOrbitOutY:
parameter.hints = PARAMETER_IS_OUTPUT;
parameter.name = "Orbit Y";
parameter.symbol = "ory";
parameter.ranges.def = 0.5f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
case paramSubOrbitOutX:
parameter.hints = PARAMETER_IS_OUTPUT;
parameter.name = "SubOrbit X";
parameter.symbol = "sorx";
parameter.ranges.def = 0.5f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
case paramSubOrbitOutY:
parameter.hints = PARAMETER_IS_OUTPUT;
parameter.name = "SubOrbit Y";
parameter.symbol = "sory";
parameter.ranges.def = 0.5f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
}
}
void VectorJuicePlugin::d_initProgramName(uint32_t index, d_string& programName)
{
if (index != 0)
return;
programName = "Default";
}
// -----------------------------------------------------------------------
// Internal data
float VectorJuicePlugin::d_getParameterValue(uint32_t index) const
{
switch (index)
{
case paramX:
return x;
case paramY:
return y;
case paramOrbitSizeX:
return orbitSizeX;
case paramOrbitSizeY:
return orbitSizeY;
case paramOrbitSpeedX:
return orbitSpeedX;
case paramOrbitSpeedY:
return orbitSpeedY;
case paramSubOrbitSize:
return subOrbitSize;
case paramSubOrbitSpeed:
return subOrbitSpeed;
case paramSubOrbitSmooth:
return subOrbitSmooth;
case paramOrbitWaveX:
return orbitWaveX;
case paramOrbitWaveY:
return orbitWaveY;
case paramOrbitPhaseX:
return orbitPhaseY;
case paramOrbitPhaseY:
return orbitPhaseY;
case paramOrbitOutX:
return orbitX;
case paramOrbitOutY:
return orbitY;
case paramSubOrbitOutX:
return subOrbitX;
case paramSubOrbitOutY:
return subOrbitY;
default:
return 0.0f;
}
}
void VectorJuicePlugin::d_setParameterValue(uint32_t index, float value)
{
bool resetPhase = false;
switch (index)
{
case paramX:
x = value;
break;
case paramY:
y = value;
break;
case paramOrbitSizeX:
orbitSizeX = value;
break;
case paramOrbitSizeY:
orbitSizeY = value;
break;
case paramOrbitSpeedX:
orbitSpeedX = value;
resetPhase = true;
break;
case paramOrbitSpeedY:
orbitSpeedY = value;
resetPhase = true;
break;
case paramSubOrbitSize:
subOrbitSize = value;
break;
case paramSubOrbitSpeed:
subOrbitSpeed = value;
resetPhase = true;
break;
case paramSubOrbitSmooth:
subOrbitSmooth = value;
break;
case paramOrbitWaveX:
orbitWaveX = value;
break;
case paramOrbitWaveY:
orbitWaveY = value;
break;
case paramOrbitPhaseX:
orbitPhaseX = value;
resetPhase = true;
break;
case paramOrbitPhaseY:
orbitPhaseY = value;
resetPhase = true;
break;
}
if (resetPhase)
{
sinePosX = 0;
sinePosY = 0;
sinePos = 0;
}
}
void VectorJuicePlugin::d_setProgram(uint32_t index)
{
if (index != 0)
return;
/* Default parameter values */
x = 0.5f;
y = 0.5f;
orbitSizeX = 0.5f;
orbitSizeY = 0.5f;
orbitSpeedX = 4.0f;
orbitSpeedY = 4.0f;
subOrbitSize = 0.5f;
subOrbitSpeed = 32.0f;
subOrbitSmooth = 0.5f;
orbitWaveX = 3.0f;
orbitWaveY = 3.0f;
orbitPhaseX = 1.0f;
orbitPhaseY = 1.0f;
/* reset filter values */
d_activate();
}
// -----------------------------------------------------------------------
// Process
void VectorJuicePlugin::d_activate()
{
/* Default variable values */
orbitX=orbitY=orbitTX=orbitTY=0.5;
subOrbitX=subOrbitY=subOrbitTX=subOrbitTY=0;
interpolationDivider=200;
bar=tickX=tickY=percentageX=percentageY=tickOffsetX=0;
tickOffsetY=sinePosX=sinePosY=tick=percentage=tickOffset=sinePos=0;
waveBlend=0;
//parameter smoothing
for (int i=0; i<2; i++) {
sA[i] = 0.99f;
sB[i] = 1.f - sA[i];
sZ[i] = 0;
}
}
void VectorJuicePlugin::d_run(const float** inputs, float** outputs, uint32_t frames)
{
float out1, out2, tX, tY;
for (uint32_t i=0; i<frames; i++) {
//1.41421 -> 1
//<0 = 0
animate();
tX = subOrbitX;
tY = subOrbitY;
out1 = inputs[0][i]*tN(1-std::sqrt((tX*tX)+(tY*tY)));
out2 = inputs[1][i]*tN(1-std::sqrt((tX*tX)+(tY*tY)));
out1 += inputs[2][i]*tN(1-std::sqrt(((1-tX)*(1-tX))+(tY*tY)));
out2 += inputs[3][i]*tN(1-std::sqrt(((1-tX)*(1-tX))+(tY*tY)));
out1 += inputs[4][i]*tN(1-std::sqrt(((1-tX)*(1-tX))+((1-tY)*(1-tY))));
out2 += inputs[5][i]*tN(1-std::sqrt(((1-tX)*(1-tX))+((1-tY)*(1-tY))));
out1 += inputs[6][i]*tN(1-std::sqrt((tX*tX)+((1-tY)*(1-tY))));
out2 += inputs[7][i]*tN(1-std::sqrt((tX*tX)+((1-tY)*(1-tY))));
outputs[0][i] = out1;
outputs[1][i] = out2;
}
}
// -----------------------------------------------------------------------
Plugin* createPlugin()
{
return new VectorJuicePlugin();
}
// -----------------------------------------------------------------------
END_NAMESPACE_DISTRHO

+ 236
- 0
plugins/VectorJuice/VectorJuicePlugin.hpp View File

@@ -0,0 +1,236 @@
/*
* Vector Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
#ifndef VECTORJUICEPLUGIN_HPP_INCLUDED
#define VECTORJUICEPLUGIN_HPP_INCLUDED
#include "DistrhoPlugin.hpp"
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
class VectorJuicePlugin : public Plugin
{
public:
enum Parameters
{
paramX = 0,
paramY,
paramOrbitSizeX,
paramOrbitSizeY,
paramOrbitSpeedX,
paramOrbitSpeedY,
paramSubOrbitSize,
paramSubOrbitSpeed,
paramSubOrbitSmooth,
paramOrbitWaveX,
paramOrbitWaveY,
paramOrbitPhaseX,
paramOrbitPhaseY,
paramOrbitOutX,
paramOrbitOutY,
paramSubOrbitOutX,
paramSubOrbitOutY,
paramCount
};
float smoothParameter(float in, int axis) {
sZ[axis] = (in * sB[axis]) + (sZ[axis] * sA[axis]);
return sZ[axis];
}
float getSinePhase(float x) {
return (-std::sin(x));
}
float getSawPhase(float x) {
return (-(2/M_PI *std::atan(1/std::tan(x/2))));
}
float getRevSawPhase(float x) {
return ((2/M_PI *std::atan(1/std::tan(x/2))));
}
float getSquarePhase(float x) {
return (std::round((std::sin(x)+1)/2)-0.5)*2;
}
//saw, sqr, sin, revSaw
float getBlendedPhase(float x, float wave)
{
//wave = 2;
if (wave>=1 && wave<2) {
/* saw vs sqr */
waveBlend = wave-1;
return (getSawPhase(x)*(1-waveBlend) + getSquarePhase(x)*waveBlend);
} else if (wave>=2 && wave<3) {
/* sqr vs sin */
waveBlend = wave-2;
return (getSquarePhase(x)*(1-waveBlend) + getSinePhase(x)*waveBlend);
} else if (wave>=3 && wave<=4) {
/* sin vs revSaw */
waveBlend = wave-3;
return (getSinePhase(x)*(1-waveBlend) + getRevSawPhase(x)*waveBlend);
} else {
return 0.0f;
}
}
float tN(float x)
{
if (x>0) return x;
else return 0;
}
void animate()
{
//sync orbit with frame, bpm
const TimePos& time = d_getTimePos();
bar = ((120.0/(time.bbt.valid ? time.bbt.beatsPerMinute : 120.0))*(d_getSampleRate()));
int multiplier = 16;//2000*4;
tickX = bar/(std::round(orbitSpeedX))*multiplier;
tickY = bar/(std::round(orbitSpeedY))*multiplier;
tick = bar/(std::round(subOrbitSpeed))*multiplier;
if (time.playing)
{
/* if rolling then sync to timepos */
tickOffsetX = time.frame-std::floor(time.frame/tickX)*tickX;
tickOffsetY = time.frame-std::floor(time.frame/tickY)*tickY;
tickOffset = time.frame-std::floor(time.frame/tick)*tick;
percentageX = tickOffsetX/tickX;
percentageY = tickOffsetY/tickY;
percentage = tickOffset/tick;
sinePosX = (M_PI*2)*percentageX;
sinePosY = (M_PI*2)*percentageY;
sinePos = (M_PI*2)*percentage;
} else {
/* else just keep on wobblin' */
sinePosX += (2*M_PI)/(tickX);
sinePosY += (2*M_PI)/(tickY);
sinePos += (M_PI)/(tick);
if (sinePosX>2*M_PI) {
sinePosX = 0;
}
if (sinePosY>2*M_PI) {
sinePosY = 0;
}
if (sinePos>2*M_PI) {
sinePos = 0;
}
}
//0..1
//0..3
//0, 1, 2, 3
//* 0.25
//0, 0.25, 0.5, 0.75
float tempPhaseX = std::round(orbitPhaseX)*0.25-0.25;
float tempPhaseY = std::round(orbitPhaseY)*0.25-0.25;
orbitX = x+getBlendedPhase(sinePosX + tempPhaseX*(2*M_PI), std::round(orbitWaveX))*(orbitSizeX/2);
orbitY = y+getBlendedPhase(sinePosY+M_PI/2 + tempPhaseY*(2*M_PI), std::round(orbitWaveY))*(orbitSizeY/2);
subOrbitX = smoothParameter(orbitX+getBlendedPhase(sinePos, 3)*(subOrbitSize/3), 0);
subOrbitY = smoothParameter(orbitY+getBlendedPhase(sinePos+M_PI/2, 3)*(subOrbitSize/3), 1);
if (orbitX<0) orbitX=0;
if (orbitX>1) orbitX=1;
if (orbitY<0) orbitY=0;
if (orbitY>1) orbitY=1;
if (subOrbitX<0) subOrbitX=0;
if (subOrbitX>1) subOrbitX=1;
if (subOrbitY<0) subOrbitY=0;
if (subOrbitY>1) subOrbitY=1;
}
VectorJuicePlugin();
protected:
// -------------------------------------------------------------------
// Information
const char* d_getLabel() const noexcept override
{
return "VectorJuice";
}
const char* d_getMaker() const noexcept override
{
return "Andre Sklenar";
}
const char* d_getLicense() const noexcept override
{
return "GPL v2+";
}
uint32_t d_getVersion() const noexcept override
{
return 0x1000;
}
long d_getUniqueId() const noexcept override
{
return d_cconst('V', 'e', 'c', 'J');
}
// -------------------------------------------------------------------
// Init
void d_initParameter(uint32_t index, Parameter& parameter) override;
void d_initProgramName(uint32_t index, d_string& programName) override;
// -------------------------------------------------------------------
// Internal data
float d_getParameterValue(uint32_t index) const override;
void d_setParameterValue(uint32_t index, float value) override;
void d_setProgram(uint32_t index) override;
// -------------------------------------------------------------------
// Process
void d_activate() override;
void d_run(const float** inputs, float** outputs, uint32_t frames) override;
// -------------------------------------------------------------------
private:
float x, y;
float orbitX, orbitY;
float orbitTX, orbitTY; //targetX and targetY for interpolation
float subOrbitX, subOrbitY;
float subOrbitTX, subOrbitTY;
float subOrbitSpeed, subOrbitSize, orbitSpeedX, orbitSpeedY;
float orbitSizeX, orbitSizeY;
float interpolationDivider;
float bar, tickX, tickY, percentageX, percentageY, tickOffsetX, tickOffsetY;
float sinePosX, sinePosY, tick, percentage, tickOffset, sinePos;
float orbitWaveX, orbitWaveY, subOrbitSmooth, waveBlend;
float orbitPhaseX, orbitPhaseY;
//parameter smoothing, for subOrbitX and subOrbitY
float sA[2], sB[2], sZ[2];
};
// -----------------------------------------------------------------------
END_NAMESPACE_DISTRHO
#endif // VECTORJUICE_HPP_INCLUDED

+ 448
- 0
plugins/VectorJuice/VectorJuiceUI.cpp View File

@@ -0,0 +1,448 @@
/*
* Vector Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#include "VectorJuicePlugin.hpp"
#include "VectorJuiceUI.hpp"

using DGL::Point;

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

VectorJuiceUI::VectorJuiceUI()
: UI(),
fAboutWindow(this)
{
// xy params
paramX = paramY = 0.5f;

// orbit params
orbitX = orbitY = subOrbitX = subOrbitY = 0.5f;

// set the XY canvas area
fDragging = false;
fDragValid = false;
fLastX = fLastY = 0;
fCanvasArea.setPos(22+12, 49+12);
fCanvasArea.setSize(368-24, 368-24);

// background
fImgBackground = Image(VectorJuiceArtwork::backgroundData, VectorJuiceArtwork::backgroundWidth, VectorJuiceArtwork::backgroundHeight, GL_BGR);

//roundlet
fImgRoundlet = Image(VectorJuiceArtwork::roundletData, VectorJuiceArtwork::roundletWidth, VectorJuiceArtwork::roundletHeight);

//orbit
fImgOrbit = Image(VectorJuiceArtwork::orbitData, VectorJuiceArtwork::orbitWidth, VectorJuiceArtwork::orbitHeight);

//subOrbit
fImgSubOrbit = Image(VectorJuiceArtwork::subOrbitData, VectorJuiceArtwork::subOrbitWidth, VectorJuiceArtwork::subOrbitHeight);

// about
Image aboutImage(VectorJuiceArtwork::aboutData, VectorJuiceArtwork::aboutWidth, VectorJuiceArtwork::aboutHeight, GL_BGR);
fAboutWindow.setImage(aboutImage);

// about button
Image aboutImageNormal(VectorJuiceArtwork::aboutButtonNormalData, VectorJuiceArtwork::aboutButtonNormalWidth, VectorJuiceArtwork::aboutButtonNormalHeight);
Image aboutImageHover(VectorJuiceArtwork::aboutButtonHoverData, VectorJuiceArtwork::aboutButtonHoverWidth, VectorJuiceArtwork::aboutButtonHoverHeight);
fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
fButtonAbout->setAbsolutePos(599, 17);
fButtonAbout->setCallback(this);

// knobs
Image knobImage(VectorJuiceArtwork::knobData, VectorJuiceArtwork::knobWidth, VectorJuiceArtwork::knobHeight);

// knob KnobOrbitSizeX
fKnobOrbitSizeX = new ImageKnob(this, knobImage, ImageKnob::Vertical, VectorJuicePlugin::paramOrbitSizeX);
fKnobOrbitSizeX->setAbsolutePos(423, 73);
fKnobOrbitSizeX->setRotationAngle(270);
fKnobOrbitSizeX->setRange(0.0f, 1.0f);
fKnobOrbitSizeX->setDefault(0.5f);
fKnobOrbitSizeX->setCallback(this);

// knob KnobOrbitSizeY
fKnobOrbitSizeY = new ImageKnob(this, knobImage, ImageKnob::Vertical, VectorJuicePlugin::paramOrbitSizeY);
fKnobOrbitSizeY->setAbsolutePos(516, 73);
fKnobOrbitSizeY->setRotationAngle(270);
fKnobOrbitSizeY->setRange(0.0f, 1.0f);
fKnobOrbitSizeY->setDefault(0.5f);
fKnobOrbitSizeY->setCallback(this);

// knob KnobOrbitSpeedX
fKnobOrbitSpeedX = new ImageKnob(this, knobImage, ImageKnob::Vertical, VectorJuicePlugin::paramOrbitSpeedX);
fKnobOrbitSpeedX->setAbsolutePos(423, 185);
fKnobOrbitSpeedX->setRotationAngle(270);
fKnobOrbitSpeedX->setStep(1.0f);
fKnobOrbitSpeedX->setRange(1.0f, 128.0f);
fKnobOrbitSpeedX->setDefault(4.0f);
fKnobOrbitSpeedX->setCallback(this);

// knob KnobOrbitSpeedY
fKnobOrbitSpeedY = new ImageKnob(this, knobImage, ImageKnob::Vertical, VectorJuicePlugin::paramOrbitSpeedY);
fKnobOrbitSpeedY->setAbsolutePos(516, 185);
fKnobOrbitSpeedY->setRotationAngle(270);
fKnobOrbitSpeedY->setStep(1.0f);
fKnobOrbitSpeedY->setRange(1.0f, 128.0f);
fKnobOrbitSpeedY->setDefault(4.0f);
fKnobOrbitSpeedY->setCallback(this);

// knob KnobSubOrbitSize
fKnobSubOrbitSize = new ImageKnob(this, knobImage, ImageKnob::Vertical, VectorJuicePlugin::paramSubOrbitSize);
fKnobSubOrbitSize->setAbsolutePos(620, 73);
fKnobSubOrbitSize->setRange(0.0f, 1.0f);
fKnobSubOrbitSize->setRotationAngle(270);
fKnobSubOrbitSize->setDefault(0.5f);
fKnobSubOrbitSize->setCallback(this);

// knob KnobSubOrbitSpeed
fKnobSubOrbitSpeed = new ImageKnob(this, knobImage, ImageKnob::Vertical, VectorJuicePlugin::paramSubOrbitSpeed);
fKnobSubOrbitSpeed->setAbsolutePos(620, 185);
fKnobSubOrbitSpeed->setRotationAngle(270);
fKnobSubOrbitSpeed->setStep(1.0f);
fKnobSubOrbitSpeed->setRange(1.0f, 128.0f);
fKnobSubOrbitSpeed->setDefault(32.0f);
fKnobSubOrbitSpeed->setCallback(this);

// knob KnobSubOrbitSmooth
fKnobSubOrbitSmooth = new ImageKnob(this, knobImage, ImageKnob::Vertical, VectorJuicePlugin::paramSubOrbitSmooth);
fKnobSubOrbitSmooth->setAbsolutePos(620, 297);
fKnobSubOrbitSmooth->setRotationAngle(270);
fKnobSubOrbitSmooth->setRange(0.0f, 1.0f);
fKnobSubOrbitSmooth->setDefault(0.5f);
fKnobSubOrbitSmooth->setCallback(this);

// sliders
Image sliderImage(VectorJuiceArtwork::sliderData, VectorJuiceArtwork::sliderWidth, VectorJuiceArtwork::sliderHeight);
Point<int> sliderPosStart(410, 284);
Point<int> sliderPosEnd(410+48, 284);

// slider OrbitWaveX
fSliderOrbitWaveX = new ImageSlider(this, sliderImage, VectorJuicePlugin::paramOrbitWaveX);
fSliderOrbitWaveX->setStartPos(sliderPosStart);
fSliderOrbitWaveX->setEndPos(sliderPosEnd);
fSliderOrbitWaveX->setRange(1.0f, 4.0f);
fSliderOrbitWaveX->setStep(1.0f);
fSliderOrbitWaveX->setCallback(this);

// slider OrbitWaveY
sliderPosStart.setX(503);
sliderPosEnd.setX(503+48);
fSliderOrbitWaveY = new ImageSlider(this, sliderImage, VectorJuicePlugin::paramOrbitWaveY);
fSliderOrbitWaveY->setStartPos(sliderPosStart);
fSliderOrbitWaveY->setEndPos(sliderPosEnd);
fSliderOrbitWaveY->setRange(1.0f, 4.0f);
fSliderOrbitWaveY->setStep(1.0f);
fSliderOrbitWaveY->setCallback(this);

// slider OrbitPhaseX
sliderPosStart.setX(410);
sliderPosStart.setY(345);
sliderPosEnd.setX(410+48);
sliderPosEnd.setY(345);
fSliderOrbitPhaseX = new ImageSlider(this, sliderImage, VectorJuicePlugin::paramOrbitPhaseX);
fSliderOrbitPhaseX->setStartPos(sliderPosStart);
fSliderOrbitPhaseX->setEndPos(sliderPosEnd);
fSliderOrbitPhaseX->setRange(1.0f, 4.0f);
fSliderOrbitPhaseX->setStep(1.0f);
fSliderOrbitPhaseX->setCallback(this);

// slider OrbitPhaseY
sliderPosStart.setX(503);
sliderPosEnd.setX(503+48);
fSliderOrbitPhaseY = new ImageSlider(this, sliderImage, VectorJuicePlugin::paramOrbitPhaseY);
fSliderOrbitPhaseY->setStartPos(sliderPosStart);
fSliderOrbitPhaseY->setEndPos(sliderPosEnd);
fSliderOrbitPhaseY->setRange(1.0f, 4.0f);
fSliderOrbitPhaseY->setStep(1.0f);
fSliderOrbitPhaseY->setCallback(this);

// set default values
d_programChanged(0);
}

// -----------------------------------------------------------------------
// DSP Callbacks

void VectorJuiceUI::d_parameterChanged(uint32_t index, float value)
{
switch (index)
{
case VectorJuicePlugin::paramX:
if (paramX != value)
{
paramX = value;
fDragValid = false;
repaint();
}
break;
case VectorJuicePlugin::paramY:
if (paramY != value)
{
paramY = value;
fDragValid = false;
repaint();
}
break;
case VectorJuicePlugin::paramOrbitSizeX:
fKnobOrbitSizeX->setValue(value);
break;
case VectorJuicePlugin::paramOrbitSizeY:
fKnobOrbitSizeY->setValue(value);
break;
case VectorJuicePlugin::paramOrbitSpeedX:
fKnobOrbitSpeedX->setValue(value);
break;
case VectorJuicePlugin::paramOrbitSpeedY:
fKnobOrbitSpeedY->setValue(value);
break;
case VectorJuicePlugin::paramSubOrbitSize:
fKnobSubOrbitSize->setValue(value);
break;
case VectorJuicePlugin::paramSubOrbitSpeed:
fKnobSubOrbitSpeed->setValue(value);
break;
case VectorJuicePlugin::paramSubOrbitSmooth:
fKnobSubOrbitSmooth->setValue(value);
break;
case VectorJuicePlugin::paramOrbitWaveX:
fSliderOrbitWaveX->setValue(value);
break;
case VectorJuicePlugin::paramOrbitWaveY:
fSliderOrbitWaveY->setValue(value);
break;
case VectorJuicePlugin::paramOrbitPhaseX:
fSliderOrbitPhaseX->setValue(value);
break;
case VectorJuicePlugin::paramOrbitPhaseY:
fSliderOrbitPhaseY->setValue(value);
break;
case VectorJuicePlugin::paramOrbitOutX:
if (orbitX != value)
{
orbitX = value;
repaint();
}
break;
case VectorJuicePlugin::paramOrbitOutY:
if (orbitY != value)
{
orbitY = value;
repaint();
}
break;
case VectorJuicePlugin::paramSubOrbitOutX:
if (subOrbitX != value)
{
subOrbitX = value;
repaint();
}
break;
case VectorJuicePlugin::paramSubOrbitOutY:
if (subOrbitY != value)
{
subOrbitY = value;
repaint();
}
break;
}
}

void VectorJuiceUI::d_programChanged(uint32_t index)
{
if (index != 0)
return;

// Default values
paramX = paramY = 0.5f;
fKnobOrbitSizeX->setValue(0.5f);
fKnobOrbitSizeY->setValue(0.5f);
fKnobOrbitSpeedX->setValue(4.0f);
fKnobOrbitSpeedY->setValue(4.0f);
fKnobSubOrbitSize->setValue(0.5f);
fKnobSubOrbitSpeed->setValue(32.0f);
fKnobSubOrbitSmooth->setValue(0.5f);
fSliderOrbitWaveX->setValue(3.0f);
fSliderOrbitWaveY->setValue(3.0f);
fSliderOrbitPhaseX->setValue(1.0f);
fSliderOrbitPhaseY->setValue(1.0f);
}

// -----------------------------------------------------------------------
// Widget Callbacks

void VectorJuiceUI::imageButtonClicked(ImageButton* button, int)
{
if (button != fButtonAbout)
return;

fAboutWindow.exec();
}

void VectorJuiceUI::imageKnobDragStarted(ImageKnob* knob)
{
d_editParameter(knob->getId(), true);
}

void VectorJuiceUI::imageKnobDragFinished(ImageKnob* knob)
{
d_editParameter(knob->getId(), false);
}

void VectorJuiceUI::imageKnobValueChanged(ImageKnob* knob, float value)
{
d_setParameterValue(knob->getId(), value);
}

void VectorJuiceUI::imageSliderDragStarted(ImageSlider* slider)
{
d_editParameter(slider->getId(), true);
}

void VectorJuiceUI::imageSliderDragFinished(ImageSlider* slider)
{
d_editParameter(slider->getId(), false);
}

void VectorJuiceUI::imageSliderValueChanged(ImageSlider* slider, float value)
{
d_setParameterValue(slider->getId(), value);
}

void VectorJuiceUI::onDisplay()
{
fImgBackground.draw();

// get x, y mapped to XY area
int x = fCanvasArea.getX() + paramX*fCanvasArea.getWidth() - fImgRoundlet.getWidth()/2;
int y = fCanvasArea.getY() + paramY*fCanvasArea.getHeight() - fImgRoundlet.getHeight()/2;
int nOrbitX = fCanvasArea.getX()+((orbitX)*fCanvasArea.getWidth())-15;
int nOrbitY = fCanvasArea.getY()+((orbitY)*fCanvasArea.getWidth())-15;
int nSubOrbitX = fCanvasArea.getX()+(subOrbitX*fCanvasArea.getWidth())-15;
int nSubOrbitY = fCanvasArea.getY()+(subOrbitY*fCanvasArea.getWidth())-14;

//draw lines, just for fun
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.0f, 1.0f, 0.0f, 0.05f);
glLineWidth(4);
glBegin(GL_LINES);
glVertex2i(x+ fImgRoundlet.getWidth()/2, y+ fImgRoundlet.getHeight()/2);
glVertex2i(nOrbitX+15, nOrbitY+15);
glEnd();
glBegin(GL_LINES);
glVertex2i(nOrbitX+15, nOrbitY+15);
glVertex2i(nSubOrbitX+15, nSubOrbitY+14);
glEnd();

// reset color
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

// draw roundlet and orbits
fImgRoundlet.drawAt(x, y);
fImgOrbit.drawAt(nOrbitX, nOrbitY);
fImgSubOrbit.drawAt(nSubOrbitX, nSubOrbitY);
}

bool VectorJuiceUI::onMouse(const MouseEvent& ev)
{
if (ev.button != 1)
return false;

if (ev.press)
{
if (! fCanvasArea.contains(ev.pos))
return false;

fDragging = true;
fDragValid = true;
fLastX = ev.pos.getX();
fLastY = ev.pos.getY();
return true;
}
else if (fDragging)
{
fDragging = false;
return true;
}

return false;
}

bool VectorJuiceUI::onMotion(const MotionEvent& ev)
{
if (! fDragging)
return false;

const int x = ev.pos.getX();
const int y = ev.pos.getY();

if (! fDragValid)
{
fDragValid = true;
fLastX = x;
fLastY = y;
}

const int movedX = fLastX - x;
const int movedY = fLastY - y;
fLastX = x;
fLastY = y;

float newX = paramX;
float newY = paramY;

newX -= float(movedX)/fCanvasArea.getWidth();
newY -= float(movedY)/fCanvasArea.getHeight();

if (newX < 0.0f)
newX = 0.0f;
else if (newX > 1.0f)
newX = 1.0f;

if (newY < 0.0f)
newY = 0.0f;
else if (newY > 1.0f)
newY = 1.0f;

if (newX != paramX)
{
paramX = newX;
d_setParameterValue(VectorJuicePlugin::paramX, paramX);
repaint();
}

if (newY != paramY)
{
paramY = newY;
d_setParameterValue(VectorJuicePlugin::paramY, paramY);
repaint();
}

return true;
}

// -----------------------------------------------------------------------

UI* createUI()
{
return new VectorJuiceUI();
}

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

+ 115
- 0
plugins/VectorJuice/VectorJuiceUI.hpp View File

@@ -0,0 +1,115 @@
/*
* Vector Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef VECTORJUICEUI_HPP_INCLUDED
#define VECTORJUICEUI_HPP_INCLUDED

#include "DistrhoUI.hpp"

#include "ImageAboutWindow.hpp"
#include "ImageButton.hpp"
#include "ImageKnob.hpp"
#include "ImageSlider.hpp"

#include "VectorJuiceArtwork.hpp"

using DGL::Image;
using DGL::ImageAboutWindow;
using DGL::ImageButton;
using DGL::ImageKnob;
using DGL::ImageSlider;

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

class VectorJuiceUI : public UI,
public ImageButton::Callback,
public ImageKnob::Callback,
public ImageSlider::Callback
{
public:
VectorJuiceUI();

protected:
// -------------------------------------------------------------------
// Information

uint d_getWidth() const noexcept override
{
return VectorJuiceArtwork::backgroundWidth;
}

uint d_getHeight() const noexcept override
{
return VectorJuiceArtwork::backgroundHeight;
}

// -------------------------------------------------------------------
// DSP Callbacks

void d_parameterChanged(uint32_t index, float value) override;
void d_programChanged(uint32_t index) override;

// -------------------------------------------------------------------
// Widget Callbacks

void imageButtonClicked(ImageButton* button, int) override;
void imageKnobDragStarted(ImageKnob* knob) override;
void imageKnobDragFinished(ImageKnob* knob) override;
void imageKnobValueChanged(ImageKnob* knob, float value) override;
void imageSliderDragStarted(ImageSlider* slider) override;
void imageSliderDragFinished(ImageSlider* slider) override;
void imageSliderValueChanged(ImageSlider* slider, float value) override;

void onDisplay() override;
bool onMouse(const MouseEvent&) override;
bool onMotion(const MotionEvent&) override;

private:
float paramX, paramY;

Image fImgBackground;
Image fImgRoundlet;
Image fImgOrbit;
Image fImgSubOrbit;
ImageAboutWindow fAboutWindow;

ScopedPointer<ImageButton> fButtonAbout;

//knobs
ScopedPointer<ImageKnob> fKnobOrbitSpeedX, fKnobOrbitSpeedY, fKnobOrbitSizeX, fKnobOrbitSizeY;
ScopedPointer<ImageKnob> fKnobSubOrbitSpeed, fKnobSubOrbitSize, fKnobSubOrbitSmooth;

//sliders
ScopedPointer<ImageSlider> fSliderOrbitWaveX, fSliderOrbitWaveY;
ScopedPointer<ImageSlider> fSliderOrbitPhaseX, fSliderOrbitPhaseY;

// needed for XY canvas handling
bool fDragging;
bool fDragValid;
int fLastX;
int fLastY;
DGL::Rectangle<int> fCanvasArea;
float orbitX, orbitY, subOrbitX, subOrbitY;
};

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

#endif // VECTORJUICEUI_HPP_INCLUDED

BIN
plugins/VectorJuice/artwork/about.png View File

Before After
Width: 300  |  Height: 200  |  Size: 39KB

BIN
plugins/VectorJuice/artwork/about.xcf View File


BIN
plugins/VectorJuice/artwork/aboutButtonHover.png View File

Before After
Width: 92  |  Height: 16  |  Size: 4.0KB

BIN
plugins/VectorJuice/artwork/aboutButtonNormal.png View File

Before After
Width: 92  |  Height: 16  |  Size: 4.1KB

BIN
plugins/VectorJuice/artwork/background.png View File

Before After
Width: 712  |  Height: 437  |  Size: 206KB

BIN
plugins/VectorJuice/artwork/gui.xcf View File


BIN
plugins/VectorJuice/artwork/knob.png View File

Before After
Width: 51  |  Height: 51  |  Size: 4.6KB

BIN
plugins/VectorJuice/artwork/orbit.png View File

Before After
Width: 32  |  Height: 32  |  Size: 1.7KB

BIN
plugins/VectorJuice/artwork/roundlet.png View File

Before After
Width: 25  |  Height: 25  |  Size: 974B

BIN
plugins/VectorJuice/artwork/slider.png View File

Before After
Width: 26  |  Height: 25  |  Size: 785B

BIN
plugins/VectorJuice/artwork/subOrbit.png View File

Before After
Width: 29  |  Height: 29  |  Size: 1.3KB

+ 36
- 0
plugins/WobbleJuice/DistrhoPluginInfo.h View File

@@ -0,0 +1,36 @@
/*
* Wobble Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED
#define DISTRHO_PLUGIN_INFO_H_INCLUDED

#define DISTRHO_PLUGIN_NAME "WobbleJuice"

#define DISTRHO_PLUGIN_HAS_UI 1
#define DISTRHO_PLUGIN_IS_SYNTH 0

#define DISTRHO_PLUGIN_NUM_INPUTS 2
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2

#define DISTRHO_PLUGIN_WANT_LATENCY 0
#define DISTRHO_PLUGIN_WANT_PROGRAMS 1
#define DISTRHO_PLUGIN_WANT_STATE 0
#define DISTRHO_PLUGIN_WANT_TIMEPOS 1

#define DISTRHO_PLUGIN_URI "urn:distrho:WobbleJuice"

#endif // DISTRHO_PLUGIN_INFO_H_INCLUDED

+ 36
- 0
plugins/WobbleJuice/Makefile View File

@@ -0,0 +1,36 @@
#!/usr/bin/make -f
# Makefile for DISTRHO Plugins #
# ---------------------------- #
# Created by falkTX
#

# --------------------------------------------------------------
# Project name, used for binaries

NAME = WobbleJuice

# --------------------------------------------------------------
# Files to build

OBJS_DSP = \
WobbleJuicePlugin.cpp.o

OBJS_UI = \
WobbleJuiceArtwork.cpp.o \
WobbleJuiceUI.cpp.o

# --------------------------------------------------------------
# Do some magic

include ../Makefile.mk

# --------------------------------------------------------------
# Enable all possible plugin types

ifeq ($(LINUX),true)
all: jack lv2_sep vst
else
all: lv2_sep vst
endif

# --------------------------------------------------------------

+ 10312
- 0
plugins/WobbleJuice/WobbleJuiceArtwork.cpp
File diff suppressed because it is too large
View File


+ 35
- 0
plugins/WobbleJuice/WobbleJuiceArtwork.hpp View File

@@ -0,0 +1,35 @@
/* (Auto-generated binary data file). */

#ifndef BINARY_WOBBLEJUICEARTWORK_HPP
#define BINARY_WOBBLEJUICEARTWORK_HPP

namespace WobbleJuiceArtwork
{
extern const char* aboutData;
const unsigned int aboutDataSize = 180000;
const unsigned int aboutWidth = 300;
const unsigned int aboutHeight = 200;

extern const char* aboutButtonHoverData;
const unsigned int aboutButtonHoverDataSize = 5888;
const unsigned int aboutButtonHoverWidth = 92;
const unsigned int aboutButtonHoverHeight = 16;

extern const char* aboutButtonNormalData;
const unsigned int aboutButtonNormalDataSize = 5888;
const unsigned int aboutButtonNormalWidth = 92;
const unsigned int aboutButtonNormalHeight = 16;

extern const char* backgroundData;
const unsigned int backgroundDataSize = 450000;
const unsigned int backgroundWidth = 500;
const unsigned int backgroundHeight = 300;

extern const char* knobData;
const unsigned int knobDataSize = 12544;
const unsigned int knobWidth = 56;
const unsigned int knobHeight = 56;
}

#endif // BINARY_WOBBLEJUICEARTWORK_HPP


+ 243
- 0
plugins/WobbleJuice/WobbleJuicePlugin.cpp View File

@@ -0,0 +1,243 @@
/*
* Wobble Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
#include "WobbleJuicePlugin.hpp"
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
WobbleJuicePlugin::WobbleJuicePlugin()
: Plugin(paramCount, 1, 0) // 1 program, 0 states
{
// set default values
d_setProgram(0);
}
// -----------------------------------------------------------------------
// Init
void WobbleJuicePlugin::d_initParameter(uint32_t index, Parameter& parameter)
{
switch (index)
{
case paramDivision:
parameter.hints = PARAMETER_IS_AUTOMABLE|PARAMETER_IS_INTEGER;
parameter.name = "Division";
parameter.symbol = "div";
parameter.unit = "x";
parameter.ranges.def = 4.0f;
parameter.ranges.min = 1.0f;
parameter.ranges.max = 16.0f;
break;
case paramReso:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Resonance";
parameter.symbol = "reso";
parameter.unit = "";
parameter.ranges.def = 0.1f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 0.2f;
break;
case paramRange:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Range";
parameter.symbol = "rng";
parameter.unit = "Hz";
parameter.ranges.def = 16000.0f;
parameter.ranges.min = 500.0f;
parameter.ranges.max = 16000.0f;
break;
case paramPhase:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Phase";
parameter.symbol = "phs";
parameter.unit = "Deg";
parameter.ranges.def = 0.0f;
parameter.ranges.min = -1.0f;
parameter.ranges.max = 1.0f;
break;
case paramWave:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Wave";
parameter.symbol = "wav";
parameter.unit = "";
parameter.ranges.def = 2.0f;
parameter.ranges.min = 1.0f;
parameter.ranges.max = 4.0f;
break;
case paramDrive:
parameter.hints = PARAMETER_IS_AUTOMABLE;
parameter.name = "Drive";
parameter.symbol = "drv";
parameter.unit = "";
parameter.ranges.def = 0.5f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
}
}
void WobbleJuicePlugin::d_initProgramName(uint32_t index, d_string& programName)
{
if (index != 0)
return;
programName = "Default";
}
// -----------------------------------------------------------------------
// Internal data
float WobbleJuicePlugin::d_getParameterValue(uint32_t index) const
{
switch (index)
{
case paramDivision:
return division;
case paramReso:
return reso;
case paramRange:
return range;
case paramPhase:
return phase;
case paramWave:
return wave;
case paramDrive:
return drive;
default:
return 0.0f;
}
}
void WobbleJuicePlugin::d_setParameterValue(uint32_t index, float value)
{
switch (index)
{
case paramDivision:
division = value;
break;
case paramReso:
reso = value;
break;
case paramRange:
range = value;
break;
case paramPhase:
phase = value;
break;
case paramWave:
wave = value;
break;
case paramDrive:
drive = value;
break;
}
}
void WobbleJuicePlugin::d_setProgram(uint32_t index)
{
if (index != 0)
return;
/* Default parameter values */
division = 4.0f;
reso = 0.1f;
range = 16000.0f;
phase = 0.0f;
wave = 2.0f;
drive = 0.5f;
/* Default variable values */
bar=tick=tickOffset=percentage=phaseOffset=currentPhaseL=0.0f;
currentPhaseR=posL=posR=cutoffL=cutoffR=0.0f;
waveType=2.0f;
/* reset filter values */
d_activate();
}
// -----------------------------------------------------------------------
// Process
void WobbleJuicePlugin::d_activate()
{
sinePos = 0.0;
}
void WobbleJuicePlugin::d_run(const float** inputs, float** outputs, uint32_t frames)
{
//fetch the timepos struct from host;
const TimePos& time(d_getTimePos());
/* sample count for one bar */
bar = ((120.0/(time.bbt.valid ? time.bbt.beatsPerMinute : 120.0))*(d_getSampleRate())); //ONE, two, three, four
tick = bar/(std::round(division)); //size of one target wob
phaseOffset = phase*M_PI; //2pi = 1 whole cycle
/* if rolling then sync to timepos */
if (time.playing)
{
tickOffset = time.frame-std::floor(time.frame/tick)*tick; //how much after last tick
if (tickOffset!=0) {
//TODO: why do we need this??
percentage = tickOffset/tick;
} else {
percentage = 0;
}
sinePos = (M_PI*2)*percentage;
if (sinePos>2*M_PI) {
//TODO: can this ever happen??
sinePos = 0;
}
}
/* else just keep on wobblin' */
else
{
sinePos += (M_PI)/(tick/2000); //wtf, but works
if (sinePos>2*M_PI) {
sinePos = 0;
}
}
/* phase of 0..1 filter = 500..16k */
currentPhaseL = getBlendedPhase(sinePos+phaseOffset, wave);
currentPhaseR = getBlendedPhase(sinePos-phaseOffset, wave);
/* logarithmic */
cutoffL = std::exp((std::log(range)-std::log(500))*currentPhaseL+std::log(500));
cutoffR = std::exp((std::log(range)-std::log(500))*currentPhaseR+std::log(500));
//output filtered signal
filterL.recalc(cutoffL, reso*4, d_getSampleRate(), drive);
filterR.recalc(cutoffR, reso*4, d_getSampleRate(), drive);
filterL.process(frames, inputs[0], outputs[0]);
filterR.process(frames, inputs[1], outputs[1]);
}
// -----------------------------------------------------------------------
Plugin* createPlugin()
{
return new WobbleJuicePlugin();
}
// -----------------------------------------------------------------------
END_NAMESPACE_DISTRHO

+ 142
- 0
plugins/WobbleJuice/WobbleJuicePlugin.hpp View File

@@ -0,0 +1,142 @@
/*
* Wobble Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/
#ifndef WOBBLEJUICEPLUGIN_HPP_INCLUDED
#define WOBBLEJUICEPLUGIN_HPP_INCLUDED
#include "DistrhoPlugin.hpp"
#include "moogVCF.hxx"
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
class WobbleJuicePlugin : public Plugin
{
public:
enum Parameters
{
paramDivision = 0,
paramReso,
paramRange,
paramPhase,
paramWave,
paramDrive,
paramCount
};
float getSinePhase(float x) {
return ((-std::cos(x)+1)/2);
}
float getSawPhase(float x) {
return (-((2/M_PI * std::atan(1/std::tan(x/2)))-1)/2);
}
float getRevSawPhase(float x) {
return (((2/M_PI * std::atan(1/std::tan(x/2)))+1)/2);
}
float getSquarePhase(float x) {
return (std::round((std::sin(x)+1)/2));
}
//saw, sqr, sin, revSaw
float getBlendedPhase(float x, float wave)
{
//wave = 2;
if (wave>=1 && wave<2) {
/* saw vs sqr */
waveBlend = wave-1;
return (getSawPhase(x)*(1-waveBlend) + getSquarePhase(x)*waveBlend);
} else if (wave>=2 && wave<3) {
/* sqr vs sin */
waveBlend = wave-2;
return (getSquarePhase(x)*(1-waveBlend) + getSinePhase(x)*waveBlend);
} else if (wave>=3 && wave<=4) {
/* sin vs revSaw */
waveBlend = wave-3;
return (getSinePhase(x)*(1-waveBlend) + getRevSawPhase(x)*waveBlend);
} else {
return 0.0f;
}
}
WobbleJuicePlugin();
protected:
// -------------------------------------------------------------------
// Information
const char* d_getLabel() const noexcept override
{
return "WobbleJuice";
}
const char* d_getMaker() const noexcept override
{
return "Andre Sklenar";
}
const char* d_getLicense() const noexcept override
{
return "GPL v2+";
}
uint32_t d_getVersion() const noexcept override
{
return 0x1000;
}
long d_getUniqueId() const noexcept override
{
return d_cconst('W', 'b', 'l', 'J');
}
// -------------------------------------------------------------------
// Init
void d_initParameter(uint32_t index, Parameter& parameter) override;
void d_initProgramName(uint32_t index, d_string& programName) override;
// -------------------------------------------------------------------
// Internal data
float d_getParameterValue(uint32_t index) const override;
void d_setParameterValue(uint32_t index, float value) override;
void d_setProgram(uint32_t index) override;
// -------------------------------------------------------------------
// Process
void d_activate() override;
void d_run(const float** inputs, float** outputs, uint32_t frames) override;
// -------------------------------------------------------------------
private:
MoogVCF filterL, filterR;
float division, reso, range, phase, wave, drive; //parameters
float bar, tick, tickOffset, percentage, phaseOffset, currentPhaseL, currentPhaseR, posL, posR, cutoffL, cutoffR;
double sinePos;
float waveType, waveBlend;
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(WobbleJuicePlugin)
};
// -----------------------------------------------------------------------
END_NAMESPACE_DISTRHO
#endif // WOBBLEJUICE_HPP_INCLUDED

+ 181
- 0
plugins/WobbleJuice/WobbleJuiceUI.cpp View File

@@ -0,0 +1,181 @@
/*
* Wobble Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#include "WobbleJuicePlugin.hpp"
#include "WobbleJuiceUI.hpp"

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

WobbleJuiceUI::WobbleJuiceUI()
: UI(),
fAboutWindow(this)
{
// background
fImgBackground = Image(WobbleJuiceArtwork::backgroundData, WobbleJuiceArtwork::backgroundWidth, WobbleJuiceArtwork::backgroundHeight, GL_BGR);

// about
Image aboutImage(WobbleJuiceArtwork::aboutData, WobbleJuiceArtwork::aboutWidth, WobbleJuiceArtwork::aboutHeight, GL_BGR);
fAboutWindow.setImage(aboutImage);

// knobs
Image knobImage(WobbleJuiceArtwork::knobData, WobbleJuiceArtwork::knobWidth, WobbleJuiceArtwork::knobHeight);

// knob Division
fKnobDivision = new ImageKnob(this, knobImage, ImageKnob::Vertical, WobbleJuicePlugin::paramDivision);
fKnobDivision->setAbsolutePos(222, 74);
fKnobDivision->setRotationAngle(270);
fKnobDivision->setRange(1.0f, 16.0f);
fKnobDivision->setDefault(4.0f);
fKnobDivision->setStep(1.0f);
fKnobDivision->setCallback(this);

// knob Resonance
fKnobResonance = new ImageKnob(this, knobImage, ImageKnob::Vertical, WobbleJuicePlugin::paramReso);
fKnobResonance->setAbsolutePos(222, 199);
fKnobResonance->setRotationAngle(270);
fKnobResonance->setRange(0.0f, 0.2f);
fKnobResonance->setDefault(0.1f);
fKnobResonance->setCallback(this);

// knob Range
fKnobRange = new ImageKnob(this, knobImage, ImageKnob::Vertical, WobbleJuicePlugin::paramRange);
fKnobRange->setAbsolutePos(77, 199);
fKnobRange->setRotationAngle(270);
fKnobRange->setRange(500.0f, 16000.0f);
fKnobRange->setDefault(16000.0f);
fKnobRange->setCallback(this);

// knob Phase
fKnobPhase = new ImageKnob(this, knobImage, ImageKnob::Vertical, WobbleJuicePlugin::paramPhase);
fKnobPhase->setAbsolutePos(362, 74);
fKnobPhase->setRotationAngle(270);
fKnobPhase->setRange(-1.0f, 1.0f);
fKnobPhase->setDefault(0.0f);
fKnobPhase->setCallback(this);

// knob Wave
fKnobWave = new ImageKnob(this, knobImage, ImageKnob::Vertical, WobbleJuicePlugin::paramWave);
fKnobWave->setAbsolutePos(77, 74);
fKnobWave->setRotationAngle(270);
fKnobWave->setRange(1.0f, 4.0f);
fKnobWave->setDefault(2.0f);
fKnobWave->setCallback(this);

// knob Drive
fKnobDrive = new ImageKnob(this, knobImage, ImageKnob::Vertical, WobbleJuicePlugin::paramDrive);
fKnobDrive->setAbsolutePos(362, 199);
fKnobDrive->setRotationAngle(270);
fKnobDrive->setRange(0.0f, 1.0f);
fKnobDrive->setDefault(0.5f);
fKnobDrive->setCallback(this);

// about button
Image aboutImageNormal(WobbleJuiceArtwork::aboutButtonNormalData, WobbleJuiceArtwork::aboutButtonNormalWidth, WobbleJuiceArtwork::aboutButtonNormalHeight);
Image aboutImageHover(WobbleJuiceArtwork::aboutButtonHoverData, WobbleJuiceArtwork::aboutButtonHoverWidth, WobbleJuiceArtwork::aboutButtonHoverHeight);
fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
fButtonAbout->setAbsolutePos(390, 20);
fButtonAbout->setCallback(this);

// set default values
d_programChanged(0);
}

// -----------------------------------------------------------------------
// DSP Callbacks

void WobbleJuiceUI::d_parameterChanged(uint32_t index, float value)
{
switch (index)
{
case WobbleJuicePlugin::paramDivision:
fKnobDivision->setValue(value);
break;
case WobbleJuicePlugin::paramReso:
fKnobResonance->setValue(value);
break;
case WobbleJuicePlugin::paramRange:
fKnobRange->setValue(value);
break;
case WobbleJuicePlugin::paramPhase:
fKnobPhase->setValue(value);
break;
case WobbleJuicePlugin::paramWave:
fKnobWave->setValue(value);
break;
case WobbleJuicePlugin::paramDrive:
fKnobDrive->setValue(value);
break;
}
}

void WobbleJuiceUI::d_programChanged(uint32_t index)
{
if (index != 0)
return;

// Default values
fKnobDivision->setValue(4.0f);
fKnobResonance->setValue(0.1f);
fKnobRange->setValue(16000.0f);
fKnobPhase->setValue(0.0f);
fKnobWave->setValue(2.0f);
fKnobDrive->setValue(0.5f);
}

// -----------------------------------------------------------------------
// Widget Callbacks

void WobbleJuiceUI::imageButtonClicked(ImageButton* button, int)
{
if (button != fButtonAbout)
return;

fAboutWindow.exec();
}

void WobbleJuiceUI::imageKnobDragStarted(ImageKnob* knob)
{
d_editParameter(knob->getId(), true);
}

void WobbleJuiceUI::imageKnobDragFinished(ImageKnob* knob)
{
d_editParameter(knob->getId(), false);
}

void WobbleJuiceUI::imageKnobValueChanged(ImageKnob* knob, float value)
{
d_setParameterValue(knob->getId(), value);
}

void WobbleJuiceUI::onDisplay()
{
fImgBackground.draw();
}

// -----------------------------------------------------------------------

UI* createUI()
{
return new WobbleJuiceUI();
}

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

+ 90
- 0
plugins/WobbleJuice/WobbleJuiceUI.hpp View File

@@ -0,0 +1,90 @@
/*
* Wobble Juice Plugin
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef WOBBLEJUICEUI_HPP_INCLUDED
#define WOBBLEJUICEUI_HPP_INCLUDED

#include "DistrhoUI.hpp"

#include "ImageAboutWindow.hpp"
#include "ImageButton.hpp"
#include "ImageKnob.hpp"

#include "WobbleJuiceArtwork.hpp"

using DGL::Image;
using DGL::ImageAboutWindow;
using DGL::ImageButton;
using DGL::ImageKnob;

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

class WobbleJuiceUI : public UI,
public ImageButton::Callback,
public ImageKnob::Callback
{
public:
WobbleJuiceUI();

protected:
// -------------------------------------------------------------------
// Information

uint d_getWidth() const noexcept override
{
return WobbleJuiceArtwork::backgroundWidth;
}

uint d_getHeight() const noexcept override
{
return WobbleJuiceArtwork::backgroundHeight;
}

// -------------------------------------------------------------------
// DSP Callbacks

void d_parameterChanged(uint32_t index, float value) override;
void d_programChanged(uint32_t index) override;

// -------------------------------------------------------------------
// Widget Callbacks

void imageButtonClicked(ImageButton* button, int) override;
void imageKnobDragStarted(ImageKnob* knob) override;
void imageKnobDragFinished(ImageKnob* knob) override;
void imageKnobValueChanged(ImageKnob* knob, float value) override;

void onDisplay() override;

private:
Image fImgBackground;
ImageAboutWindow fAboutWindow;

ScopedPointer<ImageButton> fButtonAbout;
ScopedPointer<ImageKnob> fKnobDivision, fKnobResonance, fKnobRange;
ScopedPointer<ImageKnob> fKnobPhase, fKnobWave, fKnobDrive;

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(WobbleJuiceUI)
};

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO

#endif // WOBBLEJUICEUI_HPP_INCLUDED

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save