Browse Source

ZynAddSubFX UI support via ntk

tags/1.9.4
falkTX 11 years ago
parent
commit
94d9dbee2c
7 changed files with 206 additions and 54 deletions
  1. +1
    -0
      source/Makefile.mk
  2. +4
    -0
      source/backend/Makefile.mk
  3. +38
    -54
      source/backend/native/Makefile
  4. +39
    -0
      source/backend/native/zynaddsubfx-ui.cpp
  5. +120
    -0
      source/backend/native/zynaddsubfx.cpp
  6. +3
    -0
      source/backend/standalone/Makefile
  7. +1
    -0
      source/bridges/Makefile

+ 1
- 0
source/Makefile.mk View File

@@ -57,6 +57,7 @@ HAVE_OPENGL = $(shell pkg-config --exists gl && echo true)

HAVE_AF_DEPS = $(shell pkg-config --exists libavcodec libavformat sndfile && echo true)
HAVE_ZYN_DEPS = $(shell pkg-config --exists fftw3 mxml zlib && echo true)
HAVE_ZYN_UI_DEPS = $(shell pkg-config --exists ntk ntk_images && echo true)

ifeq ($(HAVE_JACK),true)
HAVE_JACK_LATENCY = $(shell pkg-config --atleast-version=0.121.0 jack && echo true)


+ 4
- 0
source/backend/Makefile.mk View File

@@ -57,3 +57,7 @@ endif
ifeq ($(HAVE_ZYN_DEPS),true)
BUILD_CXX_FLAGS += -DWANT_ZYNADDSUBFX
endif

ifeq ($(HAVE_ZYN_UI_DEPS),true)
BUILD_CXX_FLAGS += -DWANT_ZYNADDSUBFX_UI
endif

+ 38
- 54
source/backend/native/Makefile View File

@@ -17,10 +17,17 @@ AF_C_FLAGS += $(shell pkg-config --cflags libavcodec libavformat sndfile)
LINK_FLAGS += $(shell pkg-config --libs libavcodec libavformat sndfile)
endif

# -Izynaddsubfx/UI

ifeq ($(HAVE_ZYN_DEPS),true)
ZYN_CXX_FLAGS = $(BUILD_CXX_FLAGS)
ZYN_CXX_FLAGS = $(BUILD_CXX_FLAGS) -DNTK_GUI
ZYN_CXX_FLAGS += $(shell pkg-config --cflags fftw3 mxml zlib)
LINK_FLAGS += $(shell pkg-config --libs fftw3 mxml zlib)
ifeq ($(HAVE_ZYN_UI_DEPS),true)
ZYN_CXX_FLAGS += -DNTK_GUI
ZYN_CXX_FLAGS += $(shell pkg-config --cflags ntk ntk_images)
LINK_FLAGS += $(shell pkg-config --libs ntk ntk_images)
endif
endif

# --------------------------------------------------------------
@@ -50,57 +57,30 @@ endif
# ZynAddSubFX
ifeq ($(HAVE_ZYN_DEPS),true)
OBJS += \
zynaddsubfx.cpp.o
# zynaddsubfx-src.cpp.o

