Browse Source

Continue bls1 plugin; Misc changes

tags/1.9.6
falkTX 9 years ago
parent
commit
e0ee3c678b
6 changed files with 151 additions and 78 deletions
  1. +1
    -4
      source/includes/CarlaNative.hpp
  2. +3
    -3
      source/interposer/interposer-x11.cpp
  3. +123
    -53
      source/native-plugins/zita-bls1.cpp
  4. +0
    -5
      source/native-plugins/zita-bls1/source/mainwin.cc
  5. +5
    -3
      source/native-plugins/zita-bls1/source/mainwin.h
  6. +19
    -10
      source/native-plugins/zita-bls1/source/rotary.cc

+ 1
- 4
source/includes/CarlaNative.hpp View File

@@ -365,10 +365,7 @@ protected:

virtual void uiNameChanged(const char* const uiName)
{
return;

// unused
(void)uiName;
CARLA_SAFE_ASSERT_RETURN(uiName != nullptr && uiName[0] != '\0',);
}

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


+ 3
- 3
source/interposer/interposer-x11.cpp View File

@@ -36,7 +36,7 @@ static int sMapWindowCounter = 0;

static int real_XMapWindow(Display* display, Window w)
{
static XMapWindowFunc func = (XMapWindowFunc)::dlsym(RTLD_NEXT, "XMapWindow");
static const XMapWindowFunc func = (XMapWindowFunc)::dlsym(RTLD_NEXT, "XMapWindow");
CARLA_SAFE_ASSERT_RETURN(func != nullptr, 0);

return func(display, w);
@@ -44,7 +44,7 @@ static int real_XMapWindow(Display* display, Window w)

static int real_XUnmapWindow(Display* display, Window w)
{
static XUnmapWindowFunc func = (XUnmapWindowFunc)::dlsym(RTLD_NEXT, "XUnmapWindow");
static const XUnmapWindowFunc func = (XUnmapWindowFunc)::dlsym(RTLD_NEXT, "XUnmapWindow");
CARLA_SAFE_ASSERT_RETURN(func != nullptr, 0);

return func(display, w);
@@ -66,7 +66,7 @@ int XMapWindow(Display* display, Window w)
CARLA_SAFE_ASSERT_RETURN(winIdStr[0] != '\0', real_XMapWindow(display, w));

const long long winIdLL(std::strtoll(winIdStr, nullptr, 16));
CARLA_SAFE_ASSERT_RETURN(winIdLL >= 0, real_XMapWindow(display, w));
CARLA_SAFE_ASSERT_RETURN(winIdLL > 0, real_XMapWindow(display, w));

const Window winId(static_cast<Window>(winIdLL));
XSetTransientForHint(display, w, static_cast<Window>(winId));


+ 123
- 53
source/native-plugins/zita-bls1.cpp View File

@@ -41,17 +41,22 @@ using juce::ScopedPointer;
class BLS1Plugin : public NativePluginClass
{
public:
#if 0
static const uint32_t kNumInputs = 2;
static const uint32_t kNumOutputs = 2;

enum Parameters {
kParameterInput = 0,
kParameterCount
kParameterINPBAL,
kParameterHPFILT,
kParameterSHGAIN,
kParameterSHFREQ,
kParameterLFFREQ,
kParameterLFGAIN,
kParameterNROTARY
};
#endif

BLS1Plugin(const NativeHostDescriptor* const host)
: NativePluginClass(host),
fJackClient(),
fMutex(),
xresman(),
jclient(nullptr),
display(nullptr),
@@ -75,21 +80,31 @@ public:

jclient = new Jclient(xresman.rname(), nullptr);

//fParameters[kParameterInput] = 1.0f;
// set initial values
fParameters[kParameterINPBAL] = 0.0f;
fParameters[kParameterHPFILT] = 40.0f;
fParameters[kParameterSHGAIN] = 15.0f;
fParameters[kParameterSHFREQ] = 5e2f;
fParameters[kParameterLFFREQ] = 80.0f;
fParameters[kParameterLFGAIN] = 0.0f;

jclient->set_inpbal(fParameters[kParameterINPBAL]);
jclient->set_hpfilt(fParameters[kParameterHPFILT]);
jclient->shuffler()->prepare(fParameters[kParameterSHGAIN], fParameters[kParameterSHFREQ]);
jclient->set_loshelf(fParameters[kParameterLFGAIN], fParameters[kParameterLFFREQ]);
}

#if 0
// -------------------------------------------------------------------
// Plugin parameter calls

uint32_t getParameterCount() const override
{
return kParameterCount;
return kParameterNROTARY;
}

const NativeParameter* getParameterInfo(const uint32_t index) const override
{
CARLA_SAFE_ASSERT_RETURN(index < kParameterCount, nullptr);
CARLA_SAFE_ASSERT_RETURN(index < kParameterNROTARY, nullptr);

static NativeParameter param;

@@ -109,12 +124,44 @@ public:

switch (index)
{
case kParameterInput:
hints |= NATIVE_PARAMETER_IS_INTEGER;
param.name = "Input";
param.ranges.def = 1.0f;
param.ranges.min = 1.0f;
param.ranges.max = 8.0f;
case kParameterINPBAL:
param.name = "INPBAL";
param.ranges.def = 0.0f;
param.ranges.min = -3.0f;
param.ranges.max = 3.0f;
break;
case kParameterHPFILT:
hints |= NATIVE_PARAMETER_IS_LOGARITHMIC;
param.name = "HPFILT";
param.ranges.def = 40.0f;
param.ranges.min = 10.0f;
param.ranges.max = 320.0f;
break;
case kParameterSHGAIN:
param.name = "SHGAIN";
param.ranges.def = 15.0f;
param.ranges.min = 0.0f;
param.ranges.max = 24.0f;
break;
case kParameterSHFREQ:
hints |= NATIVE_PARAMETER_IS_LOGARITHMIC;
param.name = "SHFREQ";
param.ranges.def = 5e2f;
param.ranges.min = 125.0f;
param.ranges.max = 2e3f;
break;
case kParameterLFFREQ:
hints |= NATIVE_PARAMETER_IS_LOGARITHMIC;
param.name = "LFFREQ";
param.ranges.def = 80.0f;
param.ranges.min = 20.0f;
param.ranges.max = 320.0f;
break;
case kParameterLFGAIN:
param.name = "LFGAIN";
param.ranges.def = 0.0f;
param.ranges.min = -9.0f;
param.ranges.max = 9.0f;
break;
}

@@ -125,7 +172,7 @@ public:

float getParameterValue(const uint32_t index) const override
{
CARLA_SAFE_ASSERT_RETURN(index < kParameterCount, 0.0f);
CARLA_SAFE_ASSERT_RETURN(index < kParameterNROTARY, 0.0f);

return fParameters[index];
}
@@ -135,11 +182,32 @@ public:

void setParameterValue(const uint32_t index, const float value) override
{
CARLA_SAFE_ASSERT_RETURN(index < kParameterCount,);
CARLA_SAFE_ASSERT_RETURN(index < kParameterNROTARY,);

fParameters[index] = value;

switch (index)
{
case kParameterINPBAL:
jclient->set_inpbal(value);
break;
case kParameterHPFILT:
jclient->set_hpfilt(value);
break;
case kParameterSHGAIN:
jclient->shuffler()->prepare(value, fParameters[kParameterSHFREQ]);
break;
case kParameterSHFREQ:
jclient->shuffler()->prepare(fParameters[kParameterSHGAIN], value);
break;
case kParameterLFFREQ:
jclient->set_loshelf(fParameters[kParameterLFGAIN], value);
break;
case kParameterLFGAIN:
jclient->set_loshelf(value, fParameters[kParameterLFFREQ]);
break;
}
}
#endif

// -------------------------------------------------------------------
// Plugin process calls
@@ -150,16 +218,16 @@ public:
{
const int iframes(static_cast<int>(frames));

for (int i=0; i<2; ++i)
for (uint32_t i=0; i<kNumInputs; ++i)
FloatVectorOperations::clear(outBuffer[i], iframes);

return;
}

for (int i=0; i<2; ++i)
for (uint32_t i=0; i<kNumInputs; ++i)
fJackClient.portsAudioIn[i]->buffer = inBuffer[i];

for (int i=0; i<2; ++i)
for (uint32_t i=0; i<kNumOutputs; ++i)
fJackClient.portsAudioOut[i]->buffer = outBuffer[i];

fJackClient.processCallback(frames, fJackClient.processPtr);
@@ -170,8 +238,6 @@ public:

void uiShow(const bool show) override
{
const CarlaMutexLocker cml(fMutex);

if (show)
{
if (display == nullptr)
@@ -183,9 +249,10 @@ public:

styles_init(display, &xresman);

rootwin = new X_rootwin(display);
mainwin = new Mainwin(rootwin, &xresman, 0, 0, jclient);
rootwin = new X_rootwin(display);
mainwin = new Mainwin(rootwin, &xresman, 0, 0, jclient);
rootwin->handle_event();
mainwin->x_set_title(getUiName());

handler = new X_handler(display, mainwin, EV_X11);

@@ -199,15 +266,15 @@ public:
else
{
handler = nullptr;
mainwin = nullptr;
rootwin = nullptr;
display = nullptr;
mainwin = nullptr;
rootwin = nullptr;
display = nullptr;
}
}

void uiIdle() override
{
if (display == nullptr)
if (mainwin == nullptr)
return;

int ev;
@@ -218,14 +285,19 @@ public:
handler->next_event();
}

#if 0
// check if parameters were updated
if (mainwin->_input+1 != static_cast<int>(fParameters[kParameterInput]))
float value;

for (uint32_t i=0; i<kParameterNROTARY; ++i)
{
fParameters[kParameterInput] = mainwin->_input+1;
uiParameterChanged(kParameterInput, fParameters[kParameterInput]);
value = mainwin->_rotary[i]->value();

if (fParameters[i] == value)
continue;

fParameters[i] = value;
uiParameterChanged(i, value);
}
#endif

if (ev == EV_EXIT)
{
@@ -237,24 +309,15 @@ public:
}
}

#if 0
void uiSetParameterValue(const uint32_t index, const float value) override
{
CARLA_SAFE_ASSERT_RETURN(index < kParameterCount,);
CARLA_SAFE_ASSERT_RETURN(index < kParameterNROTARY,);

const CarlaMutexLocker cml(fMutex);

if (itcc == nullptr)
if (mainwin == nullptr)
return;

switch (index)
{
case kParameterInput:
mainwin->set_input(static_cast<int>(value)-1);
break;
}
mainwin->_rotary[index]->set_value(value);
}
#endif

// -------------------------------------------------------------------
// Plugin dispatcher calls
@@ -269,15 +332,22 @@ public:
fJackClient.sampleRate = sampleRate;
}

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

if (mainwin == nullptr)
return;

mainwin->x_set_title(uiName);
}

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

private:
// Fake jack client
jack_client_t fJackClient;

// Mutex just in case
CarlaMutex fMutex;

// Zita stuff (core)
X_resman xresman;
ScopedPointer<Jclient> jclient;
@@ -286,7 +356,7 @@ private:
ScopedPointer<Mainwin> mainwin;
ScopedPointer<X_handler> handler;

//float fParameters[kParameterCount];
float fParameters[kParameterNROTARY];

PluginClassEND(BLS1Plugin)
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(BLS1Plugin)
@@ -302,11 +372,11 @@ static const NativePluginDescriptor bls1Desc = {
|NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD
|NATIVE_PLUGIN_USES_PARENT_ID),
/* supports */ static_cast<NativePluginSupports>(0x0),
/* audioIns */ 2,
/* audioOuts */ 2,
/* audioIns */ BLS1Plugin::kNumInputs,
/* audioOuts */ BLS1Plugin::kNumOutputs,
/* midiIns */ 0,
/* midiOuts */ 0,
/* paramIns */ 0, //JaaaPlugin::kParameterCount,
/* paramIns */ BLS1Plugin::kParameterNROTARY,
/* paramOuts */ 0,
/* name */ "BLS1",
/* label */ "bls1",


+ 0
- 5
source/native-plugins/zita-bls1/source/mainwin.cc View File

@@ -61,11 +61,6 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc
_rotary [LFGAIN] = new Rlinctl (this, this, &lfgain_img, 410, 0, 180, 5, -9.0f, 9.0f, 0.0f, LFGAIN);
for (i = 0; i < NROTARY; i++) _rotary [i]->x_map ();

_jclient->set_inpbal (_rotary [INPBAL]->value ());
_jclient->set_hpfilt (_rotary [HPFILT]->value ());
_jclient->set_loshelf (_rotary [LFGAIN]->value (),_rotary [LFFREQ]->value ());
_jclient->shuffler ()->prepare (_rotary [SHGAIN]->value (), _rotary [SHFREQ]->value ());

_numtext = new X_textip (this, 0, &tstyle1, 0, 0, 45, 15, 15);
_numtext->set_align (0);
_parmind = -1;


+ 5
- 3
source/native-plugins/zita-bls1/source/mainwin.h View File

@@ -1,7 +1,7 @@
// ----------------------------------------------------------------------
//
// Copyright (C) 2011 Fons Adriaensen <fons@linuxaudio.org>
//
//
// 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
@@ -41,12 +41,12 @@ public:
Mainwin& operator=(const Mainwin&);

void stop (void) { _stop = true; }
int process (void);
int process (void);

private:

enum { INPBAL, HPFILT, SHGAIN, SHFREQ, LFFREQ, LFGAIN, NROTARY };
virtual void thr_main (void) {}

void handle_time (void);
@@ -68,6 +68,8 @@ private:
int _parmind;
int _timeout;
int _touch;

friend class BLS1Plugin;
};




