Browse Source

Misc

tags/1.9.4
falkTX 11 years ago
parent
commit
d013bbff1a
13 changed files with 415 additions and 225 deletions
  1. +166
    -4
      resources/ui/carla_host.ui
  2. +49
    -24
      source/backend/engine/CarlaEngine.cpp
  3. +2
    -2
      source/backend/plugin/CarlaPlugin.cpp
  4. +4
    -2
      source/backend/plugin/CarlaPluginInternal.hpp
  5. +70
    -89
      source/backend/plugin/NativePlugin.cpp
  6. +1
    -1
      source/carla-patchbay
  7. +1
    -1
      source/carla-rack
  8. +0
    -57
      source/carla.py
  9. +96
    -20
      source/carla_host.py
  10. +16
    -16
      source/carla_rack.py
  11. +1
    -0
      source/includes/CarlaDefines.hpp
  12. +3
    -3
      source/modules/distrho/dgl/src/Window.cpp
  13. +6
    -6
      source/widgets/canvaspreviewframe.py

+ 166
- 4
resources/ui/carla_host.ui View File

@@ -6,20 +6,174 @@
<rect>
<x>0</x>
<y>0</y>
<width>679</width>
<height>191</height>
<width>688</width>
<height>355</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="mainwidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>1</number>
</property>
<item>
<widget class="QTabWidget" name="tabUtils">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>210</width>
<height>0</height>
</size>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="tabPosition">
<enum>QTabWidget::East</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="disk">
<property name="acceptDrops">
<bool>false</bool>
</property>
<attribute name="title">
<string>Disk</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="cb_disk">
<item>
<property name="text">
<string>Home</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QToolButton" name="b_disk_add">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/16x16/list-add.png</normaloff>:/16x16/list-add.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="b_disk_remove">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/16x16/list-remove.png</normaloff>:/16x16/list-remove.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTreeView" name="fileTreeView">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="CanvasPreviewFrame" name="miniCanvasPreview">
<property name="minimumSize">
<size>
<width>210</width>
<height>162</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>210</width>
<height>162</height>
</size>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>679</width>
<width>688</width>
<height>19</height>
</rect>
</property>
@@ -474,6 +628,14 @@
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>CanvasPreviewFrame</class>
<extends>QFrame</extends>
<header>canvaspreviewframe.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../resources.qrc"/>
</resources>


+ 49
- 24
source/backend/engine/CarlaEngine.cpp View File

@@ -1059,7 +1059,7 @@ const char* CarlaEngine::getUniquePluginName(const char* const name)

bool CarlaEngine::loadFilename(const char* const filename)
{
CARLA_ASSERT(filename != nullptr);
CARLA_ASSERT(filename != nullptr && filename[0] != '\0');
carla_debug("CarlaEngine::loadFilename(\"%s\")", filename);

using namespace juce;
@@ -1073,7 +1073,10 @@ bool CarlaEngine::loadFilename(const char* const filename)
}

CarlaString baseName(file.getFileNameWithoutExtension().toRawUTF8());
CarlaString extension(file.getFileExtension().toRawUTF8());
CarlaString extension(file.getFileExtension().toRawUTF8()+1);
extension.toLower();

carla_stdout("loadFilename with extension %s", (const char*)extension);

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

@@ -1190,7 +1193,7 @@ bool charEndsWith(const char* const str, const char* const suffix)

