Browse Source

Cadence: Implement multiple aloop channels and zita support

tags/v0.9.0
falkTX 12 years ago
parent
commit
1153d7ed08
6 changed files with 213 additions and 41 deletions
  1. +16
    -16
      resources/ui/cadence.ui
  2. +107
    -5
      resources/ui/cadence_tb_alsa.ui
  3. +45
    -13
      src/cadence.py
  4. +35
    -6
      src/cadence_aloop_daemon.py
  5. +1
    -1
      src/cadence_session_start.py
  6. +9
    -0
      src/shared_cadence.py

+ 16
- 16
resources/ui/cadence.ui View File

@@ -720,8 +720,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>360</width>
<height>97</height>
<width>290</width>
<height>77</height>
</rect>
</property>
<attribute name="label">
@@ -861,8 +861,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>360</width>
<height>97</height>
<width>204</width>
<height>77</height>
</rect>
</property>
<attribute name="label">
@@ -1079,7 +1079,7 @@
<pixmap resource="../resources.qrc">:/screens/catia.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
@@ -1126,7 +1126,7 @@
<pixmap resource="../resources.qrc">:/screens/claudia.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
@@ -1173,7 +1173,7 @@
<pixmap resource="../resources.qrc">:/screens/cadence-jackmeter.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
@@ -1270,7 +1270,7 @@
<pixmap resource="../resources.qrc">:/screens/cadence-logs.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
@@ -1317,7 +1317,7 @@
<pixmap resource="../resources.qrc">:/screens/cadence-render.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
@@ -1364,7 +1364,7 @@
<pixmap resource="../resources.qrc">:/screens/cadence-xycontroller.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
@@ -1671,8 +1671,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>416</width>
<height>334</height>
<width>94</width>
<height>66</height>
</rect>
</property>
<attribute name="label">
@@ -1701,7 +1701,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>89</width>
<width>94</width>
<height>66</height>
</rect>
</property>
@@ -1731,7 +1731,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>89</width>
<width>94</width>
<height>66</height>
</rect>
</property>
@@ -1761,8 +1761,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>416</width>
<height>334</height>
<width>94</width>
<height>66</height>
</rect>
</property>
<attribute name="label">


+ 107
- 5
resources/ui/cadence_tb_alsa.ui View File

@@ -15,17 +15,119 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>This is your current ~/.asoundrc file:</string>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>This is your current ~/.asoundrc file:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextBrowser" name="textBrowser"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Number of channels:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBox">
<property name="minimum">
<number>2</number>
</property>
<property name="maximum">
<number>16</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Bridge tool:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>alsa_in/out</string>
</property>
</item>
<item>
<property name="text">
<string>zita_a2j/j2a (EXPERIMENTAL)</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QTextBrowser" name="textBrowser"/>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>255</x>
<y>440</y>
</hint>
<hint type="destinationlabel">
<x>255</x>
<y>229</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>255</x>
<y>440</y>
</hint>
<hint type="destinationlabel">
<x>255</x>
<y>229</y>
</hint>
</hints>
</connection>
</connections>
</ui>

+ 45
- 13
src/cadence.py View File

@@ -21,7 +21,7 @@

from platform import architecture
from PyQt4.QtCore import QFileSystemWatcher, QThread
from PyQt4.QtGui import QApplication, QLabel, QMainWindow, QSizePolicy
from PyQt4.QtGui import QApplication, QDialogButtonBox, QLabel, QMainWindow, QSizePolicy

# ------------------------------------------------------------------------------------------------------------
# Imports (Custom Stuff)
@@ -96,6 +96,7 @@ DESKTOP_X_TEXT = [
DESKTOP_X_BROWSER = [
"chrome.desktop",
"firefox.desktop",
"iceweasel.desktop",
"kde4/konqbrowser.desktop"
]

@@ -548,7 +549,7 @@ class ForceRestartThread(QThread):

# ALSA-Audio
if GlobalSettings.value("ALSA-Audio/BridgeIndexType", iAlsaFileNone, type=int) == iAlsaFileLoop:
os.system("cadence-aloop-daemon &")
startAlsaAudioLoopBridge()
sleep(0.5)

self.emit(SIGNAL("progressChanged(int)"), 94)
@@ -657,16 +658,43 @@ class ToolBarJackDialog(QDialog, ui_cadence_tb_jack.Ui_Dialog):

# Additional ALSA Audio options
class ToolBarAlsaAudioDialog(QDialog, ui_cadence_tb_alsa.Ui_Dialog):
def __init__(self, parent):
def __init__(self, parent, customMode):
QDialog.__init__(self, parent)
self.setupUi(self)

asoundrcFile = os.path.join(HOME, ".asoundrc")
asoundrcFd = open(asoundrcFile, "r")
asoundrcRead = asoundrcFd.read().strip()
asoundrcFd.close()
self.asoundrcFile = os.path.join(HOME, ".asoundrc")
self.fCustomMode = customMode

if customMode:
asoundrcFd = open(self.asoundrcFile, "r")
asoundrcRead = asoundrcFd.read().strip()
asoundrcFd.close()
self.textBrowser.setPlainText(asoundrcRead)
self.stackedWidget.setCurrentIndex(0)
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel)
else:
self.textBrowser.hide()
self.stackedWidget.setCurrentIndex(1)
self.adjustSize()

