Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Use jack module from system #83

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ clean:
cd debian; rm -fr superboucle debhelper-build-stamp files superboucle.substvars

deb: dep
make deb_aux || make unpatch_setup

deb_aux:
git apply setup.py.debian.patch
dpkg-buildpackage -us -uc
cp ../superboucle_1.2.0-1_all.deb debian/
make unpatch_setup

unpatch_setup:
git checkout -- setup.py

docker-test: deb
cp ../superboucle_1.2.0-1_all.deb debian/
cd debian; docker-compose build && docker-compose up

%_ui.py : %_ui.ui
Expand Down
3 changes: 2 additions & 1 deletion SuperBoucle.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
python3 boucle.py
export PYTHONPATH=$(pwd):$PYTHONPATH
python3 superboucle/boucle.py $*
2 changes: 2 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Build-Depends: debhelper (>= 9),
dh-python,
python3-all (>= 3.3),
python3-cffi (>= 1.12),
python3-jack-client (>=0.4.5),
python3-numpy (>= 1.16),
python3-pyqt5 (>= 5.11),
python3-setuptools,
Expand All @@ -18,6 +19,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends},
libjack-jackd2-dev,
libsndfile1-dev,
python3-cffi (>= 1.12),
python3-jack-client (>=0.4.5),
python3-numpy (>= 1.16),
python3-pyqt5 (>= 5.11),
python3-soundfile (>= 0.10),
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SoundFile>=0.10
JACK-Client>=0.4.5
PyQt5>=5.11
SoundFile>=0.10
numpy>=1.16
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
setup(
name='superboucle',
version='1.2.0',
python_requires='>=3',
packages=find_packages(),
author='Vampouille',
author_email='[email protected]',
description='Loop application synced with jack transport',
long_description=open('readme.md').read(),
install_requires=["SoundFile>=0.10", "PyQt5>=5.11", "numpy>=1.16"],
install_requires=["JACK-Client>=0.4.5",
"PyQt5>=5.11",
"SoundFile>=0.10",
"numpy>=1.16"],
include_package_data=True,
url='http://superboucle.nura.eu',
classifiers=[
Expand Down
15 changes: 7 additions & 8 deletions setup.py.debian.patch
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
--- setup.py.orig 2019-09-20 20:37:21.225084734 +0200
+++ setup.py 2019-09-20 20:37:36.697702211 +0200
@@ -9,7 +9,7 @@
author_email='[email protected]',
--- setup.py.orig 2019-09-30 19:16:22.578773094 +0200
+++ setup.py 2019-09-30 19:16:29.371726762 +0200
@@ -10,7 +10,6 @@
description='Loop application synced with jack transport',
long_description=open('readme.md').read(),
- install_requires=["SoundFile>=0.10", "PyQt5>=5.11", "numpy>=1.16"],
+ install_requires=["SoundFile>=0.10", "numpy>=1.16"],
install_requires=["JACK-Client>=0.4.5",
- "PyQt5>=5.11",
"SoundFile>=0.10",
"numpy>=1.16"],
include_package_data=True,
url='http://superboucle.nura.eu',
classifiers=[
29 changes: 24 additions & 5 deletions superboucle/boucle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

"""JACK client that prints all received MIDI events."""

import superboucle.jack as jack
import sys, os.path
import jack
import sys
import os.path
from superboucle.clip import Clip, Song, load_song_from_file
from superboucle.gui import Gui
from PyQt5.QtWidgets import QApplication
Expand All @@ -13,6 +14,7 @@

parser = argparse.ArgumentParser(description='launch superboucle')
parser.add_argument("songfile", nargs="?", help="load the song specified here")
parser.add_argument("--debug", help="enable debug log", action="store_true")
args = parser.parse_args()

song = None
Expand All @@ -30,6 +32,25 @@
inL = client.inports.register("input_L")
inR = client.inports.register("input_R")

if args.debug:
from superboucle.debug import (client_registration_callback,
port_registration_callback,
port_connect_callback,
port_rename_callback,
graph_order_callback,
xrun_callback,
property_change_callback)
client.set_client_registration_callback(client_registration_callback)
client.set_port_registration_callback(port_registration_callback,
only_available=False)
client.set_port_connect_callback(port_connect_callback,
only_available=False)
client.set_port_rename_callback(port_rename_callback,
only_available=False)
client.set_graph_order_callback(graph_order_callback)
client.set_xrun_callback(xrun_callback)
#client.set_property_change_callback(property_change_callback)

app = QApplication(sys.argv)
gui = Gui(song, client)

Expand Down Expand Up @@ -186,8 +207,6 @@ def my_callback(frames):
except Empty:
pass

return jack.CALL_AGAIN


client.set_process_callback(my_callback)

Expand Down Expand Up @@ -222,4 +241,4 @@ def start():


if __name__ == "__main__":
start()
start()
26 changes: 26 additions & 0 deletions superboucle/debug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
def client_registration_callback(name, register):
print('client_registration: %s %s' % (name, register))


def port_registration_callback(port, register):
print('port_registration: %s %s' % (port, register))


def port_connect_callback(portFrom, portTo, register):
print('port_connect: %s -> %s %s' % (portFrom, portTo, register))


def port_rename_callback(port, old, new):
print('port_rename: %s %s -> %s' % (port, old, new))


def graph_order_callback():
print('graph_order')


def xrun_callback(delayed_usecs):
print('xrun: %sus')


def property_change_callback(*args):
print('property_change: %s ' % (args))
22 changes: 16 additions & 6 deletions superboucle/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,29 @@ class DeviceInput(DeviceOutput):


class Device:
def __init__(self, mapping=None):
if mapping is None:
self.updateMapping({})
else:
self.updateMapping(mapping)
def __init__(self, mapping={}):
self.updateMapping(mapping)

def updateMapping(self, new_mapping):
self.note_to_coord = {}
for key in new_mapping.keys():
new_mapping[key] = self._formatMapping(new_mapping[key])
self.mapping = new_mapping
for y in range(len(self.start_stop)):
line = self.start_stop[y]
for x in range(len(line)):
self.note_to_coord[tuple(line[x])] = (x, y)
self.note_to_coord[line[x]] = (x, y)

def _formatMapping(self, value):
if type(value) is not list or not len(value):
return value
elif type(value[0]) is int:
return tuple(value)
elif type(value[0]) is list:
return [self._formatMapping(v) for v in value]
else:
print("Unknown structure...")
return value

def generateNote(self, x, y, state):
(msg_type, channel, pitch, velocity) = self.start_stop[y][x]
Expand Down
18 changes: 12 additions & 6 deletions superboucle/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import struct
from queue import Queue, Empty
import pickle
from os.path import expanduser, dirname
from os.path import expanduser, dirname, isfile
import numpy as np
import soundfile as sf

Expand Down Expand Up @@ -103,7 +103,7 @@ def __init__(self, song, jack_client):
for raw_device in device_settings.value('devices'):
self.devices.append(Device(pickle.loads(raw_device)))
else:
self.devices.append(Device({'name': 'No Device',}))
self.devices.append(Device({'name': 'No Device'}))
self.updateDevices()
self.deviceGroup.triggered.connect(self.onDeviceSelect)

Expand Down Expand Up @@ -211,7 +211,7 @@ def initUI(self, song):

def openSongFromDisk(self, file_name):
self._jack_client.transport_stop()
self._jack_client.transport_locate(0)
self._jack_client.transport_frame = 0

self.setEnabled(False)
message = QMessageBox(self)
Expand Down Expand Up @@ -338,7 +338,7 @@ def onGotoClicked(self):
* (self.gotoTarget.value() - 1)
* position['frame_rate']
* (60 / position['beats_per_minute']))
self._jack_client.transport_locate(int(round(new_position, 0)))
self._jack_client.transport_frame = int(round(new_position, 0))

def onRecord(self):
self.song.is_record = not self.song.is_record
Expand All @@ -356,7 +356,7 @@ def updateRecordBtn(self):
self.queue_out.put(((msg_type << 4) + channel, pitch, color))

def onRewindClicked(self):
self._jack_client.transport_locate(0)
self._jack_client.transport_frame = 0

def onClipNameChange(self):
self.last_clip.name = self.clip_name.text()
Expand Down Expand Up @@ -459,8 +459,14 @@ def getSaveFileName(self, *args):
def onActionOpen(self):
file_name, a = self.getOpenFileName('Open Song',
'Super Boucle Song (*.sbs)')
if a and file_name:
if a and file_name and self.checkFileExists(file_name):
self.openSongFromDisk(file_name)
else:
QMessageBox.critical(self, "File not found",
"File %s does not seem to exist" % file_name)

def checkFileExists(self, file_name):
return isfile(file_name)

def onActionSave(self):
if self.song.file_name:
Expand Down
Loading