Browse Source

General fixing, RtAudio engine is now working

tags/1.9.4
falkTX 11 years ago
parent
commit
acccee8bde
8 changed files with 111 additions and 77 deletions
  1. +1
    -1
      data/windows/build-win32.sh
  2. +1
    -1
      data/windows/build-win64.sh
  3. +1
    -1
      resources/ui/carla_settings.ui
  4. +42
    -10
      resources/ui/carla_settings_driver.ui
  5. +1
    -1
      source/Makefile.mk
  6. +48
    -47
      source/backend/engine/CarlaEngineRtAudio.cpp
  7. +11
    -9
      source/backend/standalone/CarlaStandalone.cpp
  8. +6
    -7
      source/carla.py

+ 1
- 1
data/windows/build-win32.sh View File

@@ -49,7 +49,7 @@ make $JOBS -C source/discovery WIN32=true EXTRA_LIBS="$EXTRA_LIBS1"
mv source/discovery/carla-discovery-native source/discovery/carla-discovery-win32.exe

# Build backend
make $JOBS -C source/backend/standalone ../libcarla_standalone.dll CARLA_RTAUDIO_SUPPORT=true WIN32=true EXTRA_LIBS="$EXTRA_LIBS1 $EXTRA_LIBS2"
make $JOBS -C source/backend/standalone ../libcarla_standalone.dll WIN32=true EXTRA_LIBS="$EXTRA_LIBS1 $EXTRA_LIBS2"

rm -rf ./data/windows/Carla
cp ./source/carla.py ./source/carla.pyw


+ 1
- 1
data/windows/build-win64.sh View File

@@ -49,7 +49,7 @@ make $JOBS -C source/discovery WIN32=true EXTRA_LIBS="$EXTRA_LIBS1"
mv source/discovery/carla-discovery-native source/discovery/carla-discovery-win32.exe

# Build backend
make $JOBS -C source/backend/standalone ../libcarla_standalone.dll CARLA_RTAUDIO_SUPPORT=true WIN32=true EXTRA_LIBS="$EXTRA_LIBS1 $EXTRA_LIBS2"
make $JOBS -C source/backend/standalone ../libcarla_standalone.dll WIN32=true EXTRA_LIBS="$EXTRA_LIBS1 $EXTRA_LIBS2"

rm -rf ./data/windows/Carla
cp ./source/carla.py ./source/carla.pyw


+ 1
- 1
resources/ui/carla_settings.ui View File

@@ -268,7 +268,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<widget class="QGroupBox" name="group_theme">
<property name="title">
<string>Theme</string>
</property>


+ 42
- 10
resources/ui/carla_settings_driver.ui View File

@@ -23,6 +23,9 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="cb_jack_autoconnect">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Auto-connect to hardware ports</string>
</property>
@@ -30,15 +33,38 @@
</item>
<item>
<widget class="QCheckBox" name="cb_jack_timemaster">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>JACK Transport master</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>(JACK driver options not implemented yet)</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Sample rate:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
@@ -65,19 +91,25 @@
<item row="1" column="1">
<widget class="QComboBox" name="cb_rtaudio_buffersize"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Sample rate:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="cb_rtaudio_samplerate"/>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<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>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>


+ 1
- 1
source/Makefile.mk View File

@@ -41,7 +41,7 @@ CARLA_PLUGIN_SUPPORT = true
CARLA_SAMPLERS_SUPPORT = true

# Support for Native Audio (ALSA and/or PulseAudio in Linux)
CARLA_RTAUDIO_SUPPORT = false
CARLA_RTAUDIO_SUPPORT = true

# Comment this line to not use vestige header
BUILD_CXX_FLAGS += -DVESTIGE_HEADER


+ 48
- 47
source/backend/engine/CarlaEngineRtAudio.cpp View File

@@ -96,8 +96,8 @@ public:
fAudioCountOut(0),
fAudioIsInterleaved(false),
fAudioIsReady(false),
fDummyMidiIn(getMatchedAudioMidiAPi(api), "Carla-Probe-In"),
fDummyMidiOut(getMatchedAudioMidiAPi(api), "Carla-Probe-Out"),
fDummyMidiIn(getMatchedAudioMidiAPi(api), "Carla"),
fDummyMidiOut(getMatchedAudioMidiAPi(api), "Carla"),
fLastConnectionId(0)
{
carla_debug("CarlaEngineRtAudio::CarlaEngineRtAudio(%i)", api);
@@ -348,7 +348,7 @@ public:
fMidiOuts.clear();

fMidiInEvents.clear();
fMidiOutEvents.clear();
//fMidiOutEvents.clear();

return true;
}
@@ -376,6 +376,7 @@ public:
CARLA_ASSERT(fAudioIsReady);
CARLA_ASSERT(portA > PATCHBAY_PORT_MAX);
CARLA_ASSERT(portB > PATCHBAY_PORT_MAX);
carla_debug("CarlaEngineRtAudio::patchbayConnect(%i, %i)", portA, portB);