self.spinBox.setValue(GlobalSettings.value("ALSA-Audio/BridgeChannels", 2, type=int))

if GlobalSettings.value("ALSA-Audio/BridgeTool", "alsa_in", type=str) == "zita":
self.comboBox.setCurrentIndex(1)
else:
self.comboBox.setCurrentIndex(0)

self.connect(self, SIGNAL("accepted()"), SLOT("slot_setOptions()"))

@pyqtSlot()
def slot_setOptions(self):
channels = self.spinBox.value()
GlobalSettings.setValue("ALSA-Audio/BridgeChannels", channels)
GlobalSettings.setValue("ALSA-Audio/BridgeTool", "zita" if (self.comboBox.currentIndex() == 1) else "alsa_in")

self.textBrowser.setPlainText(asoundrcRead)
asoundrcFd = open(self.asoundrcFile, "w")
asoundrcFd.write(asoundrc_aloop.replace("channels 2\n", "channels %i\n" % channels) + "\n")
asoundrcFd.close()

def done(self, r):
QDialog.done(self, r)
@@ -840,6 +868,10 @@ class CadenceMainW(QMainWindow, ui_cadence.Ui_CadenceMainW):
self.toolBox_pulseaudio.setEnabled(False)
self.label_bridge_pulse.setText(self.tr("PulseAudio is not installed"))

# Not available in cxfreeze builds
if sys.argv[0].endswith("/cadence"):
self.groupBox_bridges.setEnabled(False)

# -------------------------------------------------------------
# Set-up GUI (Tweaks)

@@ -1379,7 +1411,7 @@ class CadenceMainW(QMainWindow, ui_cadence.Ui_CadenceMainW):
self.label_bridge_alsa.setText(self.tr("Using Cadence snd-aloop daemon, stopped"))

self.cb_alsa_type.setCurrentIndex(iAlsaFileLoop)
self.tb_alsa_options.setEnabled(False)
self.tb_alsa_options.setEnabled(True)

elif asoundrcRead == asoundrc_jack:
self.b_alsa_start.setEnabled(False)
@@ -1388,7 +1420,7 @@ class CadenceMainW(QMainWindow, ui_cadence.Ui_CadenceMainW):
self.systray.setActionEnabled("alsa_stop", False)
self.cb_alsa_type.setCurrentIndex(iAlsaFileJACK)
self.tb_alsa_options.setEnabled(False)
self.label_bridge_alsa.setText(self.tr("Using JACK plugin bridge"))
self.label_bridge_alsa.setText(self.tr("Using JACK plugin bridge (Always on)"))

elif asoundrcRead == asoundrc_pulse:
self.b_alsa_start.setEnabled(False)
@@ -1397,7 +1429,7 @@ class CadenceMainW(QMainWindow, ui_cadence.Ui_CadenceMainW):
self.systray.setActionEnabled("alsa_stop", False)
self.cb_alsa_type.setCurrentIndex(iAlsaFilePulse)
self.tb_alsa_options.setEnabled(False)
self.label_bridge_alsa.setText(self.tr("Using PulseAudio plugin bridge"))
self.label_bridge_alsa.setText(self.tr("Using PulseAudio plugin bridge (Always on)"))

else:
self.b_alsa_start.setEnabled(False)
@@ -1610,7 +1642,7 @@ class CadenceMainW(QMainWindow, ui_cadence.Ui_CadenceMainW):
@pyqtSlot()
def slot_AlsaBridgeStart(self):
self.slot_AlsaBridgeStop()
self.func_start_tool("cadence-aloop-daemon")
startAlsaAudioLoopBridge()

@pyqtSlot()
def slot_AlsaBridgeStop(self):
@@ -1669,7 +1701,7 @@ class CadenceMainW(QMainWindow, ui_cadence.Ui_CadenceMainW):

@pyqtSlot()
def slot_AlsaAudioBridgeOptions(self):
ToolBarAlsaAudioDialog(self).exec_()
ToolBarAlsaAudioDialog(self, (self.cb_alsa_type.currentIndex() != iAlsaFileLoop)).exec_()

