Browse Source

Make at1 UI external, fix note-mask not saved

tags/1.9.7
falkTX 10 years ago
parent
commit
653c6d9de4
32 changed files with 516 additions and 265 deletions
  1. +1
    -0
      .gitignore
  2. +1
    -0
      Makefile
  3. +0
    -1
      source/includes/CarlaNativeExtUI.hpp
  4. +5
    -19
      source/includes/CarlaNativeJack.h
  5. +9
    -8
      source/native-plugins/Makefile
  6. +237
    -0
      source/native-plugins/zita-at1-ui.cpp
  7. +105
    -123
      source/native-plugins/zita-at1.cpp
  8. +2
    -3
      source/native-plugins/zita-at1/button.cc
  9. +2
    -2
      source/native-plugins/zita-at1/button.h
  10. +2
    -2
      source/native-plugins/zita-at1/global.h
  11. +2
    -2
      source/native-plugins/zita-at1/guiclass.cc
  12. +2
    -2
      source/native-plugins/zita-at1/guiclass.h
  13. +11
    -16
      source/native-plugins/zita-at1/jclient.cc
  14. +4
    -6
      source/native-plugins/zita-at1/jclient.h
  15. +33
    -22
      source/native-plugins/zita-at1/mainwin.cc
  16. +13
    -7
      source/native-plugins/zita-at1/mainwin.h
  17. +2
    -2
      source/native-plugins/zita-at1/png2img.cc
  18. +2
    -2
      source/native-plugins/zita-at1/png2img.h
  19. +2
    -2
      source/native-plugins/zita-at1/retuner.cc
  20. +2
    -2
      source/native-plugins/zita-at1/retuner.h
  21. +18
    -6
      source/native-plugins/zita-at1/rotary.cc
  22. +7
    -5
      source/native-plugins/zita-at1/rotary.h
  23. +39
    -16
      source/native-plugins/zita-at1/styles.cc
  24. +3
    -3
      source/native-plugins/zita-at1/styles.h
  25. +2
    -2
      source/native-plugins/zita-at1/tmeter.cc
  26. +2
    -2
      source/native-plugins/zita-at1/tmeter.h
  27. +1
    -0
      source/native-plugins/zita-bls1-ui.cpp
  28. +2
    -3
      source/native-plugins/zita-bls1.cpp
  29. +1
    -2
      source/native-plugins/zita-bls1/mainwin.cc
  30. +1
    -0
      source/native-plugins/zita-rev1-ui.cpp
  31. +2
    -3
      source/native-plugins/zita-rev1.cpp
  32. +1
    -2
      source/native-plugins/zita-rev1/mainwin.cc

+ 1
- 0
.gitignore View File

@@ -90,6 +90,7 @@ carla-discovery-posix64
carla-frontend carla-frontend
carla-lv2-export carla-lv2-export


at1-ui
bls1-ui bls1-ui
rev1-ui rev1-ui
zynaddsubfx-ui zynaddsubfx-ui


+ 1
- 0
Makefile View File

@@ -535,6 +535,7 @@ ifeq ($(EXPERIMENTAL_PLUGINS),true)
$(DESTDIR)$(PREFIX)/share/carla/resources/rev1/ $(DESTDIR)$(PREFIX)/share/carla/resources/rev1/


install -m 755 \ install -m 755 \
bin/resources/at1-ui \
bin/resources/bls1-ui \ bin/resources/bls1-ui \
bin/resources/rev1-ui \ bin/resources/rev1-ui \
$(DESTDIR)$(PREFIX)/share/carla/resources/ $(DESTDIR)$(PREFIX)/share/carla/resources/


+ 0
- 1
source/includes/CarlaNativeExtUI.hpp View File

@@ -233,7 +233,6 @@ protected:
return true; return true;
} }


carla_stderr("NativePluginAndUiClass::msgReceived : %s", msg);
return false; return false;
} }




+ 5
- 19
source/includes/CarlaNativeJack.h View File

