Browse Source

Add carla_get_internal_parameter_value func

tags/1.9.4
falkTX 10 years ago
parent
commit
e27d18f534
6 changed files with 118 additions and 42 deletions
  1. +8
    -0
      source/backend/CarlaHost.h
  2. +7
    -0
      source/backend/CarlaPlugin.hpp
  3. +39
    -8
      source/backend/plugin/CarlaPlugin.cpp
  4. +12
    -0
      source/backend/standalone/CarlaStandalone.cpp
  5. +10
    -0
      source/carla_backend.py
  6. +42
    -34
      source/carla_widgets.py

+ 8
- 0
source/backend/CarlaHost.h View File

@@ -772,6 +772,14 @@ CARLA_EXPORT float carla_get_default_parameter_value(uint pluginId, uint32_t par
*/
CARLA_EXPORT float carla_get_current_parameter_value(uint pluginId, uint32_t parameterId);

/*!
* Get a plugin's internal parameter value.
* @param pluginId Plugin
* @param parameterId Parameter index, maybe be negative
* @see InternalParameterIndex
*/
CARLA_EXPORT float carla_get_internal_parameter_value(uint pluginId, int32_t parameterId);

/*!
* Get a plugin's input peak value.
* @param pluginId Plugin


+ 7
- 0
source/backend/CarlaPlugin.hpp View File

@@ -337,6 +337,13 @@ public:
*/
virtual void getParameterScalePointLabel(const uint32_t parameterId, const uint32_t scalePointId, char* const strBuf) const noexcept;

/*!
* Get the current parameter value of \a parameterId.
* \a parameterId can be negative to allow internal parameters.
* \see InternalParametersIndex
*/
float getInternalParameterValue(const int32_t parameterId) const noexcept;

/*!
* Get the name of the program at \a index.
*/


+ 39
- 8
source/backend/plugin/CarlaPlugin.cpp View File

@@ -388,6 +388,35 @@ void CarlaPlugin::getParameterScalePointLabel(const uint32_t parameterId, const
strBuf[0] = '\0';
}

float CarlaPlugin::getInternalParameterValue(const int32_t parameterId) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(parameterId != PARAMETER_NULL && parameterId > PARAMETER_MAX, 0.0f);

switch (parameterId)
{
case PARAMETER_ACTIVE:
return pData->active;
case PARAMETER_CTRL_CHANNEL:
return pData->ctrlChannel;
#ifndef BUILD_BRIDGE
case PARAMETER_DRYWET:
return pData->postProc.dryWet;
case PARAMETER_VOLUME:
return pData->postProc.volume;
case PARAMETER_BALANCE_LEFT:
return pData->postProc.balanceLeft;
case PARAMETER_BALANCE_RIGHT:
return pData->postProc.balanceRight;
case PARAMETER_PANNING:
return pData->postProc.panning;
#endif
};

CARLA_SAFE_ASSERT_RETURN(parameterId >= 0, 0.0f);

return getParameterValue(static_cast<uint32_t>(parameterId));
}

void CarlaPlugin::getProgramName(const uint32_t index, char* const strBuf) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(index < pData->prog.count,);
@@ -1060,23 +1089,25 @@ void CarlaPlugin::setParameterValueByRealIndex(const int32_t rindex, const float
{
CARLA_SAFE_ASSERT_RETURN(rindex > PARAMETER_MAX && rindex != PARAMETER_NULL,);

if (rindex == PARAMETER_ACTIVE)
switch (rindex)
{
case PARAMETER_ACTIVE:
return setActive((value > 0.0f), sendOsc, sendCallback);
if (rindex == PARAMETER_CTRL_CHANNEL)
case PARAMETER_CTRL_CHANNEL:
return setCtrlChannel(int8_t(value), sendOsc, sendCallback);

#ifndef BUILD_BRIDGE
if (rindex == PARAMETER_DRYWET)
case PARAMETER_DRYWET:
return setDryWet(value, sendOsc, sendCallback);
if (rindex == PARAMETER_VOLUME)
case PARAMETER_VOLUME:
return setVolume(value, sendOsc, sendCallback);
if (rindex == PARAMETER_BALANCE_LEFT)
case PARAMETER_BALANCE_LEFT:
return setBalanceLeft(value, sendOsc, sendCallback);
if (rindex == PARAMETER_BALANCE_RIGHT)
case PARAMETER_BALANCE_RIGHT:
return setBalanceRight(value, sendOsc, sendCallback);
if (rindex == PARAMETER_PANNING)
case PARAMETER_PANNING:
return setPanning(value, sendOsc, sendCallback);
#endif
}

for (uint32_t i=0; i < pData->param.count; ++i)
{


+ 12
- 0
source/backend/standalone/CarlaStandalone.cpp View File

@@ -1767,6 +1767,18 @@ float carla_get_current_parameter_value(uint pluginId, uint32_t parameterId)
return 0.0f;
}

float carla_get_internal_parameter_value(uint pluginId, int32_t parameterId)
{
CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0.0f);
CARLA_SAFE_ASSERT_RETURN(parameterId != CB::PARAMETER_NULL && parameterId > CB::PARAMETER_MAX, 0.0f);

if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId))
return plugin->getInternalParameterValue(parameterId);