if (! fAudioIsReady)
{
@@ -396,12 +397,12 @@ public:
// only allow connections between Carla and other ports
if (portA < 0 && portB < 0)
{
setLastError("Invalid connection");
setLastError("Invalid connection (1)");
return false;
}
if (portA >= 0 && portB >= 0)
{
setLastError("Invalid connection");
setLastError("Invalid connection (2)");
return false;
}

@@ -449,20 +450,20 @@ public:

case PATCHBAY_PORT_MIDI_IN:
CARLA_ASSERT(targetPort >= PATCHBAY_GROUP_MIDI_IN*1000);
CARLA_ASSERT(targetPort <= PATCHBAY_GROUP_MIDI_IN*1000 + 999);
CARLA_ASSERT(targetPort <= PATCHBAY_GROUP_MIDI_IN*1000+999);
makeConnection = connectMidiInPort(targetPort - PATCHBAY_GROUP_MIDI_IN*1000);
break;

case PATCHBAY_PORT_MIDI_OUT:
CARLA_ASSERT(targetPort >= PATCHBAY_GROUP_MIDI_OUT*1000);
CARLA_ASSERT(targetPort <= PATCHBAY_GROUP_MIDI_OUT*1000 + 999);
CARLA_ASSERT(targetPort <= PATCHBAY_GROUP_MIDI_OUT*1000+999);
makeConnection = connectMidiOutPort(targetPort - PATCHBAY_GROUP_MIDI_OUT*1000);
break;
}

if (! makeConnection)
{
setLastError("Invalid connection");
setLastError("Invalid connection (3)");
return false;
}