@@ -109,7 +109,6 @@ typedef struct {
typedef struct { typedef struct {
// current state // current state
bool active; bool active;
const char* clientName;
jack_nframes_t bufferSize; jack_nframes_t bufferSize;
jack_nframes_t sampleRate; jack_nframes_t sampleRate;


@@ -153,7 +152,12 @@ jack_client_t* jack_client_open(const char* clientname, jack_options_t options,
static inline static inline
int jack_client_close(jack_client_t* client) int jack_client_close(jack_client_t* client)
{ {
// keep bufsize and srate
const jack_nframes_t bufferSize = client->bufferSize;
const jack_nframes_t sampleRate = client->sampleRate;
memset(client, 0, sizeof(jack_client_t)); memset(client, 0, sizeof(jack_client_t));
client->bufferSize = bufferSize;
client->sampleRate = sampleRate;
return 0; return 0;
} }


@@ -298,12 +302,6 @@ int jack_deactivate(jack_client_t* client)
/* ------------------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------------------
* Get data functions */ * Get data functions */


static inline
const char* jack_get_client_name(const jack_client_t* client)
{
return client->clientName;
}

static inline static inline
jack_nframes_t jack_get_buffer_size(const jack_client_t* client) jack_nframes_t jack_get_buffer_size(const jack_client_t* client)
{ {
@@ -316,18 +314,6 @@ jack_nframes_t jack_get_sample_rate(const jack_client_t* client)
return client->sampleRate; return client->sampleRate;
} }


/* ------------------------------------------------------------------------------------------------------------
* Misc */

static inline
pthread_t jack_client_thread_id(const jack_client_t* client)
{
return pthread_self();

// unused
(void)client;
}

/* ------------------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------------------ */


#ifdef __cplusplus #ifdef __cplusplus


+ 9
- 8
source/native-plugins/Makefile View File

@@ -170,6 +170,7 @@ OBJS += \
$(OBJDIR)/zita-rev1.cpp.o $(OBJDIR)/zita-rev1.cpp.o


TARGETS += \ TARGETS += \
resources/at1-ui$(APP_EXT) \
resources/bls1-ui$(APP_EXT) \ resources/bls1-ui$(APP_EXT) \
resources/rev1-ui$(APP_EXT) resources/rev1-ui$(APP_EXT)
endif endif
@@ -194,14 +195,19 @@ $(MODULEDIR)/$(MODULENAME).a: $(OBJS)
@rm -f $@ @rm -f $@
@$(AR) crs $@ $^ @$(AR) crs $@ $^


resources/at1-ui$(APP_EXT): $(OBJDIR)/zita-at1-ui.cpp.o
-@mkdir -p $(OBJDIR)
@echo "Linking at1-ui"
@$(CXX) $^ $(ZITA_UI_LINK_FLAGS) -o $@

resources/bls1-ui$(APP_EXT): $(OBJDIR)/zita-bls1-ui.cpp.o resources/bls1-ui$(APP_EXT): $(OBJDIR)/zita-bls1-ui.cpp.o
-@mkdir -p $(OBJDIR) -@mkdir -p $(OBJDIR)
@echo "Linking zita-bls1-ui"
@echo "Linking bls1-ui"
@$(CXX) $^ $(ZITA_UI_LINK_FLAGS) -o $@ @$(CXX) $^ $(ZITA_UI_LINK_FLAGS) -o $@


resources/rev1-ui$(APP_EXT): $(OBJDIR)/zita-rev1-ui.cpp.o resources/rev1-ui$(APP_EXT): $(OBJDIR)/zita-rev1-ui.cpp.o
-@mkdir -p $(OBJDIR) -@mkdir -p $(OBJDIR)
@echo "Linking zita-rev1-ui"
@echo "Linking rev1-ui"
@$(CXX) $^ $(ZITA_UI_LINK_FLAGS) -o $@ @$(CXX) $^ $(ZITA_UI_LINK_FLAGS) -o $@


resources/zynaddsubfx-ui$(APP_EXT): $(OBJDIR)/zynaddsubfx-ui.cpp.o resources/zynaddsubfx-ui$(APP_EXT): $(OBJDIR)/zynaddsubfx-ui.cpp.o
@@ -301,12 +307,6 @@ $(OBJDIR)/zynaddsubfx-ui.cpp.o: zynaddsubfx-ui.cpp $(ZYN_UI_FILES_H) $(ZYN_UI_FI


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


# TODO
$(OBJDIR)/zita-at1.cpp.o: zita-at1.cpp
-@mkdir -p $(OBJDIR)
@echo "Compiling $<"
@$(CXX) $< $(BUILD_CXX_FLAGS) $(shell pkg-config --cflags fftw3f x11 xft) -Wno-unused-parameter -Wno-unused-result -c -o $@

$(OBJDIR)/zita-%-ui.cpp.o: zita-%-ui.cpp $(OBJDIR)/zita-%-ui.cpp.o: zita-%-ui.cpp
-@mkdir -p $(OBJDIR) -@mkdir -p $(OBJDIR)
@echo "Compiling $<" @echo "Compiling $<"
@@ -327,6 +327,7 @@ $(OBJDIR)/%.cpp.o: %.cpp
# ---------------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------------


-include $(OBJS:%.o=%.d) -include $(OBJS:%.o=%.d)
-include $(OBJDIR)/zita-at1-ui.cpp.d
-include $(OBJDIR)/zita-bls1-ui.cpp.d -include $(OBJDIR)/zita-bls1-ui.cpp.d
-include $(OBJDIR)/zita-rev1-ui.cpp.d -include $(OBJDIR)/zita-rev1-ui.cpp.d
-include $(OBJDIR)/zynaddsubfx-ui.cpp.d -include $(OBJDIR)/zynaddsubfx-ui.cpp.d


+ 237
- 0
source/native-plugins/zita-at1-ui.cpp View File

@@ -0,0 +1,237 @@
/*
* Carla Native Plugins
* Copyright (C) 2012-2015 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 doc/GPL.txt file.
*/

#include "CarlaPipeUtils.cpp"

#include "zita-at1/png2img.cc"
#include "zita-at1/button.cc"
#include "zita-at1/guiclass.cc"
#include "zita-at1/mainwin.cc"
#include "zita-at1/rotary.cc"
#include "zita-at1/styles.cc"
#include "zita-at1/tmeter.cc"

using namespace AT1;

static Mainwin* mainwin = nullptr;

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

class ZitaPipeClient : public CarlaPipeClient,
public Mainwin::ValueChangedCallback
{
public:
ZitaPipeClient() noexcept
: CarlaPipeClient(),
fQuitReceived(false) {}

~ZitaPipeClient() noexcept override
{
if (fQuitReceived || ! isPipeRunning())
return;

const CarlaMutexLocker cml(getPipeLock());

writeMessage("exiting\n");
flushMessages();
}

bool quitRequested() const noexcept
{
return fQuitReceived;
}

protected:
bool msgReceived(const char* const msg) noexcept override
{
if (std::strcmp(msg, "zita-data") == 0)
{
float error;
int noteset, midiset;
CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(error), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(noteset), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(midiset), true);

mainwin->setdata_ui(error, noteset, midiset);
return true;
}

if (std::strcmp(msg, "zita-mask") == 0)
{
uint mask;
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(mask), true);

mainwin->setmask_ui(mask);
return true;
}

if (std::strcmp(msg, "control") == 0)
{
uint index;
float value;
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(index), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);

if (index < Mainwin::NROTARY)
mainwin->_rotary[index]->set_value(value);
else if (index == Mainwin::NROTARY) // == kParameterM_CHANNEL
mainwin->setchan_ui(value);

return true;
}

if (std::strcmp(msg, "show") == 0)
{
mainwin->x_map();
return true;
}

if (std::strcmp(msg, "hide") == 0)
{
mainwin->x_unmap();
return true;
}

if (std::strcmp(msg, "focus") == 0)
{
mainwin->x_mapraised();
return true;
}

if (std::strcmp(msg, "uiTitle") == 0)
{
const char* uiTitle;

CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(uiTitle), true);

mainwin->x_set_title(uiTitle);
return true;
}

if (std::strcmp(msg, "quit") == 0)
{
fQuitReceived = true;
mainwin->stop();
return true;
}

carla_stderr("ZitaPipeClient::msgReceived : %s", msg);
return false;
}

void noteMaskChangedCallback(int mask)
{
if (! isPipeRunning())
return;

char tmpBuf[0xff+1];
tmpBuf[0xff] = '\0';
std::snprintf(tmpBuf, 0xff, "%i\n", mask);

const CarlaMutexLocker cml(getPipeLock());

writeMessage("zita-mask\n", 10);
writeMessage(tmpBuf);
flushMessages();
}

void valueChangedCallback(uint index, float value) override
{
if (! isPipeRunning())
return;

writeControlMessage(index, value);
}

private:
bool fQuitReceived;
};

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

int main(int argc, const char* argv[])
{
X_resman xresman;
X_display *display;
X_handler *handler;
X_rootwin *rootwin;
int ev, xp, yp, xs, ys;

int fake_argc = 1;
char* fake_argv[] = { (char*)"rev1" };
xresman.init(&fake_argc, fake_argv, (char*)"rev1", nullptr, 0);

display = new X_display(nullptr);
if (display->dpy () == 0)
{
carla_stderr("Can't open display.");
delete display;
return 1;
}

ZitaPipeClient pipe;
const char* uiTitle = "Test UI";

if (argc > 1)
{
uiTitle = argv[2];

if (! pipe.initPipeClient(argv))
return 1;
}

xp = yp = 100;
xs = Mainwin::XSIZE + 4;
ys = Mainwin::YSIZE + 30;
xresman.geometry(".geometry", display->xsize(), display->ysize(), 1, xp, yp, xs, ys);

styles_init(display, &xresman);
rootwin = new X_rootwin(display);
mainwin = new Mainwin(rootwin, &xresman, xp, yp, &pipe);
mainwin->x_set_title(uiTitle);
rootwin->handle_event();
handler = new X_handler(display, mainwin, EV_X11);
handler->next_event();
XFlush(display->dpy());

do
{
ev = mainwin->process();
if (ev == EV_X11)
{
rootwin->handle_event();
handler->next_event();
}
else if (ev == Esync::EV_TIME)
{
handler->next_event();

if (pipe.isPipeRunning())
pipe.idlePipe();
}
}
while (ev != EV_EXIT && ! pipe.quitRequested());

styles_fini(display);
delete handler;
delete rootwin;
delete display;

return 0;
}

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

+ 105
- 123
source/native-plugins/zita-at1.cpp View File

@@ -15,23 +15,15 @@
* For a full copy of the GNU General Public License see the doc/GPL.txt file. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/ */


#include "CarlaNative.hpp"
#include "CarlaMathUtils.hpp"
#include "CarlaNativeExtUI.hpp"
#include "CarlaJuceUtils.hpp" #include "CarlaJuceUtils.hpp"


#include "juce_audio_basics.h" #include "juce_audio_basics.h"


#include "zita-common.hpp"
#include "zita-at1/button.cc"
#include "zita-at1/guiclass.cc"
#include "zita-at1/jclient.cc" #include "zita-at1/jclient.cc"
#include "zita-at1/mainwin.cc"
#include "zita-at1/png2img.cc"
#include "zita-at1/retuner.cc" #include "zita-at1/retuner.cc"
#include "zita-at1/rotary.cc"
#include "zita-at1/styles.cc"
#include "zita-at1/tmeter.cc"


using juce::roundToIntAccurate;
using juce::FloatVectorOperations; using juce::FloatVectorOperations;
using juce::ScopedPointer; using juce::ScopedPointer;


@@ -40,9 +32,7 @@ using namespace AT1;
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// AT1 Plugin // AT1 Plugin


class AT1Plugin : public NativePluginClass,
public X_handler_thread<Mainwin>::SetValueCallback,
private Mainwin::ValueChangedCallback
class AT1Plugin : public NativePluginAndUiClass
{ {
public: public:
enum Parameters { enum Parameters {
@@ -61,48 +51,28 @@ public:
}; };


AT1Plugin(const NativeHostDescriptor* const host) AT1Plugin(const NativeHostDescriptor* const host)
: NativePluginClass(host),
: NativePluginAndUiClass(host, "at1-ui"),
fJackClient(), fJackClient(),
xresman(),
jclient(nullptr), jclient(nullptr),
display(nullptr),
rootwin(nullptr),
mainwin(nullptr),
handler(nullptr),
handlerThread(this),
notemask(0xfff),
leakDetector_AT1Plugin() leakDetector_AT1Plugin()
{ {
CARLA_SAFE_ASSERT(host != nullptr); CARLA_SAFE_ASSERT(host != nullptr);


carla_zeroStruct(fJackClient); carla_zeroStruct(fJackClient);


fJackClient.clientName = "at1";
fJackClient.bufferSize = getBufferSize(); fJackClient.bufferSize = getBufferSize();
fJackClient.sampleRate = getSampleRate(); fJackClient.sampleRate = getSampleRate();


int argc = 1;
char* argv[] = { (char*)"at1" };
xresman.init(&argc, argv, (char*)"at1", nullptr, 0);

jclient = new Jclient(xresman.rname(), &fJackClient);

// set initial values // set initial values
fParameters[kParameterR_TUNE] = 440.0f; fParameters[kParameterR_TUNE] = 440.0f;
fParameters[kParameterR_FILT] = 0.1f; fParameters[kParameterR_FILT] = 0.1f;
fParameters[kParameterR_BIAS] = 0.5f; fParameters[kParameterR_BIAS] = 0.5f;
fParameters[kParameterR_CORR] = 1.0f; fParameters[kParameterR_CORR] = 1.0f;
fParameters[kParameterR_OFFS] = 0.0f; fParameters[kParameterR_OFFS] = 0.0f;

fParameters[kParameterM_CHANNEL] = 0.0f; fParameters[kParameterM_CHANNEL] = 0.0f;


Retuner* const retuner(jclient->retuner());

jclient->set_midichan(-1);
retuner->set_refpitch(fParameters[kParameterR_TUNE]);
retuner->set_corrfilt(fParameters[kParameterR_FILT]);
retuner->set_notebias(fParameters[kParameterR_BIAS]);
retuner->set_corrgain(fParameters[kParameterR_CORR]);
retuner->set_corroffs(fParameters[kParameterR_OFFS]);
_recreateZitaClient();
} }


// ------------------------------------------------------------------- // -------------------------------------------------------------------
@@ -162,7 +132,7 @@ public:
param.ranges.max = 1.0f; param.ranges.max = 1.0f;
break; break;
case kParameterR_OFFS: case kParameterR_OFFS:
param.name = "OfOfset";
param.name = "Offset";
param.ranges.def = 0.0f; param.ranges.def = 0.0f;
param.ranges.min = -2.0f; param.ranges.min = -2.0f;
param.ranges.max = 2.0f; param.ranges.max = 2.0f;
@@ -284,72 +254,74 @@ public:


void uiShow(const bool show) override void uiShow(const bool show) override
{ {
if (show)
NativePluginAndUiClass::uiShow(show);

if (show && isPipeRunning())
{ {
if (display != nullptr)
return;
char tmpBuf[0xff+1];
tmpBuf[0xff] = '\0';


display = new X_display(nullptr);
const CarlaMutexLocker cml(getPipeLock());


if (display->dpy() == nullptr)
return hostUiUnavailable();
writeMessage("zita-mask\n", 10);


styles_init(display, &xresman, getResourceDir());
std::snprintf(tmpBuf, 0xff, "%i\n", notemask);
writeMessage(tmpBuf);


rootwin = new X_rootwin(display);
mainwin = new Mainwin(rootwin, &xresman, 0, 0, jclient, this);
flushMessages();
}
}


mainwin->x_set_title(getUiName());
void uiIdle() override
{
NativePluginAndUiClass::uiIdle();


if (const uintptr_t winId = getUiParentId())
XSetTransientForHint(display->dpy(), mainwin->win(), static_cast<Window>(winId));
if (! isPipeRunning())
return;


rootwin->handle_event();
char tmpBuf[0xff+1];
tmpBuf[0xff] = '\0';


handler = new X_handler(display, mainwin, EV_X11);
handler->next_event();
XFlush(display->dpy());
const CarlaMutexLocker cmlc(fClientMutex);
const CarlaMutexLocker cmlp(getPipeLock());
const ScopedLocale csl;


handlerThread.setupAndRun(handler, rootwin, mainwin);
}
else
{
if (handlerThread.isThreadRunning())
handlerThread.stopThread();
Retuner* const retuner(jclient->retuner());


handler = nullptr;
mainwin = nullptr;
rootwin = nullptr;
display = nullptr;
}
writeMessage("zita-data\n", 10);

std::snprintf(tmpBuf, 0xff, "%f\n", retuner->get_error());
writeMessage(tmpBuf);

std::snprintf(tmpBuf, 0xff, "%i\n", retuner->get_noteset());
writeMessage(tmpBuf);

std::snprintf(tmpBuf, 0xff, "%i\n", jclient->get_midiset());
writeMessage(tmpBuf);

flushMessages();
} }


void uiIdle() override
// -------------------------------------------------------------------
// Plugin state calls

char* getState() const override
{ {
if (mainwin == nullptr)
return;
char tmpBuf[0xff+1];
tmpBuf[0xff] = '\0';
std::snprintf(tmpBuf, 0xff, "%i", notemask);


if (handlerThread.wasClosed())
{
{
const CarlaMutexLocker cml(handlerThread.getLock());
handler = nullptr;
mainwin = nullptr;
rootwin = nullptr;
display = nullptr;
}
uiClosed();
}
return strdup(tmpBuf);
} }


void uiSetParameterValue(const uint32_t index, const float value) override
void setState(const char* const data) override
{ {
CARLA_SAFE_ASSERT_RETURN(index < kNumParameters,);
CARLA_SAFE_ASSERT_RETURN(data != nullptr && data[0] != '\0',);


if (mainwin == nullptr)
return;
notemask = std::atoi(data);


handlerThread.setParameterValueLater(index, value);
const CarlaMutexLocker cml(fClientMutex);
jclient->set_notemask(notemask);
} }


// ------------------------------------------------------------------- // -------------------------------------------------------------------
@@ -358,51 +330,47 @@ public:
void bufferSizeChanged(const uint32_t bufferSize) override void bufferSizeChanged(const uint32_t bufferSize) override
{ {
fJackClient.bufferSize = bufferSize; fJackClient.bufferSize = bufferSize;
// _recreateZitaClient(); // FIXME
} }


void sampleRateChanged(const double sampleRate) override void sampleRateChanged(const double sampleRate) override
{ {
fJackClient.sampleRate = sampleRate; fJackClient.sampleRate = sampleRate;
}

void uiNameChanged(const char* const uiName) override
{
CARLA_SAFE_ASSERT_RETURN(uiName != nullptr && uiName[0] != '\0',);

if (mainwin == nullptr)
return;

const CarlaMutexLocker cml(handlerThread.getLock());

mainwin->x_set_title(uiName);
// _recreateZitaClient(); // FIXME
} }


// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Mainwin callbacks
// Pipe Server calls


void valueChangedCallback(uint index, float value) override
bool msgReceived(const char* const msg) noexcept override
{ {
fParameters[index] = value;
uiParameterChanged(index, value);
}
if (NativePluginAndUiClass::msgReceived(msg))
return true;


// -------------------------------------------------------------------
// X_handler_thread callbacks
if (std::strcmp(msg, "zita-mask") == 0)
{
int mask;


void setParameterValueFromHandlerThread(uint32_t index, float value) override
{
CARLA_SAFE_ASSERT_RETURN(mainwin != nullptr,);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(mask), true);


if (index < kParameterNROTARY)
{
mainwin->_rotary[index]->set_value(value);
return;
}
if (index == kParameterM_CHANNEL)
{
mainwin->setchan_ui(value);
return;
const CarlaMutexLocker cml(fClientMutex);

try {
if (mask < 0)
{
jclient->clr_midimask();
}
else
{
notemask = static_cast<uint>(mask);
jclient->set_notemask(mask);
}
} CARLA_SAFE_EXCEPTION("msgReceived, zita-mask");

return true;
} }

return false;
} }


// ------------------------------------------------------------------- // -------------------------------------------------------------------
@@ -412,16 +380,31 @@ private:
jack_client_t fJackClient; jack_client_t fJackClient;


// Zita stuff (core) // Zita stuff (core)
X_resman xresman;
ScopedPointer<Jclient> jclient;
ScopedPointer<X_display> display;
ScopedPointer<X_rootwin> rootwin;
ScopedPointer<Mainwin> mainwin;
ScopedPointer<X_handler> handler;
X_handler_thread<Mainwin> handlerThread;
ScopedPointer<Jclient> jclient;
uint notemask;


// Parameters
float fParameters[kNumParameters]; float fParameters[kNumParameters];


// mutex to make sure jclient is always valid
CarlaMutex fClientMutex;

void _recreateZitaClient()
{
const CarlaMutexLocker cml(fClientMutex);

jclient = new Jclient(&fJackClient);
jclient->set_notemask(notemask);
jclient->set_midichan(roundToIntAccurate(fParameters[kParameterM_CHANNEL])-1);

Retuner* const retuner(jclient->retuner());
retuner->set_refpitch(fParameters[kParameterR_TUNE]);
retuner->set_corrfilt(fParameters[kParameterR_FILT]);
retuner->set_notebias(fParameters[kParameterR_BIAS]);
retuner->set_corrgain(fParameters[kParameterR_CORR]);
retuner->set_corroffs(fParameters[kParameterR_OFFS]);
}

PluginClassEND(AT1Plugin) PluginClassEND(AT1Plugin)
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AT1Plugin) CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AT1Plugin)
}; };
@@ -433,8 +416,7 @@ static const NativePluginDescriptor at1Desc = {
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE
|NATIVE_PLUGIN_HAS_UI |NATIVE_PLUGIN_HAS_UI
|NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS |NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS
|NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
|NATIVE_PLUGIN_USES_PARENT_ID),
|NATIVE_PLUGIN_USES_STATE),
/* supports */ static_cast<NativePluginSupports>(0x0), /* supports */ static_cast<NativePluginSupports>(0x0),
/* audioIns */ 1, /* audioIns */ 1,
/* audioOuts */ 1, /* audioOuts */ 1,