carla_stderr2("carla_get_internal_parameter_value(%i, %i) - could not find plugin", pluginId, parameterId);
return 0.0f;
}

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

float carla_get_input_peak_value(uint pluginId, bool isLeft)


+ 10
- 0
source/carla_backend.py View File

@@ -1583,6 +1583,13 @@ class Host(object):
def get_current_parameter_value(self, pluginId, parameterId):
return float(self.lib.carla_get_current_parameter_value(pluginId, parameterId))

# Get a plugin's internal parameter value.
# @param pluginId Plugin
# @param parameterId Parameter index, maybe be negative
# @see InternalParameterIndex
def get_internal_parameter_value(self, pluginId, parameterId):
return float(self.lib.carla_get_internal_parameter_value(pluginId, parameterId))

# Get a plugin's input peak value.
# @param pluginId Plugin
# @param isLeft Wherever to get the left/mono value, otherwise right.
@@ -1915,6 +1922,9 @@ class Host(object):
self.lib.carla_get_current_parameter_value.argtypes = [c_uint, c_uint32]
self.lib.carla_get_current_parameter_value.restype = c_float

self.lib.carla_get_internal_parameter_value.argtypes = [c_uint, c_int32]
self.lib.carla_get_internal_parameter_value.restype = c_float

self.lib.carla_get_input_peak_value.argtypes = [c_uint, c_bool]
self.lib.carla_get_input_peak_value.restype = c_float



+ 42
- 34
source/carla_widgets.py View File

@@ -397,7 +397,7 @@ class PluginEdit(QDialog):
self.fCurrentProgram = -1
self.fCurrentMidiProgram = -1
self.fCurrentStateFilename = None
self.fControlChannel = 0
self.fControlChannel = int(gCarla.host.get_internal_parameter_value(pluginId, PARAMETER_CTRL_CHANNEL)) if gCarla.host is not None else 0
self.fFirstInit = True

self.fParameterCount = 0
@@ -419,35 +419,45 @@ class PluginEdit(QDialog):
self.ui.dial_drywet.setLabel("Dry/Wet")
self.ui.dial_drywet.setMinimum(0.0)
self.ui.dial_drywet.setMaximum(1.0)
self.ui.dial_drywet.setValue(1.0)

self.ui.dial_vol.setCustomPaintMode(self.ui.dial_vol.CUSTOM_PAINT_MODE_CARLA_VOL)
self.ui.dial_vol.setPixmap(3)
self.ui.dial_vol.setLabel("Volume")
self.ui.dial_vol.setMinimum(0.0)
self.ui.dial_vol.setMaximum(1.27)
self.ui.dial_vol.setValue(1.0)

self.ui.dial_b_left.setCustomPaintMode(self.ui.dial_b_left.CUSTOM_PAINT_MODE_CARLA_L)
self.ui.dial_b_left.setPixmap(4)
self.ui.dial_b_left.setLabel("L")
self.ui.dial_b_left.setMinimum(-1.0)
self.ui.dial_b_left.setMaximum(1.0)
self.ui.dial_b_left.setValue(0.0)

self.ui.dial_b_right.setCustomPaintMode(self.ui.dial_b_right.CUSTOM_PAINT_MODE_CARLA_R)
self.ui.dial_b_right.setPixmap(4)
self.ui.dial_b_right.setLabel("R")
self.ui.dial_b_right.setMinimum(-1.0)
self.ui.dial_b_right.setMaximum(1.0)
self.ui.dial_b_right.setValue(0.0)