bool CarlaEngine::loadProject(const char* const filename)
{
CARLA_ASSERT(filename != nullptr);
CARLA_ASSERT(filename != nullptr && filename[0] != '\0');
carla_debug("CarlaEngine::loadProject(\"%s\")", filename);

using namespace juce;
@@ -1260,7 +1263,7 @@ bool CarlaEngine::loadProject(const char* const filename)

bool CarlaEngine::saveProject(const char* const filename)
{
CARLA_ASSERT(filename != nullptr);
CARLA_ASSERT(filename != nullptr && filename[0] != '\0');
carla_debug("CarlaEngine::saveProject(\"%s\")", filename);

using namespace juce;
@@ -1694,11 +1697,20 @@ void setValueIfHigher(float& value, const float& compare)
value = compare;
}

void CarlaEngine::processRack(float* inBuf[2], float* outBuf[2], const uint32_t frames)
void CarlaEngine::processRack(float* inBufReal[2], float* outBuf[2], const uint32_t frames)
{
CARLA_ASSERT(pData->bufEvents.in != nullptr);
CARLA_ASSERT(pData->bufEvents.out != nullptr);

// safe copy
float inBuf0[frames];
float inBuf1[frames];
float* inBuf[2] = { inBuf0, inBuf1 };

// initialize inputs
carla_copyFloat(inBuf0, inBufReal[0], frames);
carla_copyFloat(inBuf1, inBufReal[1], frames);

// initialize outputs (zero)
carla_zeroFloat(outBuf[0], frames);
carla_zeroFloat(outBuf[1], frames);
@@ -1706,6 +1718,9 @@ void CarlaEngine::processRack(float* inBuf[2], float* outBuf[2], const uint32_t

bool processed = false;

uint32_t oldAudioInCount = 0;
uint32_t oldMidiOutCount = 0;

// process plugins
for (unsigned int i=0; i < pData->curPluginCount; ++i)
{
@@ -1716,9 +1731,10 @@ void CarlaEngine::processRack(float* inBuf[2], float* outBuf[2], const uint32_t

if (processed)
{

// initialize inputs (from previous outputs)
carla_copyFloat(inBuf[0], outBuf[0], frames);
carla_copyFloat(inBuf[1], outBuf[1], frames);
carla_copyFloat(inBuf0, outBuf[0], frames);
carla_copyFloat(inBuf1, outBuf[1], frames);
std::memcpy(pData->bufEvents.in, pData->bufEvents.out, sizeof(EngineEvent)*kEngineMaxInternalEventCount);

// initialize outputs (zero)
@@ -1727,26 +1743,35 @@ void CarlaEngine::processRack(float* inBuf[2], float* outBuf[2], const uint32_t
carla_zeroMem(pData->bufEvents.out, sizeof(EngineEvent)*kEngineMaxInternalEventCount);
}

oldAudioInCount = plugin->getAudioInCount();
oldMidiOutCount = plugin->getMidiOutCount();

// if plugin has no audio inputs, add input buffer
//if (oldAudioInCount == 0)
{
carla_addFloat(outBuf[0], inBuf0, frames);
carla_addFloat(outBuf[1], inBuf1, frames);
}

// if plugin has no midi out, add previous events
if (oldMidiOutCount == 0 && pData->bufEvents.in[0].type != CarlaBackend::kEngineEventTypeNull)
{
if (pData->bufEvents.out[0].type != CarlaBackend::kEngineEventTypeNull)
{
// TODO: carefully add to output, sorted events
}
else
{
// nothing in output, can be replaced directly
std::memcpy(pData->bufEvents.out, pData->bufEvents.in, sizeof(EngineEvent)*kEngineMaxInternalEventCount);
}
}

// process
plugin->initBuffers();
plugin->process(inBuf, outBuf, frames);
plugin->unlock();

// if plugin has no audio inputs, add previous buffers
if (plugin->getAudioInCount() == 0)
{
carla_addFloat(outBuf[0], inBuf[0], frames);
carla_addFloat(outBuf[1], inBuf[1], frames);
}
// if plugin has no midi output, add previous events
if (plugin->getMidiOutCount() == 0)
{
//for (uint32_t j=0, k=0; j < frames; ++j)
//{
//}
std::memcpy(pData->bufEvents.out, pData->bufEvents.in, sizeof(EngineEvent)*kEngineMaxInternalEventCount);
}

// set peaks
{
float inPeak1 = 0.0f;
@@ -1756,8 +1781,8 @@ void CarlaEngine::processRack(float* inBuf[2], float* outBuf[2], const uint32_t

for (uint32_t k=0; k < frames; ++k)
{
setValueIfHigher(inPeak1, std::fabs(inBuf[0][k]));
setValueIfHigher(inPeak2, std::fabs(inBuf[1][k]));
setValueIfHigher(inPeak1, std::fabs(inBuf0[k]));
setValueIfHigher(inPeak2, std::fabs(inBuf1[k]));
setValueIfHigher(outPeak1, std::fabs(outBuf[0][k]));
setValueIfHigher(outPeak2, std::fabs(outBuf[1][k]));
}


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

@@ -816,7 +816,7 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState)

bool CarlaPlugin::saveStateToFile(const char* const filename)
{
CARLA_SAFE_ASSERT_RETURN(filename != nullptr, false);
CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false);
carla_debug("CarlaPlugin::saveStateToFile(\"%s\")", filename);

File file(filename);
@@ -836,7 +836,7 @@ bool CarlaPlugin::saveStateToFile(const char* const filename)

bool CarlaPlugin::loadStateFromFile(const char* const filename)
{
CARLA_SAFE_ASSERT_RETURN(filename != nullptr, false);
CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false);
carla_debug("CarlaPlugin::loadStateFromFile(\"%s\")", filename);

File file(filename);


+ 4
- 2
source/backend/plugin/CarlaPluginInternal.hpp View File

@@ -659,9 +659,11 @@ struct CarlaPluginProtectedData {
if (client != nullptr)
{
if (client->isActive())
client->deactivate();
else
{
// must not happen
carla_assert("client->isActive()", __FILE__, __LINE__);
client->deactivate();
}

clearBuffers();



+ 70
- 89
source/backend/plugin/NativePlugin.cpp View File

@@ -313,7 +313,7 @@ public:

PluginCategory getCategory() const override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr, PLUGIN_CATEGORY_NONE);

return static_cast<PluginCategory>(fDescriptor->category);
}
@@ -333,16 +333,15 @@ public:

uint32_t getParameterScalePointCount(const uint32_t parameterId) const override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_ASSERT(parameterId < pData->param.count);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr, 0);
CARLA_SAFE_ASSERT_RETURN(fDescriptor->get_parameter_info != nullptr, 0);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr, 0);
CARLA_SAFE_ASSERT_RETURN(parameterId < pData->param.count, 0);

if (fDescriptor->get_parameter_info != nullptr && parameterId < pData->param.count)
{
if (const Parameter* const param = fDescriptor->get_parameter_info(fHandle, parameterId))
return param->scalePointCount;
}
if (const Parameter* const param = fDescriptor->get_parameter_info(fHandle, parameterId))
return param->scalePointCount;

carla_assert("const Parameter* const param = fDescriptor->get_parameter_info(fHandle, parameterId)", __FILE__, __LINE__);
return 0;
}

@@ -356,10 +355,7 @@ public:

unsigned int getAvailableOptions() const override
{
CARLA_ASSERT(fDescriptor != nullptr);

if (fDescriptor == nullptr)
return 0x0;
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr, 0x0);

const bool hasMidiProgs(fDescriptor->get_midi_program_count != nullptr && fDescriptor->get_midi_program_count(fHandle) > 0);

@@ -395,38 +391,35 @@ public:

float getParameterValue(const uint32_t parameterId) const override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_ASSERT(parameterId < pData->param.count);

if (fDescriptor->get_parameter_value != nullptr && parameterId < pData->param.count)
return fDescriptor->get_parameter_value(fHandle, parameterId);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr, 0.0f);
CARLA_SAFE_ASSERT_RETURN(fDescriptor->get_parameter_value != nullptr, 0.0f);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr, 0.0f);
CARLA_SAFE_ASSERT_RETURN(parameterId < pData->param.count, 0.0f);

return 0.0f;
return fDescriptor->get_parameter_value(fHandle, parameterId);
}

float getParameterScalePointValue(const uint32_t parameterId, const uint32_t scalePointId) const override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_ASSERT(parameterId < pData->param.count);
CARLA_ASSERT(scalePointId < getParameterScalePointCount(parameterId));
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr, 0.0f);
CARLA_SAFE_ASSERT_RETURN(fDescriptor->get_parameter_info != nullptr, 0.0f);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr, 0.0f);
CARLA_SAFE_ASSERT_RETURN(parameterId < pData->param.count, 0.0f);
CARLA_SAFE_ASSERT_RETURN(scalePointId < getParameterScalePointCount(parameterId), 0.0f);