+ 2
- 3
source/native-plugins/zita-at1/button.cc View File

@@ -1,8 +1,8 @@
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
@@ -136,5 +136,4 @@ void PushButton::render (void)
} }





} }

+ 2
- 2
source/native-plugins/zita-at1/button.h View File

@@ -1,8 +1,8 @@
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or


+ 2
- 2
source/native-plugins/zita-at1/global.h View File

@@ -1,8 +1,8 @@
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or


+ 2
- 2
source/native-plugins/zita-at1/guiclass.cc View File

@@ -1,8 +1,8 @@
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// Copyright (C) 2010-2014 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2010-2014 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or


+ 2
- 2
source/native-plugins/zita-at1/guiclass.h View File

@@ -1,8 +1,8 @@
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// Copyright (C) 2010-2014 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2010-2014 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or


+ 11
- 16
source/native-plugins/zita-at1/jclient.cc View File

@@ -1,8 +1,8 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// //
// Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
@@ -29,13 +29,12 @@
namespace AT1 { namespace AT1 {




Jclient::Jclient (const char *jname, jack_client_t *jclient) :
Jclient::Jclient (jack_client_t *jclient) :
A_thread ("jclient"), A_thread ("jclient"),
_jack_client (jclient), _jack_client (jclient),
_active (false),
_jname (0)
_active (false)
{ {
init_jack (jname);
init_jack ();
} }




@@ -45,17 +44,12 @@ Jclient::~Jclient (void)
} }