self.ui.dial_pan.setCustomPaintMode(self.ui.dial_b_right.CUSTOM_PAINT_MODE_CARLA_PAN)
self.ui.dial_pan.setPixmap(4)
self.ui.dial_pan.setLabel("Pan")
self.ui.dial_pan.setMinimum(-1.0)
self.ui.dial_pan.setMaximum(1.0)
self.ui.dial_pan.setValue(0.0)

if gCarla.host is not None:
self.ui.dial_drywet.setValue(gCarla.host.get_internal_parameter_value(pluginId, PARAMETER_DRYWET))
self.ui.dial_vol.setValue(gCarla.host.get_internal_parameter_value(pluginId, PARAMETER_VOLUME))
self.ui.dial_b_left.setValue(gCarla.host.get_internal_parameter_value(pluginId, PARAMETER_BALANCE_LEFT))
self.ui.dial_b_right.setValue(gCarla.host.get_internal_parameter_value(pluginId, PARAMETER_BALANCE_RIGHT))
self.ui.dial_pan.setValue(gCarla.host.get_internal_parameter_value(pluginId, PARAMETER_PANNING))
else:
self.ui.dial_drywet.setValue(1.0)
self.ui.dial_vol.setValue(1.0)
self.ui.dial_b_left.setValue(-1.0)
self.ui.dial_b_right.setValue(1.0)
self.ui.dial_pan.setValue(0.0)

self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)

self.ui.scrollArea = PixmapKeyboardHArea(self)
self.layout().addWidget(self.ui.scrollArea)
@@ -456,8 +466,6 @@ class PluginEdit(QDialog):
self.ui.keyboard.setMode(self.ui.keyboard.HORIZONTAL)
self.ui.keyboard.setOctaves(10)

self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)

self.ui.scrollArea.setEnabled(False)
self.ui.scrollArea.setVisible(False)

@@ -1248,44 +1256,44 @@ class PluginEdit(QDialog):
def slot_knobCustomMenu(self):
knobName = self.sender().objectName()
if knobName == "dial_drywet":
minimum = 0
maximum = 100
default = 100
minimum = 0.0
maximum = 1.0
default = 1.0
label = "Dry/Wet"
elif knobName == "dial_vol":
minimum = 0
maximum = 127
default = 100
minimum = 0.0
maximum = 1.27
default = 1.0
label = "Volume"
elif knobName == "dial_b_left":
minimum = -100
maximum = 100
default = -100
minimum = -1.0
maximum = 1.0
default = -1.0
label = "Balance-Left"
elif knobName == "dial_b_right":
minimum = -100
maximum = 100
default = 100
minimum = -1.0
maximum = 1.0
default = 1.0
label = "Balance-Right"
elif knobName == "dial_pan":
minimum = -100
maximum = 100
default = 0
minimum = -1.0
maximum = 1.0
default = 0.0
label = "Panning"
else:
minimum = 0
maximum = 100
default = 100
minimum = 0.0
maximum = 1.0
default = 0.5
label = "Unknown"

current = self.sender().value() / 10

menu = QMenu(self)
actReset = menu.addAction(self.tr("Reset (%i%%)" % default))
actReset = menu.addAction(self.tr("Reset (%i%%)" % (default*100)))
menu.addSeparator()
actMinimum = menu.addAction(self.tr("Set to Minimum (%i%%)" % minimum))
actMinimum = menu.addAction(self.tr("Set to Minimum (%i%%)" % (minimum*100)))
actCenter = menu.addAction(self.tr("Set to Center"))
actMaximum = menu.addAction(self.tr("Set to Maximum (%i%%)" % maximum))
actMaximum = menu.addAction(self.tr("Set to Maximum (%i%%)" % (maximum*100)))
menu.addSeparator()
actSet = menu.addAction(self.tr("Set value..."))

@@ -1295,20 +1303,20 @@ class PluginEdit(QDialog):
actSelected = menu.exec_(QCursor.pos())

if actSelected == actSet:
valueTry = QInputDialog.getInteger(self, self.tr("Set value"), label, current, minimum, maximum, 1)
valueTry = QInputDialog.getDouble(self, self.tr("Set value"), label, current, minimum, maximum, 3)
if valueTry[1]:
value = valueTry[0] * 10
else:
return

elif actSelected == actMinimum:
value = minimum * 10
value = minimum
elif actSelected == actMaximum:
value = maximum * 10
value = maximum
elif actSelected == actReset:
value = default * 10
value = default
elif actSelected == actCenter:
value = 0
value = 0.0
else:
return



Loading…
Cancel
Save