if (fDescriptor->get_parameter_info != nullptr && parameterId < pData->param.count)
if (const Parameter* const param = fDescriptor->get_parameter_info(fHandle, parameterId))
{
if (const Parameter* const param = fDescriptor->get_parameter_info(fHandle, parameterId))
{
const ParameterScalePoint& scalePoint(param->scalePoints[scalePointId]);
return scalePoint.value;
}
const ParameterScalePoint& scalePoint(param->scalePoints[scalePointId]);
return scalePoint.value;
}

carla_assert("const Parameter* const param = fDescriptor->get_parameter_info(fHandle, parameterId)", __FILE__, __LINE__);
return 0.0f;
}

void getLabel(char* const strBuf) const override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);

if (fDescriptor->label != nullptr)
std::strncpy(strBuf, fDescriptor->label, STR_MAX);
@@ -436,7 +429,7 @@ public:

void getMaker(char* const strBuf) const override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);

if (fDescriptor->maker != nullptr)
std::strncpy(strBuf, fDescriptor->maker, STR_MAX);
@@ -446,7 +439,7 @@ public:

void getCopyright(char* const strBuf) const override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);

if (fDescriptor->copyright != nullptr)
std::strncpy(strBuf, fDescriptor->copyright, STR_MAX);
@@ -456,7 +449,7 @@ public:

void getRealName(char* const strBuf) const override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);

if (fDescriptor->name != nullptr)
std::strncpy(strBuf, fDescriptor->name, STR_MAX);
@@ -466,7 +459,7 @@ public:

void getParameterName(const uint32_t parameterId, char* const strBuf) const override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_ASSERT(fHandle != nullptr);
CARLA_ASSERT(parameterId < pData->param.count);

@@ -486,7 +479,7 @@ public:

void getParameterText(const uint32_t parameterId, char* const strBuf) const override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_ASSERT(fHandle != nullptr);
CARLA_ASSERT(parameterId < pData->param.count);

@@ -506,7 +499,7 @@ public:

void getParameterUnit(const uint32_t parameterId, char* const strBuf) const override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_ASSERT(fHandle != nullptr);
CARLA_ASSERT(parameterId < pData->param.count);

@@ -526,7 +519,7 @@ public:

void getParameterScalePointLabel(const uint32_t parameterId, const uint32_t scalePointId, char* const strBuf) const override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_ASSERT(fHandle != nullptr);
CARLA_ASSERT(parameterId < pData->param.count);
CARLA_ASSERT(scalePointId < getParameterScalePointCount(parameterId));
@@ -553,10 +546,10 @@ public:

void prepareForSave() override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);

if (pData->midiprog.count > 0 /*&& (fHints & PLUGIN_IS_SYNTH) != 0*/) // TODO
if (pData->midiprog.count > 0 && fDescriptor->category == ::PLUGIN_CATEGORY_SYNTH)
{
char strBuf[STR_MAX+1];
std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i",
@@ -584,8 +577,9 @@ public:

void setName(const char* const newName) override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);
CARLA_SAFE_ASSERT_RETURN(newName != nullptr && newName[0] != '\0',);

char uiName[std::strlen(newName)+6+1];
std::strcpy(uiName, newName);
@@ -595,7 +589,7 @@ public:
delete[] fHost.uiName;
fHost.uiName = carla_strdup(uiName);

if (fDescriptor != nullptr && fDescriptor->dispatcher != nullptr)
if (fDescriptor->dispatcher != nullptr)
fDescriptor->dispatcher(fHandle, PLUGIN_OPCODE_UI_NAME_CHANGED, 0, 0, uiName, 0.0f);

CarlaPlugin::setName(newName);
@@ -614,8 +608,8 @@ public:

void setParameterValue(const uint32_t parameterId, const float value, const bool sendGui, const bool sendOsc, const bool sendCallback) override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);
CARLA_ASSERT(parameterId < pData->param.count);

const float fixedValue(pData->param.getFixedValue(parameterId, value));
@@ -633,8 +627,8 @@ public:

void setCustomData(const char* const type, const char* const key, const char* const value, const bool sendGui) override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);
CARLA_ASSERT(type != nullptr);
CARLA_ASSERT(key != nullptr);
CARLA_ASSERT(value != nullptr);
@@ -720,8 +714,8 @@ public:

void setMidiProgram(int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback) override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);
CARLA_ASSERT(index >= -1 && index < static_cast<int32_t>(pData->midiprog.count));

if (index < -1)
@@ -757,8 +751,8 @@ public:

void showGui(const bool yesNo) override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);

if (fDescriptor->ui_show == nullptr)
return;
@@ -799,8 +793,8 @@ public:

void idleGui() override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);

if (fIsUiVisible && fDescriptor->ui_idle != nullptr)
fDescriptor->ui_idle(fHandle);
@@ -812,16 +806,9 @@ public:
void reload() override
{
carla_debug("NativePlugin::reload() - start");
CARLA_ASSERT(pData->engine != nullptr);
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);

if (pData->engine == nullptr)
return;
if (fDescriptor == nullptr)
return;
if (fHandle == nullptr)
return;
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);

const ProcessMode processMode(pData->engine->getProccessMode());

@@ -1294,8 +1281,8 @@ public:

void activate() override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);

if (fDescriptor->activate != nullptr)
{
@@ -1308,8 +1295,8 @@ public:

void deactivate() override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);

if (fDescriptor->deactivate != nullptr)
{
@@ -2034,8 +2021,8 @@ public:

void uiParameterChange(const uint32_t index, const float value) override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);
CARLA_ASSERT(index < pData->param.count);

if (! fIsUiVisible)
@@ -2051,8 +2038,8 @@ public:

void uiMidiProgramChange(const uint32_t index) override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);
CARLA_ASSERT(index < pData->midiprog.count);

if (! fIsUiVisible)
@@ -2068,8 +2055,8 @@ public:

void uiNoteOn(const uint8_t channel, const uint8_t note, const uint8_t velo) override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);
CARLA_ASSERT(channel < MAX_MIDI_CHANNELS);
CARLA_ASSERT(note < MAX_MIDI_NOTE);
CARLA_ASSERT(velo > 0 && velo < MAX_MIDI_VALUE);
@@ -2090,8 +2077,8 @@ public:

void uiNoteOff(const uint8_t channel, const uint8_t note) override
{
CARLA_ASSERT(fDescriptor != nullptr);
CARLA_ASSERT(fHandle != nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);
CARLA_ASSERT(channel < MAX_MIDI_CHANNELS);
CARLA_ASSERT(note < MAX_MIDI_NOTE);

@@ -2110,24 +2097,24 @@ public:
// -------------------------------------------------------------------

protected:
uint32_t handleGetBufferSize()
uint32_t handleGetBufferSize() const
{
return pData->engine->getBufferSize();
}

double handleGetSampleRate()
double handleGetSampleRate() const
{
return pData->engine->getSampleRate();
}

bool handleIsOffline()
bool handleIsOffline() const
{
return pData->engine->isOffline();
}

const ::TimeInfo* handleGetTimeInfo()
const ::TimeInfo* handleGetTimeInfo() const
{
CARLA_ASSERT(fIsProcessing);
CARLA_SAFE_ASSERT_RETURN(fIsProcessing, nullptr);

return &fTimeInfo;
}
@@ -2296,10 +2283,6 @@ public:

bool init(const char* const name, const char* const label)
{
CARLA_ASSERT(pData->engine != nullptr);
CARLA_ASSERT(pData->client == nullptr);
CARLA_ASSERT(label != nullptr);

// ---------------------------------------------------------------
// first checks

@@ -2314,7 +2297,7 @@ public:
return false;
}

if (label == nullptr)
if (label == nullptr && label[0] != '\0')
{
pData->engine->setLastError("null label");
return false;
@@ -2327,10 +2310,8 @@ public:
{
fDescriptor = *it;

CARLA_ASSERT(fDescriptor != nullptr);
CARLA_SAFE_ASSERT_BREAK(fDescriptor != nullptr);

if (fDescriptor == nullptr)
break;
if (fDescriptor->label != nullptr && std::strcmp(fDescriptor->label, label) == 0)
break;



+ 1
- 1
source/carla-patchbay View File

@@ -30,7 +30,7 @@ class CarlaHostW(HostWindow):
HostWindow.__init__(self, parent)

self.fContainer = CarlaPatchbayW(self)
self.setCentralWidget(self.fContainer)
self.setupContainer(True)

# ------------------------------------------------------------------------------------------------------------
# Main


+ 1
- 1
source/carla-rack View File

@@ -30,7 +30,7 @@ class CarlaHostW(HostWindow):
HostWindow.__init__(self, parent)

self.fContainer = CarlaRackW(self)
self.setCentralWidget(self.fContainer)
self.setupContainer(False)

# ------------------------------------------------------------------------------------------------------------
# Main


+ 0
- 57
source/carla.py View File

@@ -79,10 +79,6 @@ class CarlaMainW(QMainWindow):
self.fInfoLabel.setText("")
self.fInfoText = ""

self.fDirModel = QFileSystemModel(self)
self.fDirModel.setNameFilters(cString(Carla.host.get_supported_file_types()).split(";"))
self.fDirModel.setRootPath(HOME)

if not WINDOWS:
self.fSyntaxLog = LogSyntaxHighlighter(self.ui.pte_log)
self.fSyntaxLog.setDocument(self.ui.pte_log.document())
@@ -93,13 +89,6 @@ class CarlaMainW(QMainWindow):
else:
self.ui.tabMain.removeTab(2)

self.ui.fileTreeView.setModel(self.fDirModel)
self.ui.fileTreeView.setRootIndex(self.fDirModel.index(HOME))
self.ui.fileTreeView.setColumnHidden(1, True)
self.ui.fileTreeView.setColumnHidden(2, True)
self.ui.fileTreeView.setColumnHidden(3, True)
self.ui.fileTreeView.setHeaderHidden(True)

self.ui.act_engine_start.setEnabled(False)
self.ui.act_engine_stop.setEnabled(False)
self.ui.act_plugin_remove_all.setEnabled(False)
@@ -189,52 +178,6 @@ class CarlaMainW(QMainWindow):
def slot_splitterMoved(self):
self.updateInfoLabelSize()

@pyqtSlot(int)
def slot_diskFolderChanged(self, index):
if index < 0:
return
elif index == 0:
filename = HOME
self.ui.b_disk_remove.setEnabled(False)
else:
filename = self.ui.cb_disk.itemData(index)
self.ui.b_disk_remove.setEnabled(True)

self.fDirModel.setRootPath(filename)
self.ui.fileTreeView.setRootIndex(self.fDirModel.index(filename))

@pyqtSlot()
def slot_diskFolderAdd(self):
newPath = QFileDialog.getExistingDirectory(self, self.tr("New Folder"), "", QFileDialog.ShowDirsOnly)

if newPath:
if newPath[-1] == os.sep:
newPath = newPath[:-1]
self.ui.cb_disk.addItem(os.path.basename(newPath), newPath)
self.ui.cb_disk.setCurrentIndex(self.ui.cb_disk.count()-1)
self.ui.b_disk_remove.setEnabled(True)

@pyqtSlot()
def slot_diskFolderRemove(self):
index = self.ui.cb_disk.currentIndex()

if index <= 0:
return

self.ui.cb_disk.removeItem(index)

if self.ui.cb_disk.currentIndex() == 0:
self.ui.b_disk_remove.setEnabled(False)

@pyqtSlot(QModelIndex)
def slot_fileTreeDoubleClicked(self, modelIndex):
filename = self.fDirModel.filePath(modelIndex)

if not Carla.host.load_filename(filename):
CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"),
self.tr("Failed to load file"),
cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)

@pyqtSlot(float, float)
def slot_miniCanvasMoved(self, xp, yp):
self.ui.graphicsView.horizontalScrollBar().setValue(xp * DEFAULT_CANVAS_WIDTH)


+ 96
- 20
source/carla_host.py View File

@@ -20,12 +20,12 @@
# Imports (Global)

try:
from PyQt5.QtCore import QTimer
from PyQt5.QtCore import QModelIndex, QTimer
from PyQt5.QtGui import QPalette
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtWidgets import QApplication, QFileSystemModel, QMainWindow
except:
from PyQt4.QtCore import QTimer
from PyQt4.QtGui import QApplication, QMainWindow, QPalette
from PyQt4.QtCore import QModelIndex, QTimer
from PyQt4.QtGui import QApplication, QFileSystemModel, QMainWindow, QPalette

# ------------------------------------------------------------------------------------------------------------
# Imports (Custom)
@@ -213,6 +213,20 @@ class HostWindow(QMainWindow):

self.setTransportMenuEnabled(False)

# -------------------------------------------------------------
# Set up GUI (right panel)

self.fDirModel = QFileSystemModel(self)
self.fDirModel.setNameFilters(cString(Carla.host.get_supported_file_types()).split(";"))
self.fDirModel.setRootPath(HOME)

self.ui.fileTreeView.setModel(self.fDirModel)
self.ui.fileTreeView.setRootIndex(self.fDirModel.index(HOME))
self.ui.fileTreeView.setColumnHidden(1, True)
self.ui.fileTreeView.setColumnHidden(2, True)
self.ui.fileTreeView.setColumnHidden(3, True)
self.ui.fileTreeView.setHeaderHidden(True)

self.setProperWindowTitle()

# -------------------------------------------------------------
@@ -240,10 +254,10 @@ class HostWindow(QMainWindow):

#self.ui.splitter.splitterMoved.connect(self.slot_splitterMoved)

#self.ui.cb_disk.currentIndexChanged.connect(self.slot_diskFolderChanged)
#self.ui.b_disk_add.clicked.connect(self.slot_diskFolderAdd)
#self.ui.b_disk_remove.clicked.connect(self.slot_diskFolderRemove)
#self.ui.fileTreeView.doubleClicked.connect(self.slot_fileTreeDoubleClicked)
self.ui.cb_disk.currentIndexChanged.connect(self.slot_diskFolderChanged)
self.ui.b_disk_add.clicked.connect(self.slot_diskFolderAdd)
self.ui.b_disk_remove.clicked.connect(self.slot_diskFolderRemove)
self.ui.fileTreeView.doubleClicked.connect(self.slot_fileTreeDoubleClicked)

self.DebugCallback.connect(self.slot_handleDebugCallback)
self.PluginAddedCallback.connect(self.slot_handlePluginAddedCallback)
@@ -277,6 +291,20 @@ class HostWindow(QMainWindow):
dialog = CarlaSettingsW(self, hasCanvas, hasCanvasGL)
return dialog.exec_()

def setupContainer(self, showMiniCanvas):
if showMiniCanvas:
CARLA_DEFAULT_CANVAS_WIDTH = 3100
CARLA_DEFAULT_CANVAS_HEIGHT = 2400
self.ui.miniCanvasPreview.setRealParent(self)
#self.ui.miniCanvasPreview.setViewTheme(patchcanvas.canvas.theme.canvas_bg, patchcanvas.canvas.theme.rubberband_brush, patchcanvas.canvas.theme.rubberband_pen.color())
self.ui.miniCanvasPreview.init(self.fContainer.scene, CARLA_DEFAULT_CANVAS_WIDTH, CARLA_DEFAULT_CANVAS_HEIGHT, self.fSavedSettings["UseCustomMiniCanvasPaint"])
else:
self.ui.miniCanvasPreview.hide()

self.ui.mainwidget.hide()
self.ui.splitter.insertWidget(0, self.fContainer)
del self.ui.mainwidget

# -----------------------------------------------------------------
# Internal stuff (files)

@@ -521,16 +549,16 @@ class HostWindow(QMainWindow):
#if settings.contains("SplitterState"):
#self.ui.splitter.restoreState(settings.value("SplitterState", ""))
#else:
#self.ui.splitter.setSizes([99999, 210])
self.ui.splitter.setSizes([99999, 210])

#diskFolders = toList(settings.value("DiskFolders", [HOME]))
diskFolders = toList(settings.value("DiskFolders", [HOME]))

#self.ui.cb_disk.setItemData(0, HOME)
self.ui.cb_disk.setItemData(0, HOME)

#for i in range(len(diskFolders)):
#if i == 0: continue
#folder = diskFolders[i]
#self.ui.cb_disk.addItem(os.path.basename(folder), folder)
for i in range(len(diskFolders)):
if i == 0: continue
folder = diskFolders[i]
self.ui.cb_disk.addItem(os.path.basename(folder), folder)

if MACOS and not settings.value("Main/UseProTheme", True, type=bool):
self.setUnifiedTitleAndToolBarOnMac(True)
@@ -601,17 +629,17 @@ class HostWindow(QMainWindow):
settings = QSettings()

settings.setValue("Geometry", self.saveGeometry())
#settings.setValue("SplitterState", self.ui.splitter.saveState())
settings.setValue("SplitterState", self.ui.splitter.saveState())
settings.setValue("ShowToolbar", self.ui.toolBar.isVisible())
#settings.setValue("HorizontalScrollBarValue", self.ui.graphicsView.horizontalScrollBar().value())
#settings.setValue("VerticalScrollBarValue", self.ui.graphicsView.verticalScrollBar().value())

#diskFolders = []
diskFolders = []

#for i in range(self.ui.cb_disk.count()):
#diskFolders.append(self.ui.cb_disk.itemData(i))
for i in range(self.ui.cb_disk.count()):
diskFolders.append(self.ui.cb_disk.itemData(i))

#settings.setValue("DiskFolders", diskFolders)
settings.setValue("DiskFolders", diskFolders)

self.fContainer.saveSettings(settings)

@@ -823,6 +851,54 @@ class HostWindow(QMainWindow):

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

@pyqtSlot(int)
def slot_diskFolderChanged(self, index):
if index < 0:
return
elif index == 0:
filename = HOME
self.ui.b_disk_remove.setEnabled(False)
else:
filename = self.ui.cb_disk.itemData(index)
self.ui.b_disk_remove.setEnabled(True)

self.fDirModel.setRootPath(filename)
self.ui.fileTreeView.setRootIndex(self.fDirModel.index(filename))

@pyqtSlot()
def slot_diskFolderAdd(self):
newPath = QFileDialog.getExistingDirectory(self, self.tr("New Folder"), "", QFileDialog.ShowDirsOnly)

if newPath:
if newPath[-1] == os.sep:
newPath = newPath[:-1]
self.ui.cb_disk.addItem(os.path.basename(newPath), newPath)
self.ui.cb_disk.setCurrentIndex(self.ui.cb_disk.count()-1)
self.ui.b_disk_remove.setEnabled(True)

@pyqtSlot()
def slot_diskFolderRemove(self):
index = self.ui.cb_disk.currentIndex()

if index <= 0:
return

self.ui.cb_disk.removeItem(index)

if self.ui.cb_disk.currentIndex() == 0:
self.ui.b_disk_remove.setEnabled(False)

@pyqtSlot(QModelIndex)
def slot_fileTreeDoubleClicked(self, modelIndex):
filename = self.fDirModel.filePath(modelIndex)

if not Carla.host.load_filename(filename):
CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"),
self.tr("Failed to load file"),
cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)

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

@pyqtSlot(int, int, int, float, str)
def slot_handleDebugCallback(self, pluginId, value1, value2, value3, valueStr):
print("DEBUG:", pluginId, value1, value2, value3, valueStr)


+ 16
- 16
source/carla_rack.py View File

@@ -76,22 +76,22 @@ class CarlaRackW(QListWidget):
#self.setMnimumWidth(800)
self.setSortingEnabled(False)

app = QApplication.instance()
pal1 = app.palette().base().color()
pal2 = app.palette().button().color()
col1 = "stop:0 rgb(%i, %i, %i)" % (pal1.red(), pal1.green(), pal1.blue())
col2 = "stop:1 rgb(%i, %i, %i)" % (pal2.red(), pal2.green(), pal2.blue())
self.setStyleSheet("""
QListWidget {
background-color: qlineargradient(spread:pad,
x1:0.0, y1:0.0,
x2:0.2, y2:1.0,
%s,
%s
);
}
""" % (col1, col2))
#app = QApplication.instance()
#pal1 = app.palette().base().color()
#pal2 = app.palette().button().color()
#col1 = "stop:0 rgb(%i, %i, %i)" % (pal1.red(), pal1.green(), pal1.blue())
#col2 = "stop:1 rgb(%i, %i, %i)" % (pal2.red(), pal2.green(), pal2.blue())
#self.setStyleSheet("""
#QListWidget {
#background-color: qlineargradient(spread:pad,
#x1:0.0, y1:0.0,
#x2:0.2, y2:1.0,
#%s,
#%s
#);
#}
#""" % (col1, col2))

# -------------------------------------------------------------
# Connect actions to functions


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

@@ -136,6 +136,7 @@
#define CARLA_SAFE_ASSERT_INT(cond, value) if (cond) pass(); else carla_assert_int (#cond, __FILE__, __LINE__, value);
#define CARLA_SAFE_ASSERT_INT2(cond, v1, v2) if (cond) pass(); else carla_assert_int2(#cond, __FILE__, __LINE__, v1, v2);

#define CARLA_SAFE_ASSERT_BREAK(cond) if (cond) pass(); else { carla_assert(#cond, __FILE__, __LINE__); break; }
#define CARLA_SAFE_ASSERT_CONTINUE(cond) if (cond) pass(); else { carla_assert(#cond, __FILE__, __LINE__); continue; }
#define CARLA_SAFE_ASSERT_RETURN(cond, ret) if (cond) pass(); else { carla_assert(#cond, __FILE__, __LINE__); return ret; }



+ 3
- 3
source/modules/distrho/dgl/src/Window.cpp View File

@@ -333,11 +333,11 @@ public:
height = 1;

#ifndef DGL_OS_MAC
fView->width = width;
fView->height = height;

if (fView->width == (int)width && fView->height == (int)height && ! forced)
return;

fView->width = width;
fView->height = height;
#endif

#if DGL_OS_WINDOWS


+ 6
- 6
source/widgets/canvaspreviewframe.py View File

@@ -99,7 +99,7 @@ class CanvasPreviewFrame(QFrame):

def setViewScale(self, scale):
self.fScale = scale
QTimer.singleShot(0, self.fRealParent, SLOT("slot_miniCanvasCheckAll()"))
#QTimer.singleShot(0, self.fRealParent, SLOT("slot_miniCanvasCheckAll()"))

def setViewSize(self, width, height):
self.fViewRect[iWidth] = width * self.fFakeWidth
@@ -139,7 +139,7 @@ class CanvasPreviewFrame(QFrame):
self.fViewRect[iY] = y + self.fRenderSource.y()
self.update()

self.emit(SIGNAL("miniCanvasMoved(double, double)"), x * self.fScale / self.fFakeWidth, y * self.fScale / self.fFakeHeight)
#self.emit(SIGNAL("miniCanvasMoved(double, double)"), x * self.fScale / self.fFakeWidth, y * self.fScale / self.fFakeHeight)

def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
@@ -178,7 +178,7 @@ class CanvasPreviewFrame(QFrame):
else:
painter.setBrush(self.fViewBg)
painter.setPen(self.fViewBg)
painter.drawRoundRect(2, 2, self.width()-6, self.height()-6, 3, 3)
painter.drawRoundedRect(2, 2, self.width()-6, self.height()-6, 3, 3)

self.fScene.render(painter, self.fRenderSource, self.fRenderTarget, Qt.KeepAspectRatio)

@@ -201,6 +201,6 @@ class CanvasPreviewFrame(QFrame):

def resizeEvent(self, event):
self.fRenderSource = self.getRenderSource()
if self.fRealParent:
QTimer.singleShot(0, self.fRealParent, SLOT("slot_miniCanvasCheckAll()"))
QFrame.resizeEvent(self, event)
#if self.fRealParent:
#QTimer.singleShot(0, self.fRealParent, SLOT("slot_miniCanvasCheckAll()"))
#QFrame.resizeEvent(self, event)

Loading…
Cancel
Save