Browse Source

libjack: new option for buffer addition mode

tags/1.9.8
falkTX 7 years ago
parent
commit
4787f56f7b
4 changed files with 199 additions and 141 deletions
  1. +164
    -127
      resources/ui/carla_add_jack.ui
  2. +2
    -2
      source/backend/plugin/CarlaPluginJack.cpp
  3. +5
    -2
      source/carla_database.py
  4. +28
    -10
      source/libjack/libjack.cpp

+ 164
- 127
resources/ui/carla_add_jack.ui View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>416</width>
<height>344</height>
<width>468</width>
<height>369</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -94,62 +94,113 @@
<string>Setup</string> <string>Setup</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="6">
<widget class="QLabel" name="label_7">
<item row="0" column="1" colspan="8">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Session Manager:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cb_session_mgr">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>None / Manual</string>
</property>
</item>
<item>
<property name="text">
<string>LADISH (SIGUSR1)</string>
</property>
</item>
<item>
<property name="text">
<string>Non Session Manager (OSC)</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="1" colspan="3">
<widget class="QCheckBox" name="cb_manage_window">
<property name="text"> <property name="text">
<string>MIDI inputs:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<string>Take control of main applicaton window</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="7">
<widget class="QSpinBox" name="sb_midi_ins">
<property name="maximum">
<number>1</number>
<item row="2" column="0">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property> </property>
</widget>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="sb_audio_outs">
<property name="maximum">
<number>64</number>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property> </property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</item> </item>
<item row="3" column="6">
<widget class="QLabel" name="label_8">
<item row="2" column="1">
<widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>MIDI outputs:</string>
<string>Audio inputs:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="7">
<widget class="QSpinBox" name="sb_midi_outs">
<item row="2" column="2">
<widget class="QSpinBox" name="sb_audio_ins">
<property name="maximum"> <property name="maximum">
<number>1</number>
<number>64</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="8">
<spacer name="horizontalSpacer_15">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="8">
<spacer name="horizontalSpacer_16">
<item row="2" column="3">
<spacer name="horizontalSpacer_7">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@@ -161,34 +212,18 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="3" column="3">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="2" column="4" rowspan="2">
<widget class="Line" name="line">
<property name="lineWidth">
<number>0</number>
</property> </property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
<property name="midLineWidth">
<number>1</number>
</property> </property>
</spacer>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer_5">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>1</height>
</size>
<enum>Qt::Vertical</enum>
</property> </property>
</spacer>
</widget>
</item> </item>
<item row="2" column="5"> <item row="2" column="5">
<spacer name="horizontalSpacer_13"> <spacer name="horizontalSpacer_13">
@@ -203,18 +238,25 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="2" column="1">
<widget class="QLabel" name="label_3">
<item row="2" column="6">
<widget class="QLabel" name="label_7">
<property name="text"> <property name="text">
<string>Audio inputs:</string>
<string>MIDI inputs:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="3">
<spacer name="horizontalSpacer_7">
<item row="2" column="7">
<widget class="QSpinBox" name="sb_midi_ins">
<property name="maximum">
<number>1</number>
</property>
</widget>
</item>
<item row="2" column="8">
<spacer name="horizontalSpacer_15">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@@ -226,26 +268,6 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="2" column="2">
<widget class="QSpinBox" name="sb_audio_ins">
<property name="maximum">
<number>64</number>
</property>
</widget>
</item>
<item row="2" column="4" rowspan="2">
<widget class="Line" name="line">
<property name="lineWidth">
<number>0</number>
</property>
<property name="midLineWidth">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="3" column="0"> <item row="3" column="0">
<spacer name="horizontalSpacer_6"> <spacer name="horizontalSpacer_6">
<property name="orientation"> <property name="orientation">
@@ -272,6 +294,26 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="2">
<widget class="QSpinBox" name="sb_audio_outs">
<property name="maximum">
<number>64</number>
</property>
</widget>
</item>
<item row="3" column="3">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="5"> <item row="3" column="5">
<spacer name="horizontalSpacer_14"> <spacer name="horizontalSpacer_14">
<property name="orientation"> <property name="orientation">
@@ -285,47 +327,35 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="1" colspan="7">
<widget class="QCheckBox" name="cb_manage_window">
<item row="3" column="6">
<widget class="QLabel" name="label_8">
<property name="text"> <property name="text">
<string>Take control of main applicaton window</string>
<string>MIDI outputs:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="6" colspan="3">
<widget class="QComboBox" name="cb_session_mgr">
<property name="enabled">
<bool>false</bool>
<item row="3" column="7">
<widget class="QSpinBox" name="sb_midi_outs">
<property name="maximum">
<number>1</number>
</property> </property>
<item>
<property name="text">
<string>None / Manual</string>
</property>
</item>
<item>
<property name="text">
<string>LADISH (SIGUSR1)</string>
</property>
</item>
<item>
<property name="text">
<string>Non Session Manager (OSC)</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="0" column="1" colspan="3">
<widget class="QLabel" name="label_6">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Session Manager:</string>
<item row="3" column="8">
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
</property> </property>
</widget>
</spacer>
</item> </item>
</layout> </layout>
</widget> </widget>
@@ -336,6 +366,16 @@
<string>Workarounds</string> <string>Workarounds</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="QCheckBox" name="cb_capture_first_window">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Capture only the first X11 Window</string>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
@@ -365,13 +405,10 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="1">
<widget class="QCheckBox" name="cb_capture_first_window">
<property name="enabled">
<bool>false</bool>
</property>
<item row="1" column="1">
<widget class="QCheckBox" name="cb_buffers_addition_mode">
<property name="text"> <property name="text">
<string>Capture only the first X11 Window</string>
<string>Use previous client output buffer as input for the next client</string>
</property> </property>
</widget> </widget>
</item> </item>