OBJS += \
zynaddsubfx/DSP/AnalogFilter.cpp.o \
zynaddsubfx/DSP/FFTwrapper.cpp.o \
zynaddsubfx/DSP/Filter.cpp.o \
zynaddsubfx/DSP/FormantFilter.cpp.o \
zynaddsubfx/DSP/SVFilter.cpp.o \
zynaddsubfx/DSP/Unison.cpp.o \
zynaddsubfx/Effects/Alienwah.cpp.o \
zynaddsubfx/Effects/Chorus.cpp.o \
zynaddsubfx/Effects/Distorsion.cpp.o \
zynaddsubfx/Effects/DynamicFilter.cpp.o \
zynaddsubfx/Effects/Echo.cpp.o \
zynaddsubfx/Effects/Effect.cpp.o \
zynaddsubfx/Effects/EffectLFO.cpp.o \
zynaddsubfx/Effects/EffectMgr.cpp.o \
zynaddsubfx/Effects/EQ.cpp.o \
zynaddsubfx/Effects/Phaser.cpp.o \
zynaddsubfx/Effects/Reverb.cpp.o \
zynaddsubfx/Misc/Bank.cpp.o \
zynaddsubfx/Misc/Config.cpp.o \
zynaddsubfx/Misc/Dump.cpp.o \
zynaddsubfx/Misc/Master.cpp.o \
zynaddsubfx/Misc/Microtonal.cpp.o \
zynaddsubfx/Misc/Part.cpp.o \
zynaddsubfx/Misc/Recorder.cpp.o \
zynaddsubfx/Misc/Util.cpp.o \
zynaddsubfx/Misc/WavFile.cpp.o \
zynaddsubfx/Misc/WaveShapeSmps.cpp.o \
zynaddsubfx/Misc/XMLwrapper.cpp.o \
zynaddsubfx/Params/ADnoteParameters.cpp.o \
zynaddsubfx/Params/Controller.cpp.o \
zynaddsubfx/Params/EnvelopeParams.cpp.o \
zynaddsubfx/Params/FilterParams.cpp.o \
zynaddsubfx/Params/LFOParams.cpp.o \
zynaddsubfx/Params/PADnoteParameters.cpp.o \
zynaddsubfx/Params/Presets.cpp.o \
zynaddsubfx/Params/PresetsArray.cpp.o \
zynaddsubfx/Params/PresetsStore.cpp.o \
zynaddsubfx/Params/SUBnoteParameters.cpp.o \
zynaddsubfx/Synth/ADnote.cpp.o \
zynaddsubfx/Synth/Envelope.cpp.o \
zynaddsubfx/Synth/LFO.cpp.o \
zynaddsubfx/Synth/OscilGen.cpp.o \
zynaddsubfx/Synth/PADnote.cpp.o \
zynaddsubfx/Synth/Resonance.cpp.o \
zynaddsubfx/Synth/SUBnote.cpp.o \
zynaddsubfx/Synth/SynthNote.cpp.o
# zynaddsubfx/Misc/Stereo.cpp.o
zynaddsubfx.cpp.o \
zynaddsubfx-src.cpp.o

ifeq ($(HAVE_ZYN_UI_DEPS),true)
OBJS += zynaddsubfx-ui.cpp.o

ZYN_UI_FILES = \
zynaddsubfx/UI/ADnoteUI.cpp \
zynaddsubfx/UI/BankUI.cpp \
zynaddsubfx/UI/ConfigUI.cpp \
zynaddsubfx/UI/EffUI.cpp \
zynaddsubfx/UI/EnvelopeUI.cpp \
zynaddsubfx/UI/FilterUI.cpp \
zynaddsubfx/UI/LFOUI.cpp \
zynaddsubfx/UI/MasterUI.cpp \
zynaddsubfx/UI/MicrotonalUI.cpp \
zynaddsubfx/UI/OscilGenUI.cpp \
zynaddsubfx/UI/PADnoteUI.cpp \
zynaddsubfx/UI/PartUI.cpp \
zynaddsubfx/UI/PresetsUI.cpp \
zynaddsubfx/UI/ResonanceUI.cpp \
zynaddsubfx/UI/SUBnoteUI.cpp \
zynaddsubfx/UI/VirKeyboard.cpp
endif
endif

SHARED = ../libcarla_native.so
@@ -115,6 +95,7 @@ all: $(STATIC)

clean:
rm -f $(OBJS) $(SHARED) $(STATIC)
rm -f $(ZYN_UI_FILES)
rm -f moc_*.cpp

debug:
@@ -151,13 +132,13 @@ distrho-notes.cpp.o: distrho-notes.cpp notes/DistrhoPluginNotes.cpp notes/Distrh
audiofile.c.o: audiofile.c
$(CC) $< $(AF_C_FLAGS) -c -o $@

zynaddsubfx.cpp.o: zynaddsubfx.cpp
zynaddsubfx.cpp.o: zynaddsubfx.cpp $(ZYN_UI_FILES)
$(CXX) $< $(ZYN_CXX_FLAGS) -c -o $@

zynaddsubfx-src.cpp.o: zynaddsubfx-src.cpp
$(CXX) $< $(ZYN_CXX_FLAGS) -c -o $@

zynaddsubfx/%.cpp.o: zynaddsubfx/%.cpp
zynaddsubfx-ui.cpp.o: zynaddsubfx-ui.cpp $(ZYN_UI_FILES)
$(CXX) $< $(ZYN_CXX_FLAGS) -c -o $@

# --------------------------------------------------------------
@@ -165,6 +146,9 @@ zynaddsubfx/%.cpp.o: zynaddsubfx/%.cpp
moc_DistrhoUINotes.cpp: notes/DistrhoUINotes.hpp
$(MOC) $< -o $@