void Jclient::init_jack (const char *jname)
void Jclient::init_jack (void)
{ {
jack_on_shutdown (_jack_client, jack_static_shutdown, (void *) this); jack_on_shutdown (_jack_client, jack_static_shutdown, (void *) this);
jack_set_process_callback (_jack_client, jack_static_process, (void *) this); jack_set_process_callback (_jack_client, jack_static_process, (void *) this);
if (jack_activate (_jack_client))
{
fprintf(stderr, "Can't activate JACK.\n");
exit (1);
}
jack_activate (_jack_client);


_jname = jack_get_client_name (_jack_client);
_fsamp = jack_get_sample_rate (_jack_client); _fsamp = jack_get_sample_rate (_jack_client);
_fsize = jack_get_buffer_size (_jack_client); _fsize = jack_get_buffer_size (_jack_client);


@@ -115,19 +109,20 @@ void Jclient::midi_process (int nframes)


p = jack_port_get_buffer (_midi_port, nframes); p = jack_port_get_buffer (_midi_port, nframes);
i = 0; i = 0;
while (jack_midi_event_get (&E, p, i) == 0)
while (jack_midi_event_get (&E, p, i) == 0 && E.size == 3)
{ {
t = E.buffer [0]; t = E.buffer [0];
n = E.buffer [1]; n = E.buffer [1];
v = E.buffer [2]; v = E.buffer [2];
if ((_midichan < 0) || ((t & 0x0F) == _midichan)) if ((_midichan < 0) || ((t & 0x0F) == _midichan))
{ {
const int n12 = n % 12;
switch (t & 0xF0) switch (t & 0xF0)
{ {
case 0x80: case 0x80:
case 0x90: case 0x90:
if (v && (t & 0x10))_notes [n % 12] += 1;
else _notes [n % 12] -= 1;
if (v && (t & 0x10))_notes [n12] += 1;
else if (_notes [n12] > 0) _notes [n12] -= 1;
break; break;
} }
} }


+ 4
- 6
source/native-plugins/zita-at1/jclient.h View File

@@ -1,8 +1,8 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// //
// Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
@@ -35,10 +35,9 @@ class Jclient : public A_thread
{ {
public: public:


Jclient (const char *jname, jack_client_t *jclient);
Jclient (jack_client_t *jclient);
~Jclient (void); ~Jclient (void);


const char *jname (void) { return _jname; }
unsigned int fsize (void) const { return _fsize; } unsigned int fsize (void) const { return _fsize; }
unsigned int fsamp (void) const { return _fsamp; } unsigned int fsamp (void) const { return _fsamp; }
Retuner *retuner (void) { return _retuner; } Retuner *retuner (void) { return _retuner; }
@@ -52,7 +51,7 @@ private:


virtual void thr_main (void) {} virtual void thr_main (void) {}


void init_jack (const char *jname);
void init_jack (void);
void close_jack (void); void close_jack (void);
void jack_shutdown (void); void jack_shutdown (void);
int jack_process (int nframes); int jack_process (int nframes);
@@ -63,7 +62,6 @@ private:
jack_port_t *_aout_port; jack_port_t *_aout_port;
jack_port_t *_midi_port; jack_port_t *_midi_port;
bool _active; bool _active;
const char *_jname;
unsigned int _fsamp; unsigned int _fsamp;
unsigned int _fsize; unsigned int _fsize;
Retuner *_retuner; Retuner *_retuner;


+ 33
- 22
source/native-plugins/zita-at1/mainwin.cc View File

@@ -1,8 +1,8 @@
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// Copyright (C) 2010-2014 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2010-2014 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
@@ -30,24 +30,23 @@
namespace AT1 { namespace AT1 {




Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jclient, ValueChangedCallback* valuecb) :
Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, ValueChangedCallback* valuecb) :
A_thread ("Main"), A_thread ("Main"),
X_window (parent, xp, yp, XSIZE, YSIZE, XftColors [C_MAIN_BG]->pixel), X_window (parent, xp, yp, XSIZE, YSIZE, XftColors [C_MAIN_BG]->pixel),
_stop (false), _stop (false),
_xres (xres), _xres (xres),
_jclient (jclient),
z_error (0.0f),
z_noteset (0),
z_midiset (0),
_valuecb (valuecb) _valuecb (valuecb)
{ {
X_hints H; X_hints H;
char s [256];
int i, j, x, y; int i, j, x, y;


_atom = XInternAtom (dpy (), "WM_DELETE_WINDOW", True); _atom = XInternAtom (dpy (), "WM_DELETE_WINDOW", True);
XSetWMProtocols (dpy (), win (), &_atom, 1); XSetWMProtocols (dpy (), win (), &_atom, 1);
_atom = XInternAtom (dpy (), "WM_PROTOCOLS", True); _atom = XInternAtom (dpy (), "WM_PROTOCOLS", True);


sprintf (s, "%s", jclient->jname ());
x_set_title (s);
H.position (xp, yp); H.position (xp, yp);
H.minsize (XSIZE, YSIZE); H.minsize (XSIZE, YSIZE);
H.maxsize (XSIZE, YSIZE); H.maxsize (XSIZE, YSIZE);
@@ -88,6 +87,7 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc
} }




RotaryCtl::init (disp ());
x = 270; x = 270;
_rotary [R_TUNE] = new Rlinctl (this, this, R_TUNE, &r_tune_geom, x, 0, 400, 5, 400.0, 480.0, 440.0); _rotary [R_TUNE] = new Rlinctl (this, this, R_TUNE, &r_tune_geom, x, 0, 400, 5, 400.0, 480.0, 440.0);
_rotary [R_BIAS] = new Rlinctl (this, this, R_BIAS, &r_bias_geom, x, 0, 270, 5, 0.0, 1.0, 0.5); _rotary [R_BIAS] = new Rlinctl (this, this, R_BIAS, &r_bias_geom, x, 0, 270, 5, 0.0, 1.0, 0.5);
@@ -99,10 +99,9 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc
_textln = new X_textip (this, 0, &tstyle1, 0, 0, 50, 15, 15); _textln = new X_textip (this, 0, &tstyle1, 0, 0, 50, 15, 15);
_textln->set_align (0); _textln->set_align (0);
_ttimer = 0; _ttimer = 0;
_notes = 0xFFF;
_notes = 0xFFF;


x_add_events (ExposureMask);
x_map ();
x_add_events (ExposureMask);
set_time (0); set_time (0);
inc_time (500000); inc_time (500000);
} }
@@ -110,6 +109,7 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc
Mainwin::~Mainwin (void) Mainwin::~Mainwin (void)
{ {
RotaryCtl::fini ();
} }


@@ -130,6 +130,14 @@ int Mainwin::process (void)
} }




void Mainwin::setdata_ui (float error, int noteset, int midiset)
{
z_error = error;
z_noteset = noteset;
z_midiset = midiset;
}


void Mainwin::setchan_ui (int chan) void Mainwin::setchan_ui (int chan)
{ {
char s [16]; char s [16];
@@ -145,6 +153,15 @@ void Mainwin::setchan_ui (int chan)
} }




void Mainwin::setmask_ui (int mask)
{
_notes = mask;

for (int i = 0; i < 12; i++)
_bnote [i]->set_state ( (_notes & (1 << i)) != 0 ? 1 : 0 );
}


void Mainwin::handle_event (XEvent *E) void Mainwin::handle_event (XEvent *E)
{ {
switch (E->type) switch (E->type)
@@ -178,9 +195,9 @@ void Mainwin::handle_time (void)
int i, k, s; int i, k, s;
float v; float v;


v = _jclient->retuner ()->get_error ();
v = z_error;
_tmeter->update (v, v); _tmeter->update (v, v);
k = _jclient->retuner ()->get_noteset ();
k = z_noteset;
for (i = 0; i < 12; i++) for (i = 0; i < 12; i++)
{ {
s = _bnote [i]->state (); s = _bnote [i]->state ();
@@ -189,14 +206,14 @@ void Mainwin::handle_time (void)
_bnote [i]->set_state (s); _bnote [i]->set_state (s);
k >>= 1; k >>= 1;
} }
k = _jclient->get_midiset();
k = z_midiset;
if (k) _bmidi->set_state (_bmidi->state () | 1); if (k) _bmidi->set_state (_bmidi->state () | 1);
else _bmidi->set_state (_bmidi->state () & ~1); else _bmidi->set_state (_bmidi->state () & ~1);
if (_ttimer) if (_ttimer)
{ {
if (--_ttimer == 0) _textln->x_unmap (); if (--_ttimer == 0) _textln->x_unmap ();
} }
inc_time (50000);
inc_time (5000);
XFlush (dpy ()); XFlush (dpy ());
} }


@@ -246,11 +263,11 @@ void Mainwin::handle_callb (int type, X_window *W, XEvent *E)
k = 1 << k; k = 1 << k;
if (B->state () & 1) _notes |= k; if (B->state () & 1) _notes |= k;
else _notes &= ~k; else _notes &= ~k;
_jclient->set_notemask (_notes);
_valuecb->noteMaskChangedCallback (_notes);
} }
else if (k == B_MIDI) else if (k == B_MIDI)
{ {
_jclient->clr_midimask ();
_valuecb->noteMaskChangedCallback (-1);
} }
break; break;