+ 2
- 2
source/backend/plugin/CarlaPluginJack.cpp View File

@@ -1279,9 +1279,9 @@ public:
// setup hints and options // setup hints and options


// FIXME dryWet broken // FIXME dryWet broken
pData->hints = PLUGIN_IS_BRIDGE | PLUGIN_OPTION_FIXED_BUFFERS;
pData->hints = PLUGIN_IS_BRIDGE | PLUGIN_OPTION_FIXED_BUFFERS;
#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
pData->options|= /*PLUGIN_CAN_DRYWET |*/ PLUGIN_CAN_VOLUME | PLUGIN_CAN_BALANCE;
pData->hints |= /*PLUGIN_CAN_DRYWET |*/ PLUGIN_CAN_VOLUME | PLUGIN_CAN_BALANCE;
#endif #endif
//fInfo.optionsAvailable = optionAv; //fInfo.optionsAvailable = optionAv;




+ 5
- 2
source/carla_database.py View File

@@ -1890,8 +1890,9 @@ class JackApplicationW(QDialog):
SESSION_MGR_LASH = 3 SESSION_MGR_LASH = 3
SESSION_MGR_NSM = 4 SESSION_MGR_NSM = 4


FLAG_CONTROL_WINDOW = 0x1
FLAG_CAPTURE_FIRST_WINDOW = 0x2
FLAG_CONTROL_WINDOW = 0x01
FLAG_CAPTURE_FIRST_WINDOW = 0x02
FLAG_BUFFERS_ADDITION_MODE = 0x10


def __init__(self, parent, host): def __init__(self, parent, host):
QDialog.__init__(self, parent) QDialog.__init__(self, parent)
@@ -1935,6 +1936,8 @@ class JackApplicationW(QDialog):
flags |= self.FLAG_CONTROL_WINDOW flags |= self.FLAG_CONTROL_WINDOW
if self.ui.cb_capture_first_window.isChecked(): if self.ui.cb_capture_first_window.isChecked():
flags |= self.FLAG_CAPTURE_FIRST_WINDOW flags |= self.FLAG_CAPTURE_FIRST_WINDOW
if self.ui.cb_buffers_addition_mode.isChecked():
flags |= self.FLAG_BUFFERS_ADDITION_MODE