@pyqtSlot()
def slot_A2JBridgeStart(self):


+ 35
- 6
src/cadence_aloop_daemon.py View File

@@ -1,13 +1,33 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Cadence ALSA-Loop daemon
# Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
#
# 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
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For a full copy of the GNU General Public License see the COPYING file

# ------------------------------------------------------------------------------------------------------------
# Imports (Global)
import os, sys

import os
import sys
from signal import signal, SIGINT, SIGTERM
from time import sleep
from PyQt4.QtCore import QProcess

# ------------------------------------------------------------------------------------------------------------
# Imports (Custom Stuff)

import jacklib

# --------------------------------------------------
@@ -90,8 +110,8 @@ def run_alsa_bridge():
procOut.waitForFinished(1000)

if useZita:
procIn.start("env", ["JACK_SAMPLE_RATE=%i" % sampleRate, "JACK_PERIOD_SIZE=%i" % bufferSize, "zita-a2j", "-L", "-j", "alsa2jack", "-d", "hw:Loopback,1,0"])
procOut.start("env", ["JACK_SAMPLE_RATE=%i" % sampleRate, "JACK_PERIOD_SIZE=%i" % bufferSize, "zita-j2a", "-L", "-j", "jack2alsa", "-d", "hw:Loopback,1,1"])
procIn.start("env", ["JACK_SAMPLE_RATE=%i" % sampleRate, "JACK_PERIOD_SIZE=%i" % bufferSize, "zita-a2j", "-j", "alsa2jack", "-d", "hw:Loopback,1,0", "-c", "%i" % channels])
procOut.start("env", ["JACK_SAMPLE_RATE=%i" % sampleRate, "JACK_PERIOD_SIZE=%i" % bufferSize, "zita-j2a", "-j", "jack2alsa", "-d", "hw:Loopback,1,1", "-c", "%i" % channels])
else:
procIn.start("env", ["JACK_SAMPLE_RATE=%i" % sampleRate, "JACK_PERIOD_SIZE=%i" % bufferSize, "alsa_in", "-j", "alsa2jack", "-d", "cloop", "-q", "1", "-c", "%i" % channels])
procOut.start("env", ["JACK_SAMPLE_RATE=%i" % sampleRate, "JACK_PERIOD_SIZE=%i" % bufferSize, "alsa_out", "-j", "jack2alsa", "-d", "ploop", "-q", "1", "-c", "%i" % channels])
@@ -109,9 +129,18 @@ def run_alsa_bridge():
#--------------- main ------------------
if __name__ == '__main__':

useZita = bool(len(sys.argv) == 2 and sys.argv[1] in ("-zita", "--zita"))
for i in range(len(sys.argv)):
if i == 0: continue

argv = sys.argv[i]

if argv == "--zita":
useZita = True
elif argv.startswith("--channels="):
chStr = argv.replace("--channels=", "")

# TODO - check consistency, and check channels value
if chStr.isdigit():
channels = int(chStr)

# Init JACK client
client = jacklib.client_open("cadence-aloop-daemon", jacklib.JackUseExactName, None)
@@ -149,7 +178,7 @@ if __name__ == '__main__':

if firstStart:
firstStart = False
print("cadence-aloop-daemon started, using %s" % ("zita-a2j/j2a" if useZita else "alsa_in/out"))
print("cadence-aloop-daemon started, using %s and %i channels" % ("zita-a2j/j2a" if useZita else "alsa_in/out", channels))

sleep(1)



+ 1
- 1
src/cadence_session_start.py View File

@@ -110,7 +110,7 @@ def startSession(systemStarted):

# ALSA-Audio
if GlobalSettings.value("ALSA-Audio/BridgeIndexType", iAlsaFileNone, type=int) == iAlsaFileLoop:
os.system("cadence-aloop-daemon &")
startAlsaAudioLoopBridge()
sleep(0.5)

# ALSA-MIDI


+ 9
- 0
src/shared_cadence.py View File

@@ -92,6 +92,15 @@ def getProcList():

return retProcs

# ------------------------------------------------------------------------------------------------------------
# Start ALSA-Audio Bridge, reading its settings

def startAlsaAudioLoopBridge():
channels = GlobalSettings.value("ALSA-Audio/BridgeChannels", 2, type=int)
useZita = bool(GlobalSettings.value("ALSA-Audio/BridgeTool", "alsa_in", type=str) == "zita")

os.system("cadence-aloop-daemon --channels=%i %s &" % (channels, "--zita" if useZita else ""))

# ------------------------------------------------------------------------------------------------------------
# Stop all audio processes, used for force-restart



Loading…
Cancel
Save