@@ -273,28 +290,23 @@ void Mainwin::handle_callb (int type, X_window *W, XEvent *E)
{ {
case R_TUNE: case R_TUNE:
v = _rotary [R_TUNE]->value (); v = _rotary [R_TUNE]->value ();
_jclient->retuner ()->set_refpitch (v);
_valuecb->valueChangedCallback (R_TUNE, v); _valuecb->valueChangedCallback (R_TUNE, v);
showval (k); showval (k);
break; break;
case R_BIAS: case R_BIAS:
v = _rotary [R_BIAS]->value (); v = _rotary [R_BIAS]->value ();
_jclient->retuner ()->set_notebias (v);
_valuecb->valueChangedCallback (R_BIAS, v); _valuecb->valueChangedCallback (R_BIAS, v);
break; break;
case R_FILT: case R_FILT:
v = _rotary [R_FILT]->value (); v = _rotary [R_FILT]->value ();
_jclient->retuner ()->set_corrfilt (v);
_valuecb->valueChangedCallback (R_FILT, v); _valuecb->valueChangedCallback (R_FILT, v);
break; break;
case R_CORR: case R_CORR:
v = _rotary [R_CORR]->value (); v = _rotary [R_CORR]->value ();
_jclient->retuner ()->set_corrgain (v);
_valuecb->valueChangedCallback (R_CORR, v); _valuecb->valueChangedCallback (R_CORR, v);
break; break;
case R_OFFS: case R_OFFS:
v = _rotary [R_OFFS]->value (); v = _rotary [R_OFFS]->value ();
_jclient->retuner ()->set_corroffs (v);
_valuecb->valueChangedCallback (R_OFFS, v); _valuecb->valueChangedCallback (R_OFFS, v);
showval (k); showval (k);
break; break;
@@ -317,7 +329,6 @@ void Mainwin::setchan (int d)
_bchan->set_text (s, 0); _bchan->set_text (s, 0);
} }
else _bchan->set_text ("Omni", 0); else _bchan->set_text ("Omni", 0);
_jclient->set_midichan (_midich - 1);
_valuecb->valueChangedCallback (NROTARY, _midich); _valuecb->valueChangedCallback (NROTARY, _midich);
} }