baseIntVal = ord('0') baseIntVal = ord('0')
labelSetup = "%s%s%s%s%s%s" % (chr(baseIntVal+self.ui.sb_audio_ins.value()), labelSetup = "%s%s%s%s%s%s" % (chr(baseIntVal+self.ui.sb_audio_ins.value()),


+ 28
- 10
source/libjack/libjack.cpp View File

@@ -558,9 +558,15 @@ bool CarlaJackAppClient::handleRtData()
{ {
CARLA_SAFE_ASSERT_BREAK(fShmAudioPool.data != nullptr); CARLA_SAFE_ASSERT_BREAK(fShmAudioPool.data != nullptr);


// mixdown is default, do buffer addition (for multiple clients) if requested
const bool doBufferAddition = fSetupHints & 0x10;

// location to start of audio outputs (shm buffer) // location to start of audio outputs (shm buffer)
float* const fdataRealOuts = fShmAudioPool.data+(fServer.bufferSize*fServer.numAudioIns); float* const fdataRealOuts = fShmAudioPool.data+(fServer.bufferSize*fServer.numAudioIns);


if (doBufferAddition && fServer.numAudioOuts > 0)
FloatVectorOperations::clear(fdataRealOuts, fServer.bufferSize*fServer.numAudioOuts);

if (! fClients.isEmpty()) if (! fClients.isEmpty())
{ {
// save tranport for all clients // save tranport for all clients
@@ -629,7 +635,11 @@ bool CarlaJackAppClient::handleRtData()


if (i++ < fServer.numAudioIns) if (i++ < fServer.numAudioIns)
{ {
jport->buffer = fdataReal;
if (numClientOutputsProcessed == 0 || ! doBufferAddition)
jport->buffer = fdataReal;
else
jport->buffer = fdataRealOuts + (i*fServer.bufferSize);

fdataReal += fServer.bufferSize; fdataReal += fServer.bufferSize;
fdataCopy += fServer.bufferSize; fdataCopy += fServer.bufferSize;
} }
@@ -639,11 +649,11 @@ bool CarlaJackAppClient::handleRtData()
needsTmpBufClear = true; needsTmpBufClear = true;
} }
} }
// FIXME one single "if"
for (; i++ < fServer.numAudioIns;)
if (i < fServer.numAudioIns)
{ {
fdataReal += fServer.bufferSize;
fdataCopy += fServer.bufferSize;
const std::size_t remainingBufferSize = fServer.bufferSize * (fServer.numAudioIns - i);
fdataReal += remainingBufferSize;
fdataCopy += remainingBufferSize;
} }


// location to start of audio outputs // location to start of audio outputs
@@ -667,11 +677,11 @@ bool CarlaJackAppClient::handleRtData()
needsTmpBufClear = true; needsTmpBufClear = true;
} }
} }
// FIXME one single "if"
for (; i++ < fServer.numAudioOuts;)
if (i < fServer.numAudioOuts)
{ {
FloatVectorOperations::clear(fdataCopy, fServer.bufferSize);
fdataCopy += fServer.bufferSize;
const std::size_t remainingBufferSize = fServer.bufferSize * (fServer.numAudioOuts - i);
FloatVectorOperations::clear(fdataCopy, remainingBufferSize);
fdataCopy += remainingBufferSize;
} }


// set midi inputs // set midi inputs
@@ -718,6 +728,14 @@ bool CarlaJackAppClient::handleRtData()
// subsequent clients, add data (then divide by number of clients later on) // subsequent clients, add data (then divide by number of clients later on)
FloatVectorOperations::add(fdataRealOuts, fdataCopyOuts, FloatVectorOperations::add(fdataRealOuts, fdataCopyOuts,
fServer.bufferSize*fServer.numAudioOuts); fServer.bufferSize*fServer.numAudioOuts);

if (doBufferAddition)
{
// for more than 1 client addition, we need to divide buffers now
FloatVectorOperations::multiply(fdataRealOuts,
1.0f/static_cast<float>(numClientOutputsProcessed),
fServer.bufferSize*fServer.numAudioOuts);
}
} }


if (jclient->audioOuts.count() == 1 && fServer.numAudioOuts > 1) if (jclient->audioOuts.count() == 1 && fServer.numAudioOuts > 1)
@@ -733,7 +751,7 @@ bool CarlaJackAppClient::handleRtData()
} }
} }


if (numClientOutputsProcessed > 1)
if (numClientOutputsProcessed > 1 && ! doBufferAddition)
{ {
// more than 1 client active, need to divide buffers // more than 1 client active, need to divide buffers
FloatVectorOperations::multiply(fdataRealOuts, FloatVectorOperations::multiply(fdataRealOuts,


Loading…
Cancel
Save