zynaddsubfx/UI/%.cpp: zynaddsubfx/UI/%.fl
ntk-fluid -c -o zynaddsubfx/UI/$*.cpp -h zynaddsubfx/UI/$*.h $<

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

../libs/%:


+ 39
- 0
source/backend/native/zynaddsubfx-ui.cpp View File

@@ -0,0 +1,39 @@
/*
* Carla Native Plugins
* Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
*
* 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 GPL.txt file
*/

#define PIXMAP_PATH "/usr/share/zynaddsubfx/pixmaps/"
#define SOURCE_DIR "/usr/share/zynaddsubfx/examples"

// zynaddsubfx ui includes
#include "zynaddsubfx/UI/NioUI.cpp"
#include "zynaddsubfx/UI/WidgetPDial.cpp"
#include "zynaddsubfx/UI/ADnoteUI.cpp"
#include "zynaddsubfx/UI/BankUI.cpp"
#include "zynaddsubfx/UI/ConfigUI.cpp"
#include "zynaddsubfx/UI/EffUI.cpp"
#include "zynaddsubfx/UI/EnvelopeUI.cpp"
#include "zynaddsubfx/UI/FilterUI.cpp"
#include "zynaddsubfx/UI/LFOUI.cpp"
#include "zynaddsubfx/UI/MasterUI.cpp"
#include "zynaddsubfx/UI/MicrotonalUI.cpp"
#include "zynaddsubfx/UI/OscilGenUI.cpp"
#include "zynaddsubfx/UI/PADnoteUI.cpp"
#include "zynaddsubfx/UI/PartUI.cpp"
#include "zynaddsubfx/UI/PresetsUI.cpp"
#include "zynaddsubfx/UI/ResonanceUI.cpp"
#include "zynaddsubfx/UI/SUBnoteUI.cpp"
#include "zynaddsubfx/UI/VirKeyboard.cpp"

+ 120
- 0
source/backend/native/zynaddsubfx.cpp View File

@@ -28,14 +28,33 @@
#include "zynaddsubfx/Misc/Master.h"
#include "zynaddsubfx/Misc/Util.h"

#define WANT_ZYNADDSUBFX_UI

#ifdef WANT_ZYNADDSUBFX_UI
#include "zynaddsubfx/UI/common.H"
#include "zynaddsubfx/UI/MasterUI.h"
#include <FL/Fl_Shared_Image.H>
#include <FL/Fl_Tiled_Image.H>
#include <FL/Fl_Dial.H>
#endif

#include <ctime>

#include <set>
#include <string>