+ 13
- 7
source/native-plugins/zita-at1/mainwin.h View File

@@ -1,8 +1,8 @@
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// Copyright (C) 2010-2014 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2010-2014 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
@@ -30,7 +30,7 @@
#include "tmeter.h" #include "tmeter.h"
#include "global.h" #include "global.h"


class AT1Plugin;
class ZitaPipeClient;


namespace AT1 { namespace AT1 {


@@ -41,12 +41,14 @@ public:


struct ValueChangedCallback { struct ValueChangedCallback {
virtual ~ValueChangedCallback() {} virtual ~ValueChangedCallback() {}
virtual void noteMaskChangedCallback(int) = 0;
virtual void valueChangedCallback(uint, float) = 0; virtual void valueChangedCallback(uint, float) = 0;
}; };


enum { XSIZE = 600, YSIZE = 75 };


Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jclient, ValueChangedCallback* valuecb);
enum { XSIZE = 580, YSIZE = 75 };

Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, ValueChangedCallback* valuecb);
~Mainwin (void); ~Mainwin (void);
Mainwin (const Mainwin&); Mainwin (const Mainwin&);
Mainwin& operator=(const Mainwin&); Mainwin& operator=(const Mainwin&);
@@ -54,7 +56,9 @@ public:
void stop (void) { _stop = true; } void stop (void) { _stop = true; }
int process (void); int process (void);


void setdata_ui (float error, int noteset, int midiset);
void setchan_ui (int chan); void setchan_ui (int chan);
void setmask_ui (int mask);


private: private:


@@ -77,7 +81,6 @@ private:
bool _stop; bool _stop;
bool _ambis; bool _ambis;
X_resman *_xres; X_resman *_xres;
Jclient *_jclient;
int _notes; int _notes;
PushButton *_bmidi; PushButton *_bmidi;
PushButton *_bnote [12]; PushButton *_bnote [12];
@@ -88,9 +91,12 @@ private:
int _midich; int _midich;
int _ttimer; int _ttimer;


float z_error;
int z_noteset, z_midiset;

ValueChangedCallback* _valuecb; ValueChangedCallback* _valuecb;


friend class ::AT1Plugin;
friend class ::ZitaPipeClient;
}; };






+ 2
- 2
source/native-plugins/zita-at1/png2img.cc View File

@@ -1,8 +1,8 @@
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// Copyright (C) 2007-2010 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2007-2010 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or


+ 2
- 2
source/native-plugins/zita-at1/png2img.h View File

@@ -1,8 +1,8 @@
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// Copyright (C) 2007-2010 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2007-2010 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or


+ 2
- 2
source/native-plugins/zita-at1/retuner.cc View File

@@ -1,8 +1,8 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// //
// Copyright (C) 2009-2011 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2009-2011 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or


+ 2
- 2
source/native-plugins/zita-at1/retuner.h View File

@@ -1,8 +1,8 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// //
// Copyright (C) 2009-2011 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2009-2011 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or


+ 18
- 6
source/native-plugins/zita-at1/rotary.cc View File