@@ -483,6 +484,7 @@ public:
{
CARLA_ASSERT(fAudioIsReady);
CARLA_ASSERT(fUsedConnections.count() > 0);
carla_debug("CarlaEngineRtAudio::patchbayDisconnect(%i)", connectionId);

if (! fAudioIsReady)
{
@@ -506,7 +508,7 @@ public:

if (targetPort >= PATCHBAY_GROUP_MIDI_OUT*1000)
{
int portId = targetPort-PATCHBAY_GROUP_MIDI_IN*1000;
const int portId(targetPort-PATCHBAY_GROUP_MIDI_OUT*1000);

for (auto it=fMidiOuts.begin(); it.valid(); it.next())
{
@@ -525,7 +527,7 @@ public:
}
else if (targetPort >= PATCHBAY_GROUP_MIDI_IN*1000)
{
int portId = targetPort-PATCHBAY_GROUP_MIDI_IN*1000;
const int portId(targetPort-PATCHBAY_GROUP_MIDI_IN*1000);

for (auto it=fMidiIns.begin(); it.valid(); it.next())
{
@@ -547,12 +549,14 @@ public:
{
CARLA_ASSERT(carlaPort == PATCHBAY_PORT_AUDIO_OUT1 || carlaPort == PATCHBAY_PORT_AUDIO_OUT2);

const int portId(targetPort-PATCHBAY_GROUP_AUDIO_OUT*1000);

fConnectAudioLock.lock();

if (carlaPort == PATCHBAY_PORT_AUDIO_OUT1)
fConnectedAudioOuts[0].removeAll(targetPort-PATCHBAY_GROUP_AUDIO_OUT*1000);
fConnectedAudioOuts[0].removeAll(portId);
else
fConnectedAudioOuts[1].removeAll(targetPort-PATCHBAY_GROUP_AUDIO_OUT*1000);
fConnectedAudioOuts[1].removeAll(portId);

fConnectAudioLock.unlock();
}
@@ -560,12 +564,14 @@ public:
{
CARLA_ASSERT(carlaPort == PATCHBAY_PORT_AUDIO_IN1 || carlaPort == PATCHBAY_PORT_AUDIO_IN2);

const int portId(targetPort-PATCHBAY_GROUP_AUDIO_IN*1000);

fConnectAudioLock.lock();

if (carlaPort == PATCHBAY_PORT_AUDIO_IN1)
fConnectedAudioIns[0].removeAll(targetPort-PATCHBAY_GROUP_AUDIO_IN*1000);
fConnectedAudioIns[0].removeAll(portId);
else
fConnectedAudioIns[1].removeAll(targetPort-PATCHBAY_GROUP_AUDIO_IN*1000);
fConnectedAudioIns[1].removeAll(portId);

fConnectAudioLock.unlock();
}
@@ -657,6 +663,7 @@ public:
}
}

#if 0 // midi-out not implemented yet
// MIDI Out
{
callback(CALLBACK_PATCHBAY_CLIENT_ADDED, 0, PATCHBAY_GROUP_MIDI_OUT, 0, 0.0f, "Writable MIDI ports");
@@ -671,6 +678,7 @@ public:
callback(CALLBACK_PATCHBAY_PORT_ADDED, 0, PATCHBAY_GROUP_MIDI_OUT, portNameToId.portId, PATCHBAY_PORT_IS_MIDI|PATCHBAY_PORT_IS_INPUT, portNameToId.name);
}
}
#endif

// Connections
fConnectAudioLock.lock();
@@ -747,7 +755,7 @@ public:

ConnectionToId connectionToId;
connectionToId.id = fLastConnectionId;
connectionToId.portOut = midiPort.portId;
connectionToId.portOut = PATCHBAY_GROUP_MIDI_IN*1000 + midiPort.portId;
connectionToId.portIn = PATCHBAY_PORT_MIDI_IN;

callback(CALLBACK_PATCHBAY_CONNECTION_ADDED, 0, fLastConnectionId, connectionToId.portOut, connectionToId.portIn, nullptr);
@@ -763,7 +771,7 @@ public:
ConnectionToId connectionToId;
connectionToId.id = fLastConnectionId;
connectionToId.portOut = PATCHBAY_PORT_MIDI_OUT;
connectionToId.portIn = midiPort.portId;
connectionToId.portIn = PATCHBAY_GROUP_MIDI_OUT*1000 + midiPort.portId;

callback(CALLBACK_PATCHBAY_CONNECTION_ADDED, 0, fLastConnectionId, connectionToId.portOut, connectionToId.portIn, nullptr);

@@ -1011,7 +1019,7 @@ protected:
// output events
{
// TODO
//fMidiOut.sendMessage();
//fMidiOutEvents...
}

proccessPendingEvents();
@@ -1042,7 +1050,6 @@ protected:

RtMidiEvent midiEvent;
midiEvent.time = fTimeInfo.frame + (timeStamp*(double)fBufferSize);
carla_stdout("Put midi, frame:%09i/%09i, stamp:%f", fTimeInfo.frame, midiEvent.time, timeStamp);

if (midiEvent.time < lastTime)
midiEvent.time = lastTime;
@@ -1087,25 +1094,22 @@ protected:

bool connectMidiInPort(const int portId)
{
const char* portName = nullptr;
CARLA_ASSERT(fUsedMidiIns.count() > 0);
CARLA_ASSERT(portId >= 0);
CARLA_ASSERT(static_cast<size_t>(portId) < fUsedMidiIns.count());
carla_debug("CarlaEngineRtAudio::connectMidiInPort(%i)", portId);

for (auto it = fUsedMidiIns.begin(); it.valid(); it.next())
{
const PortNameToId& portNameId(*it);
if (portId < 0 || static_cast<size_t>(portId) >= fUsedMidiIns.count())
return false;

if (portNameId.portId == portId)
{
portName = portNameId.name;
break;
}
}
const char* const portName(fUsedMidiIns.getAt(portId).name);

if (portName == nullptr)
return false;
char newPortName[STR_MAX+1];
std::snprintf(newPortName, STR_MAX, "%s:in-%i", (const char*)getName(), portId+1);

int rtMidiPortIndex = -1;

RtMidiIn* const rtMidiIn(new RtMidiIn(getMatchedAudioMidiAPi(fAudio.getCurrentApi()), getName(), 512));
RtMidiIn* const rtMidiIn(new RtMidiIn(getMatchedAudioMidiAPi(fAudio.getCurrentApi()), newPortName, 512));
rtMidiIn->ignoreTypes();
rtMidiIn->setCallback(carla_rtmidi_callback, this);

@@ -1124,7 +1128,7 @@ protected:
return false;
}

rtMidiIn->openPort(rtMidiPortIndex, "in");
rtMidiIn->openPort(rtMidiPortIndex, newPortName+(std::strlen(getName())+1));

MidiPort midiPort;
midiPort.portId = portId;
@@ -1137,25 +1141,22 @@ protected:

bool connectMidiOutPort(const int portId)
{
const char* portName = nullptr;
CARLA_ASSERT(fUsedMidiOuts.count() > 0);
CARLA_ASSERT(portId >= 0);
CARLA_ASSERT(static_cast<size_t>(portId) < fUsedMidiOuts.count());
carla_debug("CarlaEngineRtAudio::connectMidiOutPort(%i)", portId);

for (auto it = fUsedMidiOuts.begin(); it.valid(); it.next())
{
const PortNameToId& portNameId(*it);
if (portId < 0 || static_cast<size_t>(portId) >= fUsedMidiOuts.count())
return false;

if (portNameId.portId == portId)
{
portName = portNameId.name;
break;
}
}
const char* const portName(fUsedMidiOuts.getAt(portId).name);

if (portName == nullptr)
return false;
char newPortName[STR_MAX+1];
std::snprintf(newPortName, STR_MAX, "%s:out-%i", (const char*)getName(), portId+1);

int rtMidiPortIndex = -1;

RtMidiOut* const rtMidiOut(new RtMidiOut(getMatchedAudioMidiAPi(fAudio.getCurrentApi()), getName()));
RtMidiOut* const rtMidiOut(new RtMidiOut(getMatchedAudioMidiAPi(fAudio.getCurrentApi()), newPortName));

for (unsigned int i=0, count=rtMidiOut->getPortCount(); i < count; ++i)
{
@@ -1172,7 +1173,7 @@ protected:
return false;
}

rtMidiOut->openPort(rtMidiPortIndex, "in");
rtMidiOut->openPort(rtMidiPortIndex, newPortName+(std::strlen(getName())+1));

MidiPort midiPort;
midiPort.portId = portId;
@@ -1292,7 +1293,7 @@ private:
};

RtMidiEvents fMidiInEvents;
RtMidiEvents fMidiOutEvents;
//RtMidiEvents fMidiOutEvents;

#define handlePtr ((CarlaEngineRtAudio*)userData)



+ 11
- 9
source/backend/standalone/CarlaStandalone.cpp View File

@@ -488,6 +488,17 @@ bool carla_engine_init(const char* driverName, const char* clientName)
}
#endif

#ifdef Q_OS_WIN
carla_setenv("WINEASIO_CLIENT_NAME", clientName);
#endif

// TODO: make this an option, put somewhere else
if (getenv("WINE_RT") == nullptr)
{
carla_setenv("WINE_RT", "15");
carla_setenv("WINE_SVR_RT", "10");
}

if (standalone.engine != nullptr)
{
standalone.lastError = "Engine is already running";
@@ -502,15 +513,6 @@ bool carla_engine_init(const char* driverName, const char* clientName)
return false;
}

#ifndef Q_OS_WIN
// TODO: make this an option, put somewhere else
if (getenv("WINE_RT") == nullptr)
{
carla_setenv("WINE_RT", "15");
carla_setenv("WINE_SVR_RT", "10");
}
#endif

if (standalone.callback != nullptr)
standalone.engine->setCallback(standalone.callback, nullptr);



+ 6
- 7
source/carla.py View File

@@ -194,9 +194,6 @@ class CarlaSettingsW(QDialog):
driverName = cString(Carla.host.get_engine_driver_name(i))
self.ui.cb_engine_audio_driver.addItem(driverName)

# TODO in backend
self.ui.tb_engine_driver_config.setEnabled(False)

# -------------------------------------------------------------
# Load settings

@@ -207,6 +204,8 @@ class CarlaSettingsW(QDialog):
self.ui.cb_canvas_use_opengl.setEnabled(False)

if WINDOWS:
self.ui.group_theme.setEnabled(False)
self.ui.ch_theme_pro.setChecked(False)
self.ui.ch_engine_dssi_chunks.setChecked(False)
self.ui.ch_engine_dssi_chunks.setEnabled(False)

@@ -697,8 +696,8 @@ class CarlaMainW(QMainWindow):
if not WINDOWS:
self.fSyntaxLog = LogSyntaxHighlighter(self.ui.pte_log)
self.fSyntaxLog.setDocument(self.ui.pte_log.document())
#else:
#self.ui.tabMain.setT
else:
self.ui.tabMain.removeTab(2)

self.ui.fileTreeView.setModel(self.fDirModel)
self.ui.fileTreeView.setRootIndex(self.fDirModel.index(HOME))
@@ -2110,13 +2109,13 @@ def canvasCallback(action, value1, value2, valueStr):
portIdB = value2

if not Carla.host.patchbay_connect(portIdA, portIdB):
print("Connection failed,", cString(Carla.host.get_last_error()))
print("Connection failed:", cString(Carla.host.get_last_error()))

elif action == patchcanvas.ACTION_PORTS_DISCONNECT:
connectionId = value1

if not Carla.host.patchbay_disconnect(connectionId):
print("Disconnect failed,", cString(Carla.host.get_last_error()))
print("Disconnect failed:", cString(Carla.host.get_last_error()))

def engineCallback(ptr, action, pluginId, value1, value2, value3, valueStr):
if pluginId < 0 or not Carla.gui:


Loading…
Cancel
Save