// Dummy variables and functions for linking purposes
const char* instance_name = nullptr;
class WavFile;
namespace Nio {
bool start(void){return 1;}
void stop(void){}
bool setSource(std::string){return true;}
bool setSink(std::string){return true;}
std::set<std::string> getSources(void){return std::set<std::string>();}
std::set<std::string> getSinks(void){return std::set<std::string>();}
std::string getSource(void){return "";}
std::string getSink(void){return "";}
void waveNew(WavFile*){}
void waveStart(void){}
void waveStop(void){}
@@ -44,6 +63,23 @@ namespace Nio {

SYNTH_T* synth = nullptr;

#ifdef WANT_ZYNADDSUBFX_UI
#define PIXMAP_PATH "/usr/share/zynaddsubfx/pixmaps"
#define SOURCE_DIR "/usr/share/zynaddsubfx/examples"

static Fl_Tiled_Image* gModuleBackdrop = nullptr;

void set_module_parameters(Fl_Widget* o)
{
CARLA_ASSERT(gModuleBackdrop != nullptr);
o->box(FL_DOWN_FRAME);
o->align(o->align() | FL_ALIGN_IMAGE_BACKDROP);
o->color(FL_BLACK);
o->image(gModuleBackdrop);
o->labeltype(FL_SHADOW_LABEL);
}
#endif

class ZynAddSubFxPlugin : public PluginDescriptorClass
{
public:
@@ -55,15 +91,49 @@ public:
: PluginDescriptorClass(host),
kMaster(new Master()),
kSampleRate(getSampleRate()),
#ifdef WANT_ZYNADDSUBFX_UI
fUi(nullptr),
fUiClosed(0),
#endif
fThread(kMaster)
{
fThread.start();
maybeInitPrograms(kMaster);
fThread.waitForStarted();

#ifdef WANT_ZYNADDSUBFX_UI
fl_register_images();

Fl_Dial::default_style(Fl_Dial::PIXMAP_DIAL);

if(Fl_Shared_Image *img = Fl_Shared_Image::get(PIXMAP_PATH "/knob.png"))
Fl_Dial::default_image(img);
else
Fl_Dial::default_image(Fl_Shared_Image::get(SOURCE_DIR "/../pixmaps/knob.png"));

if(Fl_Shared_Image *img = Fl_Shared_Image::get(PIXMAP_PATH "/window_backdrop.png"))
Fl::scheme_bg(new Fl_Tiled_Image(img));
else
Fl::scheme_bg(new Fl_Tiled_Image(Fl_Shared_Image::get(SOURCE_DIR "/../pixmaps/window_backdrop.png")));

if(Fl_Shared_Image *img = Fl_Shared_Image::get(PIXMAP_PATH "/module_backdrop.png"))
gModuleBackdrop = new Fl_Tiled_Image(img);
else
gModuleBackdrop = new Fl_Tiled_Image(Fl_Shared_Image::get(SOURCE_DIR "/../pixmaps/module_backdrop.png"));

Fl::background(50, 50, 50);
Fl::background2(70, 70, 70);
Fl::foreground(255, 255, 255);
#endif
}

~ZynAddSubFxPlugin()
{
#ifdef WANT_ZYNADDSUBFX_UI
if (fUi != nullptr)
delete fUi;
#endif

//ensure that everything has stopped
pthread_mutex_lock(&kMaster->mutex);
pthread_mutex_unlock(&kMaster->mutex);
@@ -238,6 +308,47 @@ protected:
pthread_mutex_unlock(&kMaster->mutex);
}

#ifdef WANT_ZYNADDSUBFX_UI
// -------------------------------------------------------------------
// Plugin UI calls

void uiShow(const bool show)
{
if (show)
{
CARLA_ASSERT(fUi == nullptr);

if (fUi != nullptr)
return;

fUiClosed = 0;
fUi = new MasterUI(kMaster, &fUiClosed);
fUi->showUI();

Fl::check();
}
else
{
CARLA_ASSERT(fUi != nullptr);

if (fUi == nullptr)
return;

delete fUi;
fUi = nullptr;

Fl::check();
}
}

void uiIdle()
{
CARLA_ASSERT(fUi != nullptr);

Fl::check();
}
#endif

// -------------------------------------------------------------------
// Plugin chunk calls

@@ -331,6 +442,11 @@ private:
Master* const kMaster;
const unsigned kSampleRate;

#ifdef WANT_ZYNADDSUBFX_UI
MasterUI* fUi;
int fUiClosed;
#endif

ZynThread fThread;

static int sInstanceCount;
@@ -467,7 +583,11 @@ struct ProgramsDestructor {

static const PluginDescriptor zynAddSubFxDesc = {
/* category */ PLUGIN_CATEGORY_SYNTH,
#ifdef WANT_ZYNADDSUBFX_UI
/* hints */ static_cast<PluginHints>(PLUGIN_IS_SYNTH | PLUGIN_HAS_GUI | PLUGIN_USES_CHUNKS | PLUGIN_USES_SINGLE_THREAD),
#else
/* hints */ static_cast<PluginHints>(PLUGIN_IS_SYNTH | PLUGIN_USES_CHUNKS),
#endif
/* audioIns */ 2,
/* audioOuts */ 2,
/* midiIns */ 1,


+ 3
- 0
source/backend/standalone/Makefile View File

@@ -45,6 +45,9 @@ LINK_FLAGS += $(shell pkg-config --libs libavcodec libavformat sndfile)
endif
ifeq ($(HAVE_ZYN_DEPS),true)
LINK_FLAGS += $(shell pkg-config --libs fftw3 mxml zlib)
# ifeq ($(HAVE_ZYN_UI_DEPS),true)
LINK_FLAGS += $(shell pkg-config --libs ntk ntk_images)
# endif
endif

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


+ 1
- 0
source/bridges/Makefile View File

@@ -52,6 +52,7 @@ endif
ifeq ($(HAVE_ZYN_DEPS),true)
NATIVE_BUILD_FLAGS += -DWANT_ZYNADDSUBFX
NATIVE_LINK_FLAGS += $(shell pkg-config --libs fftw3 mxml zlib)
NATIVE_LINK_FLAGS += $(shell pkg-config --libs ntk ntk_images)
endif

POSIX_BUILD_FLAGS = $(BUILD_PLUGIN_FLAGS)


Loading…
Cancel
Save