@@ -1,8 +1,8 @@
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// Copyright (C) 2010-2012 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2010-2012 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
@@ -28,6 +28,9 @@
namespace AT1 { namespace AT1 {




cairo_t *RotaryCtl::_cairotype = 0;
cairo_surface_t *RotaryCtl::_cairosurf = 0;



int RotaryCtl::_wb_up = 4; int RotaryCtl::_wb_up = 4;
int RotaryCtl::_wb_dn = 5; int RotaryCtl::_wb_dn = 5;
@@ -59,10 +62,6 @@ RotaryCtl::RotaryCtl (X_window *parent,
{ {
x_add_events ( ExposureMask x_add_events ( ExposureMask
| Button1MotionMask | ButtonPressMask | ButtonReleaseMask); | Button1MotionMask | ButtonPressMask | ButtonReleaseMask);

_cairo->initIfNeeded(parent->disp());
_cairotype = _cairo->type;
_cairosurf = _cairo->surf;
} }




@@ -71,6 +70,19 @@ RotaryCtl::~RotaryCtl (void)
} }




void RotaryCtl::init (X_display *disp)
{
_cairosurf = cairo_xlib_surface_create (disp->dpy (), 0, disp->dvi (), 50, 50);
_cairotype = cairo_create (_cairosurf);
}


void RotaryCtl::fini (void)
{
cairo_destroy (_cairotype);
cairo_surface_destroy (_cairosurf);
}



void RotaryCtl::handle_event (XEvent *E) void RotaryCtl::handle_event (XEvent *E)
{ {


+ 7
- 5
source/native-plugins/zita-at1/rotary.h View File

@@ -1,8 +1,8 @@
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// Copyright (C) 2010-2012 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2010-2012 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
@@ -72,6 +72,9 @@ public:
virtual void set_value (double v) = 0; virtual void set_value (double v) = 0;
virtual void get_string (char *p, int n) {} virtual void get_string (char *p, int n) {}


static void init (X_display *disp);
static void fini (void);

static int _wb_up; static int _wb_up;
static int _wb_dn; static int _wb_dn;


@@ -106,9 +109,8 @@ private:
virtual int handle_motion (int dx, int dy) = 0; virtual int handle_motion (int dx, int dy) = 0;
virtual int handle_mwheel (int dw) = 0; virtual int handle_mwheel (int dw) = 0;


juce::SharedResourcePointer<x_cairo_t> _cairo;
cairo_t *_cairotype;
cairo_surface_t *_cairosurf;
static cairo_t *_cairotype;
static cairo_surface_t *_cairosurf;
}; };






+ 39
- 16
source/native-plugins/zita-at1/styles.cc View File

@@ -1,8 +1,8 @@
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// Copyright (C) 2010-2014 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2010-2014 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
@@ -25,6 +25,7 @@
#include "png2img.h" #include "png2img.h"


#include "CarlaString.hpp" #include "CarlaString.hpp"
#include <dlfcn.h>


namespace AT1 { namespace AT1 {


@@ -37,7 +38,6 @@ X_button_style bstyle1;


XImage *notesect_img; XImage *notesect_img;
XImage *ctrlsect_img; XImage *ctrlsect_img;
XImage *redzita_img;


ButtonImg b_note_img; ButtonImg b_note_img;
ButtonImg b_midi_img; ButtonImg b_midi_img;
@@ -49,8 +49,20 @@ RotaryGeom r_corr_geom;
RotaryGeom r_offs_geom; RotaryGeom r_offs_geom;




int styles_init (X_display *disp, X_resman *xrm, const char *resdir)
static CarlaString getResourceDir()
{
Dl_info exeInfo;
dladdr((void*)getResourceDir, &exeInfo);

CarlaString filename(exeInfo.dli_fname);
return filename.truncate(filename.rfind("-ui"));
}


void styles_init (X_display *disp, X_resman *xrm)
{ {
CarlaString resourceDir(getResourceDir());

XftColors [C_MAIN_BG] = disp->alloc_xftcolor (0.25f, 0.25f, 0.25f, 1.0f); XftColors [C_MAIN_BG] = disp->alloc_xftcolor (0.25f, 0.25f, 0.25f, 1.0f);
XftColors [C_MAIN_FG] = disp->alloc_xftcolor (1.0f, 1.0f, 1.0f, 1.0f); XftColors [C_MAIN_FG] = disp->alloc_xftcolor (1.0f, 1.0f, 1.0f, 1.0f);
XftColors [C_TEXT_BG] = disp->alloc_xftcolor (1.0f, 1.0f, 1.0f, 1.0f); XftColors [C_TEXT_BG] = disp->alloc_xftcolor (1.0f, 1.0f, 1.0f, 1.0f);
@@ -68,29 +80,28 @@ int styles_init (X_display *disp, X_resman *xrm, const char *resdir)
bstyle1.color.fg[0] = XftColors [C_MAIN_FG]; bstyle1.color.fg[0] = XftColors [C_MAIN_FG];
bstyle1.type = X_button_style::PLAIN | X_button_style::ALEFT; bstyle1.type = X_button_style::PLAIN | X_button_style::ALEFT;


const CarlaString SHARED = CarlaString(resdir)+"/at1";
notesect_img = png2img (SHARED+"/notesect.png", disp, XftColors [C_MAIN_BG]);
ctrlsect_img = png2img (SHARED+"/ctrlsect.png", disp, XftColors [C_MAIN_BG]);
Tmeter::_scale = png2img (SHARED+"/hscale.png", disp, XftColors [C_MAIN_BG]);
Tmeter::_imag0 = png2img (SHARED+"/hmeter0.png", disp, XftColors [C_MAIN_BG]);
Tmeter::_imag1 = png2img (SHARED+"/hmeter1.png", disp, XftColors [C_MAIN_BG]);
notesect_img = png2img (resourceDir+"/notesect.png", disp, XftColors [C_MAIN_BG]);
ctrlsect_img = png2img (resourceDir+"/ctrlsect.png", disp, XftColors [C_MAIN_BG]);
Tmeter::_scale = png2img (resourceDir+"/hscale.png", disp, XftColors [C_MAIN_BG]);
Tmeter::_imag0 = png2img (resourceDir+"/hmeter0.png", disp, XftColors [C_MAIN_BG]);
Tmeter::_imag1 = png2img (resourceDir+"/hmeter1.png", disp, XftColors [C_MAIN_BG]);


if ( !notesect_img || !ctrlsect_img if ( !notesect_img || !ctrlsect_img
|| !Tmeter::_scale || !Tmeter::_imag0 || !Tmeter::_imag1) || !Tmeter::_scale || !Tmeter::_imag0 || !Tmeter::_imag1)
{ {
fprintf (stderr, "Can't load images from '%s'.\n", SHARED.buffer());
return 1;
fprintf (stderr, "Can't load images from '%s'.\n", resourceDir.buffer());
exit (1);
} }


b_midi_img._backg = XftColors [C_MAIN_BG]; b_midi_img._backg = XftColors [C_MAIN_BG];
b_midi_img._ximage = png2img (SHARED+"/midi.png", disp, XftColors [C_MAIN_BG]);
b_midi_img._ximage = png2img (resourceDir+"/midi.png", disp, XftColors [C_MAIN_BG]);
b_midi_img._x0 = 0; b_midi_img._x0 = 0;
b_midi_img._y0 = 0; b_midi_img._y0 = 0;
b_midi_img._dx = 40; b_midi_img._dx = 40;
b_midi_img._dy = 24; b_midi_img._dy = 24;


b_note_img._backg = XftColors [C_MAIN_BG]; b_note_img._backg = XftColors [C_MAIN_BG];
b_note_img._ximage = png2img (SHARED+"/note.png", disp, XftColors [C_MAIN_BG]);
b_note_img._ximage = png2img (resourceDir+"/note.png", disp, XftColors [C_MAIN_BG]);
b_note_img._x0 = 0; b_note_img._x0 = 0;
b_note_img._y0 = 0; b_note_img._y0 = 0;
b_note_img._dx = 16; b_note_img._dx = 16;
@@ -150,13 +161,25 @@ int styles_init (X_display *disp, X_resman *xrm, const char *resdir)
r_offs_geom._xref = 11.5; r_offs_geom._xref = 11.5;
r_offs_geom._yref = 11.5; r_offs_geom._yref = 11.5;
r_offs_geom._rad = 11; r_offs_geom._rad = 11;

return 0;
} }




void styles_fini (X_display *disp) void styles_fini (X_display *disp)
{ {
notesect_img->data = 0;
ctrlsect_img->data = 0;
b_midi_img._ximage->data = 0;
b_note_img._ximage->data = 0;
Tmeter::_scale->data = 0;
Tmeter::_imag0->data = 0;
Tmeter::_imag1->data = 0;
XDestroyImage (notesect_img);
XDestroyImage (ctrlsect_img);
XDestroyImage (b_midi_img._ximage);
XDestroyImage (b_note_img._ximage);
XDestroyImage (Tmeter::_scale);
XDestroyImage (Tmeter::_imag0);
XDestroyImage (Tmeter::_imag1);
} }






+ 3
- 3
source/native-plugins/zita-at1/styles.h View File

@@ -1,8 +1,8 @@
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// Copyright (C) 2010-2014 Fons Adriaensen <fons@linuxaudio.org> // Copyright (C) 2010-2014 Fons Adriaensen <fons@linuxaudio.org>
// Modified by falkTX on Jan 2015 for inclusion in Carla
//
// Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
//
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
@@ -45,7 +45,7 @@ enum
}; };




extern int styles_init (X_display *disp, X_resman *xrm, const char *resdir);
extern void styles_init (X_display *disp, X_resman *xrm);
extern void styles_fini (X_display *disp); extern void styles_fini (X_display *disp);


extern XftColor *XftColors [NXFTCOLORS]; extern XftColor *XftColors [NXFTCOLORS];


+ 2
- 2
source/native-plugins/zita-at1/tmeter.cc View File

@@ -1,7 +1,7 @@
/* /*
Copyright (C) 2009-2010 Fons Adriaensen <fons@linuxaudio.org> Copyright (C) 2009-2010 Fons Adriaensen <fons@linuxaudio.org>
Modified by falkTX on Jan 2015 for inclusion in Carla
Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or


+ 2
- 2
source/native-plugins/zita-at1/tmeter.h View File

@@ -1,7 +1,7 @@
/* /*
Copyright (C) 2009-2010 Fons Adriaensen <fons@linuxaudio.org> Copyright (C) 2009-2010 Fons Adriaensen <fons@linuxaudio.org>
Modified by falkTX on Jan 2015 for inclusion in Carla
Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or


+ 1
- 0
source/native-plugins/zita-bls1-ui.cpp View File

@@ -98,6 +98,7 @@ protected:
if (std::strcmp(msg, "quit") == 0) if (std::strcmp(msg, "quit") == 0)
{ {
fQuitReceived = true; fQuitReceived = true;
mainwin->stop();
return true; return true;
} }




+ 2
- 3
source/native-plugins/zita-bls1.cpp View File

@@ -59,7 +59,6 @@ public:


carla_zeroStruct(fJackClient); carla_zeroStruct(fJackClient);


fJackClient.clientName = "bls1";
fJackClient.bufferSize = getBufferSize(); fJackClient.bufferSize = getBufferSize();
fJackClient.sampleRate = getSampleRate(); fJackClient.sampleRate = getSampleRate();


@@ -220,13 +219,13 @@ public:
void bufferSizeChanged(const uint32_t bufferSize) override void bufferSizeChanged(const uint32_t bufferSize) override
{ {
fJackClient.bufferSize = bufferSize; fJackClient.bufferSize = bufferSize;
_recreateZitaClient();
// _recreateZitaClient(); // FIXME
} }


void sampleRateChanged(const double sampleRate) override void sampleRateChanged(const double sampleRate) override
{ {
fJackClient.sampleRate = sampleRate; fJackClient.sampleRate = sampleRate;
_recreateZitaClient();
// _recreateZitaClient(); // FIXME
} }


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


+ 1
- 2
source/native-plugins/zita-bls1/mainwin.cc View File

@@ -66,8 +66,7 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, ValueChange
_parmind = -1; _parmind = -1;
_timeout = 0; _timeout = 0;


x_add_events (ExposureMask);
x_map ();
x_add_events (ExposureMask);
set_time (0); set_time (0);
inc_time (250000); inc_time (250000);
} }


+ 1
- 0
source/native-plugins/zita-rev1-ui.cpp View File

@@ -101,6 +101,7 @@ protected:
if (std::strcmp(msg, "quit") == 0) if (std::strcmp(msg, "quit") == 0)
{ {
fQuitReceived = true; fQuitReceived = true;
mainwin->stop();
return true; return true;
} }




+ 2
- 3
source/native-plugins/zita-rev1.cpp View File

@@ -62,7 +62,6 @@ public:


carla_zeroStruct(fJackClient); carla_zeroStruct(fJackClient);


fJackClient.clientName = "rev1";
fJackClient.bufferSize = getBufferSize(); fJackClient.bufferSize = getBufferSize();
fJackClient.sampleRate = getSampleRate(); fJackClient.sampleRate = getSampleRate();


@@ -284,13 +283,13 @@ public:
void bufferSizeChanged(const uint32_t bufferSize) override void bufferSizeChanged(const uint32_t bufferSize) override
{ {
fJackClient.bufferSize = bufferSize; fJackClient.bufferSize = bufferSize;
_recreateZitaClient();
// _recreateZitaClient(); // FIXME
} }


void sampleRateChanged(const double sampleRate) override void sampleRateChanged(const double sampleRate) override
{ {
fJackClient.sampleRate = sampleRate; fJackClient.sampleRate = sampleRate;
_recreateZitaClient();
// _recreateZitaClient(); // FIXME
} }


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


+ 1
- 2
source/native-plugins/zita-rev1/mainwin.cc View File

@@ -72,8 +72,7 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, bool ambiso
if (_ambis) _rotary [R_RGXYZ]->x_map (); if (_ambis) _rotary [R_RGXYZ]->x_map ();
else _rotary [R_OPMIX]->x_map (); else _rotary [R_OPMIX]->x_map ();


x_add_events (ExposureMask);
x_map ();
x_add_events (ExposureMask);
set_time (0); set_time (0);
inc_time (50000); inc_time (50000);
} }


Loading…
Cancel
Save