+ 19
- 10
source/native-plugins/zita-bls1/source/rotary.cc View File

@@ -1,7 +1,7 @@
// ----------------------------------------------------------------------
//
// Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org>
//
//
// 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
@@ -58,7 +58,7 @@ RotaryCtl::RotaryCtl (X_window *parent,
{
x_add_events ( ExposureMask
| Button1MotionMask | ButtonPressMask | ButtonReleaseMask);
}
}


RotaryCtl::~RotaryCtl (void)
@@ -68,6 +68,9 @@ RotaryCtl::~RotaryCtl (void)

void RotaryCtl::init (X_display *disp)
{
if (_cairosurf != NULL)
return;

_cairosurf = cairo_xlib_surface_create (disp->dpy (), 0, disp->dvi (), 50, 50);
_cairotype = cairo_create (_cairosurf);
}
@@ -75,8 +78,14 @@ void RotaryCtl::init (X_display *disp)

void RotaryCtl::fini (void)
{
if (_cairosurf == NULL)
return;

cairo_destroy (_cairotype);
cairo_surface_destroy (_cairosurf);

_cairotype = NULL;
_cairosurf = NULL;
}


@@ -86,11 +95,11 @@ void RotaryCtl::handle_event (XEvent *E)
{
case Expose:
render ();
break;
break;
case ButtonPress:
bpress ((XButtonEvent *) E);
break;
break;

case ButtonRelease:
brelse ((XButtonEvent *) E);
@@ -100,7 +109,7 @@ void RotaryCtl::handle_event (XEvent *E)
motion ((XMotionEvent *) E);
break;

default:
default:
fprintf (stderr, "RotaryCtl: event %d\n", E->type );
}
}
@@ -126,11 +135,11 @@ void RotaryCtl::bpress (XButtonEvent *E)
else if ((int)E->button == _wb_up)
{
r = handle_mwheel (1);
}
else if ((int)E->button == _wb_dn)
}
else if ((int)E->button == _wb_dn)
{
r = handle_mwheel (-1);
}
}
if (r)
{
callback (r);
@@ -170,7 +179,7 @@ void RotaryCtl::motion (XMotionEvent *E)

void RotaryCtl::set_state (int s)
{
_state = s;
_state = s;
render ();
}



Loading…
Cancel
Save