From 38db12c9ea617ac5849ddae65286830db12318d4 Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Sat, 19 Oct 2024 19:52:17 +0200 Subject: [PATCH 001/113] Drop Frontier Tranzport surface - it has been dead for a decade --- gtk2_ardour/preference-metadata | 1 - libs/ardour/ardour/rc_configuration_vars.h | 3 +- libs/surfaces/frontier/kernel_drivers/BUILD | 10 - .../surfaces/frontier/kernel_drivers/Makefile | 35 - libs/surfaces/frontier/kernel_drivers/README | 16 - .../frontier/kernel_drivers/doc/keycodes.html | 35 - .../frontier/kernel_drivers/tests/Makefile | 23 - .../frontier/kernel_drivers/tests/README | 104 - .../frontier/kernel_drivers/tests/tranzport.c | 375 ---- .../kernel_drivers/tests/tranzport_lights.c | 361 --- .../kernel_drivers/tests/tranzport_tests.sh | 27 - .../frontier/kernel_drivers/tranzport.c | 1070 --------- libs/surfaces/frontier/tests/Makefile | 17 - libs/surfaces/frontier/tests/README | 104 - libs/surfaces/frontier/tests/tranzport.c | 347 --- .../frontier/tests/tranzport_lights.c | 361 --- libs/surfaces/frontier/tranzport/interface.cc | 66 - .../tranzport/tranzport_control_protocol.cc | 1947 ----------------- .../tranzport/tranzport_control_protocol.h | 320 --- libs/surfaces/frontier/wscript | 25 - libs/surfaces/tranzport/README | 90 - libs/surfaces/tranzport/TODO | 6 - libs/surfaces/tranzport/bling.cc | 115 - libs/surfaces/tranzport/button_events.cc | 380 ---- libs/surfaces/tranzport/button_yn.cc | 21 - libs/surfaces/tranzport/buttons.cc | 113 - libs/surfaces/tranzport/general.cc | 333 --- libs/surfaces/tranzport/init.cc | 295 --- libs/surfaces/tranzport/interface.cc | 60 - libs/surfaces/tranzport/io.cc | 95 - libs/surfaces/tranzport/io_kernel.cc | 144 -- libs/surfaces/tranzport/io_midi.cc | 26 - libs/surfaces/tranzport/io_usb.cc | 232 -- libs/surfaces/tranzport/lcd.cc | 120 - libs/surfaces/tranzport/lights.cc | 95 - libs/surfaces/tranzport/meter.cc | 21 - libs/surfaces/tranzport/mode.cc | 107 - libs/surfaces/tranzport/mode_loop.cc | 21 - libs/surfaces/tranzport/mode_tuner.cc | 21 - libs/surfaces/tranzport/panner.cc | 34 - libs/surfaces/tranzport/screen.cc | 95 - libs/surfaces/tranzport/show.cc | 399 ---- libs/surfaces/tranzport/slider_gain.h | 40 - libs/surfaces/tranzport/state.cc | 146 -- libs/surfaces/tranzport/tranzport_base.h | 77 - libs/surfaces/tranzport/tranzport_common.h | 44 - .../tranzport/tranzport_control_protocol.h | 380 ---- libs/surfaces/tranzport/view_automation.cc | 21 - libs/surfaces/tranzport/view_bigmeter.cc | 21 - libs/surfaces/tranzport/view_bling.cc | 21 - libs/surfaces/tranzport/view_bus.cc | 21 - libs/surfaces/tranzport/view_config.cc | 21 - libs/surfaces/tranzport/view_layer.cc | 21 - libs/surfaces/tranzport/view_loop.cc | 21 - libs/surfaces/tranzport/view_manymeter.cc | 21 - libs/surfaces/tranzport/view_marker.cc | 21 - libs/surfaces/tranzport/view_master.cc | 21 - libs/surfaces/tranzport/view_plugins.cc | 21 - libs/surfaces/tranzport/view_std.cc | 21 - libs/surfaces/tranzport/view_tempo.cc | 21 - libs/surfaces/tranzport/view_tuner.cc | 21 - libs/surfaces/tranzport/wheel.cc | 203 -- libs/surfaces/tranzport/wheel_modes.cc | 138 -- libs/surfaces/tranzport/wscript | 37 - libs/surfaces/wscript | 5 - wscript | 5 - 66 files changed, 1 insertion(+), 9438 deletions(-) delete mode 100644 libs/surfaces/frontier/kernel_drivers/BUILD delete mode 100644 libs/surfaces/frontier/kernel_drivers/Makefile delete mode 100644 libs/surfaces/frontier/kernel_drivers/README delete mode 100644 libs/surfaces/frontier/kernel_drivers/doc/keycodes.html delete mode 100644 libs/surfaces/frontier/kernel_drivers/tests/Makefile delete mode 100644 libs/surfaces/frontier/kernel_drivers/tests/README delete mode 100644 libs/surfaces/frontier/kernel_drivers/tests/tranzport.c delete mode 100644 libs/surfaces/frontier/kernel_drivers/tests/tranzport_lights.c delete mode 100755 libs/surfaces/frontier/kernel_drivers/tests/tranzport_tests.sh delete mode 100644 libs/surfaces/frontier/kernel_drivers/tranzport.c delete mode 100644 libs/surfaces/frontier/tests/Makefile delete mode 100644 libs/surfaces/frontier/tests/README delete mode 100644 libs/surfaces/frontier/tests/tranzport.c delete mode 100644 libs/surfaces/frontier/tests/tranzport_lights.c delete mode 100644 libs/surfaces/frontier/tranzport/interface.cc delete mode 100644 libs/surfaces/frontier/tranzport/tranzport_control_protocol.cc delete mode 100644 libs/surfaces/frontier/tranzport/tranzport_control_protocol.h delete mode 100644 libs/surfaces/frontier/wscript delete mode 100644 libs/surfaces/tranzport/README delete mode 100644 libs/surfaces/tranzport/TODO delete mode 100644 libs/surfaces/tranzport/bling.cc delete mode 100644 libs/surfaces/tranzport/button_events.cc delete mode 100644 libs/surfaces/tranzport/button_yn.cc delete mode 100644 libs/surfaces/tranzport/buttons.cc delete mode 100644 libs/surfaces/tranzport/general.cc delete mode 100644 libs/surfaces/tranzport/init.cc delete mode 100644 libs/surfaces/tranzport/interface.cc delete mode 100644 libs/surfaces/tranzport/io.cc delete mode 100644 libs/surfaces/tranzport/io_kernel.cc delete mode 100644 libs/surfaces/tranzport/io_midi.cc delete mode 100644 libs/surfaces/tranzport/io_usb.cc delete mode 100644 libs/surfaces/tranzport/lcd.cc delete mode 100644 libs/surfaces/tranzport/lights.cc delete mode 100644 libs/surfaces/tranzport/meter.cc delete mode 100644 libs/surfaces/tranzport/mode.cc delete mode 100644 libs/surfaces/tranzport/mode_loop.cc delete mode 100644 libs/surfaces/tranzport/mode_tuner.cc delete mode 100644 libs/surfaces/tranzport/panner.cc delete mode 100644 libs/surfaces/tranzport/screen.cc delete mode 100644 libs/surfaces/tranzport/show.cc delete mode 100644 libs/surfaces/tranzport/slider_gain.h delete mode 100644 libs/surfaces/tranzport/state.cc delete mode 100644 libs/surfaces/tranzport/tranzport_base.h delete mode 100644 libs/surfaces/tranzport/tranzport_common.h delete mode 100644 libs/surfaces/tranzport/tranzport_control_protocol.h delete mode 100644 libs/surfaces/tranzport/view_automation.cc delete mode 100644 libs/surfaces/tranzport/view_bigmeter.cc delete mode 100644 libs/surfaces/tranzport/view_bling.cc delete mode 100644 libs/surfaces/tranzport/view_bus.cc delete mode 100644 libs/surfaces/tranzport/view_config.cc delete mode 100644 libs/surfaces/tranzport/view_layer.cc delete mode 100644 libs/surfaces/tranzport/view_loop.cc delete mode 100644 libs/surfaces/tranzport/view_manymeter.cc delete mode 100644 libs/surfaces/tranzport/view_marker.cc delete mode 100644 libs/surfaces/tranzport/view_master.cc delete mode 100644 libs/surfaces/tranzport/view_plugins.cc delete mode 100644 libs/surfaces/tranzport/view_std.cc delete mode 100644 libs/surfaces/tranzport/view_tempo.cc delete mode 100644 libs/surfaces/tranzport/view_tuner.cc delete mode 100644 libs/surfaces/tranzport/wheel.cc delete mode 100644 libs/surfaces/tranzport/wheel_modes.cc delete mode 100644 libs/surfaces/tranzport/wscript diff --git a/gtk2_ardour/preference-metadata b/gtk2_ardour/preference-metadata index 2416569c91..5300fd6053 100644 --- a/gtk2_ardour/preference-metadata +++ b/gtk2_ardour/preference-metadata @@ -623,7 +623,6 @@ osc open sound control [use-plugin-own-gui] plugins GUI editor prefer use own -[use-tranzport] [use-vst3] plugins vst3 [use-windows-vst] diff --git a/libs/ardour/ardour/rc_configuration_vars.h b/libs/ardour/ardour/rc_configuration_vars.h index 0eb1c240ba..f6587c232a 100644 --- a/libs/ardour/ardour/rc_configuration_vars.h +++ b/libs/ardour/ardour/rc_configuration_vars.h @@ -89,8 +89,7 @@ CONFIG_VARIABLE (float, ltc_output_volume, "ltc-output-volume", 0.125893) /* control surfaces */ -CONFIG_VARIABLE (uint32_t, feedback_interval_ms, "feedback-interval-ms", 100) -CONFIG_VARIABLE (bool, use_tranzport, "use-tranzport", false) +CONFIG_VARIABLE (uint32_t, feedback_interval_ms, "feedback-interval-ms", 100) CONFIG_VARIABLE (bool, auto_enable_surfaces, "auto-enable-surfaces", true) /* disk operations */ diff --git a/libs/surfaces/frontier/kernel_drivers/BUILD b/libs/surfaces/frontier/kernel_drivers/BUILD deleted file mode 100644 index dc612e20bf..0000000000 --- a/libs/surfaces/frontier/kernel_drivers/BUILD +++ /dev/null @@ -1,10 +0,0 @@ -To build, type make - -# make install and run -ir: install - rmmod tranzport - modprobe tranzport - -# make install, run, and run tests -irt: ir - diff --git a/libs/surfaces/frontier/kernel_drivers/Makefile b/libs/surfaces/frontier/kernel_drivers/Makefile deleted file mode 100644 index 223fcdb6fc..0000000000 --- a/libs/surfaces/frontier/kernel_drivers/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -ifneq ($(KERNELRELEASE),) - -obj-m := tranzport.o -tranzport-objs := - -else - -KDIR := /lib/modules/$(shell uname -r)/build -PWD := $(shell pwd) -MODDIR := $(DESTDIR)/lib/modules/$(shell uname -r)/kernel/sound/usb/misc -BINDIR := $(DESTDIR)/usr/local/bin - -default:: - $(MAKE) -Wall -C $(KDIR) SUBDIRS=$(PWD) modules - $(MAKE) -C tests - -install-only:: default - mkdir -p $(MODDIR) $(BINDIR) - cp tranzport.ko $(MODDIR) - $(MAKE) -C tests install - -install:: install-only - /sbin/depmod -a - +/sbin/rmmod tranzport - /sbin/modprobe tranzport - -irt:: install - tranzport_tests.sh - -clean:: - rm -f core .*.cmd *.o *.ko *.mod.c Module.symvers *.bak .\#* *~ - rm -rf .tmp_versions - $(MAKE) -C tests clean - -endif diff --git a/libs/surfaces/frontier/kernel_drivers/README b/libs/surfaces/frontier/kernel_drivers/README deleted file mode 100644 index 51b4af0f2e..0000000000 --- a/libs/surfaces/frontier/kernel_drivers/README +++ /dev/null @@ -1,16 +0,0 @@ -This directory contains the USB Tranzport Kernel driver for Linux. - -At present it accepts reads/writes of 8 byte cmds to /dev/tranzport0 to control -the lights and screen. - -Reads are possible. Wheel Compression does not currently account for button changes - -It also has some sysfs hooks that are non-functional at the moment. - -The API is closely tied to the ardour revision and WILL change. - -A sysfs interface is PERFECT for simple userspace apps to do fun things with the -lights and screen. It's fairly lousy for handling input events and very lousy -for watching the state of the shuttle wheel. - -In the end this is going to be driven by a midi layer diff --git a/libs/surfaces/frontier/kernel_drivers/doc/keycodes.html b/libs/surfaces/frontier/kernel_drivers/doc/keycodes.html deleted file mode 100644 index 651517a7f2..0000000000 --- a/libs/surfaces/frontier/kernel_drivers/doc/keycodes.html +++ /dev/null @@ -1,35 +0,0 @@ - - - TRANZPORT KEYCODES REFERENCE - - -

TRANZPORT KEYCODES REFERENCE

- -

Footswitch

- -At least on every footswitch I've tried, the polarity appears to be wrong, in that the footswitch "up" position results -in 0100 being OR'd into the result. Pressing it down results in a 0, if no other keys are pressed. Releasing it results in 0100. - -Every other key when up results in 0. This odd behavior would hopefully be controllable via a command to the tranzport, -but I don't have that, so dealing with footswitch events is weird. - -So, seeing this bit enabled would be something like "HAVE_FOOTSWITCH INSTALLED", BE SMART ABOUT IT. - - -

Special Key Combinations

-

-In addition to the normal keycodes generated by the tranzport, it is possible to hit several combinations of keys and get a unique -result. Some are really weird. Perhaps the following assignments make sense: -

- - - - - - - - -
PRESSINGRESULTASSIGNED TO
TRACKLEFT+TRACKRIGHTTRACKLEFT+TRACKRIGHTMaster
SHIFT+TRACKLEFT+TRACKRIGHTSHIFT+TRACKLEFT+TRACKRIGHT+UNDOShow Bus Only Toggle
IN+OUTIN+OUTZoom 100%
SHIFT+IN+OUTSHIFT+IN+OUT+UNDOMax Zoom
SHIFT+REW+FFWSHIFT+REW+FFW+UNDO
RECORD+TRACKSOLO+FOOTSWITCHNOTDEPRESSEDRECORD+TRACKSOLO+BATTERY
PLAY+MUTEPLAY+MUTE
-

- - diff --git a/libs/surfaces/frontier/kernel_drivers/tests/Makefile b/libs/surfaces/frontier/kernel_drivers/tests/Makefile deleted file mode 100644 index 534bc7da4b..0000000000 --- a/libs/surfaces/frontier/kernel_drivers/tests/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# Some basic utilities for testing the tranzport's I/O -# eventually "tranzport" will become a flexible command -# -# - -FILES:=tranzport tranzport_lights tranzport_tests.sh -BINDIR ?= $(DESTDIR)/usr/local/bin - -all: tranzport tranzport_lights - -tranzport: tranzport.c - gcc -g -Wall -o tranzport tranzport.c - -tranzport_lights: tranzport_lights.c - gcc -g -Wall -o tranzport_lights tranzport_lights.c - -clean:: - rm -f core .*.cmd *.o *.ko *.mod.c Module.symvers *.bak .\#* *~ - rm -rf .tmp_versions tranzport tranzport_lights - -install:: - cp $(FILES) $(BINDIR) - diff --git a/libs/surfaces/frontier/kernel_drivers/tests/README b/libs/surfaces/frontier/kernel_drivers/tests/README deleted file mode 100644 index f9efd18f69..0000000000 --- a/libs/surfaces/frontier/kernel_drivers/tests/README +++ /dev/null @@ -1,104 +0,0 @@ -tranzport 0.1 -oct 18, 2005 -arthur@artcmusic.com ---- - -The Frontier Design Tranzport(tm) (www.frontierdesign.com) is a simple -wireless USB device. It is not a MIDI device. The document on their web -site "Tranzport(tm) Native Mode Interface Description" describes the -Tranzport(tm) as if it were a MIDI device, but this is implemented by their -Windows and Macintosh software drivers. - -This code will allow you to use your Tranzport(tm) at a lower level of -abstraction. This code relies on libusb, which can be obtained from -libusb.sourceforge.net. - -To compile the program, type "make". You should end up with a executable -called "tranzport". You'll probably have to run this program as root. - -Using the program is straightforward. It will simply tell you which -buttons are being pressed and what not. If you press one of the buttons -with a light, the light will turn on. If you hold shift and press one of -the buttons with a light, the light will turn off. If you take out the -batteries to the device (or go out of range), it will tell you that the -device is offline. When you replace the batteries (or come back in -range), it should tell you it is back online. - -Once you understand how everything works, you should be able to -incorporate it into your own setup however you wish. - -This code was developed on a Linux machine, but (theoretically) it -should work on any system that is supported by libusb, since that is how -it communicates with the device. - -Here are a few more details about the device: - -There are two endpoints for communication with the device. All data -reads and writes are done in 8-byte segments. - -One endpoint is for interrupt reads. This is used to read button data -from the device. It also supplies status information for when the device -goes out of range and comes back in range, loses power and regains -power, etc. The format of the data is: - - 00 ss bb bb bb bb dd 00 (hexadecimal) - -where: - - ss - status code, 01=online ff=offline - bb - button bits - dd - data wheel, 01-3f=forward 41-7f=backward - -Please refer to the source code for a list of the button bits. - -The other endpoint is for interrupt writes. This is used to toggle the -lights on the device, and to write data to the LCD. - -There are 7 lights on the device. To turn a light on, send the following -sequence of bytes: - - 00 00 nn 01 00 00 00 00 (hexadecimal) - -where nn is the light number. - -To turn a light off: - - 00 00 nn 00 00 00 00 00 (hexadecimal) - -Here is the list of lights: - - 00 Record - 01 Track Rec - 02 Track Mute - 03 Track Solo - 04 Any Solo - 05 Loop - 06 Punch - -The size of the LCD is 20x2, and it is split into 10 cells, each cell -being 4 characters wide. The cells progress across, then down. To write -to the LCD, send the following sequence of bytes: - - 00 01 cc aa aa aa aa 00 (hexadecimal) - -where: - - cc - cell number - aa - ASCII code - -Here is a list of the cells to clarify: - - 00 row 0, column 0-3 - 01 row 0, column 4-7 - 02 row 0, column 8-11 - 03 row 0, column 12-15 - 04 row 0, column 16-19 - 05 row 1, column 0-3 - 06 row 1, column 4-7 - 07 row 1, column 8-11 - 08 row 1, column 12-15 - 09 row 1, column 16-19 - -You should refer to the "Tranzport(tm) Native Mode Interface -Description" document for a listing of the ASCII codes the LCD uses. - diff --git a/libs/surfaces/frontier/kernel_drivers/tests/tranzport.c b/libs/surfaces/frontier/kernel_drivers/tests/tranzport.c deleted file mode 100644 index 480c49c7b6..0000000000 --- a/libs/surfaces/frontier/kernel_drivers/tests/tranzport.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - * tranzport 0.1 - * oct 18, 2005 - * arthur@artcmusic.com - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define VENDORID 0x165b -#define PRODUCTID 0x8101 - -#define READ_ENDPOINT 0x81 -#define WRITE_ENDPOINT 0x02 - -enum { - LIGHT_RECORD = 0, - LIGHT_TRACKREC, - LIGHT_TRACKMUTE, - LIGHT_TRACKSOLO, - LIGHT_ANYSOLO, - LIGHT_LOOP, - LIGHT_PUNCH -}; - -#define BUTTONMASK_BATTERY 0x00004000 -#define BUTTONMASK_BACKLIGHT 0x00008000 -#define BUTTONMASK_TRACKLEFT 0x04000000 -#define BUTTONMASK_TRACKRIGHT 0x40000000 -#define BUTTONMASK_TRACKREC 0x00040000 -#define BUTTONMASK_TRACKMUTE 0x00400000 -#define BUTTONMASK_TRACKSOLO 0x00000400 -#define BUTTONMASK_UNDO 0x80000000 -#define BUTTONMASK_IN 0x02000000 -#define BUTTONMASK_OUT 0x20000000 -#define BUTTONMASK_PUNCH 0x00800000 -#define BUTTONMASK_LOOP 0x00080000 -#define BUTTONMASK_PREV 0x00020000 -#define BUTTONMASK_ADD 0x00200000 -#define BUTTONMASK_NEXT 0x00000200 -#define BUTTONMASK_REWIND 0x01000000 -#define BUTTONMASK_FASTFORWARD 0x10000000 -#define BUTTONMASK_STOP 0x00010000 -#define BUTTONMASK_PLAY 0x00100000 -#define BUTTONMASK_RECORD 0x00000100 -#define BUTTONMASK_SHIFT 0x08000000 - -#define STATUS_OFFLINE 0xff -#define STATUS_ONLINE 0x01 -#define STATUS_OK 0x00 - -struct tranzport_s { - int *dev; - int udev; -}; - -typedef struct tranzport_s tranzport_t; - -void log_entry(FILE *fp, char *format, va_list ap) -{ - vfprintf(fp, format, ap); - fputc('\n', fp); -} - -void log_error(char *format, ...) -{ - va_list ap; - va_start(ap, format); - log_entry(stderr, format, ap); - va_end(ap); -} - -void vlog_error(char *format, va_list ap) -{ - log_entry(stderr, format, ap); -} - -void die(char *format, ...) -{ - va_list ap; - va_start(ap, format); - vlog_error(format, ap); - va_end(ap); - exit(1); -} - -tranzport_t *open_tranzport_core() -{ - tranzport_t *z; - int val; - - z = malloc(sizeof(tranzport_t)); - if (!z) - die("not enough memory"); - memset(z, 0, sizeof(tranzport_t)); - - z->udev = open("/dev/tranzport0",O_RDWR); - if (z->udev < 1) - die("unable to open tranzport"); - - return z; -} - -tranzport_t *open_tranzport() -{ -return open_tranzport_core(); -} - -void close_tranzport(tranzport_t *z) -{ - int val; - - val = close(z->udev); - if (val < 0) - log_error("unable to release tranzport"); - - free(z); -} - -int tranzport_write_core(tranzport_t *z, uint8_t *cmd, int timeout) -{ - int val; - val = write(z->udev, cmd, 8); - if (val < 0) - return val; - if (val != 8) - return -1; - return 0; -} - -int tranzport_lcdwrite(tranzport_t *z, uint8_t cell, char *text, int timeout) -{ - uint8_t cmd[8]; - - if (cell > 9) { - return -1; - } - - cmd[0] = 0x00; - cmd[1] = 0x01; - cmd[2] = cell; - cmd[3] = text[0]; - cmd[4] = text[1]; - cmd[5] = text[2]; - cmd[6] = text[3]; - cmd[7] = 0x00; - - return tranzport_write_core(z, cmd, timeout); -} - -int tranzport_lighton(tranzport_t *z, uint8_t light, int timeout) -{ - uint8_t cmd[8]; - - cmd[0] = 0x00; - cmd[1] = 0x00; - cmd[2] = light; - cmd[3] = 0x01; - cmd[4] = 0x00; - cmd[5] = 0x00; - cmd[6] = 0x00; - cmd[7] = 0x00; - - return tranzport_write_core(z, &cmd[0], timeout); -} - -int tranzport_lightoff(tranzport_t *z, uint8_t light, int timeout) -{ - uint8_t cmd[8]; - - cmd[0] = 0x00; - cmd[1] = 0x00; - cmd[2] = light; - cmd[3] = 0x00; - cmd[4] = 0x00; - cmd[5] = 0x00; - cmd[6] = 0x00; - cmd[7] = 0x00; - - return tranzport_write_core(z, &cmd[0], timeout); -} - -int tranzport_read(tranzport_t *z, uint8_t *status, uint32_t *buttons, uint8_t *datawheel, int timeout) -{ - uint8_t buf[8]; - int val; - - memset(buf, 0xff, 8); - val = read(z->udev, buf, 8); - if (val < 0) { - printf("errno: %d\n",errno); - switch(errno) { - case ENOENT: ; - case ECONNRESET: ; - case ESHUTDOWN: printf("dying\n"); exit(1); break; - } - return val; - } - if (val != 8) - return -1; - - /*printf("read: %02x %02x %02x %02x %02x %02x %02x %02x\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);*/ - - *status = buf[1]; - - *buttons = 0; - *buttons |= buf[2] << 24; - *buttons |= buf[3] << 16; - *buttons |= buf[4] << 8; - *buttons |= buf[5]; - - *datawheel = buf[6]; - - return 0; -} - -void lights_core(tranzport_t *z, uint32_t buttons, uint32_t buttonmask, uint8_t light) -{ - if (buttons & buttonmask) { - if (buttons & BUTTONMASK_SHIFT) { - tranzport_lightoff(z, light, 10); - } else { - tranzport_lighton(z, light, 10); - } - } -} - -void do_lights(tranzport_t *z, uint32_t buttons) -{ - lights_core(z, buttons, BUTTONMASK_RECORD, LIGHT_RECORD); - lights_core(z, buttons, BUTTONMASK_TRACKREC, LIGHT_TRACKREC); - lights_core(z, buttons, BUTTONMASK_TRACKMUTE, LIGHT_TRACKMUTE); - lights_core(z, buttons, BUTTONMASK_TRACKSOLO, LIGHT_TRACKSOLO); - lights_core(z, buttons, BUTTONMASK_TRACKSOLO, LIGHT_ANYSOLO); - lights_core(z, buttons, BUTTONMASK_PUNCH, LIGHT_PUNCH); - lights_core(z, buttons, BUTTONMASK_LOOP, LIGHT_LOOP); -} - -void buttons_core(tranzport_t *z, uint32_t buttons, uint32_t buttonmask, char *str) -{ - if (buttons & buttonmask) - printf(" %s", str); -} - -void do_buttons(tranzport_t *z, uint32_t buttons, uint8_t datawheel) -{ - printf("buttons: %x ", buttons); - buttons_core(z, buttons, BUTTONMASK_BATTERY, "battery"); - buttons_core(z, buttons, BUTTONMASK_BACKLIGHT, "backlight"); - buttons_core(z, buttons, BUTTONMASK_TRACKLEFT, "trackleft"); - buttons_core(z, buttons, BUTTONMASK_TRACKRIGHT, "trackright"); - buttons_core(z, buttons, BUTTONMASK_TRACKREC, "trackrec"); - buttons_core(z, buttons, BUTTONMASK_TRACKMUTE, "trackmute"); - buttons_core(z, buttons, BUTTONMASK_TRACKSOLO, "tracksolo"); - buttons_core(z, buttons, BUTTONMASK_UNDO, "undo"); - buttons_core(z, buttons, BUTTONMASK_IN, "in"); - buttons_core(z, buttons, BUTTONMASK_OUT, "out"); - buttons_core(z, buttons, BUTTONMASK_PUNCH, "punch"); - buttons_core(z, buttons, BUTTONMASK_LOOP, "loop"); - buttons_core(z, buttons, BUTTONMASK_PREV, "prev"); - buttons_core(z, buttons, BUTTONMASK_ADD, "add"); - buttons_core(z, buttons, BUTTONMASK_NEXT, "next"); - buttons_core(z, buttons, BUTTONMASK_REWIND, "rewind"); - buttons_core(z, buttons, BUTTONMASK_FASTFORWARD, "fastforward"); - buttons_core(z, buttons, BUTTONMASK_STOP, "stop"); - buttons_core(z, buttons, BUTTONMASK_PLAY, "play"); - buttons_core(z, buttons, BUTTONMASK_RECORD, "record"); - buttons_core(z, buttons, BUTTONMASK_SHIFT, "shift"); - if (datawheel) - printf(" datawheel=%02x", datawheel); - printf("\n"); -} - -void do_lcd(tranzport_t *z) -{ - tranzport_lcdwrite(z, 0, " ", 10); - tranzport_lcdwrite(z, 1, "DISL", 10); - tranzport_lcdwrite(z, 2, "EXIA", 10); - tranzport_lcdwrite(z, 3, " FOR", 10); - tranzport_lcdwrite(z, 4, " ", 10); - - tranzport_lcdwrite(z, 5, " ", 10); - tranzport_lcdwrite(z, 6, " CUR", 10); - tranzport_lcdwrite(z, 7, "E FO", 10); - tranzport_lcdwrite(z, 8, "UND ", 10); - tranzport_lcdwrite(z, 9, " ", 10); -} - -void do_lcd2(tranzport_t *z) -{ - tranzport_lcdwrite(z, 0, "THE ", 10); - tranzport_lcdwrite(z, 1, "TRAN", 10); - tranzport_lcdwrite(z, 2, "ZPOR", 10); - tranzport_lcdwrite(z, 3, "T RO", 10); - tranzport_lcdwrite(z, 4, " KS", 10); - - tranzport_lcdwrite(z, 5, "AWES", 10); - tranzport_lcdwrite(z, 6, "OMEE", 10); - tranzport_lcdwrite(z, 7, "LEEE", 10); - tranzport_lcdwrite(z, 8, "UND ", 10); - tranzport_lcdwrite(z, 9, "GROK", 10); -} - -int lights_off(tranzport_t *z) { - static int i = 0; - int j = 0; - for(;j<2; j++,i = (i+1) % 7) { - tranzport_lightoff(z, i, 10); - } -return 0; -} - -int lights_on(tranzport_t *z) { - static int i = 0; - int j = 0; - for(;j<2; j++,i = (i+1) % 7) { - tranzport_lighton(z, i, 10); - } -return 0; -} - -int main() -{ - tranzport_t *z; - uint8_t status; - uint32_t buttons; - uint8_t datawheel; - int val; - - z = open_tranzport(); - - do_lcd(z); - - for(;;) { - - // do_lcd(z); - lights_on(z); - // do_lcd2(z); - - val = tranzport_read(z, &status, &buttons, &datawheel, 60000); - if (val < 0) - continue; - - if (status == STATUS_OFFLINE) { - printf("offline: "); - continue; - } - - if (status == STATUS_ONLINE) { - printf("online: "); - do_lcd(z); - } - - if (status == STATUS_OK) { - printf("OK: "); - do_lcd(z); - } - -// do_lights(z, buttons); - do_buttons(z, buttons, datawheel); - lights_off(z); - } - - close_tranzport(z); - - return 0; -} - diff --git a/libs/surfaces/frontier/kernel_drivers/tests/tranzport_lights.c b/libs/surfaces/frontier/kernel_drivers/tests/tranzport_lights.c deleted file mode 100644 index f116c50a74..0000000000 --- a/libs/surfaces/frontier/kernel_drivers/tests/tranzport_lights.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - * tranzport 0.1 - * oct 18, 2005 - * arthur@artcmusic.com - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define VENDORID 0x165b -#define PRODUCTID 0x8101 - -#define READ_ENDPOINT 0x81 -#define WRITE_ENDPOINT 0x02 - -enum { - LIGHT_RECORD = 0, - LIGHT_TRACKREC, - LIGHT_TRACKMUTE, - LIGHT_TRACKSOLO, - LIGHT_ANYSOLO, - LIGHT_LOOP, - LIGHT_PUNCH -}; - -#define BUTTONMASK_BATTERY 0x00004000 -#define BUTTONMASK_BACKLIGHT 0x00008000 -#define BUTTONMASK_TRACKLEFT 0x04000000 -#define BUTTONMASK_TRACKRIGHT 0x40000000 -#define BUTTONMASK_TRACKREC 0x00040000 -#define BUTTONMASK_TRACKMUTE 0x00400000 -#define BUTTONMASK_TRACKSOLO 0x00000400 -#define BUTTONMASK_UNDO 0x80000000 -#define BUTTONMASK_IN 0x02000000 -#define BUTTONMASK_OUT 0x20000000 -#define BUTTONMASK_PUNCH 0x00800000 -#define BUTTONMASK_LOOP 0x00080000 -#define BUTTONMASK_PREV 0x00020000 -#define BUTTONMASK_ADD 0x00200000 -#define BUTTONMASK_NEXT 0x00000200 -#define BUTTONMASK_REWIND 0x01000000 -#define BUTTONMASK_FASTFORWARD 0x10000000 -#define BUTTONMASK_STOP 0x00010000 -#define BUTTONMASK_PLAY 0x00100000 -#define BUTTONMASK_RECORD 0x00000100 -#define BUTTONMASK_SHIFT 0x08000000 - -#define STATUS_OFFLINE 0xff -#define STATUS_ONLINE 0x01 -#define STATUS_OK 0x00 - -struct tranzport_s { - int *dev; - int udev; -}; - -typedef struct tranzport_s tranzport_t; - -void log_entry(FILE *fp, char *format, va_list ap) -{ - vfprintf(fp, format, ap); - fputc('\n', fp); -} - -void log_error(char *format, ...) -{ - va_list ap; - va_start(ap, format); - log_entry(stderr, format, ap); - va_end(ap); -} - -void vlog_error(char *format, va_list ap) -{ - log_entry(stderr, format, ap); -} - -void die(char *format, ...) -{ - va_list ap; - va_start(ap, format); - vlog_error(format, ap); - va_end(ap); - exit(1); -} - -tranzport_t *open_tranzport_core() -{ - tranzport_t *z; - int val; - - z = malloc(sizeof(tranzport_t)); - if (!z) - die("not enough memory"); - memset(z, 0, sizeof(tranzport_t)); - - z->udev = open("/dev/tranzport0",O_RDWR); - if (!z->udev) - die("unable to open tranzport"); - - return z; -} - -tranzport_t *open_tranzport() -{ -return open_tranzport_core(); -} - -void close_tranzport(tranzport_t *z) -{ - int val; - - val = close(z->udev); - if (val < 0) - log_error("unable to release tranzport"); - - free(z); -} - -int tranzport_write_core(tranzport_t *z, uint8_t *cmd, int timeout) -{ - int val; - val = write(z->udev, cmd, 8); - if (val < 0) - return val; - if (val != 8) - return -1; - return 0; -} - -int tranzport_lcdwrite(tranzport_t *z, uint8_t cell, char *text, int timeout) -{ - uint8_t cmd[8]; - - if (cell > 9) { - return -1; - } - - cmd[0] = 0x00; - cmd[1] = 0x01; - cmd[2] = cell; - cmd[3] = text[0]; - cmd[4] = text[1]; - cmd[5] = text[2]; - cmd[6] = text[3]; - cmd[7] = 0x00; - - return tranzport_write_core(z, cmd, timeout); -} - -int tranzport_lighton(tranzport_t *z, uint8_t light, int timeout) -{ - uint8_t cmd[8]; - - cmd[0] = 0x00; - cmd[1] = 0x00; - cmd[2] = light; - cmd[3] = 0x01; - cmd[4] = 0x00; - cmd[5] = 0x00; - cmd[6] = 0x00; - cmd[7] = 0x00; - - return tranzport_write_core(z, &cmd[0], timeout); -} - -int tranzport_lightoff(tranzport_t *z, uint8_t light, int timeout) -{ - uint8_t cmd[8]; - - cmd[0] = 0x00; - cmd[1] = 0x00; - cmd[2] = light; - cmd[3] = 0x00; - cmd[4] = 0x00; - cmd[5] = 0x00; - cmd[6] = 0x00; - cmd[7] = 0x00; - - return tranzport_write_core(z, &cmd[0], timeout); -} - -int tranzport_read(tranzport_t *z, uint8_t *status, uint32_t *buttons, uint8_t *datawheel, int timeout) -{ - uint8_t buf[8]; - int val; - - memset(buf, 0xff, 8); - val = read(z->udev, buf, 8); - if (val < 0) { - // printf("errno: %d\n",errno); - return val; - } - if (val != 8) - return -1; - - /*printf("read: %02x %02x %02x %02x %02x %02x %02x %02x\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);*/ - - *status = buf[1]; - - *buttons = 0; - *buttons |= buf[2] << 24; - *buttons |= buf[3] << 16; - *buttons |= buf[4] << 8; - *buttons |= buf[5]; - - *datawheel = buf[6]; - - return 0; -} - -void lights_core(tranzport_t *z, uint32_t buttons, uint32_t buttonmask, uint8_t light) -{ - if (buttons & buttonmask) { - if (buttons & BUTTONMASK_SHIFT) { - tranzport_lightoff(z, light, 1000); - } else { - tranzport_lighton(z, light, 1000); - } - } -} - -void do_lights(tranzport_t *z, uint32_t buttons) -{ - lights_core(z, buttons, BUTTONMASK_RECORD, LIGHT_RECORD); - lights_core(z, buttons, BUTTONMASK_TRACKREC, LIGHT_TRACKREC); - lights_core(z, buttons, BUTTONMASK_TRACKMUTE, LIGHT_TRACKMUTE); - lights_core(z, buttons, BUTTONMASK_TRACKSOLO, LIGHT_TRACKSOLO); - lights_core(z, buttons, BUTTONMASK_TRACKSOLO, LIGHT_ANYSOLO); - lights_core(z, buttons, BUTTONMASK_PUNCH, LIGHT_PUNCH); - lights_core(z, buttons, BUTTONMASK_LOOP, LIGHT_LOOP); -} - -void buttons_core(tranzport_t *z, uint32_t buttons, uint32_t buttonmask, char *str) -{ - if (buttons & buttonmask) - printf(" %s", str); -} - -void do_buttons(tranzport_t *z, uint32_t buttons, uint8_t datawheel) -{ - printf("buttons: %x ", buttons); - buttons_core(z, buttons, BUTTONMASK_BATTERY, "battery"); - buttons_core(z, buttons, BUTTONMASK_BACKLIGHT, "backlight"); - buttons_core(z, buttons, BUTTONMASK_TRACKLEFT, "trackleft"); - buttons_core(z, buttons, BUTTONMASK_TRACKRIGHT, "trackright"); - buttons_core(z, buttons, BUTTONMASK_TRACKREC, "trackrec"); - buttons_core(z, buttons, BUTTONMASK_TRACKMUTE, "trackmute"); - buttons_core(z, buttons, BUTTONMASK_TRACKSOLO, "tracksolo"); - buttons_core(z, buttons, BUTTONMASK_UNDO, "undo"); - buttons_core(z, buttons, BUTTONMASK_IN, "in"); - buttons_core(z, buttons, BUTTONMASK_OUT, "out"); - buttons_core(z, buttons, BUTTONMASK_PUNCH, "punch"); - buttons_core(z, buttons, BUTTONMASK_LOOP, "loop"); - buttons_core(z, buttons, BUTTONMASK_PREV, "prev"); - buttons_core(z, buttons, BUTTONMASK_ADD, "add"); - buttons_core(z, buttons, BUTTONMASK_NEXT, "next"); - buttons_core(z, buttons, BUTTONMASK_REWIND, "rewind"); - buttons_core(z, buttons, BUTTONMASK_FASTFORWARD, "fastforward"); - buttons_core(z, buttons, BUTTONMASK_STOP, "stop"); - buttons_core(z, buttons, BUTTONMASK_PLAY, "play"); - buttons_core(z, buttons, BUTTONMASK_RECORD, "record"); - buttons_core(z, buttons, BUTTONMASK_SHIFT, "shift"); - if (datawheel) - printf(" datawheel=%02x", datawheel); - printf("\n"); -} - -void do_lcd(tranzport_t *z) -{ - tranzport_lcdwrite(z, 0, " ", 1000); - tranzport_lcdwrite(z, 1, "DISL", 1000); - tranzport_lcdwrite(z, 2, "EXIA", 1000); - tranzport_lcdwrite(z, 3, " FOR", 1000); - tranzport_lcdwrite(z, 4, " ", 1000); - - tranzport_lcdwrite(z, 5, " ", 1000); - tranzport_lcdwrite(z, 6, " CUR", 1000); - tranzport_lcdwrite(z, 7, "E FO", 1000); - tranzport_lcdwrite(z, 8, "UND ", 1000); - tranzport_lcdwrite(z, 9, " ", 1000); -} - -void do_lcd2(tranzport_t *z) -{ - tranzport_lcdwrite(z, 0, "THE ", 1000); - tranzport_lcdwrite(z, 1, "TRAN", 1000); - tranzport_lcdwrite(z, 2, "ZPOR", 1000); - tranzport_lcdwrite(z, 3, "T RO", 1000); - tranzport_lcdwrite(z, 4, "KS ", 1000); - - tranzport_lcdwrite(z, 5, "AWES", 1000); - tranzport_lcdwrite(z, 6, "OMEE", 1000); - tranzport_lcdwrite(z, 7, "LEEE", 1000); - tranzport_lcdwrite(z, 8, "WITH", 1000); - tranzport_lcdwrite(z, 9, "ARDO", 1000); -} - -lights_off(tranzport_t *z) { -int i; - for(i=0;i<7;i++) { - tranzport_lightoff(z, i, 1000); - } -} - -lights_on(tranzport_t *z) { -int i; - for(i=0;i<7;i++) { - tranzport_lighton(z, i, 1000); - } -} - -int main() -{ - tranzport_t *z; - uint8_t status; - uint32_t buttons; - uint8_t datawheel; - int val; - - z = open_tranzport(); - - do_lcd(z); - - for(;;) { - - do_lcd(z); - lights_on(z); - do_lcd2(z); - lights_off(z); - -// val = tranzport_read(z, &status, &buttons, &datawheel, 60000); - val = -1; - if (val < 0) - continue; - - if (status == STATUS_OFFLINE) { - printf("offline: "); - continue; - } - - if (status == STATUS_ONLINE) { - printf("online: "); - do_lcd(z); - } - - do_lights(z, buttons); - do_buttons(z, buttons, datawheel); - } - - close_tranzport(z); - - return 0; -} - diff --git a/libs/surfaces/frontier/kernel_drivers/tests/tranzport_tests.sh b/libs/surfaces/frontier/kernel_drivers/tests/tranzport_tests.sh deleted file mode 100755 index 540c62fe16..0000000000 --- a/libs/surfaces/frontier/kernel_drivers/tests/tranzport_tests.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -echo "Testing lights" -tranzport_lights & -A=$! -sleep 30 -kill $A -echo "Testing interleaved_reads/writes" -tranzport & -A=$! -sleep 30 -kill $A - -exit 0 - -# not done yet -echo "Testing_screen" -tranzport_screen & -A=$! -sleep 30 -kill $A -echo "Testing_reads" -tranzport_read & -A=$! -sleep 30 -kill $A - diff --git a/libs/surfaces/frontier/kernel_drivers/tranzport.c b/libs/surfaces/frontier/kernel_drivers/tranzport.c deleted file mode 100644 index 0be632529e..0000000000 --- a/libs/surfaces/frontier/kernel_drivers/tranzport.c +++ /dev/null @@ -1,1070 +0,0 @@ -/* - * Copyright (C) 2008-2015 Paul Davis - * - * Based on the usbled driver and ldusb drivers by - * Copyright (C) 2004 Greg Kroah-Hartman (greg@kroah.com) - * Copyright (C) 2005 Michael Hund - * - * The ldusb driver was, in turn, derived from Lego USB Tower drive - * Copyright (C) 2003 David Glance - * Copyright (C) 2001-2004 Juergen Stuber - * - * 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, version 2. - * - * 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/** - * This driver uses a ring buffer for time critical reading of - * interrupt in reports and provides read and write methods for - * raw interrupt reports. - */ - -/* Note: this currently uses a dumb ringbuffer for reads and writes. - * A more optimal driver would cache and kill off outstanding urbs that are - * now invalid, and ignore ones that already were in the queue but valid - * as we only have 17 commands for the tranzport. In particular this is - * key for getting lights to flash in time as otherwise many commands - * can be buffered up before the light change makes it to the interface. -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -/* Define these values to match your devices */ -#define VENDOR_ID 0x165b -#define PRODUCT_ID 0x8101 - -#ifdef CONFIG_USB_DYNAMIC_MINORS -#define USB_TRANZPORT_MINOR_BASE 0 -#else -// FIXME 176 - is the ldusb driver's minor - apply for that -#define USB_TRANZPORT_MINOR_BASE 176 -#endif - -/* table of devices that work with this driver */ -static struct usb_device_id usb_tranzport_table [] = { - { USB_DEVICE(VENDOR_ID, PRODUCT_ID) }, - { } /* Terminating entry */ -}; -MODULE_DEVICE_TABLE(usb, usb_tranzport_table); -MODULE_VERSION("0.29"); -MODULE_AUTHOR("Mike Taht "); -MODULE_DESCRIPTION("Tranzport USB Driver"); -MODULE_LICENSE("GPL"); -MODULE_SUPPORTED_DEVICE("Frontier Designs Control Surface"); - - -/* make this work on older kernel versions */ - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) - -/** - * usb_endpoint_dir_out - check if the endpoint has OUT direction - * @epd: endpoint to be checked - * - * Returns true if the endpoint is of type OUT, otherwise it returns false. - */ - -static inline int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) -{ - return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); -} - -static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) -{ - return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); -} - - -/** - * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type - * @epd: endpoint to be checked - * - * Returns true if the endpoint is of type interrupt, otherwise it returns - * false. - */ -static inline int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) -{ - return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == - USB_ENDPOINT_XFER_INT); -} - - -/** - * usb_endpoint_is_int_in - check if the endpoint is interrupt IN - * @epd: endpoint to be checked - * - * Returns true if the endpoint has interrupt transfer type and IN direction, - * otherwise it returns false. - */ - -static inline int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) -{ - return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd)); -} - -/** - * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT - * @epd: endpoint to be checked - * - * Returns true if the endpoint has interrupt transfer type and OUT direction, - * otherwise it returns false. - */ - -static inline int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd) -{ - return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd)); -} - -#endif /* older kernel versions */ - -/* These two aren't done yet */ - -#define SUPPRESS_EXTRA_ONLINE_EVENTS 0 -#define BUFFERED_WRITES 0 - -#define SUPPRESS_EXTRA_OFFLINE_EVENTS 1 -#define COMPRESS_WHEEL_EVENTS 1 -#define BUFFERED_READS 1 -#define RING_BUFFER_SIZE 1000 -#define WRITE_BUFFER_SIZE 34 -#define TRANZPORT_USB_TIMEOUT 10 - - -static int debug = 0; - -/* Use our own dbg macro */ -#define dbg_info(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0) - -/* Module parameters */ - -module_param(debug, int, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(debug, "Debug enabled or not"); - -/* All interrupt in transfers are collected in a ring buffer to - * avoid racing conditions and get better performance of the driver. - */ - -static int ring_buffer_size = RING_BUFFER_SIZE; - -module_param(ring_buffer_size, int, S_IRUGO); -MODULE_PARM_DESC(ring_buffer_size, "Read ring buffer size in reports"); - -/* The write_buffer can one day contain more than one interrupt out transfer. - */ -static int write_buffer_size = WRITE_BUFFER_SIZE; -module_param(write_buffer_size, int, S_IRUGO); -MODULE_PARM_DESC(write_buffer_size, "Write buffer size"); - -/* - * Increase the interval for debugging purposes. - * or set to 1 to use the standard interval from the endpoint descriptors. - */ - -static int min_interrupt_in_interval = TRANZPORT_USB_TIMEOUT; -module_param(min_interrupt_in_interval, int, 0); -MODULE_PARM_DESC(min_interrupt_in_interval, "Minimum interrupt in interval in ms"); - -static int min_interrupt_out_interval = TRANZPORT_USB_TIMEOUT; -module_param(min_interrupt_out_interval, int, 0); -MODULE_PARM_DESC(min_interrupt_out_interval, "Minimum interrupt out interval in ms"); - -struct tranzport_cmd { - unsigned char cmd[8]; -}; - -/* Structure to hold all of our device specific stuff */ -struct usb_tranzport { - struct semaphore sem; /* locks this structure */ - struct usb_interface* intf; /* save off the usb interface pointer */ - - int open_count; /* number of times this port has been opened */ - - struct tranzport_cmd (*ring_buffer)[RING_BUFFER_SIZE]; /* just make c happy */ - unsigned int ring_head; - unsigned int ring_tail; - - wait_queue_head_t read_wait; - wait_queue_head_t write_wait; - - unsigned char* interrupt_in_buffer; - struct usb_endpoint_descriptor* interrupt_in_endpoint; - struct urb* interrupt_in_urb; - int interrupt_in_interval; - size_t interrupt_in_endpoint_size; - int interrupt_in_running; - int interrupt_in_done; - - char* interrupt_out_buffer; - struct usb_endpoint_descriptor* interrupt_out_endpoint; - struct urb* interrupt_out_urb; - int interrupt_out_interval; - size_t interrupt_out_endpoint_size; - int interrupt_out_busy; - - /* Sysfs support - most of these are not hooked up yet */ - - int event; /* alternate interface to events */ - int wheel; /* - for negative, 0 for none, + for positive */ - int lights; - unsigned char dump_state; /* 0 if disabled 1 if enabled */ - unsigned char enable; /* 0 if disabled 1 if enabled */ - unsigned char offline; /* if the device is out of range or asleep */ - unsigned char compress_wheel; /* flag to compress wheel events */ - unsigned char LightRecord; - unsigned char LightTrackrec; - unsigned char LightTrackmute; - unsigned char LightTracksolo; - unsigned char LightAnysolo; - unsigned char LightLoop; - unsigned char LightPunch; - unsigned char last_cmd[8]; - unsigned char screen[40]; // We'll also have cells - -}; - -/* prevent races between open() and disconnect() */ -static DEFINE_MUTEX(disconnect_mutex); - -static struct usb_driver usb_tranzport_driver; - -/** - * usb_tranzport_abort_transfers - * aborts transfers and frees associated data structures - */ -static void usb_tranzport_abort_transfers(struct usb_tranzport *dev) -{ - /* shutdown transfer */ - if (dev->interrupt_in_running) { - dev->interrupt_in_running = 0; - if (dev->intf) - usb_kill_urb(dev->interrupt_in_urb); - } - if (dev->interrupt_out_busy) - if (dev->intf) - usb_kill_urb(dev->interrupt_out_urb); -} - -#define show_set_light(value) \ -static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct usb_interface *intf = to_usb_interface(dev); \ - struct usb_tranzport *t = usb_get_intfdata(intf); \ - \ - return sprintf(buf, "%d\n", t->value); \ -} \ -static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ -{ \ - struct usb_interface *intf = to_usb_interface(dev); \ - struct usb_tranzport *t = usb_get_intfdata(intf); \ - int temp = simple_strtoul(buf, NULL, 10); \ - \ - t->value = temp; \ - return count; \ -} \ -static DEVICE_ATTR(value, S_IWUGO | S_IRUGO, show_##value, set_##value); - -show_set_light(LightRecord); -show_set_light(LightTrackrec); -show_set_light(LightTrackmute); -show_set_light(LightTracksolo); -show_set_light(LightAnysolo); -show_set_light(LightLoop); -show_set_light(LightPunch); - -show_set_light(enable); -show_set_light(offline); -show_set_light(compress_wheel); -show_set_light(dump_state); - -#define show_set_int(value) \ -static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct usb_interface *intf = to_usb_interface(dev); \ - struct usb_tranzport *t = usb_get_intfdata(intf); \ - \ - return sprintf(buf, "%d\n", t->value); \ -} \ -static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ -{ \ - struct usb_interface *intf = to_usb_interface(dev); \ - struct usb_tranzport *t = usb_get_intfdata(intf); \ - int temp = simple_strtoul(buf, NULL, 10); \ - \ - t->value = temp; \ - return count; \ -} \ -static DEVICE_ATTR(value, S_IWUGO | S_IRUGO, show_##value, set_##value); - -show_set_int(wheel); -show_set_int(event); - -#define show_set_cmd(value) \ -static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct usb_interface *intf = to_usb_interface(dev); \ - struct usb_tranzport *t = usb_get_intfdata(intf); \ - \ - return sprintf(buf, "%d\n", t->value); \ -} \ -static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ -{ \ - struct usb_interface *intf = to_usb_interface(dev); \ - struct usb_tranzport *t = usb_get_intfdata(intf); \ - int temp = simple_strtoul(buf, NULL, 10); \ - \ - t->value = temp; \ - return count; \ -} \ -static DEVICE_ATTR(value, S_IWUGO | S_IRUGO, show_##value, set_##value); - - - - -/** - * usb_tranzport_delete - */ -static void usb_tranzport_delete(struct usb_tranzport *dev) -{ - usb_tranzport_abort_transfers(dev); - /* This is just too twisted to be correct */ - if(dev->intf != NULL) { - device_remove_file(&dev->intf->dev, &dev_attr_LightRecord); - device_remove_file(&dev->intf->dev, &dev_attr_LightTrackrec); - device_remove_file(&dev->intf->dev, &dev_attr_LightTrackmute); - device_remove_file(&dev->intf->dev, &dev_attr_LightTracksolo); - device_remove_file(&dev->intf->dev, &dev_attr_LightTrackmute); - device_remove_file(&dev->intf->dev, &dev_attr_LightAnysolo); - device_remove_file(&dev->intf->dev, &dev_attr_LightLoop); - device_remove_file(&dev->intf->dev, &dev_attr_LightPunch); - device_remove_file(&dev->intf->dev, &dev_attr_wheel); - device_remove_file(&dev->intf->dev, &dev_attr_enable); - device_remove_file(&dev->intf->dev, &dev_attr_event); - device_remove_file(&dev->intf->dev, &dev_attr_offline); - device_remove_file(&dev->intf->dev, &dev_attr_compress_wheel); - - device_remove_file(&dev->intf->dev, &dev_attr_dump_state); - } - - /* free data structures */ - usb_free_urb(dev->interrupt_in_urb); - usb_free_urb(dev->interrupt_out_urb); - kfree(dev->ring_buffer); - kfree(dev->interrupt_in_buffer); - kfree(dev->interrupt_out_buffer); - kfree(dev); -} - -/** - * usb_tranzport_interrupt_in_callback - */ - -static void usb_tranzport_interrupt_in_callback(struct urb *urb) -{ - struct usb_tranzport *dev = urb->context; - unsigned int next_ring_head; - int retval = -1; - - if (urb->status) { - if (urb->status == -ENOENT || - urb->status == -ECONNRESET || - urb->status == -ESHUTDOWN) { - goto exit; - } else { - dbg_info(&dev->intf->dev, "%s: nonzero status received: %d\n", - __FUNCTION__, urb->status); - goto resubmit; /* maybe we can recover */ - } - } - - if (urb->actual_length != 8) { - dev_warn(&dev->intf->dev, - "Urb length was %d bytes!! Do something intelligent \n", urb->actual_length); - } else { - dbg_info(&dev->intf->dev, "%s: received: %02x%02x%02x%02x%02x%02x%02x%02x\n", - __FUNCTION__, dev->interrupt_in_buffer[0],dev->interrupt_in_buffer[1],dev->interrupt_in_buffer[2],dev->interrupt_in_buffer[3],dev->interrupt_in_buffer[4],dev->interrupt_in_buffer[5],dev->interrupt_in_buffer[6],dev->interrupt_in_buffer[7]); -#if SUPPRESS_EXTRA_OFFLINE_EVENTS - if(dev->offline == 2 && dev->interrupt_in_buffer[1] == 0xff) { goto resubmit; } - if(dev->offline == 1 && dev->interrupt_in_buffer[1] == 0xff) { dev->offline = 2; goto resubmit; } - -/* Always pass one offline event up the stack */ - if(dev->offline > 0 && dev->interrupt_in_buffer[1] != 0xff) { dev->offline = 0; } - if(dev->offline == 0 && dev->interrupt_in_buffer[1] == 0xff) { dev->offline = 1; } - -#endif - dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", __FUNCTION__,dev->ring_head,dev->ring_tail); - - next_ring_head = (dev->ring_head+1) % ring_buffer_size; - - if (next_ring_head != dev->ring_tail) { - memcpy(&((*dev->ring_buffer)[dev->ring_head]), dev->interrupt_in_buffer, urb->actual_length); - dev->ring_head = next_ring_head; - retval = 0; - memset(dev->interrupt_in_buffer, 0, urb->actual_length); - } else { - dev_warn(&dev->intf->dev, - "Ring buffer overflow, %d bytes dropped\n", - urb->actual_length); - memset(dev->interrupt_in_buffer, 0, urb->actual_length); - } - } - -resubmit: - /* resubmit if we're still running */ - if (dev->interrupt_in_running && dev->intf) { - retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC); - if (retval) - dev_err(&dev->intf->dev, - "usb_submit_urb failed (%d)\n", retval); - } - -exit: - dev->interrupt_in_done = 1; - wake_up_interruptible(&dev->read_wait); -} - -/** - * usb_tranzport_interrupt_out_callback - */ -static void usb_tranzport_interrupt_out_callback(struct urb *urb) -{ - struct usb_tranzport *dev = urb->context; - - /* sync/async ::g_unlink faults aren't errors */ - if (urb->status && !(urb->status == -ENOENT || - urb->status == -ECONNRESET || - urb->status == -ESHUTDOWN)) - dbg_info(&dev->intf->dev, - "%s - nonzero write interrupt status received: %d\n", - __FUNCTION__, urb->status); - - dev->interrupt_out_busy = 0; - wake_up_interruptible(&dev->write_wait); -} - -/** - * usb_tranzport_open - */ -static int usb_tranzport_open(struct inode *inode, struct file *file) -{ - struct usb_tranzport *dev; - int subminor; - int retval = 0; - struct usb_interface *interface; - - nonseekable_open(inode, file); - subminor = iminor(inode); - - mutex_lock(&disconnect_mutex); - - interface = usb_find_interface(&usb_tranzport_driver, subminor); - - if (!interface) { - err("%s - error, can't find device for minor %d\n", - __FUNCTION__, subminor); - retval = -ENODEV; - goto unlock_disconnect_exit; - } - - dev = usb_get_intfdata(interface); - - if (!dev) { - retval = -ENODEV; - goto unlock_disconnect_exit; - } - - /* lock this device */ - if (down_interruptible(&dev->sem)) { - retval = -ERESTARTSYS; - goto unlock_disconnect_exit; - } - - /* allow opening only once */ - if (dev->open_count) { - retval = -EBUSY; - goto unlock_exit; - } - dev->open_count = 1; - - /* initialize in direction */ - dev->ring_head = 0; - dev->ring_tail = 0; - usb_fill_int_urb(dev->interrupt_in_urb, - interface_to_usbdev(interface), - usb_rcvintpipe(interface_to_usbdev(interface), - dev->interrupt_in_endpoint->bEndpointAddress), - dev->interrupt_in_buffer, - dev->interrupt_in_endpoint_size, - usb_tranzport_interrupt_in_callback, - dev, - dev->interrupt_in_interval); - - dev->interrupt_in_running = 1; - dev->interrupt_in_done = 0; - dev->enable = 1; - dev->offline = 0; - dev->compress_wheel = 1; - - retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL); - if (retval) { - dev_err(&interface->dev, "Couldn't submit interrupt_in_urb %d\n", retval); - dev->interrupt_in_running = 0; - dev->open_count = 0; - goto unlock_exit; - } - - /* save device in the file's private structure */ - file->private_data = dev; - - -unlock_exit: - up(&dev->sem); - -unlock_disconnect_exit: - mutex_unlock(&disconnect_mutex); - - return retval; -} - -/** - * usb_tranzport_release - */ -static int usb_tranzport_release(struct inode *inode, struct file *file) -{ - struct usb_tranzport *dev; - int retval = 0; - - dev = file->private_data; - - if (dev == NULL) { - retval = -ENODEV; - goto exit; - } - - if (down_interruptible(&dev->sem)) { - retval = -ERESTARTSYS; - goto exit; - } - - if (dev->open_count != 1) { - retval = -ENODEV; - goto unlock_exit; - } - - if (dev->intf == NULL) { - /* the device was unplugged before the file was released */ - up(&dev->sem); - /* unlock here as usb_tranzport_delete frees dev */ - usb_tranzport_delete(dev); - retval = -ENODEV; - goto exit; - } - - /* wait until write transfer is finished */ - if (dev->interrupt_out_busy) - wait_event_interruptible_timeout(dev->write_wait, !dev->interrupt_out_busy, 2 * HZ); - usb_tranzport_abort_transfers(dev); - dev->open_count = 0; - -unlock_exit: - up(&dev->sem); - -exit: - return retval; -} - -/** - * usb_tranzport_poll - */ -static unsigned int usb_tranzport_poll(struct file *file, poll_table *wait) -{ - struct usb_tranzport *dev; - unsigned int mask = 0; - - dev = file->private_data; - - poll_wait(file, &dev->read_wait, wait); - poll_wait(file, &dev->write_wait, wait); - - if (dev->ring_head != dev->ring_tail) - mask |= POLLIN | POLLRDNORM; - if (!dev->interrupt_out_busy) - mask |= POLLOUT | POLLWRNORM; - - return mask; -} - -/** - * usb_tranzport_read - */ -static ssize_t usb_tranzport_read(struct file *file, char __user *buffer, size_t count, - loff_t *ppos) -{ - struct usb_tranzport *dev; - size_t bytes_to_read; - int retval = 0; - -#if BUFFERED_READS - int c = 0; -#endif - -#if COMPRESS_WHEEL_EVENTS - signed char oldwheel; - signed char newwheel; - int cancompress = 1; - int next_tail; -#endif - -/* do I have such a thing as a null event? */ - - dev = file->private_data; - - /* verify that we actually have some data to read */ - if (count == 0) - goto exit; - - /* lock this object */ - if (down_interruptible(&dev->sem)) { - retval = -ERESTARTSYS; - goto exit; - } - - /* verify that the device wasn't unplugged */ - if (dev->intf == NULL) { - retval = -ENODEV; - err("No device or device unplugged %d\n", retval); - goto unlock_exit; - } - - while (dev->ring_head == dev->ring_tail) { - - if (file->f_flags & O_NONBLOCK) { - retval = -EAGAIN; - goto unlock_exit; - } - // atomic_cmp_exchange(&dev->interrupt_in_done,0,0); - dev->interrupt_in_done = 0 ; /* tiny race - FIXME: make atomic? */ - retval = wait_event_interruptible(dev->read_wait, dev->interrupt_in_done); - if (retval < 0) { - goto unlock_exit; - } - } - - dbg_info(&dev->intf->dev, "%s: copying to userspace: %02x%02x%02x%02x%02x%02x%02x%02x\n", - __FUNCTION__, (*dev->ring_buffer)[dev->ring_tail].cmd[0],(*dev->ring_buffer)[dev->ring_tail].cmd[1],(*dev->ring_buffer)[dev->ring_tail].cmd[2],(*dev->ring_buffer)[dev->ring_tail].cmd[3],(*dev->ring_buffer)[dev->ring_tail].cmd[4],(*dev->ring_buffer)[dev->ring_tail].cmd[5],(*dev->ring_buffer)[dev->ring_tail].cmd[6],(*dev->ring_buffer)[dev->ring_tail].cmd[7]); - -#if BUFFERED_READS - c = 0; - while((c < count) && (dev->ring_tail != dev->ring_head)) { - -/* This started off in the lower level service routine, and I moved it here. Then my brain died. Not done yet. */ -#if COMPRESS_WHEEL_EVENTS - next_tail = (dev->ring_tail+1) % ring_buffer_size; - if(dev->compress_wheel) cancompress = 1; - while(dev->ring_head != next_tail && cancompress == 1 ) { - newwheel = (*dev->ring_buffer)[next_tail].cmd[6]; - oldwheel = (*dev->ring_buffer)[dev->ring_tail].cmd[6]; - // if both are wheel events, and no buttons have changes (FIXME, do I have to check?), - // and we are the same sign, we can compress +- 7F - // FIXME: saner check for overflow! - max of +- 7F - // FIXME the math is wrong for going in reverse, actually, as the midi spec doesn't allow signed chars - - dbg_info(&dev->intf->dev, "%s: trying to compress: %02x%02x%02x%02x%02x %02x %02x %02x\n", - __FUNCTION__, (*dev->ring_buffer)[dev->ring_tail].cmd[0],(*dev->ring_buffer)[dev->ring_tail].cmd[1],(*dev->ring_buffer)[dev->ring_tail].cmd[2],(*dev->ring_buffer)[dev->ring_tail].cmd[3],(*dev->ring_buffer)[dev->ring_tail].cmd[4],(*dev->ring_buffer)[dev->ring_tail].cmd[5],(*dev->ring_buffer)[dev->ring_tail].cmd[6],(*dev->ring_buffer)[dev->ring_tail].cmd[7]); - - - if(((*dev->ring_buffer)[dev->ring_tail].cmd[6] != 0 && - (*dev->ring_buffer)[next_tail].cmd[6] != 0 ) && - ((newwheel > 0 && oldwheel > 0) || - (newwheel < 0 && oldwheel < 0)) && - ((*dev->ring_buffer)[dev->ring_tail].cmd[2] == (*dev->ring_buffer)[next_tail].cmd[2]) && - ((*dev->ring_buffer)[dev->ring_tail].cmd[3] == (*dev->ring_buffer)[next_tail].cmd[3]) && - ((*dev->ring_buffer)[dev->ring_tail].cmd[4] == (*dev->ring_buffer)[next_tail].cmd[4]) && - ((*dev->ring_buffer)[dev->ring_tail].cmd[5] == (*dev->ring_buffer)[next_tail].cmd[5])) - { - dbg_info(&dev->intf->dev, "%s: should compress: %02x%02x%02x%02x%02x%02x%02x%02x\n", - __FUNCTION__, (*dev->ring_buffer)[dev->ring_tail].cmd[0],(*dev->ring_buffer)[dev->ring_tail].cmd[1],(*dev->ring_buffer)[dev->ring_tail].cmd[2],(*dev->ring_buffer)[dev->ring_tail].cmd[3],(*dev->ring_buffer)[dev->ring_tail].cmd[4],(*dev->ring_buffer)[dev->ring_tail].cmd[5],(*dev->ring_buffer)[dev->ring_tail].cmd[6],(*dev->ring_buffer)[dev->ring_tail].cmd[7]); - - newwheel += oldwheel; - if(oldwheel > 0 && !(newwheel > 0)) { - newwheel = 0x7f; - cancompress = 0; - } - if(oldwheel < 0 && !(newwheel < 0)) { - newwheel = 0x80; - cancompress = 0; - } - - (*dev->ring_buffer)[next_tail].cmd[6] = newwheel; - dev->ring_tail = next_tail; - next_tail = (dev->ring_tail+1) % ring_buffer_size; - } else { - cancompress = 0; - } - } -#endif /* COMPRESS_WHEEL_EVENTS */ - - if (copy_to_user(&buffer[c], &(*dev->ring_buffer)[dev->ring_tail], 8)) { - retval = -EFAULT; - goto unlock_exit; - } - - dev->ring_tail = (dev->ring_tail+1) % ring_buffer_size; - c+=8; - dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", __FUNCTION__,dev->ring_head,dev->ring_tail); - } - retval = c; - -#else - if (copy_to_user(buffer, &(*dev->ring_buffer)[dev->ring_tail], 8)) { - retval = -EFAULT; - goto unlock_exit; - } - - dev->ring_tail = (dev->ring_tail+1) % ring_buffer_size; - dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", __FUNCTION__,dev->ring_head,dev->ring_tail); - - retval = 8; -#endif /* BUFFERED_READS */ - -unlock_exit: - /* unlock the device */ - up(&dev->sem); - -exit: - return retval; -} - -/** - * usb_tranzport_write - */ -static ssize_t usb_tranzport_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - struct usb_tranzport *dev; - size_t bytes_to_write; - int retval = 0; - - dev = file->private_data; - - /* verify that we actually have some data to write */ - if (count == 0) - goto exit; - - /* lock this object */ - if (down_interruptible(&dev->sem)) { - retval = -ERESTARTSYS; - goto exit; - } - - /* verify that the device wasn't unplugged */ - if (dev->intf == NULL) { - retval = -ENODEV; - err("No device or device unplugged %d\n", retval); - goto unlock_exit; - } - - /* wait until previous transfer is finished */ - if (dev->interrupt_out_busy) { - if (file->f_flags & O_NONBLOCK) { - retval = -EAGAIN; - goto unlock_exit; - } - retval = wait_event_interruptible(dev->write_wait, !dev->interrupt_out_busy); - if (retval < 0) { - goto unlock_exit; - } - } - - /* write the data into interrupt_out_buffer from userspace */ - bytes_to_write = min(count, write_buffer_size*dev->interrupt_out_endpoint_size); - if (bytes_to_write < count) - dev_warn(&dev->intf->dev, "Write buffer overflow, %zd bytes dropped\n",count-bytes_to_write); - - dbg_info(&dev->intf->dev, "%s: count = %zd, bytes_to_write = %zd\n", __FUNCTION__, count, bytes_to_write); - - if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) { - retval = -EFAULT; - goto unlock_exit; - } - - if (dev->interrupt_out_endpoint == NULL) { - err("Endpoint should not be be null! \n"); - goto unlock_exit; - } - - /* send off the urb */ - usb_fill_int_urb(dev->interrupt_out_urb, - interface_to_usbdev(dev->intf), - usb_sndintpipe(interface_to_usbdev(dev->intf), - dev->interrupt_out_endpoint->bEndpointAddress), - dev->interrupt_out_buffer, - bytes_to_write, - usb_tranzport_interrupt_out_callback, - dev, - dev->interrupt_out_interval); - - dev->interrupt_out_busy = 1; - wmb(); - - retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL); - if (retval) { - dev->interrupt_out_busy = 0; - err("Couldn't submit interrupt_out_urb %d\n", retval); - goto unlock_exit; - } - retval = bytes_to_write; - -unlock_exit: - /* unlock the device */ - up(&dev->sem); - -exit: - return retval; -} - -/* file operations needed when we register this driver */ -static const struct file_operations usb_tranzport_fops = { - .owner = THIS_MODULE, - .read = usb_tranzport_read, - .write = usb_tranzport_write, - .open = usb_tranzport_open, - .release = usb_tranzport_release, - .poll = usb_tranzport_poll, -}; - -/* - * usb class driver info in order to get a minor number from the usb core, - * and to have the device registered with the driver core - */ -static struct usb_class_driver usb_tranzport_class = { - .name = "tranzport%d", - .fops = &usb_tranzport_fops, - .minor_base = USB_TRANZPORT_MINOR_BASE, -}; - - -/** - * usb_tranzport_probe - * - * Called by the usb core when a new device is connected that it thinks - * this driver might be interested in. - */ -static int usb_tranzport_probe(struct usb_interface *intf, const struct usb_device_id *id) -{ - struct usb_device *udev = interface_to_usbdev(intf); - struct usb_tranzport *dev = NULL; - struct usb_host_interface *iface_desc; - struct usb_endpoint_descriptor *endpoint; - int i; - int true_size; - int retval = -ENOMEM; - - /* allocate memory for our device state and initialize it */ - - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (dev == NULL) { - dev_err(&intf->dev, "Out of memory\n"); - goto exit; - } - init_MUTEX(&dev->sem); - dev->intf = intf; - init_waitqueue_head(&dev->read_wait); - init_waitqueue_head(&dev->write_wait); - - iface_desc = intf->cur_altsetting; - - /* set up the endpoint information */ - for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { - endpoint = &iface_desc->endpoint[i].desc; - - if (usb_endpoint_is_int_in(endpoint)) - dev->interrupt_in_endpoint = endpoint; - - if (usb_endpoint_is_int_out(endpoint)) - dev->interrupt_out_endpoint = endpoint; - } - if (dev->interrupt_in_endpoint == NULL) { - dev_err(&intf->dev, "Interrupt in endpoint not found\n"); - goto error; - } - if (dev->interrupt_out_endpoint == NULL) - dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n"); - - - dev->interrupt_in_endpoint_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize); - - if (dev->interrupt_in_endpoint_size != 8) - dev_warn(&intf->dev, "Interrupt in endpoint size is not 8!\n"); - - if(ring_buffer_size == 0) { ring_buffer_size = RING_BUFFER_SIZE; } - true_size = min(ring_buffer_size,RING_BUFFER_SIZE); - /* FIXME - there are more usb_alloc routines for dma correctness. Needed? */ - - dev->ring_buffer = kmalloc((true_size*sizeof(struct tranzport_cmd))+8, GFP_KERNEL); - - if (!dev->ring_buffer) { - dev_err(&intf->dev, "Couldn't allocate ring_buffer of size %d\n",true_size); - goto error; - } - dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); - if (!dev->interrupt_in_buffer) { - dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer\n"); - goto error; - } - dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!dev->interrupt_in_urb) { - dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n"); - goto error; - } - dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize) : - udev->descriptor.bMaxPacketSize0; - - if (dev->interrupt_out_endpoint_size !=8) - dev_warn(&intf->dev, "Interrupt out endpoint size is not 8!)\n"); - - dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL); - if (!dev->interrupt_out_buffer) { - dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer\n"); - goto error; - } - dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!dev->interrupt_out_urb) { - dev_err(&intf->dev, "Couldn't allocate interrupt_out_urb\n"); - goto error; - } - dev->interrupt_in_interval = min_interrupt_in_interval > dev->interrupt_in_endpoint->bInterval ? min_interrupt_in_interval : dev->interrupt_in_endpoint->bInterval; - if (dev->interrupt_out_endpoint) - dev->interrupt_out_interval = min_interrupt_out_interval > dev->interrupt_out_endpoint->bInterval ? min_interrupt_out_interval : dev->interrupt_out_endpoint->bInterval; - - /* we can register the device now, as it is ready */ - usb_set_intfdata(intf, dev); - - retval = usb_register_dev(intf, &usb_tranzport_class); - if (retval) { - /* something prevented us from registering this driver */ - dev_err(&intf->dev, "Not able to get a minor for this device.\n"); - usb_set_intfdata(intf, NULL); - goto error; - } - - if((retval = device_create_file(&intf->dev, &dev_attr_LightRecord))) goto error; - if((retval = device_create_file(&intf->dev, &dev_attr_LightTrackrec))) goto error; - if((retval = device_create_file(&intf->dev, &dev_attr_LightTrackmute))) goto error; - if((retval = device_create_file(&intf->dev, &dev_attr_LightTracksolo))) goto error; - if((retval = device_create_file(&intf->dev, &dev_attr_LightAnysolo))) goto error; - if((retval = device_create_file(&intf->dev, &dev_attr_LightLoop))) goto error; - if((retval = device_create_file(&intf->dev, &dev_attr_LightPunch))) goto error; - if((retval = device_create_file(&intf->dev, &dev_attr_wheel))) goto error; - if((retval = device_create_file(&intf->dev, &dev_attr_event))) goto error; - if((retval = device_create_file(&intf->dev, &dev_attr_dump_state))) goto error; - if((retval = device_create_file(&intf->dev, &dev_attr_compress_wheel))) goto error; - if((retval = device_create_file(&intf->dev, &dev_attr_enable))) goto error; - if((retval = device_create_file(&intf->dev, &dev_attr_offline))) goto error; - - /* let the user know what node this device is now attached to */ - dev_info(&intf->dev, "Tranzport Device #%d now attached to major %d minor %d\n", - (intf->minor - USB_TRANZPORT_MINOR_BASE), USB_MAJOR, intf->minor); - -exit: - return retval; - -error: - usb_tranzport_delete(dev); - - return retval; -} - -/** - * usb_tranzport_disconnect - * - * Called by the usb core when the device is removed from the system. - */ -static void usb_tranzport_disconnect(struct usb_interface *intf) -{ - struct usb_tranzport *dev; - int minor; - - /* FIXME: The skel code calls lock_kernel here, doesn't use a mutex, needed? */ - mutex_lock(&disconnect_mutex); - - dev = usb_get_intfdata(intf); - usb_set_intfdata(intf, NULL); - - down(&dev->sem); - - minor = intf->minor; - - /* give back our minor */ - usb_deregister_dev(intf, &usb_tranzport_class); - - /* if the device is not opened, then we clean up right now */ - if (!dev->open_count) { - up(&dev->sem); - usb_tranzport_delete(dev); - } else { - dev->intf = NULL; - up(&dev->sem); - } - - mutex_unlock(&disconnect_mutex); - - dev_info(&intf->dev, "Tranzport Surface #%d now disconnected\n", - (minor - USB_TRANZPORT_MINOR_BASE)); -} - -/* usb specific object needed to register this driver with the usb subsystem */ -static struct usb_driver usb_tranzport_driver = { - .name = "tranzport", - .probe = usb_tranzport_probe, - .disconnect = usb_tranzport_disconnect, - .id_table = usb_tranzport_table, -}; - -/** - * usb_tranzport_init - */ -static int __init usb_tranzport_init(void) -{ - int retval; - - /* register this driver with the USB subsystem */ - retval = usb_register(&usb_tranzport_driver); - if (retval) - err("usb_register failed for the "__FILE__" driver. Error number %d\n", retval); - - return retval; -} - -/** - * usb_tranzport_exit - */ -static void __exit usb_tranzport_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&usb_tranzport_driver); -} - -module_init(usb_tranzport_init); -module_exit(usb_tranzport_exit); - diff --git a/libs/surfaces/frontier/tests/Makefile b/libs/surfaces/frontier/tests/Makefile deleted file mode 100644 index aafb9aaa57..0000000000 --- a/libs/surfaces/frontier/tests/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# Some basic utilities for testing the tranzport's I/O -# eventually "tranzport" will become a flexible command -# -# -all: tranzport tranzport_lights - -tranzport: tranzport.c - gcc -g -Wall -o tranzport tranzport.c - -tranzport_lights: tranzport_lights.c - gcc -g -Wall -o tranzport_lights tranzport_lights.c - -clean:: - rm -f core .*.cmd *.o *.ko *.mod.c Module.symvers *.bak .\#* *~ - rm -rf .tmp_versions tranzport tranzport_lights - - diff --git a/libs/surfaces/frontier/tests/README b/libs/surfaces/frontier/tests/README deleted file mode 100644 index f9efd18f69..0000000000 --- a/libs/surfaces/frontier/tests/README +++ /dev/null @@ -1,104 +0,0 @@ -tranzport 0.1 -oct 18, 2005 -arthur@artcmusic.com ---- - -The Frontier Design Tranzport(tm) (www.frontierdesign.com) is a simple -wireless USB device. It is not a MIDI device. The document on their web -site "Tranzport(tm) Native Mode Interface Description" describes the -Tranzport(tm) as if it were a MIDI device, but this is implemented by their -Windows and Macintosh software drivers. - -This code will allow you to use your Tranzport(tm) at a lower level of -abstraction. This code relies on libusb, which can be obtained from -libusb.sourceforge.net. - -To compile the program, type "make". You should end up with a executable -called "tranzport". You'll probably have to run this program as root. - -Using the program is straightforward. It will simply tell you which -buttons are being pressed and what not. If you press one of the buttons -with a light, the light will turn on. If you hold shift and press one of -the buttons with a light, the light will turn off. If you take out the -batteries to the device (or go out of range), it will tell you that the -device is offline. When you replace the batteries (or come back in -range), it should tell you it is back online. - -Once you understand how everything works, you should be able to -incorporate it into your own setup however you wish. - -This code was developed on a Linux machine, but (theoretically) it -should work on any system that is supported by libusb, since that is how -it communicates with the device. - -Here are a few more details about the device: - -There are two endpoints for communication with the device. All data -reads and writes are done in 8-byte segments. - -One endpoint is for interrupt reads. This is used to read button data -from the device. It also supplies status information for when the device -goes out of range and comes back in range, loses power and regains -power, etc. The format of the data is: - - 00 ss bb bb bb bb dd 00 (hexadecimal) - -where: - - ss - status code, 01=online ff=offline - bb - button bits - dd - data wheel, 01-3f=forward 41-7f=backward - -Please refer to the source code for a list of the button bits. - -The other endpoint is for interrupt writes. This is used to toggle the -lights on the device, and to write data to the LCD. - -There are 7 lights on the device. To turn a light on, send the following -sequence of bytes: - - 00 00 nn 01 00 00 00 00 (hexadecimal) - -where nn is the light number. - -To turn a light off: - - 00 00 nn 00 00 00 00 00 (hexadecimal) - -Here is the list of lights: - - 00 Record - 01 Track Rec - 02 Track Mute - 03 Track Solo - 04 Any Solo - 05 Loop - 06 Punch - -The size of the LCD is 20x2, and it is split into 10 cells, each cell -being 4 characters wide. The cells progress across, then down. To write -to the LCD, send the following sequence of bytes: - - 00 01 cc aa aa aa aa 00 (hexadecimal) - -where: - - cc - cell number - aa - ASCII code - -Here is a list of the cells to clarify: - - 00 row 0, column 0-3 - 01 row 0, column 4-7 - 02 row 0, column 8-11 - 03 row 0, column 12-15 - 04 row 0, column 16-19 - 05 row 1, column 0-3 - 06 row 1, column 4-7 - 07 row 1, column 8-11 - 08 row 1, column 12-15 - 09 row 1, column 16-19 - -You should refer to the "Tranzport(tm) Native Mode Interface -Description" document for a listing of the ASCII codes the LCD uses. - diff --git a/libs/surfaces/frontier/tests/tranzport.c b/libs/surfaces/frontier/tests/tranzport.c deleted file mode 100644 index 1eeacd6578..0000000000 --- a/libs/surfaces/frontier/tests/tranzport.c +++ /dev/null @@ -1,347 +0,0 @@ -/* - * tranzport 0.1 - * oct 18, 2005 - * arthur@artcmusic.com - */ - -#include -#include -#include -#include -#include - -#define VENDORID 0x165b -#define PRODUCTID 0x8101 - -#define READ_ENDPOINT 0x81 -#define WRITE_ENDPOINT 0x02 - -enum { - LIGHT_RECORD = 0, - LIGHT_TRACKREC, - LIGHT_TRACKMUTE, - LIGHT_TRACKSOLO, - LIGHT_ANYSOLO, - LIGHT_LOOP, - LIGHT_PUNCH -}; - -#define BUTTONMASK_BATTERY 0x00004000 -#define BUTTONMASK_BACKLIGHT 0x00008000 -#define BUTTONMASK_TRACKLEFT 0x04000000 -#define BUTTONMASK_TRACKRIGHT 0x40000000 -#define BUTTONMASK_TRACKREC 0x00040000 -#define BUTTONMASK_TRACKMUTE 0x00400000 -#define BUTTONMASK_TRACKSOLO 0x00000400 -#define BUTTONMASK_UNDO 0x80000000 -#define BUTTONMASK_IN 0x02000000 -#define BUTTONMASK_OUT 0x20000000 -#define BUTTONMASK_PUNCH 0x00800000 -#define BUTTONMASK_LOOP 0x00080000 -#define BUTTONMASK_PREV 0x00020000 -#define BUTTONMASK_ADD 0x00200000 -#define BUTTONMASK_NEXT 0x00000200 -#define BUTTONMASK_REWIND 0x01000000 -#define BUTTONMASK_FASTFORWARD 0x10000000 -#define BUTTONMASK_STOP 0x00010000 -#define BUTTONMASK_PLAY 0x00100000 -#define BUTTONMASK_RECORD 0x00000100 -#define BUTTONMASK_SHIFT 0x08000000 - -#define STATUS_OFFLINE 0xff -#define STATUS_ONLINE 0x01 - -struct tranzport_s { - struct usb_device *dev; - usb_dev_handle *udev; -}; - -typedef struct tranzport_s tranzport_t; - -void log_entry(FILE *fp, char *format, va_list ap) -{ - vfprintf(fp, format, ap); - fputc('\n', fp); -} - -void log_error(char *format, ...) -{ - va_list ap; - va_start(ap, format); - log_entry(stderr, format, ap); - va_end(ap); -} - -void vlog_error(char *format, va_list ap) -{ - log_entry(stderr, format, ap); -} - -void die(char *format, ...) -{ - va_list ap; - va_start(ap, format); - vlog_error(format, ap); - va_end(ap); - exit(1); -} - -tranzport_t *open_tranzport_core(struct usb_device *dev) -{ - tranzport_t *z; - int val; - - z = malloc(sizeof(tranzport_t)); - if (!z) - die("not enough memory"); - memset(z, 0, sizeof(tranzport_t)); - - z->dev = dev; - z->udev = usb_open(z->dev); - if (!z->udev) - die("unable to open tranzport"); - - val = usb_claim_interface(z->udev, 0); - if (val < 0) - die("unable to claim tranzport"); - - return z; -} - -tranzport_t *open_tranzport() -{ - struct usb_bus *bus; - struct usb_device *dev; - - usb_init(); - usb_find_busses(); - usb_find_devices(); - - for(bus=usb_busses; bus; bus=bus->next) { - for(dev=bus->devices; dev; dev=dev->next) { - if (dev->descriptor.idVendor != VENDORID) - continue; - if (dev->descriptor.idProduct != PRODUCTID) - continue; - - return open_tranzport_core(dev); - } - } - - die("can't find tranzport"); - return 0; -} - -void close_tranzport(tranzport_t *z) -{ - int val; - - val = usb_release_interface(z->udev, 0); - if (val < 0) - log_error("unable to release tranzport"); - - val = usb_close(z->udev); - if (val < 0) - log_error("unable to close tranzport"); - - free(z); -} - -int tranzport_write_core(tranzport_t *z, uint8_t *cmd, int timeout) -{ - int val; - val = usb_interrupt_write(z->udev, WRITE_ENDPOINT, cmd, 8, timeout); - if (val < 0) - return val; - if (val != 8) - return -1; - return 0; -} - -int tranzport_lcdwrite(tranzport_t *z, uint8_t cell, char *text, int timeout) -{ - uint8_t cmd[8]; - - if (cell > 9) { - return -1; - } - - cmd[0] = 0x00; - cmd[1] = 0x01; - cmd[2] = cell; - cmd[3] = text[0]; - cmd[4] = text[1]; - cmd[5] = text[2]; - cmd[6] = text[3]; - cmd[7] = 0x00; - - return tranzport_write_core(z, cmd, timeout); -} - -int tranzport_lighton(tranzport_t *z, uint8_t light, int timeout) -{ - uint8_t cmd[8]; - - cmd[0] = 0x00; - cmd[1] = 0x00; - cmd[2] = light; - cmd[3] = 0x01; - cmd[4] = 0x00; - cmd[5] = 0x00; - cmd[6] = 0x00; - cmd[7] = 0x00; - - return tranzport_write_core(z, cmd, timeout); -} - -int tranzport_lightoff(tranzport_t *z, uint8_t light, int timeout) -{ - uint8_t cmd[8]; - - cmd[0] = 0x00; - cmd[1] = 0x00; - cmd[2] = light; - cmd[3] = 0x00; - cmd[4] = 0x00; - cmd[5] = 0x00; - cmd[6] = 0x00; - cmd[7] = 0x00; - - return tranzport_write_core(z, cmd, timeout); -} - -int tranzport_read(tranzport_t *z, uint8_t *status, uint32_t *buttons, uint8_t *datawheel, int timeout) -{ - uint8_t buf[8]; - int val; - - memset(buf, 0, 8); - val = usb_interrupt_read(z->udev, READ_ENDPOINT, buf, 8, timeout); - if (val < 0) - return val; - if (val != 8) - return -1; - - /*printf("read: %02x %02x %02x %02x %02x %02x %02x %02x\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);*/ - - *status = buf[1]; - - *buttons = 0; - *buttons |= buf[2] << 24; - *buttons |= buf[3] << 16; - *buttons |= buf[4] << 8; - *buttons |= buf[5]; - - *datawheel = buf[6]; - - return 0; -} - -void lights_core(tranzport_t *z, uint32_t buttons, uint32_t buttonmask, uint8_t light) -{ - if (buttons & buttonmask) { - if (buttons & BUTTONMASK_SHIFT) { - tranzport_lightoff(z, light, 1000); - } else { - tranzport_lighton(z, light, 1000); - } - } -} - -void do_lights(tranzport_t *z, uint32_t buttons) -{ - lights_core(z, buttons, BUTTONMASK_RECORD, LIGHT_RECORD); - lights_core(z, buttons, BUTTONMASK_TRACKREC, LIGHT_TRACKREC); - lights_core(z, buttons, BUTTONMASK_TRACKMUTE, LIGHT_TRACKMUTE); - lights_core(z, buttons, BUTTONMASK_TRACKSOLO, LIGHT_TRACKSOLO); - lights_core(z, buttons, BUTTONMASK_TRACKSOLO, LIGHT_ANYSOLO); - lights_core(z, buttons, BUTTONMASK_PUNCH, LIGHT_PUNCH); - lights_core(z, buttons, BUTTONMASK_LOOP, LIGHT_LOOP); -} - -void buttons_core(tranzport_t *z, uint32_t buttons, uint32_t buttonmask, char *str) -{ - if (buttons & buttonmask) - printf(" %s", str); -} - -void do_buttons(tranzport_t *z, uint32_t buttons, uint8_t datawheel) -{ - printf("buttons:"); - buttons_core(z, buttons, BUTTONMASK_BATTERY, "battery"); - buttons_core(z, buttons, BUTTONMASK_BACKLIGHT, "backlight"); - buttons_core(z, buttons, BUTTONMASK_TRACKLEFT, "trackleft"); - buttons_core(z, buttons, BUTTONMASK_TRACKRIGHT, "trackright"); - buttons_core(z, buttons, BUTTONMASK_TRACKREC, "trackrec"); - buttons_core(z, buttons, BUTTONMASK_TRACKMUTE, "trackmute"); - buttons_core(z, buttons, BUTTONMASK_TRACKSOLO, "tracksolo"); - buttons_core(z, buttons, BUTTONMASK_UNDO, "undo"); - buttons_core(z, buttons, BUTTONMASK_IN, "in"); - buttons_core(z, buttons, BUTTONMASK_OUT, "out"); - buttons_core(z, buttons, BUTTONMASK_PUNCH, "punch"); - buttons_core(z, buttons, BUTTONMASK_LOOP, "loop"); - buttons_core(z, buttons, BUTTONMASK_PREV, "prev"); - buttons_core(z, buttons, BUTTONMASK_ADD, "add"); - buttons_core(z, buttons, BUTTONMASK_NEXT, "next"); - buttons_core(z, buttons, BUTTONMASK_REWIND, "rewind"); - buttons_core(z, buttons, BUTTONMASK_FASTFORWARD, "fastforward"); - buttons_core(z, buttons, BUTTONMASK_STOP, "stop"); - buttons_core(z, buttons, BUTTONMASK_PLAY, "play"); - buttons_core(z, buttons, BUTTONMASK_RECORD, "record"); - buttons_core(z, buttons, BUTTONMASK_SHIFT, "shift"); - if (datawheel) - printf(" datawheel=%02x", datawheel); - printf("\n"); -} - -void do_lcd(tranzport_t *z) -{ - tranzport_lcdwrite(z, 0, " ", 1000); - tranzport_lcdwrite(z, 1, "DISL", 1000); - tranzport_lcdwrite(z, 2, "EXIA", 1000); - tranzport_lcdwrite(z, 3, " FOR", 1000); - tranzport_lcdwrite(z, 4, " ", 1000); - - tranzport_lcdwrite(z, 5, " ", 1000); - tranzport_lcdwrite(z, 6, " CUR", 1000); - tranzport_lcdwrite(z, 7, "E FO", 1000); - tranzport_lcdwrite(z, 8, "UND ", 1000); - tranzport_lcdwrite(z, 9, " ", 1000); -} - -int main() -{ - tranzport_t *z; - uint8_t status; - uint32_t buttons; - uint8_t datawheel; - int val; - - z = open_tranzport(); - - do_lcd(z); - - for(;;) { - val = tranzport_read(z, &status, &buttons, &datawheel, 60000); - if (val < 0) - continue; - - if (status == STATUS_OFFLINE) { - printf("offline\n"); - continue; - } - - if (status == STATUS_ONLINE) { - printf("online\n"); - do_lcd(z); - } - - do_lights(z, buttons); - do_buttons(z, buttons, datawheel); - } - - close_tranzport(z); - - return 0; -} - diff --git a/libs/surfaces/frontier/tests/tranzport_lights.c b/libs/surfaces/frontier/tests/tranzport_lights.c deleted file mode 100644 index 07867d6dd0..0000000000 --- a/libs/surfaces/frontier/tests/tranzport_lights.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - * tranzport 0.1 - * oct 18, 2005 - * arthur@artcmusic.com - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define VENDORID 0x165b -#define PRODUCTID 0x8101 - -#define READ_ENDPOINT 0x81 -#define WRITE_ENDPOINT 0x02 - -enum { - LIGHT_RECORD = 0, - LIGHT_TRACKREC, - LIGHT_TRACKMUTE, - LIGHT_TRACKSOLO, - LIGHT_ANYSOLO, - LIGHT_LOOP, - LIGHT_PUNCH -}; - -#define BUTTONMASK_BATTERY 0x00004000 -#define BUTTONMASK_BACKLIGHT 0x00008000 -#define BUTTONMASK_TRACKLEFT 0x04000000 -#define BUTTONMASK_TRACKRIGHT 0x40000000 -#define BUTTONMASK_TRACKREC 0x00040000 -#define BUTTONMASK_TRACKMUTE 0x00400000 -#define BUTTONMASK_TRACKSOLO 0x00000400 -#define BUTTONMASK_UNDO 0x80000000 -#define BUTTONMASK_IN 0x02000000 -#define BUTTONMASK_OUT 0x20000000 -#define BUTTONMASK_PUNCH 0x00800000 -#define BUTTONMASK_LOOP 0x00080000 -#define BUTTONMASK_PREV 0x00020000 -#define BUTTONMASK_ADD 0x00200000 -#define BUTTONMASK_NEXT 0x00000200 -#define BUTTONMASK_REWIND 0x01000000 -#define BUTTONMASK_FASTFORWARD 0x10000000 -#define BUTTONMASK_STOP 0x00010000 -#define BUTTONMASK_PLAY 0x00100000 -#define BUTTONMASK_RECORD 0x00000100 -#define BUTTONMASK_SHIFT 0x08000000 - -#define STATUS_OFFLINE 0xff -#define STATUS_ONLINE 0x01 -#define STATUS_OK 0x00 - -struct tranzport_s { - int *dev; - int udev; -}; - -typedef struct tranzport_s tranzport_t; - -void log_entry(FILE *fp, char *format, va_list ap) -{ - vfprintf(fp, format, ap); - fputc('\n', fp); -} - -void log_error(char *format, ...) -{ - va_list ap; - va_start(ap, format); - log_entry(stderr, format, ap); - va_end(ap); -} - -void vlog_error(char *format, va_list ap) -{ - log_entry(stderr, format, ap); -} - -void die(char *format, ...) -{ - va_list ap; - va_start(ap, format); - vlog_error(format, ap); - va_end(ap); - exit(1); -} - -tranzport_t *open_tranzport_core() -{ - tranzport_t *z; - int val; - - z = malloc(sizeof(tranzport_t)); - if (!z) - die("not enough memory"); - memset(z, 0, sizeof(tranzport_t)); - - z->udev = open("/dev/tranzport0",O_RDWR); - if (!z->udev) - die("unable to open tranzport"); - - return z; -} - -tranzport_t *open_tranzport() -{ -return open_tranzport_core(); -} - -void close_tranzport(tranzport_t *z) -{ - int val; - - val = close(z->udev); - if (val < 0) - log_error("unable to release tranzport"); - - free(z); -} - -int tranzport_write_core(tranzport_t *z, uint8_t *cmd, int timeout) -{ - int val; - val = write(z->udev, cmd, 8); - if (val < 0) - return val; - if (val != 8) - return -1; - return 0; -} - -int tranzport_lcdwrite(tranzport_t *z, uint8_t cell, char *text, int timeout) -{ - uint8_t cmd[8]; - - if (cell > 9) { - return -1; - } - - cmd[0] = 0x00; - cmd[1] = 0x01; - cmd[2] = cell; - cmd[3] = text[0]; - cmd[4] = text[1]; - cmd[5] = text[2]; - cmd[6] = text[3]; - cmd[7] = 0x00; - - return tranzport_write_core(z, cmd, timeout); -} - -int tranzport_lighton(tranzport_t *z, uint8_t light, int timeout) -{ - uint8_t cmd[8]; - - cmd[0] = 0x00; - cmd[1] = 0x00; - cmd[2] = light; - cmd[3] = 0x01; - cmd[4] = 0x00; - cmd[5] = 0x00; - cmd[6] = 0x00; - cmd[7] = 0x00; - - return tranzport_write_core(z, &cmd[0], timeout); -} - -int tranzport_lightoff(tranzport_t *z, uint8_t light, int timeout) -{ - uint8_t cmd[8]; - - cmd[0] = 0x00; - cmd[1] = 0x00; - cmd[2] = light; - cmd[3] = 0x00; - cmd[4] = 0x00; - cmd[5] = 0x00; - cmd[6] = 0x00; - cmd[7] = 0x00; - - return tranzport_write_core(z, &cmd[0], timeout); -} - -int tranzport_read(tranzport_t *z, uint8_t *status, uint32_t *buttons, uint8_t *datawheel, int timeout) -{ - uint8_t buf[8]; - int val; - - memset(buf, 0xff, 8); - val = read(z->udev, buf, 8); - if (val < 0) { - // printf("errno: %d\n",errno); - return val; - } - if (val != 8) - return -1; - - /*printf("read: %02x %02x %02x %02x %02x %02x %02x %02x\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);*/ - - *status = buf[1]; - - *buttons = 0; - *buttons |= buf[2] << 24; - *buttons |= buf[3] << 16; - *buttons |= buf[4] << 8; - *buttons |= buf[5]; - - *datawheel = buf[6]; - - return 0; -} - -void lights_core(tranzport_t *z, uint32_t buttons, uint32_t buttonmask, uint8_t light) -{ - if (buttons & buttonmask) { - if (buttons & BUTTONMASK_SHIFT) { - tranzport_lightoff(z, light, 1000); - } else { - tranzport_lighton(z, light, 1000); - } - } -} - -void do_lights(tranzport_t *z, uint32_t buttons) -{ - lights_core(z, buttons, BUTTONMASK_RECORD, LIGHT_RECORD); - lights_core(z, buttons, BUTTONMASK_TRACKREC, LIGHT_TRACKREC); - lights_core(z, buttons, BUTTONMASK_TRACKMUTE, LIGHT_TRACKMUTE); - lights_core(z, buttons, BUTTONMASK_TRACKSOLO, LIGHT_TRACKSOLO); - lights_core(z, buttons, BUTTONMASK_TRACKSOLO, LIGHT_ANYSOLO); - lights_core(z, buttons, BUTTONMASK_PUNCH, LIGHT_PUNCH); - lights_core(z, buttons, BUTTONMASK_LOOP, LIGHT_LOOP); -} - -void buttons_core(tranzport_t *z, uint32_t buttons, uint32_t buttonmask, char *str) -{ - if (buttons & buttonmask) - printf(" %s", str); -} - -void do_buttons(tranzport_t *z, uint32_t buttons, uint8_t datawheel) -{ - printf("buttons: %x ", buttons); - buttons_core(z, buttons, BUTTONMASK_BATTERY, "battery"); - buttons_core(z, buttons, BUTTONMASK_BACKLIGHT, "backlight"); - buttons_core(z, buttons, BUTTONMASK_TRACKLEFT, "trackleft"); - buttons_core(z, buttons, BUTTONMASK_TRACKRIGHT, "trackright"); - buttons_core(z, buttons, BUTTONMASK_TRACKREC, "trackrec"); - buttons_core(z, buttons, BUTTONMASK_TRACKMUTE, "trackmute"); - buttons_core(z, buttons, BUTTONMASK_TRACKSOLO, "tracksolo"); - buttons_core(z, buttons, BUTTONMASK_UNDO, "undo"); - buttons_core(z, buttons, BUTTONMASK_IN, "in"); - buttons_core(z, buttons, BUTTONMASK_OUT, "out"); - buttons_core(z, buttons, BUTTONMASK_PUNCH, "punch"); - buttons_core(z, buttons, BUTTONMASK_LOOP, "loop"); - buttons_core(z, buttons, BUTTONMASK_PREV, "prev"); - buttons_core(z, buttons, BUTTONMASK_ADD, "add"); - buttons_core(z, buttons, BUTTONMASK_NEXT, "next"); - buttons_core(z, buttons, BUTTONMASK_REWIND, "rewind"); - buttons_core(z, buttons, BUTTONMASK_FASTFORWARD, "fastforward"); - buttons_core(z, buttons, BUTTONMASK_STOP, "stop"); - buttons_core(z, buttons, BUTTONMASK_PLAY, "play"); - buttons_core(z, buttons, BUTTONMASK_RECORD, "record"); - buttons_core(z, buttons, BUTTONMASK_SHIFT, "shift"); - if (datawheel) - printf(" datawheel=%02x", datawheel); - printf("\n"); -} - -void do_lcd(tranzport_t *z) -{ - tranzport_lcdwrite(z, 0, " ", 1000); - tranzport_lcdwrite(z, 1, "DISL", 1000); - tranzport_lcdwrite(z, 2, "EXIA", 1000); - tranzport_lcdwrite(z, 3, " FOR", 1000); - tranzport_lcdwrite(z, 4, " ", 1000); - - tranzport_lcdwrite(z, 5, " ", 1000); - tranzport_lcdwrite(z, 6, " CUR", 1000); - tranzport_lcdwrite(z, 7, "E FO", 1000); - tranzport_lcdwrite(z, 8, "UND ", 1000); - tranzport_lcdwrite(z, 9, " ", 1000); -} - -void do_lcd2(tranzport_t *z) -{ - tranzport_lcdwrite(z, 0, "THE ", 1000); - tranzport_lcdwrite(z, 1, "TRAN", 1000); - tranzport_lcdwrite(z, 2, "ZPOR", 1000); - tranzport_lcdwrite(z, 3, "T RO", 1000); - tranzport_lcdwrite(z, 4, " KS", 1000); - - tranzport_lcdwrite(z, 5, "AWES", 1000); - tranzport_lcdwrite(z, 6, "OMEE", 1000); - tranzport_lcdwrite(z, 7, "LEEE", 1000); - tranzport_lcdwrite(z, 8, "UND ", 1000); - tranzport_lcdwrite(z, 9, "GROK", 1000); -} - -lights_off(tranzport_t *z) { -int i; - for(i=0;i<7;i++) { - tranzport_lightoff(z, i, 1000); - } -} - -lights_on(tranzport_t *z) { -int i; - for(i=0;i<7;i++) { - tranzport_lighton(z, i, 1000); - } -} - -int main() -{ - tranzport_t *z; - uint8_t status; - uint32_t buttons; - uint8_t datawheel; - int val; - - z = open_tranzport(); - - do_lcd(z); - - for(;;) { - - do_lcd(z); - lights_on(z); - do_lcd2(z); - lights_off(z); - -// val = tranzport_read(z, &status, &buttons, &datawheel, 60000); - val = -1; - if (val < 0) - continue; - - if (status == STATUS_OFFLINE) { - printf("offline: "); - continue; - } - - if (status == STATUS_ONLINE) { - printf("online: "); - do_lcd(z); - } - - do_lights(z, buttons); - do_buttons(z, buttons, datawheel); - } - - close_tranzport(z); - - return 0; -} - diff --git a/libs/surfaces/frontier/tranzport/interface.cc b/libs/surfaces/frontier/tranzport/interface.cc deleted file mode 100644 index b76c113b8a..0000000000 --- a/libs/surfaces/frontier/tranzport/interface.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2008-2015 Paul Davis - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "control_protocol/control_protocol.h" -#include "tranzport_control_protocol.h" - -using namespace ARDOUR; - -ControlProtocol* -new_tranzport_protocol (ControlProtocolDescriptor* descriptor, Session* s) -{ - TranzportControlProtocol* tcp = new TranzportControlProtocol (*s); - - if (tcp->set_active (true)) { - delete tcp; - return 0; - } - - return tcp; - -} - -void -delete_tranzport_protocol (ControlProtocolDescriptor* descriptor, ControlProtocol* cp) -{ - delete cp; -} - -bool -probe_tranzport_protocol (ControlProtocolDescriptor* descriptor) -{ - return TranzportControlProtocol::probe(); -} - -static ControlProtocolDescriptor tranzport_descriptor = { - name : "Tranzport", - id : "uri://ardour.org/surfaces/tranzport:0", - module : 0, - probe : probe_tranzport_protocol, - initialize : new_tranzport_protocol, - destroy : delete_tranzport_protocol -}; - - -extern "C" { -ControlProtocolDescriptor* -protocol_descriptor () { - return &tranzport_descriptor; -} -} - diff --git a/libs/surfaces/frontier/tranzport/tranzport_control_protocol.cc b/libs/surfaces/frontier/tranzport/tranzport_control_protocol.cc deleted file mode 100644 index dd03f7814d..0000000000 --- a/libs/surfaces/frontier/tranzport/tranzport_control_protocol.cc +++ /dev/null @@ -1,1947 +0,0 @@ -/* - * Copyright (C) 2007-2017 Paul Davis - * Copyright (C) 2009-2010 David Robillard - * Copyright (C) 2010-2011 Carl Hetherington - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* Design notes: The tranzport is a unique device, basically a - 20 lcd gui with 22 shift keys and 8 blinking lights. - - As such it has several unique constraints. The device exerts flow control - by having a usb write fail. It is pointless to retry madly at that point, - the device is busy, and it's not going to become unbusy very quickly. - - So writes need to be either "mandatory" or "unreliable", and therein - lies the rub, as the kernel can also drop writes, and missing an - interrupt in userspace is also generally bad. - - It will be good one day, to break the gui, keyboard, and blinking light - components into separate parts, but for now, this remains monolithic. - - A more complex surface might have hundreds of lights and several displays. - - mike.taht@gmail.com - */ - -#define DEFAULT_USB_TIMEOUT 10 -#define MAX_RETRY 1 -#define MAX_TRANZPORT_INFLIGHT 4 -#define DEBUG_TRANZPORT 0 -#define HAVE_TRANZPORT_KERNEL_DRIVER 0 - -#include -#include -#include - -#define __STDC_FORMAT_MACROS -#include -#include -#include -#include - -#include "pbd/pthread_utils.h" - -#include "ardour/route.h" -#include "ardour/audio_track.h" -#include "ardour/tempo.h" -#include "ardour/location.h" -#include "ardour/dB.h" - -#include "tranzport_control_protocol.h" - -using namespace ARDOUR; -using namespace std; -using namespace sigc; -using namespace PBD; - -#include "pbd/i18n.h" - -#include "pbd/abstract_ui.cc" - -BaseUI::RequestType LEDChange = BaseUI::new_request_type (); -BaseUI::RequestType Print = BaseUI::new_request_type (); -BaseUI::RequestType SetCurrentTrack = BaseUI::new_request_type (); - -/* Base Tranzport cmd strings */ - -static const uint8_t cmd_light_on[] = { 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00 }; -static const uint8_t cmd_light_off[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; -static const uint8_t cmd_write_screen[] = { 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00 }; - -static inline double -gain_to_slider_position (ARDOUR::gain_t g) -{ - if (g == 0) return 0; - return pow((6.0*log(g)/log(2.0)+192.0)/198.0, 8.0); - -} - -static inline ARDOUR::gain_t -slider_position_to_gain (double pos) -{ - /* XXX Marcus writes: this doesn't seem right to me. but i don't have a better answer ... */ - if (pos == 0.0) return 0; - return pow (2.0,(sqrt(sqrt(sqrt(pos)))*198.0-192.0)/6.0); -} - - -TranzportControlProtocol::TranzportControlProtocol (Session& s) - : ControlProtocol (s, X_("Tranzport")) -{ - /* tranzport controls one track at a time */ - - set_route_table_size (1); - timeout = 6000; // what is this for? - buttonmask = 0; - _datawheel = 0; - _device_status = STATUS_OFFLINE; - udev = 0; - current_track_id = 0; - last_where = max_samples; - wheel_mode = WheelTimeline; - wheel_shift_mode = WheelShiftGain; - wheel_increment = WheelIncrScreen; - bling_mode = BlingOff; - timerclear (&last_wheel_motion); - last_wheel_dir = 1; - last_track_gain = FLT_MAX; - display_mode = DisplayNormal; - gain_fraction = 0.0; - invalidate(); - screen_init(); - lights_init(); - print(0,0,"!!Welcome to Ardour!!"); - print(1,0,"!Peace through Music!"); -} - -void TranzportControlProtocol::light_validate (LightID light) -{ - lights_invalid[light] = 0; -} - -void TranzportControlProtocol::light_invalidate (LightID light) -{ - lights_invalid[light] = 1; -} - -void TranzportControlProtocol::lights_validate () -{ - memset (lights_invalid, 0, sizeof (lights_invalid)); -} - -void TranzportControlProtocol::lights_invalidate () -{ - memset (lights_invalid, 1, sizeof (lights_invalid)); -} - -void TranzportControlProtocol::lights_init() -{ - for (uint32_t i = 0; i < sizeof(lights_current)/sizeof(lights_current[0]); i++) { - lights_invalid[i] = lights_current[i] = - lights_pending[i] = lights_flash[i] = false; - } -} - - - -int -TranzportControlProtocol::lights_flush () -{ - if ( _device_status == STATUS_OFFLINE) { return (0); } - - // Figure out iterators one day soon - // for (LightID i = i.start(), i = i.end(); i++) { - // if (lights_pending[i] != lights_current[i] || lights_invalid[i]) { - // if (light_set(i, lights_pending[i])) { - // return i-1; - // } - // } - //} - if ((lights_pending[LightRecord] != lights_current[LightRecord]) || lights_invalid[LightRecord]) { - if (light_set(LightRecord,lights_pending[LightRecord])) { - return 1; - } - } - if ((lights_pending[LightTrackrec] != lights_current[LightTrackrec]) || lights_invalid[LightTrackrec]) { - if (light_set(LightTrackrec,lights_pending[LightTrackrec])) { - return 1; - } - } - - if ((lights_pending[LightTrackmute] != lights_current[LightTrackmute]) || lights_invalid[LightTrackmute]) { - if (light_set(LightTrackmute,lights_pending[LightTrackmute])) { - return 1; - } - } - - if ((lights_pending[LightTracksolo] != lights_current[LightTracksolo]) || lights_invalid[LightTracksolo]) { - if (light_set(LightTracksolo,lights_pending[LightTracksolo])) { - return 1; - } - } - if ((lights_pending[LightAnysolo] != lights_current[LightAnysolo]) || lights_invalid[LightAnysolo]) { - if (light_set(LightAnysolo,lights_pending[LightAnysolo])) { - return 1; - } - } - if ((lights_pending[LightLoop] != lights_current[LightLoop]) || lights_invalid[LightLoop]) { - if (light_set(LightLoop,lights_pending[LightLoop])) { - return 1; - } - } - if ((lights_pending[LightPunch] != lights_current[LightPunch]) || lights_invalid[LightPunch]) { - if (light_set(LightPunch,lights_pending[LightPunch])) { - return 1; - } - } - - return 0; -} - -// Screen specific commands - -void -TranzportControlProtocol::screen_clear () -{ - const char *blank = " "; - print(0,0,blank); - print(1,0,blank); -} - -void TranzportControlProtocol::screen_invalidate () -{ - for(int row = 0; row < 2; row++) { - for(int col = 0; col < 20; col++) { - screen_invalid[row][col] = true; - screen_current[row][col] = 0x7f; - screen_pending[row][col] = ' '; - // screen_flash[row][col] = ' '; - } - } - // memset (&screen_invalid, 1, sizeof(screen_invalid)); - // memset (&screen_current, 0x7F, sizeof (screen_current)); // fill cache with a character we otherwise never use -} - -void TranzportControlProtocol::screen_validate () -{ -} - -void TranzportControlProtocol::screen_init () -{ - screen_invalidate(); -} - -int -TranzportControlProtocol::screen_flush () -{ - int cell = 0, row, col_base, col, pending = 0; - if ( _device_status == STATUS_OFFLINE) { return (-1); } - - for (row = 0; row < 2 && pending == 0; row++) { - for (col_base = 0, col = 0; col < 20 && pending == 0; ) { - if ((screen_pending[row][col] != screen_current[row][col]) - || screen_invalid[row][col]) { - - /* something in this cell is different, so dump the cell to the device. */ - - uint8_t cmd[8]; - cmd[0] = 0x00; - cmd[1] = 0x01; - cmd[2] = cell; - cmd[3] = screen_pending[row][col_base]; - cmd[4] = screen_pending[row][col_base+1]; - cmd[5] = screen_pending[row][col_base+2]; - cmd[6] = screen_pending[row][col_base+3]; - cmd[7] = 0x00; - - if(write(cmd) != 0) { - /* try to update this cell on the next go-round */ -#if DEBUG_TRANZPORT > 4 - printf("usb screen update failed for some reason... why? \ncmd and data were %02x %02x %02x %02x %02x %02x %02x %02x\n", - cmd[0],cmd[1],cmd[2], cmd[3], cmd[4], cmd[5],cmd[6],cmd[7]); -#endif - pending += 1; - // Shouldn't need to do this - // screen_invalid[row][col_base] = screen_invalid[row][col_base+1] = - // screen_invalid[row][col_base+2] = screen_invalid[row][col_base+3] = true; - - } else { - /* successful write: copy to current cached display */ - screen_invalid[row][col_base] = screen_invalid[row][col_base+1] = - screen_invalid[row][col_base+2] = screen_invalid[row][col_base+3] = false; - memcpy (&screen_current[row][col_base], &screen_pending[row][col_base], 4); - } - - /* skip the rest of the 4 character cell since we wrote+copied it already */ - - col_base += 4; - col = col_base; - cell++; - - } else { - - col++; - - if (col && col % 4 == 0) { - cell++; - col_base += 4; - } - } - } - } - return pending; -} - - -// Tranzport specific - -void TranzportControlProtocol::invalidate() -{ - lcd_damage(); lights_invalidate(); screen_invalidate(); // one of these days lcds can be fine but screens not -} - -TranzportControlProtocol::~TranzportControlProtocol () -{ - set_active (false); -} - - -int -TranzportControlProtocol::set_active (bool yn) -{ - if (yn != _active) { - - if (yn) { - - if (open ()) { - return -1; - } - - if (pthread_create_and_store (X_("tranzport monitor"), &thread, 0, _monitor_work, this) == 0) { - _active = true; - } else { - return -1; - } - - } else { - cerr << "Begin tranzport shutdown\n"; - screen_clear (); - lcd_damage(); - lights_off (); - for(int x = 0; x < 10 && flush(); x++) { usleep(1000); } - pthread_cancel_one (thread); - cerr << "Tranzport Thread dead\n"; - close (); - _active = false; - cerr << "End tranzport shutdown\n"; - } - } - - return 0; -} - -void -TranzportControlProtocol::show_track_gain () -{ - if (route_table[0]) { - gain_t g = route_get_gain (0); - if ((g != last_track_gain) || lcd_isdamaged(0,9,8)) { - char buf[16]; - snprintf (buf, sizeof (buf), "%6.1fdB", coefficient_to_dB (route_get_effective_gain (0))); - print (0, 9, buf); - last_track_gain = g; - } - } else { - print (0, 9, " "); - } -} - -void -TranzportControlProtocol::normal_update () -{ - show_current_track (); - show_transport_time (); - show_track_gain (); - show_wheel_mode (); -} - -void -TranzportControlProtocol::next_display_mode () -{ - switch (display_mode) { - - case DisplayNormal: - enter_big_meter_mode(); - break; - - case DisplayBigMeter: - enter_normal_display_mode(); - break; - - case DisplayRecording: - enter_normal_display_mode(); - break; - - case DisplayRecordingMeter: - enter_big_meter_mode(); - break; - - case DisplayConfig: - case DisplayBling: - case DisplayBlingMeter: - enter_normal_display_mode(); - break; - } -} - -// FIXME, these 3 aren't done yet - -void -TranzportControlProtocol::enter_recording_mode () -{ - lcd_damage(); // excessive - screen_clear (); - lights_off (); - display_mode = DisplayRecording; -} - -void -TranzportControlProtocol::enter_bling_mode () -{ - lcd_damage(); - screen_clear (); - lights_off (); - display_mode = DisplayBling; -} - -void -TranzportControlProtocol::enter_config_mode () -{ - lcd_damage(); - screen_clear (); - lights_off (); - display_mode = DisplayConfig; -} - - -void -TranzportControlProtocol::enter_big_meter_mode () -{ - screen_clear (); - lcd_damage(); - lights_off (); - last_meter_fill = 0; - display_mode = DisplayBigMeter; -} - -void -TranzportControlProtocol::enter_normal_display_mode () -{ - screen_clear (); - lcd_damage(); - lights_off (); - display_mode = DisplayNormal; - // normal_update(); -} - - -float -log_meter (float db) -{ - float def = 0.0f; /* Meter deflection %age */ - - if (db < -70.0f) return 0.0f; - if (db > 6.0f) return 1.0f; - - if (db < -60.0f) { - def = (db + 70.0f) * 0.25f; - } else if (db < -50.0f) { - def = (db + 60.0f) * 0.5f + 2.5f; - } else if (db < -40.0f) { - def = (db + 50.0f) * 0.75f + 7.5f; - } else if (db < -30.0f) { - def = (db + 40.0f) * 1.5f + 15.0f; - } else if (db < -20.0f) { - def = (db + 30.0f) * 2.0f + 30.0f; - } else if (db < 6.0f) { - def = (db + 20.0f) * 2.5f + 50.0f; - } - - /* 115 is the deflection %age that would be - when db=6.0. this is an arbitrary - endpoint for our scaling. - */ - - return def/115.0f; -} - -void -TranzportControlProtocol::show_meter () -{ - // you only seem to get a route_table[0] on moving forward - bug elsewhere - if (route_table[0] == 0) { - // Principle of least surprise - print (0, 0, "No audio to meter!!!"); - print (1, 0, "Select another track"); - return; - } - - float level = route_get_peak_input_power (0, 0); - float fraction = log_meter (level); - - /* Someday add a peak bar*/ - - /* we draw using a choice of a sort of double colon-like character ("::") or a single, left-aligned ":". - the screen is 20 chars wide, so we can display 40 different levels. compute the level, - then figure out how many "::" to fill. if the answer is odd, make the last one a ":" - */ - - uint32_t fill = (uint32_t) floor (fraction * 40); - char buf[22]; - uint32_t i; - - if (fill == last_meter_fill) { - /* nothing to do */ - return; - } - - last_meter_fill = fill; - - bool add_single_level = (fill % 2 != 0); - fill /= 2; - - if (fraction > 0.98) { - light_on (LightAnysolo); - } - - /* add all full steps */ - - for (i = 0; i < fill; ++i) { - buf[i] = 0x07; /* tranzport special code for 4 quadrant LCD block */ - } - - /* add a possible half-step */ - - if (i < 20 && add_single_level) { - buf[i] = 0x03; /* tranzport special code for 2 left quadrant LCD block */ - ++i; - } - - /* fill rest with space */ - - for (; i < 20; ++i) { - buf[i] = ' '; - } - - /* print() requires this */ - - buf[21] = '\0'; - - print (0, 0, buf); - print (1, 0, buf); -} - -void -TranzportControlProtocol::show_bbt (samplepos_t where) -{ - if ((where != last_where) || lcd_isdamaged(1,9,8)) { - char buf[16]; - Temporal::BBT_Time bbt; - session->tempo_map().bbt_time (where, bbt); - sprintf (buf, "%03" PRIu32 "|%02" PRIu32 "|%04" PRIu32, bbt.bars,bbt.beats,bbt.ticks); - last_bars = bbt.bars; - last_beats = bbt.beats; - last_ticks = bbt.ticks; - last_where = where; - - if(last_ticks < 1960) { print (1, 9, buf); } // save a write so we can do leds - - // if displaymode is recordmode show beats but not yet - lights_pending[LightRecord] = false; - lights_pending[LightAnysolo] = false; - switch(last_beats) { - case 1: if(last_ticks < 500 || last_ticks > 1960) lights_pending[LightRecord] = true; break; - default: if(last_ticks < 250) lights_pending[LightAnysolo] = true; - } - - // update lights for tempo one day - // if (bbt_upper_info_label) { - // TempoMap::Metric m (session->tempo_map().metric_at (when)); - // sprintf (buf, "%-5.2f", m.tempo().beats_per_minute()); - // bbt_lower_info_label->set_text (buf); - // sprintf (buf, "%g|%g", m.meter().beats_per_bar(), m.meter().note_divisor()); - // bbt_upper_info_label->set_text (buf); - } - } - - -void -TranzportControlProtocol::show_transport_time () -{ - show_bbt (session->transport_sample ()); -} - -void -TranzportControlProtocol::show_smpte (samplepos_t where) -{ - if ((where != last_where) || lcd_isdamaged(1,9,10)) { - - char buf[5]; - SMPTE::Time smpte; - - session->smpte_time (where, smpte); - - if (smpte.negative) { - sprintf (buf, "-%02" PRIu32 ":", smpte.hours); - } else { - sprintf (buf, " %02" PRIu32 ":", smpte.hours); - } - print (1, 8, buf); - - sprintf (buf, "%02" PRIu32 ":", smpte.minutes); - print (1, 12, buf); - - sprintf (buf, "%02" PRIu32 ":", smpte.seconds); - print (1, 15, buf); - - sprintf (buf, "%02" PRIu32, smpte.samples); - print_noretry (1, 18, buf); - - last_where = where; - } -} - -void* -TranzportControlProtocol::_monitor_work (void* arg) -{ - return static_cast(arg)->monitor_work (); -} - -// I note that these usb specific open, close, probe, read routines are basically -// pure boilerplate and could easily be abstracted elsewhere - -#if !HAVE_TRANZPORT_KERNEL_DRIVER - -bool -TranzportControlProtocol::probe () -{ - struct usb_bus *bus; - struct usb_device *dev; - - usb_init(); - usb_find_busses(); - usb_find_devices(); - - for (bus = usb_busses; bus; bus = bus->next) { - - for(dev = bus->devices; dev; dev = dev->next) { - if (dev->descriptor.idVendor == VENDORID && dev->descriptor.idProduct == PRODUCTID) { - return true; - } - } - } - - return false; -} - -int -TranzportControlProtocol::open () -{ - struct usb_bus *bus; - struct usb_device *dev; - - usb_init(); - usb_find_busses(); - usb_find_devices(); - - for (bus = usb_busses; bus; bus = bus->next) { - - for(dev = bus->devices; dev; dev = dev->next) { - if (dev->descriptor.idVendor != VENDORID) - continue; - if (dev->descriptor.idProduct != PRODUCTID) - continue; - return open_core (dev); - } - } - - error << _("Tranzport: no device detected") << endmsg; - return -1; -} - -int -TranzportControlProtocol::open_core (struct usb_device* dev) -{ - if (!(udev = usb_open (dev))) { - error << _("Tranzport: cannot open USB transport") << endmsg; - return -1; - } - - if (usb_claim_interface (udev, 0) < 0) { - error << _("Tranzport: cannot claim USB interface") << endmsg; - usb_close (udev); - udev = 0; - return -1; - } - - if (usb_set_configuration (udev, 1) < 0) { - cerr << _("Tranzport: cannot configure USB interface") << endmsg; - } - - return 0; -} - -int -TranzportControlProtocol::close () -{ - int ret = 0; - - if (udev == 0) { - return 0; - } - - if (usb_release_interface (udev, 0) < 0) { - error << _("Tranzport: cannot release interface") << endmsg; - ret = -1; - } - - if (usb_close (udev)) { - error << _("Tranzport: cannot close device") << endmsg; - udev = 0; - ret = 0; - } - - return ret; -} - -int TranzportControlProtocol::read(uint8_t *buf, uint32_t timeout_override) -{ - int val; - // Get smarter about handling usb errors soon. Like disconnect - // pthread_testcancel(); - val = usb_interrupt_read (udev, READ_ENDPOINT, (char *) buf, 8, 10); - // pthread_testcancel(); - return val; -} - - -int -TranzportControlProtocol::write_noretry (uint8_t* cmd, uint32_t timeout_override) -{ - int val; - if(inflight > MAX_TRANZPORT_INFLIGHT) { return (-1); } - val = usb_interrupt_write (udev, WRITE_ENDPOINT, (char*) cmd, 8, timeout_override ? timeout_override : timeout); - - if (val < 0) { -#if DEBUG_TRANZPORT - printf("usb_interrupt_write failed: %d\n", val); -#endif - return val; - } - - if (val != 8) { -#if DEBUG_TRANZPORT - printf("usb_interrupt_write failed: %d\n", val); -#endif - return -1; - } - ++inflight; - - return 0; - -} - -int -TranzportControlProtocol::write (uint8_t* cmd, uint32_t timeout_override) -{ -#if MAX_RETRY > 1 - int val; - int retry = 0; - if(inflight > MAX_TRANZPORT_INFLIGHT) { return (-1); } - - while((val = usb_interrupt_write (udev, WRITE_ENDPOINT, (char*) cmd, 8, timeout_override ? timeout_override : timeout))!=8 && retry++ < MAX_RETRY) { - printf("usb_interrupt_write failed, retrying: %d\n", val); - } - - if (retry == MAX_RETRY) { - printf("Too many retries on a tranzport write, aborting\n"); - } - - if (val < 0) { - printf("usb_interrupt_write failed: %d\n", val); - return val; - } - if (val != 8) { - printf("usb_interrupt_write failed: %d\n", val); - return -1; - } - ++inflight; - return 0; -#else - return (write_noretry(cmd,timeout_override)); -#endif - -} - -#else -#error Kernel API not defined yet for Tranzport -// Something like open(/dev/surface/tranzport/event) for reading and raw for writing) -#endif - -// We have a state "Unknown" - STOP USING SPACES FOR IT - switching to arrow character -// We have another state - no_retry. Misleading, as we still retry on the next pass -// I think it's pointless to keep no_retry and instead we should throttle writes -// We have an "displayed" screen -// We always draw into the pending screen, which could be any of several screens -// We have an active screen -// Print arg - we have -// setactive -// so someday I think we need a screen object. - -/* -screen_flash.clear(); -screen_flash.print(0,0,"Undone:"); // Someday pull the undo stack from somewhere -screen_flash.print(1,0,"Nextup:"); - -if(flash_messages && lcd.getactive() != screen_flash) lcd.setactive(screen_flash,2000); - -screen::setactive(screen_name,duration); // duration in ms -screen::getactive(); -*/ - - -int -TranzportControlProtocol::flush () -{ - int pending = 0; - if(!(pending = lights_flush())) { - pending = screen_flush(); - } - return pending; -} - -// doing these functions made me realize that screen_invalid should be lcd_isdamaged FIXME soon - -bool TranzportControlProtocol::lcd_damage() -{ - screen_invalidate(); - return true; -} - -bool TranzportControlProtocol::lcd_damage (int row, int col, int length) -{ - bool result = false; - int endcol = col+length-1; - if((endcol > 19)) { endcol = 19; } - if((row >= 0 && row < 2) && (col >=0 && col < 20)) { - for(int c = col; c < endcol; c++) { - screen_invalid[row][c] = true; - } - result = true; - } - return result; -} - -// Gotta switch to bitfields, this is collossally dumb -// Still working on the layering, arguably screen_invalid should be lcd_invalid - -bool TranzportControlProtocol::lcd_isdamaged () -{ - for(int r = 0; r < 2; r++) { - for(int c = 0; c < 20; c++) { - if(screen_invalid[r][c]) { -#if DEBUG_TRANZPORT > 5 - printf("row: %d,col: %d is damaged, should redraw it\n", r,c); -#endif - return true; - } - } - } - return false; -} - -bool TranzportControlProtocol::lcd_isdamaged (int row, int col, int length) -{ - bool result = 0; - int endcol = col+length; - if((endcol > 19)) { endcol = 19; } - if((row >= 0 && row < 2) && (col >=0 && col < 20)) { - for(int c = col; c < endcol; c++) { - if(screen_invalid[row][c]) { -#if DEBUG_TRANZPORT > 5 - printf("row: %d,col: %d is damaged, should redraw it\n", row,c); -#endif - return true; - } - } - } - return result; -} - -// lcd_clear would be a separate function for a smart display -// here it does nothing, but for the sake of completeness it should -// probably write the lcd, and while I'm on the topic it should probably -// take a row, col, length argument.... - -void -TranzportControlProtocol::lcd_clear () -{ - -} - -// These lcd commands are not universally used yet and may drop out of the api - -int -TranzportControlProtocol::lcd_flush () -{ - return 0; -} - -int -TranzportControlProtocol::lcd_write(uint8_t* cmd, uint32_t timeout_override) -{ - return write(cmd,timeout_override); -} - -void -TranzportControlProtocol::lcd_fill (uint8_t fill_char) -{ -} - -void -TranzportControlProtocol::lcd_print (int row, int col, const char* text) -{ - print(row,col,text); -} - -void TranzportControlProtocol::lcd_print_noretry (int row, int col, const char* text) -{ - print(row,col,text); -} - -// Lights are buffered - -void -TranzportControlProtocol::lights_on () -{ - lights_pending[LightRecord] = lights_pending[LightTrackrec] = - lights_pending[LightTrackmute] = lights_pending[LightTracksolo] = - lights_pending[LightAnysolo] = lights_pending[LightLoop] = - lights_pending[LightPunch] = true; -} - -void -TranzportControlProtocol::lights_off () -{ - lights_pending[LightRecord] = lights_pending[LightTrackrec] = - lights_pending[LightTrackmute] = lights_pending[LightTracksolo] = - lights_pending[LightAnysolo] = lights_pending[LightLoop] = - lights_pending[LightPunch] = false; -} - -int -TranzportControlProtocol::light_on (LightID light) -{ - lights_pending[light] = true; - return 0; -} - -int -TranzportControlProtocol::light_off (LightID light) -{ - lights_pending[light] = false; - return 0; -} - -int -TranzportControlProtocol::light_set (LightID light, bool offon) -{ - uint8_t cmd[8]; - cmd[0] = 0x00; cmd[1] = 0x00; cmd[2] = light; cmd[3] = offon; - cmd[4] = 0x00; cmd[5] = 0x00; cmd[6] = 0x00; cmd[7] = 0x00; - - if (write (cmd) == 0) { - lights_current[light] = offon; - lights_invalid[light] = false; - return 0; - } else { - return -1; - } -} - -int TranzportControlProtocol::rtpriority_set(int priority) -{ - struct sched_param rtparam; - int err; - // preallocate and memlock some stack with memlock? - char *a = (char*) alloca(4096*2); a[0] = 'a'; a[4096] = 'b'; - memset (&rtparam, 0, sizeof (rtparam)); - rtparam.sched_priority = priority; /* XXX should be relative to audio (JACK) thread */ - // Note - try SCHED_RR with a low limit - // - we don't care if we can't write everything this ms - // and it will help if we lose the device - if ((err = pthread_setschedparam (pthread_self(), SCHED_FIFO, &rtparam)) != 0) { - PBD::info << string_compose (_("%1: thread not running with realtime scheduling (%2)"), name(), strerror (errno)) << endmsg; - return 1; - } - return 0; -} - -// Running with realtime privs is bad when you have problems - -int TranzportControlProtocol::rtpriority_unset(int priority) -{ - struct sched_param rtparam; - int err; - memset (&rtparam, 0, sizeof (rtparam)); - rtparam.sched_priority = priority; - if ((err = pthread_setschedparam (pthread_self(), SCHED_FIFO, &rtparam)) != 0) { - PBD::info << string_compose (_("%1: can't stop realtime scheduling (%2)"), name(), strerror (errno)) << endmsg; - return 1; - } - PBD::info << string_compose (_("%1: realtime scheduling stopped (%2)"), name(), strerror (errno)) << endmsg; - return 0; -} - -// Slowly breaking this into where I can make usb processing it's own thread. - -void* -TranzportControlProtocol::monitor_work () -{ - uint8_t buf[8]; - int val = 0, pending = 0; - bool first_time = true; - uint8_t offline = 0; - - - PBD::notify_gui_about_thread_creation ("gui", pthread_self(), X_("Tranzport")); - pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, 0); - pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0); - next_track (); - rtpriority_set(); - inflight=0; - flush(); - - while (true) { - - /* bInterval for this beastie is 10ms */ - - if (_device_status == STATUS_OFFLINE) { - first_time = true; - if(offline++ == 1) { - cerr << "Transport has gone offline\n"; - } - } else { - offline = 0; // hate writing this - } - - val = read(buf); - - if (val == 8) { - process (buf); - } - -#if DEBUG_TRANZPORT > 2 - if(inflight > 1) printf("Inflight: %d\n", inflight); -#endif - - - if (_device_status != STATUS_OFFLINE) { - if (first_time) { - invalidate(); - lcd_clear (); - lights_off (); - first_time = false; - offline = 0; - pending = 3; // Give some time for the device to recover - } - /* update whatever needs updating */ - update_state (); - - /* still struggling with a good means of exerting flow control */ - // pending = flush(); - - if(pending == 0) { - pending = flush(); - } else { - if(inflight > 0) { - pending = --inflight; // we just did a whole bunch of writes so wait - } else { - pending = 0; - } - } - // pending = 0; - } - } - - return (void*) 0; -} - -int TranzportControlProtocol::lights_show_recording() -{ - // FIXME, flash recording light when recording and transport is moving - return lights_show_normal(); -} - -// gotta do bling next! - -int TranzportControlProtocol::lights_show_bling() -{ - switch (bling_mode) { - case BlingOff: break; - case BlingKit: break; // rotate rec/mute/solo/any solo back and forth - case BlingRotating: break; // switch between lights - case BlingPairs: break; // Show pairs of lights - case BlingRows: break; // light each row in sequence - case BlingFlashAll: break; // Flash everything randomly - } - return 0; -} - -int TranzportControlProtocol::lights_show_normal() -{ - /* Track only */ - - if (route_table[0]) { - std::shared_ptr at = std::dynamic_pointer_cast (route_table[0]); - lights_pending[LightTrackrec] = at && at->record_enabled(); - lights_pending[LightTrackmute] = route_get_muted(0); - lights_pending[LightTracksolo] = route_get_soloed(0); - } else { - lights_pending[LightTrackrec] = false; - lights_pending[LightTracksolo] = false; - lights_pending[LightTrackmute] = false; - } - - /* Global settings */ - - lights_pending[LightLoop] = session->get_play_loop(); - lights_pending[LightPunch] = Config->get_punch_in() || Config->get_punch_out(); - lights_pending[LightRecord] = session->get_record_enabled(); - lights_pending[LightAnysolo] = session->soloing(); - - return 0; -} - -int TranzportControlProtocol::lights_show_tempo() -{ - // someday soon fiddle with the lights based on the tempo - return lights_show_normal(); -} - -int -TranzportControlProtocol::update_state () -{ - /* do the text and light updates */ - - switch (display_mode) { - case DisplayBigMeter: - lights_show_tempo(); - show_meter (); - break; - - case DisplayNormal: - lights_show_normal(); - normal_update (); - break; - - case DisplayConfig: - break; - - case DisplayRecording: - lights_show_recording(); - normal_update(); - break; - - case DisplayRecordingMeter: - lights_show_recording(); - show_meter(); - break; - - case DisplayBling: - lights_show_bling(); - normal_update(); - break; - - case DisplayBlingMeter: - lights_show_bling(); - show_meter(); - break; - } - return 0; - -} - -#define TRANZPORT_BUTTON_HANDLER(callback, button_arg) if (button_changes & button_arg) { \ - if (buttonmask & button_arg) { \ - callback##_press (buttonmask&ButtonShift); } else { callback##_release (buttonmask&ButtonShift); } } - -int -TranzportControlProtocol::process (uint8_t* buf) -{ - // printf("read: %02x %02x %02x %02x %02x %02x %02x %02x\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); - - uint32_t this_button_mask; - uint32_t button_changes; - - _device_status = buf[1]; - - this_button_mask = 0; - this_button_mask |= buf[2] << 24; - this_button_mask |= buf[3] << 16; - this_button_mask |= buf[4] << 8; - this_button_mask |= buf[5]; - _datawheel = buf[6]; - - button_changes = (this_button_mask ^ buttonmask); - buttonmask = this_button_mask; - - if (_datawheel) { - datawheel (); - } - - // SHIFT + STOP + PLAY for bling mode? - // if (button_changes & ButtonPlay & ButtonStop) { - // bling_mode_toggle(); - // } or something like that - - TRANZPORT_BUTTON_HANDLER(button_event_battery,ButtonBattery); - TRANZPORT_BUTTON_HANDLER(button_event_backlight,ButtonBacklight); - TRANZPORT_BUTTON_HANDLER(button_event_trackleft,ButtonTrackLeft); - TRANZPORT_BUTTON_HANDLER(button_event_trackright,ButtonTrackRight); - TRANZPORT_BUTTON_HANDLER(button_event_trackrec,ButtonTrackRec); - TRANZPORT_BUTTON_HANDLER(button_event_trackmute,ButtonTrackMute); - TRANZPORT_BUTTON_HANDLER(button_event_tracksolo,ButtonTrackSolo); - TRANZPORT_BUTTON_HANDLER(button_event_undo,ButtonUndo); - TRANZPORT_BUTTON_HANDLER(button_event_in,ButtonIn); - TRANZPORT_BUTTON_HANDLER(button_event_out,ButtonOut); - TRANZPORT_BUTTON_HANDLER(button_event_punch,ButtonPunch); - TRANZPORT_BUTTON_HANDLER(button_event_loop,ButtonLoop); - TRANZPORT_BUTTON_HANDLER(button_event_prev,ButtonPrev); - TRANZPORT_BUTTON_HANDLER(button_event_add,ButtonAdd); - TRANZPORT_BUTTON_HANDLER(button_event_next,ButtonNext); - TRANZPORT_BUTTON_HANDLER(button_event_rewind,ButtonRewind); - TRANZPORT_BUTTON_HANDLER(button_event_fastforward,ButtonFastForward); - TRANZPORT_BUTTON_HANDLER(button_event_stop,ButtonStop); - TRANZPORT_BUTTON_HANDLER(button_event_play,ButtonPlay); - TRANZPORT_BUTTON_HANDLER(button_event_record,ButtonRecord); - return 0; -} - -void -TranzportControlProtocol::show_current_track () -{ - char pad[11]; - char *v; - int len; - if (route_table[0] == 0) { - print (0, 0, "----------"); - last_track_gain = FLT_MAX; - } else { - strcpy(pad," "); - v = (char *)route_get_name (0).substr (0, 10).c_str(); - if((len = strlen(v)) > 0) { - strncpy(pad,(char *)v,len); - } - print (0, 0, pad); - } -} - -void -TranzportControlProtocol::button_event_battery_press (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_battery_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_backlight_press (bool shifted) -{ -#if DEBUG_TRANZPORT - printf("backlight pressed\n"); -#endif -} - -void -TranzportControlProtocol::button_event_backlight_release (bool shifted) -{ -#if DEBUG_TRANZPORT - printf("backlight released\n\n"); -#endif - if (shifted) { - lcd_damage(); - lcd_clear(); - last_where += 1; /* force time redisplay */ - last_track_gain = FLT_MAX; - normal_update(); // redraw_screen(); - } -} - -void -TranzportControlProtocol::button_event_trackleft_press (bool shifted) -{ - prev_track (); -} - -void -TranzportControlProtocol::button_event_trackleft_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_trackright_press (bool shifted) -{ - next_track (); -} - -void -TranzportControlProtocol::button_event_trackright_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_trackrec_press (bool shifted) -{ - if (shifted) { - toggle_all_rec_enables (); - } else { - route_set_rec_enable (0, !route_get_rec_enable (0)); - } -} - -void -TranzportControlProtocol::button_event_trackrec_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_trackmute_press (bool shifted) -{ - if (shifted) { - // Mute ALL? Something useful when a phone call comes in. Mute master? - } else { - route_set_muted (0, !route_get_muted (0)); - } -} - -void -TranzportControlProtocol::button_event_trackmute_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_tracksolo_press (bool shifted) -{ -#if DEBUG_TRANZPORT - printf("solo pressed\n"); -#endif - if (display_mode == DisplayBigMeter) { - light_off (LightAnysolo); - return; - } - - if (shifted) { - session->set_all_solo (!session->soloing()); - } else { - route_set_soloed (0, !route_get_soloed (0)); - } -} - -void -TranzportControlProtocol::button_event_tracksolo_release (bool shifted) -{ -#if DEBUG_TRANZPORT - printf("solo released\n"); -#endif -} - -void -TranzportControlProtocol::button_event_undo_press (bool shifted) -{ - if (shifted) { - redo (); // someday flash the screen with what was redone - } else { - undo (); // someday flash the screen with what was undone - } -} - -void -TranzportControlProtocol::button_event_undo_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_in_press (bool shifted) -{ - if (shifted) { - toggle_punch_in (); - } else { - ControlProtocol::ZoomIn (); /* EMIT SIGNAL */ - } -} - -void -TranzportControlProtocol::button_event_in_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_out_press (bool shifted) -{ - if (shifted) { - toggle_punch_out (); - } else { - ControlProtocol::ZoomOut (); /* EMIT SIGNAL */ - } -} - -void -TranzportControlProtocol::button_event_out_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_punch_press (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_punch_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_loop_press (bool shifted) -{ - if (shifted) { - next_wheel_shift_mode (); - } else { - loop_toggle (); - } -} - -void -TranzportControlProtocol::button_event_loop_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_prev_press (bool shifted) -{ - if (shifted) { - ControlProtocol::ZoomToSession (); /* EMIT SIGNAL */ - } else { - prev_marker (); - } -} - -void -TranzportControlProtocol::button_event_prev_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_add_press (bool shifted) -{ - add_marker (); -} - -void -TranzportControlProtocol::button_event_add_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_next_press (bool shifted) -{ - if (shifted) { - next_wheel_mode (); - } else { - next_marker (); - } -} - -void -TranzportControlProtocol::button_event_next_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_rewind_press (bool shifted) -{ - if (shifted) { - goto_start (); - } else { - rewind (); - } -} - -void -TranzportControlProtocol::button_event_rewind_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_fastforward_press (bool shifted) -{ - if (shifted) { - goto_end (); - } else { - ffwd (); - } -} - -void -TranzportControlProtocol::button_event_fastforward_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_stop_press (bool shifted) -{ - if (shifted) { - next_display_mode (); - } else { - transport_stop (); - } -} - -void -TranzportControlProtocol::button_event_stop_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_play_press (bool shifted) -{ - if (shifted) { - set_transport_speed (1.0f); - } else { - transport_play (); - } -} - -void -TranzportControlProtocol::button_event_play_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_record_press (bool shifted) -{ - if (shifted) { - save_state (); - } else { - rec_enable_toggle (); - } -} - -void -TranzportControlProtocol::button_event_record_release (bool shifted) -{ -} - -void button_event_mute (bool pressed, bool shifted) -{ - static int was_pressed = 0; - // if(pressed) { } -} - -void -TranzportControlProtocol::datawheel () -{ - if ((buttonmask & ButtonTrackRight) || (buttonmask & ButtonTrackLeft)) { - - /* track scrolling */ - - if (_datawheel < WheelDirectionThreshold) { - next_track (); - } else { - prev_track (); - } - - timerclear (&last_wheel_motion); - - } else if ((buttonmask & ButtonPrev) || (buttonmask & ButtonNext)) { - - if (_datawheel < WheelDirectionThreshold) { - next_marker (); - } else { - prev_marker (); - } - - timerclear (&last_wheel_motion); - - } else if (buttonmask & ButtonShift) { - - /* parameter control */ - - if (route_table[0]) { - switch (wheel_shift_mode) { - case WheelShiftGain: - if (_datawheel < WheelDirectionThreshold) { - step_gain_up (); - } else { - step_gain_down (); - } - break; - case WheelShiftPan: - if (_datawheel < WheelDirectionThreshold) { - step_pan_right (); - } else { - step_pan_left (); - } - break; - - case WheelShiftMarker: - break; - - case WheelShiftMaster: - break; - - } - } - - timerclear (&last_wheel_motion); - - } else { - - switch (wheel_mode) { - case WheelTimeline: - scroll (); - break; - - case WheelScrub: - scrub (); - break; - - case WheelShuttle: - shuttle (); - break; - } - } -} - -void -TranzportControlProtocol::scroll () -{ - float m = 1.0; - if (_datawheel < WheelDirectionThreshold) { - m = 1.0; - } else { - m = -1.0; - } - switch(wheel_increment) { - case WheelIncrScreen: ScrollTimeline (0.2*m); break; - default: break; // other modes unimplemented as yet - } -} - -void -TranzportControlProtocol::scrub () -{ - float speed; - struct timeval now; - struct timeval delta; - int dir; - - gettimeofday (&now, 0); - - if (_datawheel < WheelDirectionThreshold) { - dir = 1; - } else { - dir = -1; - } - - if (dir != last_wheel_dir) { - /* changed direction, start over */ - speed = 0.1f; - } else { - if (timerisset (&last_wheel_motion)) { - - timersub (&now, &last_wheel_motion, &delta); - - /* 10 clicks per second => speed == 1.0 */ - - speed = 100000.0f / (delta.tv_sec * 1000000 + delta.tv_usec); - - } else { - - /* start at half-speed and see where we go from there */ - - speed = 0.5f; - } - } - - last_wheel_motion = now; - last_wheel_dir = dir; - - set_transport_speed (speed * dir); -} - -void -TranzportControlProtocol::config () -{ - // FIXME -} - -void -TranzportControlProtocol::shuttle () -{ - if (_datawheel < WheelDirectionThreshold) { - if (get_transport_speed() < 0) { - session->request_transport_speed (1.0); - } else { - session->request_transport_speed_nonzero (get_transport_speed() + 0.1); - } - } else { - if (get_transport_speed() > 0) { - session->request_transport_speed (-1.0); - } else { - session->request_transport_speed_nonzero (get_transport_speed() - 0.1); - } - } - session->request_roll (); -} - -void -TranzportControlProtocol::step_gain_up () -{ - if (buttonmask & ButtonStop) { - gain_fraction += 0.001; - } else { - gain_fraction += 0.01; - } - - if (gain_fraction > 2.0) { - gain_fraction = 2.0; - } - - route_set_gain (0, slider_position_to_gain (gain_fraction)); -} - -void -TranzportControlProtocol::step_gain_down () -{ - if (buttonmask & ButtonStop) { - gain_fraction -= 0.001; - } else { - gain_fraction -= 0.01; - } - - if (gain_fraction < 0.0) { - gain_fraction = 0.0; - } - - route_set_gain (0, slider_position_to_gain (gain_fraction)); -} - -void -TranzportControlProtocol::step_pan_right () -{ -} - -void -TranzportControlProtocol::step_pan_left () -{ -} - -void -TranzportControlProtocol::next_wheel_shift_mode () -{ - switch (wheel_shift_mode) { - case WheelShiftGain: - wheel_shift_mode = WheelShiftPan; - break; - case WheelShiftPan: - wheel_shift_mode = WheelShiftMaster; - break; - case WheelShiftMaster: - wheel_shift_mode = WheelShiftGain; - break; - case WheelShiftMarker: // Not done yet, disabled - wheel_shift_mode = WheelShiftGain; - break; - } - - show_wheel_mode (); -} - -void -TranzportControlProtocol::next_wheel_mode () -{ - switch (wheel_mode) { - case WheelTimeline: - wheel_mode = WheelScrub; - break; - case WheelScrub: - wheel_mode = WheelShuttle; - break; - case WheelShuttle: - wheel_mode = WheelTimeline; - } - - show_wheel_mode (); -} - -void -TranzportControlProtocol::next_track () -{ - ControlProtocol::next_track (current_track_id); - gain_fraction = gain_to_slider_position (route_get_effective_gain (0)); -} - -void -TranzportControlProtocol::prev_track () -{ - ControlProtocol::prev_track (current_track_id); - gain_fraction = gain_to_slider_position (route_get_effective_gain (0)); -} - -void -TranzportControlProtocol::show_wheel_mode () -{ - string text; - - switch (wheel_mode) { - case WheelTimeline: - text = "Time"; - break; - case WheelScrub: - text = "Scrb"; - break; - case WheelShuttle: - text = "Shtl"; - break; - } - - switch (wheel_shift_mode) { - case WheelShiftGain: - text += ":Gain"; - break; - - case WheelShiftPan: - text += ":Pan "; - break; - - case WheelShiftMaster: - text += ":Mstr"; - break; - - case WheelShiftMarker: - text += ":Mrkr"; - break; - } - - print (1, 0, text.c_str()); -} - -// Was going to keep state around saying to retry or not -// haven't got to it yet, still not sure it's a good idea - -void -TranzportControlProtocol::print (int row, int col, const char *text) { - print_noretry(row,col,text); -} - -void -TranzportControlProtocol::print_noretry (int row, int col, const char *text) -{ - int cell; - uint32_t left = strlen (text); - char tmp[5]; - int base_col; - - if (row < 0 || row > 1) { - return; - } - - if (col < 0 || col > 19) { - return; - } - - while (left) { - - if (col >= 0 && col < 4) { - cell = 0; - base_col = 0; - } else if (col >= 4 && col < 8) { - cell = 1; - base_col = 4; - } else if (col >= 8 && col < 12) { - cell = 2; - base_col = 8; - } else if (col >= 12 && col < 16) { - cell = 3; - base_col = 12; - } else if (col >= 16 && col < 20) { - cell = 4; - base_col = 16; - } else { - return; - } - - int offset = col % 4; - - /* copy current cell contents into tmp */ - - memcpy (tmp, &screen_pending[row][base_col], 4); - - /* overwrite with new text */ - - uint32_t tocopy = min ((4U - offset), left); - - memcpy (tmp+offset, text, tocopy); - - /* copy it back to pending */ - - memcpy (&screen_pending[row][base_col], tmp, 4); - - text += tocopy; - left -= tocopy; - col += tocopy; - } -} - -XMLNode& -TranzportControlProtocol::get_state () const -{ - return ControlProtocol::get_state(); -} - -int -TranzportControlProtocol::set_state (const XMLNode& node) -{ - return 0; -} - -int -TranzportControlProtocol::save (char *name) -{ - // Presently unimplemented - return 0; -} - -int -TranzportControlProtocol::load (char *name) -{ - // Presently unimplemented - return 0; -} diff --git a/libs/surfaces/frontier/tranzport/tranzport_control_protocol.h b/libs/surfaces/frontier/tranzport/tranzport_control_protocol.h deleted file mode 100644 index 335c6b440b..0000000000 --- a/libs/surfaces/frontier/tranzport/tranzport_control_protocol.h +++ /dev/null @@ -1,320 +0,0 @@ - -#ifndef ardour_tranzport_control_protocol_h -#define ardour_tranzport_control_protocol_h - -#include - -#include -#include -#include - -#include - -#include "ardour/types.h" - -#include "control_protocol/control_protocol.h" - -class TranzportControlProtocol : public ARDOUR::ControlProtocol -{ - public: - TranzportControlProtocol (ARDOUR::Session&); - virtual ~TranzportControlProtocol(); - - int set_active (bool yn); - - static bool probe (); - - XMLNode& get_state () const; - int set_state (const XMLNode&); - - private: - static const int VENDORID = 0x165b; - static const int PRODUCTID = 0x8101; - static const int READ_ENDPOINT = 0x81; - static const int WRITE_ENDPOINT = 0x02; - const static int STATUS_OFFLINE = 0xff; - const static int STATUS_ONLINE = 0x01; - const static uint8_t WheelDirectionThreshold = 0x3f; - - enum LightID { - LightRecord = 0, - LightTrackrec, - LightTrackmute, - LightTracksolo, - LightAnysolo, - LightLoop, - LightPunch - }; - - enum ButtonID { - ButtonBattery = 0x00004000, - ButtonBacklight = 0x00008000, - ButtonTrackLeft = 0x04000000, - ButtonTrackRight = 0x40000000, - ButtonTrackRec = 0x00040000, - ButtonTrackMute = 0x00400000, - ButtonTrackSolo = 0x00000400, - ButtonUndo = 0x80000000, - ButtonIn = 0x02000000, - ButtonOut = 0x20000000, - ButtonPunch = 0x00800000, - ButtonLoop = 0x00080000, - ButtonPrev = 0x00020000, - ButtonAdd = 0x00200000, - ButtonNext = 0x00000200, - ButtonRewind = 0x01000000, - ButtonFastForward = 0x10000000, - ButtonStop = 0x00010000, - ButtonPlay = 0x00100000, - ButtonRecord = 0x00000100, - ButtonShift = 0x08000000 - }; - - enum WheelShiftMode { - WheelShiftGain, - WheelShiftPan, - WheelShiftMaster, - WheelShiftMarker - }; - - enum WheelMode { - WheelTimeline, - WheelScrub, - WheelShuttle - }; - - // FIXME - look at gtk2_ardour for snap settings - - enum WheelIncrement { - WheelIncrSlave, - WheelIncrScreen, - WheelIncrSample, - WheelIncrBeat, - WheelIncrBar, - WheelIncrSecond, - WheelIncrMinute - }; - - enum DisplayMode { - DisplayNormal, - DisplayRecording, - DisplayRecordingMeter, - DisplayBigMeter, - DisplayConfig, - DisplayBling, - DisplayBlingMeter - }; - - enum BlingMode { - BlingOff, - BlingKit, - BlingRotating, - BlingPairs, - BlingRows, - BlingFlashAll - }; - - pthread_t thread; - uint32_t buttonmask; - uint32_t timeout; - uint32_t inflight; - uint8_t _datawheel; - uint8_t _device_status; - uint32_t current_track_id; - WheelMode wheel_mode; - WheelShiftMode wheel_shift_mode; - DisplayMode display_mode; - BlingMode bling_mode; - WheelIncrement wheel_increment; - usb_dev_handle* udev; - - ARDOUR::gain_t gain_fraction; - - Glib::Threads::Mutex update_lock; - - bool screen_invalid[2][20]; - char screen_current[2][20]; - char screen_pending[2][20]; - char screen_flash[2][20]; - - bool lights_invalid[7]; - bool lights_current[7]; - bool lights_pending[7]; - bool lights_flash[7]; - - uint32_t last_bars; - uint32_t last_beats; - uint32_t last_ticks; - - bool last_negative; - uint32_t last_hrs; - uint32_t last_mins; - uint32_t last_secs; - uint32_t last_samples; - samplepos_t last_where; - ARDOUR::gain_t last_track_gain; - uint32_t last_meter_fill; - uint64_t last_wheel_motion; - int last_wheel_dir; - - Glib::Mutex io_lock; - - int open (); - int read (uint8_t *buf,uint32_t timeout_override = 0); - int write (uint8_t* cmd, uint32_t timeout_override = 0); - int write_noretry (uint8_t* cmd, uint32_t timeout_override = 0); - int close (); - int save(char *name = "default"); - int load(char *name = "default"); - void print (int row, int col, const char* text); - void print_noretry (int row, int col, const char* text); - - int rtpriority_set(int priority = 52); - int rtpriority_unset(int priority = 0); - - int open_core (struct usb_device*); - - static void* _monitor_work (void* arg); - void* monitor_work (); - - int process (uint8_t *); - int update_state(); - void invalidate(); - int flush(); - // bool isuptodate(); // think on this. It seems futile to update more than 30/sec - - // A screen is a cache of what should be on the lcd - - void screen_init(); - void screen_validate(); - void screen_invalidate(); - int screen_flush(); - void screen_clear(); - // bool screen_isuptodate(); // think on this - - - // Commands to write to the lcd - - int lcd_init(); - bool lcd_damage(); - bool lcd_isdamaged(); - - bool lcd_damage(int row, int col = 0, int length = 20); - bool lcd_isdamaged(int row, int col = 0, int length = 20); - - int lcd_flush(); - int lcd_write(uint8_t* cmd, uint32_t timeout_override = 0); // pedantic alias for write - void lcd_fill (uint8_t fill_char); - void lcd_clear (); - void lcd_print (int row, int col, const char* text); - void lcd_print_noretry (int row, int col, const char* text); - - // Commands to write to the lights - // FIXME - on some devices lights can have intensity and colors - - void lights_init(); - void lights_validate(); - void lights_invalidate(); - void light_validate(LightID light); - void light_invalidate(LightID light); - int lights_flush(); - int lights_write(uint8_t* cmd,uint32_t timeout_override = 0); // pedantic alias to write - - // a cache of what should be lit - - void lights_off (); - void lights_on (); - int light_set(LightID, bool offon = true); - int light_on (LightID); - int light_off (LightID); - - // some modes for the lights, should probably be renamed - - int lights_show_normal(); - int lights_show_recording(); - int lights_show_tempo(); - int lights_show_bling(); - - void enter_big_meter_mode (); - void enter_normal_display_mode (); - void enter_config_mode(); - void enter_recording_mode(); - void enter_bling_mode(); - - void next_display_mode (); - void normal_update (); - - void show_current_track (); - void show_track_gain (); - void show_transport_time (); - void show_bbt (samplepos_t where); - void show_smpte (samplepos_t where); - void show_wheel_mode (); - void show_gain (); - void show_pan (); - void show_meter (); - - void datawheel (); - void scrub (); - void scroll (); - void shuttle (); - void config (); - - void next_wheel_mode (); - void next_wheel_shift_mode (); - - void set_current_track (ARDOUR::Route*); - void next_track (); - void prev_track (); - void step_gain_up (); - void step_gain_down (); - void step_pan_right (); - void step_pan_left (); - - - void button_event_battery_press (bool shifted); - void button_event_battery_release (bool shifted); - void button_event_backlight_press (bool shifted); - void button_event_backlight_release (bool shifted); - void button_event_trackleft_press (bool shifted); - void button_event_trackleft_release (bool shifted); - void button_event_trackright_press (bool shifted); - void button_event_trackright_release (bool shifted); - void button_event_trackrec_press (bool shifted); - void button_event_trackrec_release (bool shifted); - void button_event_trackmute_press (bool shifted); - void button_event_trackmute_release (bool shifted); - void button_event_tracksolo_press (bool shifted); - void button_event_tracksolo_release (bool shifted); - void button_event_undo_press (bool shifted); - void button_event_undo_release (bool shifted); - void button_event_in_press (bool shifted); - void button_event_in_release (bool shifted); - void button_event_out_press (bool shifted); - void button_event_out_release (bool shifted); - void button_event_punch_press (bool shifted); - void button_event_punch_release (bool shifted); - void button_event_loop_press (bool shifted); - void button_event_loop_release (bool shifted); - void button_event_prev_press (bool shifted); - void button_event_prev_release (bool shifted); - void button_event_add_press (bool shifted); - void button_event_add_release (bool shifted); - void button_event_next_press (bool shifted); - void button_event_next_release (bool shifted); - void button_event_rewind_press (bool shifted); - void button_event_rewind_release (bool shifted); - void button_event_fastforward_press (bool shifted); - void button_event_fastforward_release (bool shifted); - void button_event_stop_press (bool shifted); - void button_event_stop_release (bool shifted); - void button_event_play_press (bool shifted); - void button_event_play_release (bool shifted); - void button_event_record_press (bool shifted); - void button_event_record_release (bool shifted); - - // new api - void button_event_mute (bool pressed, bool shifted); -}; - - -#endif // ardour_tranzport_control_protocol_h diff --git a/libs/surfaces/frontier/wscript b/libs/surfaces/frontier/wscript deleted file mode 100644 index 7acc191129..0000000000 --- a/libs/surfaces/frontier/wscript +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python -import os - -def options(opt): - pass - -def configure(conf): - pass - -def build(bld): - # Generic MIDI - obj = bld(features = 'cxx cxxshlib') - obj.source = ''' - generic_midi_control_protocol.cc - interface.cc - midicontrollable.cc - ''' - obj.defines = [ 'PACKAGE="ardour_frontier"' ] - obj.defines += [ 'ARDOURSURFACE_DLL_EXPORTS' ] - obj.includes = ['.', './generic_midi'] - obj.name = 'libgeneric_midi' - obj.target = 'generic_midi' - obj.uselib = 'XML OSX' - obj.use = 'libardour libardourcp' - obj.install_path = os.path.join(bld.env['LIBDIR'], 'surfaces') diff --git a/libs/surfaces/tranzport/README b/libs/surfaces/tranzport/README deleted file mode 100644 index e2d37c84bf..0000000000 --- a/libs/surfaces/tranzport/README +++ /dev/null @@ -1,90 +0,0 @@ - -I'm putting this here because I don't really have a place to put it, unless I create a web page and have a place to keep the code. - -While doing some exaustive testing of my latest code (read - playing a ton of music) I have done some thinking about the ui, and decided that under apparent simplicity should lie complexity. - -The "flash" screen idea I am going to drop, and replace it with the idea of a notify area being declared on each screen. - -When the unit is idle, these messages will appear in that area statically. When the transport is running, these messages will still appear in that space, which is usually where the meter is. It's actually possible to rapidly flash the area between the competing writers and get a nifty faded effect. (I came across this idea accidentally when I had a pointer overrun) - -Also certain things will update on top of each other, whatever was updated -last will stay on the screen. This is Pan/Gain primarily. - -I need a way to get messages back into the tranzport. Example - I hit Undo, what was undone? Redo, same problem. - -I've already found many uses for being able to control more than 1 track at a time, so I think that although I'm *usually* controlling one track at a time, being able to quickly access all tracks would be good. - -Example - want to have meters for all tracks running and be able to control the -db/pan settings of the track I'm on.... - -What I am going to go with is multifold - but first my design goal: I want to do everything required for a solo musician wielding an instrument to NOT have to touch a keyboard or look at a big screen. When you are wrapped behind a bass, it's difficult to cope with that - but the tranzport is a great alternative. - -Most screens will have *4* items on them. - -There will be "display views" - which are more informational and bling oriented. - -There will be "Track based views"- which basically do track specific things - -There will be "interactive views",which basically allow for more input than output. They will do something to highlight the current selection. -Scroll wheel will select between values for a field. Track Next/Prev will move between fields. I would like to have a "No/Yes" option (hit record for yes? Stop for no?) but I'm still a little vague on that. - -Things to do: - -A) Hitting "Shift->Spacebar" will switch "views". There are ultimately going to be dozens of views. At present, there are only the "Normal" and "Big Meter" views. - -Each view will change somewhat based on the state of the transport. Holding down shift for a second will switch to the "underlying display".... - -Here's how the "normal" view looks today in my tree: - -VIEW: NORMAL - -Play Mode: Stopped -[Trackname[16]] [gain/pan[4]] -[Modes[9]] long smpte/bar counter] - -Play Mode: Playing > 1.0 speed -[Trackname[16]] [gain/pan[4]] -[meter[16]] short smpte/bar counter] - -Play Mode: Playing < 1.0 -[Trackname[16]] [gain/pan[4]] -[meter[9]] long smpte/bar counter] - -Play Mode: Recording -[Trackname[16]] [gain/pan[4]] -[meter[16]] short smpte/bar counter] - -Other views (in order of development priority) - -Marker Mode: Edit markers, setup loops and punch in points. -Config Mode: Load/Save settings, Load/Save project. Set wheel SnapTo -Loop Mode: Show track, raise layers to top for playback, editing, deletion, loop on and off, etc - -It's possible that config mode will have a "MORE" field, or ways to move around the configuration (ffw/Play?) - -(the first two are the two modes I most need personally. If you have a suggestion...) - -Mastering Mode - display master and current track with meters and panner/db -Automation Mode - I really don't think I have the pixels for this - -(I've already abstracted out the code to do most of these, but it's bling, I'm not going to bother much with it soon) - -Quad Meter Mode -Inverted Meter mode (draws meters backwards) -Quad Inverted Meter mode (bling, but my car stereo has it, and it's cool) -10 8 bar meter mode -5 8 bar meter mode - -I haven't written the panner yet, doing the stereo meter killed me. - -From a development perspective I'm going to keep revising the code to make it more stable and merely tie the new mode modes to the "bling mode"s until they are ready for prime time. I should be able to put out releases once a week for a while. - -A big help would be moving these items into a higher level of abstraction (revising the baseUI class). - -In particular, I'd really like "slave" mode. Snapto increment is really important.... - -Here's an example of something that should be fairly easy to export to the Base::UI subclasses - the current state of the main keyboard's shift key. - -That way, when shift is held down for a few seconds on the regular keyboard, I can see what's underneath the current tranzport display mode (I do like big meters) (Also, it's somewhat easier to hit shift on the main keyboard and play on the tranzport or the shuttle wheel, if that's what you are doing). - -Should be fairly easy to tap into the gdk event for this but the "right way" to propagate this event into the class is beyond me. diff --git a/libs/surfaces/tranzport/TODO b/libs/surfaces/tranzport/TODO deleted file mode 100644 index 216a5bc9d0..0000000000 --- a/libs/surfaces/tranzport/TODO +++ /dev/null @@ -1,6 +0,0 @@ -BREAK APART DRIVER INTO SIMPLER CHUNKS - done -GET KERNEL DRIVER WORKING -GET TRIPLE THREADED DRIVER WORKING -STABLIZE THE API -ADOPT SOME CONVENTIONS FROM THE MACKIE -GET SAVING STATE WORKING diff --git a/libs/surfaces/tranzport/bling.cc b/libs/surfaces/tranzport/bling.cc deleted file mode 100644 index 308430af68..0000000000 --- a/libs/surfaces/tranzport/bling.cc +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -/* The Bling class theoretically knows nothing about the device it's blinging - and depends on the overlying implementation to tell it about the format of the - device. Maybe this will become a template or people will inherit from it */ - -/* Bling is where all the bad, bad, marketing driven ideas go */ - -class bling { -public: - enum BlingMode { - BlingOff = 0, - BlingOn = 1, - BlingEnter = 2, - BlingExit = 4, - // Light Specific Stuff - BlingKit = 8, - BlingRotating = 16, - BlingPairs = 32, - BlingRows = 64, - BlingColumns = 128, - BlingFlashAllLights = 256, - // Screen Specific Stuff - // Slider Specific Stuff - BlingSliderMax, - BlingSliderMid, - BlingSliderMin, - // Random stuff - BlingRandomLight, - BlingRandomSlider, - BlingRandomScreen, - BlingAllSliders - }; - bling(); - ~bling(); - set(BlingMode); - unset(BlingMode); - run(); - next(); - prev(); - msg(string&); - scrollmsg(string&); - -protected: -// The as yet undefined "advanced_ui" class provides methods to find out at run time -// what the heck is what - BlingMode blingmode; - advancedUI *intf; - int last_light; -// I don't think these actually need to be part of the public definition of the class - enter(); - exit(); - rotate(); -// etc -}; - -// make absolutely sure we have the pointer to the interface -// something like this - -#define BLING_INTFA(a) (intf)? 0:intf->a -#define BLING_INTF(a) { if (intf) { intf->a; } else { return 0; } } - -// Should any of these bother to return a status code? - -bling::rotate() { - BLING_INTF(light(last_light,off)); - last_light = BLING_INTFA(next_light(last_light)); - BLING_INTF(light(last_light,on)); -} - -bling::enter() { -} - -bling::exit() { -} - -bling::flashall() { -} - -bling::rows() { -} - -bling::columns() { -} - -bling::msg() { -} - -bling::scrollmsg() { -} - -// Based on the current bling mode, do whatever it is you are going to do -bling::run() { - -} - -// etc diff --git a/libs/surfaces/tranzport/button_events.cc b/libs/surfaces/tranzport/button_events.cc deleted file mode 100644 index eeb16d702a..0000000000 --- a/libs/surfaces/tranzport/button_events.cc +++ /dev/null @@ -1,380 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -#include -#include - -using namespace ARDOUR; -using namespace std; -using namespace sigc; -using namespace PBD; - -#include "pbd/i18n.h" - -#include - - - -void -TranzportControlProtocol::button_event_battery_press (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_battery_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_backlight_press (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_backlight_release (bool shifted) -{ -#if DEBUG_TRANZPORT - printf("backlight released, redrawing (and possibly crashing) display\n"); -#endif - if (shifted) { - lcd_damage(); - lcd_clear(); - last_where += 1; /* force time redisplay */ - last_track_gain = FLT_MAX; - } -} - -void -TranzportControlProtocol::button_event_trackleft_press (bool shifted) -{ - prev_track (); - // not really the right layer for this - if(display_mode == DisplayBigMeter) { - if (route_table[0] != 0) { - notify(route_get_name (0).substr (0, 15).c_str()); - } - } -} - -void -TranzportControlProtocol::button_event_trackleft_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_trackright_press (bool shifted) -{ - next_track (); - // not really the right layer for this - if(display_mode == DisplayBigMeter) { - if (route_table[0] != 0) { - notify(route_get_name (0).substr (0, 15).c_str()); - } - } -} - -void -TranzportControlProtocol::button_event_trackright_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_trackrec_press (bool shifted) -{ - if (shifted) { - toggle_all_rec_enables (); - } else { - route_set_rec_enable (0, !route_get_rec_enable (0)); - } -} - -void -TranzportControlProtocol::button_event_trackrec_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_trackmute_press (bool shifted) -{ - if (shifted) { - // Mute ALL? Something useful when a phone call comes in. Mute master? - } else { - route_set_muted (0, !route_get_muted (0)); - } -} - -void -TranzportControlProtocol::button_event_trackmute_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_tracksolo_press (bool shifted) -{ -#if DEBUG_TRANZPORT - printf("solo pressed\n"); -#endif - if (display_mode == DisplayBigMeter) { - light_off (LightAnysolo); - return; - } - - if (shifted) { - session->set_all_solo (!session->soloing()); - } else { - route_set_soloed (0, !route_get_soloed (0)); - } -} - -void -TranzportControlProtocol::button_event_tracksolo_release (bool shifted) -{ -#if DEBUG_TRANZPORT - printf("solo released\n"); -#endif -} - -void -TranzportControlProtocol::button_event_undo_press (bool shifted) -{ -// undohistory->get_state(1); -//XMLNode& -//UndoHistory::get_state (uint32_t depth) - - if (shifted) { - redo (); // someday flash the screen with what was redone - notify("Redone!!"); - } else { - undo (); // someday flash the screen with what was undone - notify("Undone!!"); - } -} - -void -TranzportControlProtocol::button_event_undo_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_in_press (bool shifted) -{ - if (shifted) { - toggle_punch_in (); - } else { - ControlProtocol::ZoomIn (); /* EMIT SIGNAL */ - } -} - -void -TranzportControlProtocol::button_event_in_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_out_press (bool shifted) -{ - if (shifted) { - toggle_punch_out (); - } else { - ControlProtocol::ZoomOut (); /* EMIT SIGNAL */ - } -} - -void -TranzportControlProtocol::button_event_out_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_punch_press (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_punch_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_loop_press (bool shifted) -{ - if (shifted) { - next_wheel_shift_mode (); - } else { - loop_toggle (); - } -} - -void -TranzportControlProtocol::button_event_loop_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_prev_press (bool shifted) -{ - if (shifted) { - ControlProtocol::ZoomToSession (); /* EMIT SIGNAL */ - } else { - prev_marker (); - } -} - -void -TranzportControlProtocol::button_event_prev_release (bool shifted) -{ -} - -// Note - add_marker should adhere to the snap to setting -// maybe session->audible_sample does that - -void -TranzportControlProtocol::button_event_add_press (bool shifted) -{ - add_marker (); -} - -void -TranzportControlProtocol::button_event_add_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_next_press (bool shifted) -{ - if (shifted) { - next_wheel_mode (); - } else { - next_marker (); - } -} - -void -TranzportControlProtocol::button_event_next_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_rewind_press (bool shifted) -{ - if (shifted) { - goto_start (); - } else { - rewind (); - } -} - -void -TranzportControlProtocol::button_event_rewind_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_fastforward_press (bool shifted) -{ - if (shifted) { - goto_end (); - } else { - ffwd (); - } -} - -void -TranzportControlProtocol::button_event_fastforward_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_stop_press (bool shifted) -{ - if (shifted) { - next_display_mode (); - } else { - transport_stop (); - } -} - -void -TranzportControlProtocol::button_event_stop_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_play_press (bool shifted) -{ - if (shifted) { - set_transport_speed (1.0f); - } else { - transport_play (); - } -} - -void -TranzportControlProtocol::button_event_play_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_record_press (bool shifted) -{ - if (shifted) { - save_state (); - } else { - rec_enable_toggle (); - } -} - -void -TranzportControlProtocol::button_event_record_release (bool shifted) -{ -} - -void -TranzportControlProtocol::button_event_footswitch_press (bool shifted) -{ - if (shifted) { - next_marker (); // think this through, we could also do punch in - } else { - prev_marker (); // think this through, we could also do punch in - } -} - -void -TranzportControlProtocol::button_event_footswitch_release (bool shifted) -{ - if(get_transport_speed() == 0.0) - { - transport_play (); - } -} - -// Possible new api example -// tries harder to do the right thing if we somehow missed a button down event -// which currently happens... a lot. - -void button_event_mute (bool pressed, bool shifted) -{ - static int was_pressed = 0; - if((!pressed && !was_pressed) || pressed) { - was_pressed = 1; - } - - was_pressed = 0; -} diff --git a/libs/surfaces/tranzport/button_yn.cc b/libs/surfaces/tranzport/button_yn.cc deleted file mode 100644 index 56d6d379cf..0000000000 --- a/libs/surfaces/tranzport/button_yn.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -/* placeholder for button definitions for user edits like yes/no */ diff --git a/libs/surfaces/tranzport/buttons.cc b/libs/surfaces/tranzport/buttons.cc deleted file mode 100644 index a35f025489..0000000000 --- a/libs/surfaces/tranzport/buttons.cc +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -#include "tranzport_control_protocol.h" - -#define TRANZPORT_BUTTON_HANDLER(callback, button_arg) if (button_changes & button_arg) { \ - if (buttonmask & button_arg) { \ - callback##_press (buttonmask&ButtonShift); } else { callback##_release (buttonmask&ButtonShift); } } - -int -TranzportControlProtocol::process (uint8_t* buf) -{ - - uint32_t this_button_mask; - uint32_t button_changes; - - _device_status = buf[1]; - -#if DEBUG_TRANZPORT > 10 - // Perhaps the device can go offline due to flow control, print command bits to see if we have anything interesting - if(_device_status == STATUS_ONLINE) { - printf("ONLINE : %02x %02x %02x %02x %02x %02x %02x %02x\n", - buf[0],buf[1],buf[2], buf[3], buf[4], buf[5],buf[6],buf[7]); - } - if(_device_status == STATUS_OFFLINE) { - printf("OFFLINE : %02x %02x %02x %02x %02x %02x %02x %02x\n", - buf[0],buf[1],buf[2], buf[3], buf[4], buf[5],buf[6],buf[7]); - } - - if(_device_status != STATUS_OK) { return 1; } - -#endif - - - this_button_mask = 0; - this_button_mask |= buf[2] << 24; - this_button_mask |= buf[3] << 16; - this_button_mask |= buf[4] << 8; - this_button_mask |= buf[5]; - _datawheel = buf[6]; - -#if DEBUG_TRANZPORT_STATE > 1 - // Is the state machine incomplete? - const unsigned int knownstates = 0x00004000|0x00008000| - 0x04000000| 0x40000000| 0x00040000| 0x00400000| - 0x00000400| 0x80000000| 0x02000000| 0x20000000| - 0x00800000| 0x00080000| 0x00020000| 0x00200000| - 0x00000200| 0x01000000| 0x10000000| 0x00010000| - 0x00100000| 0x00000100| 0x08000000| 0x00001000; - - std::bitset<32> bi(knownstates); - std::bitset<32> vi(this_button_mask); - - // if an bi & vi == vi the same - it's a valid set - - if(vi != (bi & vi)) { - printf("UNKNOWN STATE: %s also, datawheel= %d\n", vi.to_string().c_str(), _datawheel); - } -#endif - - button_changes = (this_button_mask ^ buttonmask); - buttonmask = this_button_mask; - - if (_datawheel) { - datawheel (); - } - - // SHIFT + STOP + PLAY for bling mode? - // if (button_changes & ButtonPlay & ButtonStop) { - // bling_mode_toggle(); - // } or something like that - - TRANZPORT_BUTTON_HANDLER(button_event_battery,ButtonBattery); - TRANZPORT_BUTTON_HANDLER(button_event_backlight,ButtonBacklight); - TRANZPORT_BUTTON_HANDLER(button_event_trackleft,ButtonTrackLeft); - TRANZPORT_BUTTON_HANDLER(button_event_trackright,ButtonTrackRight); - TRANZPORT_BUTTON_HANDLER(button_event_trackrec,ButtonTrackRec); - TRANZPORT_BUTTON_HANDLER(button_event_trackmute,ButtonTrackMute); - TRANZPORT_BUTTON_HANDLER(button_event_tracksolo,ButtonTrackSolo); - TRANZPORT_BUTTON_HANDLER(button_event_undo,ButtonUndo); - TRANZPORT_BUTTON_HANDLER(button_event_in,ButtonIn); - TRANZPORT_BUTTON_HANDLER(button_event_out,ButtonOut); - TRANZPORT_BUTTON_HANDLER(button_event_punch,ButtonPunch); - TRANZPORT_BUTTON_HANDLER(button_event_loop,ButtonLoop); - TRANZPORT_BUTTON_HANDLER(button_event_prev,ButtonPrev); - TRANZPORT_BUTTON_HANDLER(button_event_add,ButtonAdd); - TRANZPORT_BUTTON_HANDLER(button_event_next,ButtonNext); - TRANZPORT_BUTTON_HANDLER(button_event_rewind,ButtonRewind); - TRANZPORT_BUTTON_HANDLER(button_event_fastforward,ButtonFastForward); - TRANZPORT_BUTTON_HANDLER(button_event_stop,ButtonStop); - TRANZPORT_BUTTON_HANDLER(button_event_play,ButtonPlay); - TRANZPORT_BUTTON_HANDLER(button_event_record,ButtonRecord); - TRANZPORT_BUTTON_HANDLER(button_event_footswitch,ButtonFootswitch); - return 0; -} - diff --git a/libs/surfaces/tranzport/general.cc b/libs/surfaces/tranzport/general.cc deleted file mode 100644 index dd5f33a441..0000000000 --- a/libs/surfaces/tranzport/general.cc +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -#include -#include - -using namespace ARDOUR; -using namespace std; -using namespace sigc; -using namespace PBD; - -#include "pbd/i18n.h" - -#include -// HA, I don't need this anymore -#include - -// FIXME, flash recording light when recording and transport is moving -int TranzportControlProtocol::lights_show_recording() -{ - return lights_show_normal(); -} - -void TranzportControlProtocol::show_bling() { - lights_show_bling(); - screen_show_bling(); -} - -void TranzportControlProtocol::notify(const char *msg) { - last_notify=100; - if(strlen(msg) < 21) { - strcpy(last_notify_msg,msg); - } else { - strncpy(last_notify_msg,msg,16); - last_notify_msg[16] = '\n'; - } -} - -void TranzportControlProtocol::show_notify() { -// FIXME: Get width of the notify area somehow - if(last_notify==0) { - print(1,0," "); - last_notify=-1; - } - if(last_notify > 0) { - print(1,0,last_notify_msg); - --last_notify; - } -} - -// Need more bling! - -int TranzportControlProtocol::lights_show_bling() -{ - switch (bling_mode) { - case BlingOff: break; - case BlingKit: break; // rotate rec/mute/solo/any solo back and forth - case BlingRotating: break; // switch between lights - case BlingPairs: break; // Show pairs of lights - case BlingRows: break; // light each row in sequence - case BlingFlashAll: break; // Flash everything randomly - case BlingEnter: lights_on(); // Show intro - case BlingExit: - lights_off(); - break; - } - return 0; -} - -int TranzportControlProtocol::screen_show_bling() -{ - switch (bling_mode) { - case BlingOff: break; - case BlingKit: break; // rotate rec/mute/solo/any solo back and forth - case BlingRotating: break; // switch between lights - case BlingPairs: break; // Show pairs of lights - case BlingRows: break; // light each row in sequence - case BlingFlashAll: break; // Flash everything randomly - case BlingEnter: // Show intro - print(0,0,"!!Welcome to Ardour!"); - print(1,0,"Peace through Music!"); - break; - case BlingExit: - break; - } - return 0; -} - -int TranzportControlProtocol::lights_show_normal() -{ - /* Track only */ - - if (route_table[0]) { - std::shared_ptr at = std::dynamic_pointer_cast (route_table[0]); - lights_pending[LightTrackrec] = at && at->record_enabled(); - lights_pending[LightTrackmute] = route_get_muted(0); - lights_pending[LightTracksolo] = route_get_soloed(0); - } else { - lights_pending[LightTrackrec] = false; - lights_pending[LightTracksolo] = false; - lights_pending[LightTrackmute] = false; - } - - /* Global settings */ - - lights_pending[LightLoop] = session->get_play_loop(); - lights_pending[LightPunch] = session->config.get_punch_in() || session->config.get_punch_out(); - lights_pending[LightRecord] = session->get_record_enabled(); - lights_pending[LightAnysolo] = session->soloing(); - - return 0; -} - -int TranzportControlProtocol::lights_show_tempo() -{ - // someday soon fiddle with the lights more sanely based on the tempo - return lights_show_normal(); -} - -int -TranzportControlProtocol::update_state () -{ - /* do the text and light updates */ - - switch (display_mode) { - case DisplayBigMeter: - lights_show_tempo(); - show_meter (); - break; - - case DisplayNormal: - lights_show_normal(); - normal_update(); - break; - - case DisplayConfig: - break; - - case DisplayRecording: - lights_show_recording(); - normal_update(); - break; - - case DisplayRecordingMeter: - lights_show_recording(); - show_meter(); - break; - - case DisplayBling: - show_bling(); - break; - - case DisplayBlingMeter: - lights_show_bling(); - show_meter(); - break; - } - show_notify(); - - return 0; - -} - -void -TranzportControlProtocol::prev_marker () -{ - Location *location = session->locations()->first_location_before (session->transport_sample()); - - if (location) { - session->request_locate (location->start()); - notify(location->name().c_str()); - } else { - session->goto_start (); - notify("START"); - } - -} - -void -TranzportControlProtocol::next_marker () -{ - Location *location = session->locations()->first_location_after (session->transport_sample()); - - if (location) { - session->request_locate (location->start()); - notify(location->name().c_str()); - } else { - session->request_locate (session->current_end_sample()); - notify("END "); - } -} - - -void -TranzportControlProtocol::show_current_track () -{ - char pad[COLUMNS]; - char *v; - int len; - if (route_table[0] == 0) { - print (0, 0, "---------------"); - last_track_gain = FLT_MAX; - } else { - strcpy(pad," "); - v = (char *)route_get_name (0).substr (0, 14).c_str(); - if((len = strlen(v)) > 0) { - strncpy(pad,(char *)v,len); - } - print (0, 0, pad); - } -} - - -#if 0 -void -TranzportControlProtocol::step_gain (float increment) -{ -// FIXME: buttonstop is used elsewhere - if (buttonmask & ButtonStop) { - gain_fraction += 0.001*increment; - } else { - gain_fraction += 0.01*increment; - } - - if (fabsf(gain_fraction) > 2.0) { - gain_fraction = 2.0*sign(gain_fraction); - } - - route_set_gain (0, slider_position_to_gain (gain_fraction)); -} -#endif - -void -TranzportControlProtocol::step_gain_up () -{ - if (buttonmask & ButtonStop) { - gain_fraction += 0.001; - } else { - gain_fraction += 0.01; - } - - if (gain_fraction > 2.0) { - gain_fraction = 2.0; - } - - route_set_gain (0, slider_position_to_gain (gain_fraction)); -} - -void -TranzportControlProtocol::step_gain_down () -{ - if (buttonmask & ButtonStop) { - gain_fraction -= 0.001; - } else { - gain_fraction -= 0.01; - } - - if (gain_fraction < 0.0) { - gain_fraction = 0.0; - } - - route_set_gain (0, slider_position_to_gain (gain_fraction)); -} - - -void -TranzportControlProtocol::next_track () -{ - ControlProtocol::next_track (current_track_id); - gain_fraction = gain_to_slider_position (route_get_effective_gain (0)); -// notify("NextTrak"); // not needed til we have more modes -} - -void -TranzportControlProtocol::prev_track () -{ - ControlProtocol::prev_track (current_track_id); - gain_fraction = gain_to_slider_position (route_get_effective_gain (0)); -// notify("PrevTrak"); -} - -// This should kind of switch to using notify - -// Was going to keep state around saying to retry or not -// haven't got to it yet, still not sure it's a good idea - -void -TranzportControlProtocol::print (int row, int col, const char *text) { - print_noretry(row,col,text); -} - -// -1 on failure -// 0 on no damage -// count of bit set on damage? - -void -TranzportControlProtocol::print_noretry (int row, int col, const char *text) -{ - uint32_t length = strlen (text); - if (row*COLUMNS+col+length > (ROWS*COLUMNS)) { - return; - } - // FIXME - be able to print the whole screen at a go. - uint32_t t,r,c; - std::bitset mask(screen_invalid); - for(r = row, c = col, t = 0 ; t < length; c++,t++) { - screen_pending[r][c] = text[t]; - mask[r*COLUMNS+c] = (screen_current[r][c] != screen_pending[r][c]); - } - screen_invalid = mask; -} - -void TranzportControlProtocol::invalidate() -{ - lcd_damage(); lights_invalidate(); screen_invalidate(); // one of these days lcds can be fine but screens not -} diff --git a/libs/surfaces/tranzport/init.cc b/libs/surfaces/tranzport/init.cc deleted file mode 100644 index 56501b2c2c..0000000000 --- a/libs/surfaces/tranzport/init.cc +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include -#include - -using namespace ARDOUR; -using namespace std; -using namespace sigc; -using namespace PBD; - -#include "pbd/i18n.h" - -#include - -void* -TranzportControlProtocol::_monitor_work (void* arg) -{ - return static_cast(arg)->monitor_work (); -} - -TranzportControlProtocol::~TranzportControlProtocol () -{ - set_active (false); -} - -int TranzportControlProtocol::rtpriority_set(int priority) -{ - char *a = (char*) alloca(4096*2); a[0] = 'a'; a[4096] = 'b'; - // Note - try SCHED_RR with a low limit - // - we don't care if we can't write everything this ms - // and it will help if we lose the device - if (set_thread_priority (SCHED_FIFO, priority)) { - PBD::info << string_compose (_("%1: thread not running with realtime scheduling."), name(), strerror (errno)) << endmsg; - return 1; - } - return 0; -} - -// Running with realtime privs is bad when you have problems - -int TranzportControlProtocol::rtpriority_unset(int priority) -{ - struct sched_param rtparam; - int err; - memset (&rtparam, 0, sizeof (rtparam)); - rtparam.sched_priority = priority; - if ((err = pthread_setschedparam (pthread_self(), SCHED_FIFO, &rtparam)) != 0) { - PBD::info << string_compose (_("%1: can't stop realtime scheduling (%2)"), name(), strerror (errno)) << endmsg; - return 1; - } - PBD::info << string_compose (_("%1: realtime scheduling stopped (%2)"), name(), strerror (errno)) << endmsg; - return 0; -} - - -int -TranzportControlProtocol::set_active (bool yn) -{ - if (yn != _active) { - - if (yn) { - - if (open ()) { - return -1; - } - - if (pthread_create_and_store (X_("tranzport monitor"), &thread, _monitor_work, this) == 0) { - _active = true; - } else { - return -1; - } - - } else { - cerr << "Begin tranzport shutdown\n"; -// if we got here due to an error, prettifying things will only make it worse -// And with threads involved, oh boy... - if(!(last_write_error || last_read_error)) { - bling_mode = BlingExit; - enter_bling_mode(); -// thread FIXME - wait til all writes are done - for(int x = 0; (x < 20/MAX_TRANZPORT_INFLIGHT) && flush(); x++) { usleep(100); } - } - - pthread_cancel_one (thread); - - cerr << "Tranzport Thread dead\n"; - close (); - _active = false; - cerr << "End tranzport shutdown\n"; - } - } - - return 0; -} - -TranzportControlProtocol::TranzportControlProtocol (Session& s) - : ControlProtocol (s, X_("Tranzport")) -{ - /* tranzport controls one track at a time */ - - set_route_table_size (1); - timeout = 6000; // what is this for? - buttonmask = 0; - _datawheel = 0; - _device_status = STATUS_OFFLINE; - udev = 0; - current_track_id = 0; - last_where = max_samples; - wheel_mode = WheelTimeline; - wheel_shift_mode = WheelShiftGain; - wheel_increment = WheelIncrScreen; - bling_mode = BlingEnter; - last_notify_msg[0] = '\0'; - last_notify = 0; - timerclear (&last_wheel_motion); - last_wheel_dir = 1; - last_track_gain = FLT_MAX; - last_write_error = 0; - last_read_error = 0; - display_mode = DisplayBling; - gain_fraction = 0.0; - invalidate(); - screen_init(); - lights_init(); -// FIXME: Wait til device comes online somewhere -// About 3 reads is enough -// enter_bling_mode(); - -} - -void* -TranzportControlProtocol::monitor_work () -{ - uint8_t buf[8]; // = { 0,0,0,0,0,0,0,0 }; - int val = 0, pending = 0; - bool first_time = true; - uint8_t offline = 0; - - register_thread (X_("Tranzport")); - pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, 0); - pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0); - rtpriority_set(); - inflight=0; - //int intro = 20; - - // wait for the device to come online - invalidate(); - screen_init(); - lights_init(); - update_state(); -// There has to be some specific command to enable the device!! -// while((val = read(buf,DEFAULT_USB_TIMEOUT*5)) == -110 && pending !=0) { -// pending = lights_flush(); // poke the device for a while -// } - -// pending = 1; -// while(intro-- > 0 && pending != 0) { -// usleep(1000); -// pending = screen_flush(); // kinder, gentler init -// } -// usleep(1000); -// lights_on(); -// while(flush()!=0) ; -// lights_off(); - display_mode = DisplayNormal; - - while (true) { - - /* bInterval for this beastie is 10ms */ - - if (_device_status == STATUS_OFFLINE) { - first_time = true; offline++; -#if TRANZPORT_DEBUG > 3 - if(offline == 1) { - cerr << "Transport has gone offline\n"; - } -#endif - } else { - offline = 0; // hate writing this - } - unsigned int s = (last_write_error == 0) | ((last_read_error == 0) << 1); - switch (s) { - case 0: val = read(buf,DEFAULT_USB_TIMEOUT); break; - case 1: val = read(buf,DEFAULT_USB_TIMEOUT); break; - case 2: val = read(buf,DEFAULT_USB_TIMEOUT); break; - case 3: val = read(buf,DEFAULT_USB_TIMEOUT*2); break; // Hoo, boy, we're in trouble - default: break; // not reached - } - -#if DEBUG_TRANZPORT_BITS > 9 - if(_device_status != STATUS_OFFLINE && _device_status != STATUS_ONLINE && _device_status != STATUS_OK) { - printf("The device has more status bits than off or online: %d\n",_device_status); - } -#endif - -#if DEBUG_TRANZPORT_BITS > 99 - if (val != 8) { - printf("val = %d errno = %d\n",val,errno); - buf[0] = buf[1] = buf[2] = buf[3] = - buf[4] = buf[5] = buf[6] = buf[7] = - buf[8] = 0; - } -#endif - - if(val == 8) { - last_write_error = 0; - process (buf); - } - -#if DEBUG_TRANZPORT > 9 - if(inflight > 1) printf("Inflight: %d\n", inflight); -#endif - - if (_device_status == STATUS_ONLINE) { - if (first_time) { - invalidate(); - lcd_clear (); - lights_off (); - first_time = false; - last_write_error = 0; - offline = 0; - pending = 3; // Give some time for the device to recover - } -#if DEBUG_TRANZPORT_BITS > 10 - // Perhaps an online message indicates something - - if(_device_status != buf[1]) { - printf("WTF- val: %d, device status != buf! %d != %d \n",val,_device_status,buf[1]); _device_status = buf[1]; - } -#endif - - } - -#if DEBUG_TRANZPORT_BITS > 10 - - if(val == 8) { - - if(_device_status == STATUS_ONLINE) { - printf("ONLINE : %02x %02x %02x %02x %02x %02x %02x %02x\n", - buf[0],buf[1],buf[2], buf[3], buf[4], buf[5],buf[6],buf[7]); - } - if(_device_status == STATUS_OFFLINE) { - printf("OFFLINE : %02x %02x %02x %02x %02x %02x %02x %02x\n", - buf[0],buf[1],buf[2], buf[3], buf[4], buf[5],buf[6],buf[7]); - } - - if(_device_status == STATUS_OK) { - printf("OK : %02x %02x %02x %02x %02x %02x %02x %02x\n", - buf[0],buf[1],buf[2], buf[3], buf[4], buf[5],buf[6],buf[7]); - } - - } - -#endif - - /* update whatever needs updating */ - if(last_write_error == 0 && (_device_status == STATUS_ONLINE || _device_status == STATUS_OK)) { - update_state (); - - /* still struggling with a good means of exerting flow control without having to create threads */ - // pending = flush(); - - if(pending == 0) { - pending = flush(); - } else { - if(inflight > 0) { - pending = --inflight; // we just did a whole bunch of writes so wait - } else { - pending = 0; - } - } - } - // pending = 0; - } - return (void*) 0; -} - diff --git a/libs/surfaces/tranzport/interface.cc b/libs/surfaces/tranzport/interface.cc deleted file mode 100644 index c2132980bd..0000000000 --- a/libs/surfaces/tranzport/interface.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -#include "control_protocol/control_protocol.h" -#include "tranzport_control_protocol.h" - -using namespace ARDOUR; - -static ControlProtocol* -new_tranzport_protocol (Session* s) -{ - TranzportControlProtocol* tcp = new TranzportControlProtocol (*s); - - if (tcp->set_active (true)) { - delete tcp; - return 0; - } - - return tcp; - -} - -static void -delete_tranzport_protocol (ControlProtocol* cp) -{ - delete cp; -} - -static ControlProtocolDescriptor tranzport_descriptor = { - /* name */ "Tranzport", - /* id */ "uri://ardour.org/surfaces/tranzport:0", - /* module */ 0, - /* available */ TranzportControlProtocol::available, - /* probe_port */ 0, - /* match usb */ 0, - /* initialize */ new_tranzport_protocol, - /* destroy */ delete_tranzport_protocol, -}; - - -extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &tranzport_descriptor; } - - diff --git a/libs/surfaces/tranzport/io.cc b/libs/surfaces/tranzport/io.cc deleted file mode 100644 index 3fe1b554ca..0000000000 --- a/libs/surfaces/tranzport/io.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -/* The routines in here should know absolutely nothing about how io is actually done */ - -#include - -int -TranzportControlProtocol::flush () -{ - int pending = 0; - -// Always write the lights first - if(!(pending = lights_flush())) { - pending = screen_flush(); - } - -#if DEBUG_TRANZPORT_BITS > 9 - int s; - if(s = (screen_invalid.count())) { // + lights_invalid.count())) { - printf("VALID : %s %s\n", - screen_invalid.to_string().c_str(), - lights_invalid.to_string().c_str()); - printf("CURR : %s %s\n", - screen_invalid.to_string().c_str(), - lights_current.to_string().c_str()); - printf("PENDING : %s %s\n", - screen_invalid.to_string().c_str(), - lights_pending.to_string().c_str()); -#if DEBUG_TRANZPORT_BITS > 10 - printf("invalid bits: %d\n",s); -#endif - } -#endif - return pending; -} - - -int -TranzportControlProtocol::lights_flush () -{ - std::bitset light_state; - light_state = lights_pending ^ lights_current; - if ( (light_state.none() || lights_invalid.none())) - { - return (0); - } - -#if DEBUG_TRANZPORT_LIGHTS - printf("LPEND : %s\n", lights_pending.to_string().c_str()); - printf("LCURR : %s\n", lights_current.to_string().c_str()); -#endif - - // if ever we thread reads/writes STATUS_OK will have to move into the loop - int i; - - if ( _device_status == STATUS_OK || _device_status == STATUS_ONLINE) { - for (i = 0; i 2 - printf("Did %d light writes\n",i); -#endif - return light_state.count(); - } else { - light_state[i] = 0; - } - - } - } - } - light_state = lights_pending ^ lights_current; -#if DEBUG_TRANZPORT_LIGHTS > 2 - printf("Did %d light writes, left: %d\n",i, light_state.count()); -#endif - - return light_state.count(); -} diff --git a/libs/surfaces/tranzport/io_kernel.cc b/libs/surfaces/tranzport/io_kernel.cc deleted file mode 100644 index 6c2bc37922..0000000000 --- a/libs/surfaces/tranzport/io_kernel.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -#if HAVE_TRANZPORT_KERNEL_DRIVER -#include -#include -#include -#include "tranzport_control_protocol.h" - -// Something like open(/dev/surface/tranzport/event) for reading and raw for writing) would be better in the long run -// Also support for multiple tranzports needs to be figured out -// And bulk reads/writes in general - -bool -TranzportControlProtocol::probe () -{ - if((udev = ::open(TRANZPORT_DEVICE,O_RDWR))> 0) { - ::close(udev); - return true; - } - error << _("Tranzport: Can't open device for Read/Write: ") << endmsg; - return false; -} - -int -TranzportControlProtocol::open () -{ - if((udev=::open(TRANZPORT_DEVICE,O_RDWR))> 0) { - return(udev); - } - error << _("Tranzport: no device detected") << endmsg; - return udev; -} - -int -TranzportControlProtocol::close () -{ - int ret = 0; - - if (udev < 1) { - return 0; - } - - if ((ret = ::close (udev)) != 0) { - error << _("Tranzport: cannot close device") << endmsg; - } - - return ret; -} - -// someday do buffered reads, presently this does blocking reads, which is bad... - -int TranzportControlProtocol::read(uint8_t *buf, uint32_t timeout_override) -{ - last_read_error = ::read (udev, (char *) buf, 8); - switch(errno) { - case -ENOENT: - case -ENXIO: - case -ECONNRESET: - case -ESHUTDOWN: - case -ENODEV: - cerr << "Tranzport disconnected, errno: " << last_read_error; - set_active(false); - break; - case -ETIMEDOUT: // This is not normal, but lets see what happened - cerr << "Tranzport read timed out, errno: " << last_read_error; - break; - default: -#if DEBUG_TRANZPORT - cerr << "Got an unknown error on read:" << last_read_error "\n"; -#endif - break; - } - - return last_read_error; -} - - -int -TranzportControlProtocol::write_noretry (uint8_t* cmd, uint32_t timeout_override) -{ - // inflight is now taken care of by the driver, but... - if(inflight > MAX_TRANZPORT_INFLIGHT) { return (-1); } - int val = ::write (udev, (char*) cmd, 8); - - if (val < 0 && val !=8) { -#if DEBUG_TRANZPORT - printf("write failed: %d\n", val); -#endif - last_write_error = errno; - switch(last_write_error) { - case -ENOENT: - case -ENXIO: - case -ECONNRESET: - case -ESHUTDOWN: - case -ENODEV: - cerr << "Tranzport disconnected, errno: " << last_write_error; - set_active(false); - break; - case -ETIMEDOUT: // This is not normal but - cerr << "Tranzport disconnected, errno: " << last_write_error; - break; - default: -#if DEBUG_TRANZPORT - cerr << "Got an unknown error on read:" << last_write_error "\n"; -#endif - break; - } - return last_write_error; - } - - last_write_error = 0; - ++inflight; - - return 0; - -} - -int -TranzportControlProtocol::write (uint8_t* cmd, uint32_t timeout_override) -{ - return (write_noretry(cmd,timeout_override)); -} - -// FIXME - install poll semantics -#endif /* HAVE_TRANZPORT_KERNEL_DRIVER */ - diff --git a/libs/surfaces/tranzport/io_midi.cc b/libs/surfaces/tranzport/io_midi.cc deleted file mode 100644 index b484ef79d5..0000000000 --- a/libs/surfaces/tranzport/io_midi.cc +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -/* io_midi: Implements reading and writing tranzport events via the normal - tranzport midi specification */ - -/* One day -#include -*/ diff --git a/libs/surfaces/tranzport/io_usb.cc b/libs/surfaces/tranzport/io_usb.cc deleted file mode 100644 index 467814d31a..0000000000 --- a/libs/surfaces/tranzport/io_usb.cc +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -#include - -#define __STDC_FORMAT_MACROS -#include -#include -#include -#include -#include - -#include - -#if !HAVE_TRANZPORT_KERNEL_DRIVER - -using namespace ARDOUR; -using namespace std; -using namespace sigc; -using namespace PBD; - -#include "pbd/i18n.h" - -#include - -// I note that these usb specific open, close, probe, read routines are basically -// pure boilerplate and could easily be abstracted elsewhere - -bool -TranzportControlProtocol::available () -{ - struct usb_bus *bus; - struct usb_device *dev; - - usb_init(); - usb_find_busses(); - usb_find_devices(); - - for (bus = usb_busses; bus; bus = bus->next) { - - for(dev = bus->devices; dev; dev = dev->next) { - if (dev->descriptor.idVendor == VENDORID && dev->descriptor.idProduct == PRODUCTID) { - return true; - } - } - } - - return false; -} - -int -TranzportControlProtocol::open () -{ - struct usb_bus *bus; - struct usb_device *dev; - - usb_init(); - usb_find_busses(); - usb_find_devices(); - - for (bus = usb_busses; bus; bus = bus->next) { - - for(dev = bus->devices; dev; dev = dev->next) { - if (dev->descriptor.idVendor != VENDORID) - continue; - if (dev->descriptor.idProduct != PRODUCTID) - continue; - return open_core (dev); - } - } - - cerr << _("Tranzport: no device detected") << endmsg; - return -1; -} - -int -TranzportControlProtocol::open_core (struct usb_device* dev) -{ - if (!(udev = usb_open (dev))) { - cerr << _("Tranzport: cannot open USB transport") << endmsg; - return -1; - } - - if (usb_claim_interface (udev, 0) < 0) { - cerr << _("Tranzport: cannot claim USB interface") << endmsg; - usb_close (udev); - udev = 0; - return -1; - } - - if (usb_set_configuration (udev, 1) < 0) { - cerr << _("Tranzport: cannot configure USB interface") << endmsg; - } - - return 0; -} - -int -TranzportControlProtocol::close () -{ - int ret = 0; - - if (udev == 0) { - return 0; - } - - if (usb_release_interface (udev, 0) < 0) { - cerr << _("Tranzport: cannot release interface") << endmsg; - ret = -1; - } - - if (usb_close (udev)) { - cerr << _("Tranzport: cannot close device") << endmsg; - udev = 0; - ret = 0; - } - - return ret; -} - -int TranzportControlProtocol::read(uint8_t *buf, uint32_t timeout_override) -{ - last_read_error = usb_interrupt_read (udev, READ_ENDPOINT, (char *) buf, 8, timeout_override); - switch(last_read_error) { - case -ENOENT: - case -ENXIO: - case -ECONNRESET: - case -ESHUTDOWN: - case -ENODEV: - cerr << "Tranzport disconnected, errno: " << last_read_error; - set_active(false); - case -ETIMEDOUT: // This is normal - break; - default: -#if DEBUG_TRANZPORT - cerr << "Got an unknown error on read:" << last_read_error "\n"; -#endif - break; - } - - return last_read_error; -} - - -int -TranzportControlProtocol::write_noretry (uint8_t* cmd, uint32_t timeout_override) -{ - int val; - if(inflight > MAX_TRANZPORT_INFLIGHT) { return (-1); } - val = usb_interrupt_write (udev, WRITE_ENDPOINT, (char*) cmd, 8, timeout_override ? timeout_override : timeout); - - if (val < 0 && val !=8) { -#if DEBUG_TRANZPORT - printf("usb_interrupt_write failed: %d\n", val); -#endif - last_write_error = val; - switch(last_write_error) { - case -ENOENT: - case -ENXIO: - case -ECONNRESET: - case -ESHUTDOWN: - case -ENODEV: - cerr << "Tranzport disconnected, errno: " << last_write_error; - set_active(false); - case -ETIMEDOUT: // This is normal - break; - default: -#if DEBUG_TRANZPORT - cerr << "Got an unknown error on read:" << last_write_error "\n"; -#endif - break; - } - return val; - } - - last_write_error = 0; - ++inflight; - - return 0; - -} - -int -TranzportControlProtocol::write (uint8_t* cmd, uint32_t timeout_override) -{ -#if MAX_RETRY > 1 - int val; - int retry = 0; - if(inflight > MAX_TRANZPORT_INFLIGHT) { return (-1); } - - while((val = usb_interrupt_write (udev, WRITE_ENDPOINT, (char*) cmd, 8, timeout_override ? timeout_override : timeout))!=8 && retry++ < MAX_RETRY) { - printf("usb_interrupt_write failed, retrying: %d\n", val); - } - - if (retry == MAX_RETRY) { - printf("Too many retries on a tranzport write, aborting\n"); - } - - if (val < 0) { - printf("usb_interrupt_write failed: %d\n", val); - return val; - } - if (val != 8) { - printf("usb_interrupt_write failed: %d\n", val); - return -1; - } - ++inflight; - return 0; -#else - return (write_noretry(cmd,timeout_override)); -#endif - -} - -#endif diff --git a/libs/surfaces/tranzport/lcd.cc b/libs/surfaces/tranzport/lcd.cc deleted file mode 100644 index 7e9e03c8f2..0000000000 --- a/libs/surfaces/tranzport/lcd.cc +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -#include - -// doing these functions made me realize that screen_invalid should be lcd_isdamaged FIXME soon - -bool TranzportControlProtocol::lcd_damage() -{ - screen_invalidate(); - return true; -} - -bool TranzportControlProtocol::lcd_damage (int row, int col, int length) -{ - std::bitset mask1(0); - // there's an intrinsic to do this fast, darn it, or I'm just sleepy - for (int i = 0; i < length; i++) { mask1[i] = 1; } - std::bitset mask(mask1 << (row*COLUMNS+col)); - screen_invalid |= mask; - return true; -} - -// Still working on the layering, arguably screen_invalid should be lcd_invalid -// or vice versa - -bool TranzportControlProtocol::lcd_isdamaged () -{ - if(screen_invalid.any()) { -#if DEBUG_TRANZPORT > 5 - printf("LCD is damaged somewhere, should redraw it\n"); -#endif - return true; - } - return false; -} - -bool TranzportControlProtocol::lcd_isdamaged (int row, int col, int length) -{ - // there's an intrinsic to do this fast, darn it - std::bitset mask1(0); - for (int i = 0; i < length; i++) { mask1[i] = 1; } - std::bitset mask(mask1 << (row*COLUMNS+col)); - mask &= screen_invalid; - if(mask.any()) { -#if DEBUG_TRANZPORT > 5 - printf("row: %d,col: %d is damaged, should redraw it\n", row,col); -#endif - return true; - } - return false; -} - -// lcd_clear would be a separate function for a smart display -// here it does nothing, but for the sake of completeness it should -// probably write the lcd, and while I'm on the topic it should probably -// take a row, col, length argument.... - -void -TranzportControlProtocol::lcd_clear () -{ - -} - -// These lcd commands are not universally used yet and may drop out of the api - -int -TranzportControlProtocol::lcd_flush () -{ - return 0; -} - -int -TranzportControlProtocol::lcd_write(uint8_t* cmd, uint32_t timeout_override) -{ - int result; -#if (DEBUG_TRANZPORT_SCREEN > 0) - printf("VALID : %s\n", (screen_invalid.to_string()).c_str()); -#endif - if ((result = write(cmd,timeout_override))) { -#if DEBUG_TRANZPORT > 4 - printf("usb screen update failed for some reason... why? \nresult, cmd and data were %d %02x %02x %02x %02x %02x %02x %02x %02x\n", - result, cmd[0],cmd[1],cmd[2], cmd[3], cmd[4], cmd[5],cmd[6],cmd[7]); -#endif - } - return result; -} - -void -TranzportControlProtocol::lcd_fill (uint8_t fill_char) -{ -} - -void -TranzportControlProtocol::lcd_print (int row, int col, const char* text) -{ - print(row,col,text); -} - -void TranzportControlProtocol::lcd_print_noretry (int row, int col, const char* text) -{ - print(row,col,text); -} diff --git a/libs/surfaces/tranzport/lights.cc b/libs/surfaces/tranzport/lights.cc deleted file mode 100644 index 89cf107ace..0000000000 --- a/libs/surfaces/tranzport/lights.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -#include - -// Lights are buffered, and arguably these functions should be eliminated or inlined - -void -TranzportControlProtocol::lights_on () -{ - lights_pending.set(); -} - -void -TranzportControlProtocol::lights_off () -{ - lights_pending.reset(); -} - -int -TranzportControlProtocol::light_on (LightID light) -{ - lights_pending.set(light); - return 0; -} - -int -TranzportControlProtocol::light_off (LightID light) -{ - lights_pending.reset(light); - return 0; -} - -void TranzportControlProtocol::lights_init() -{ - lights_invalid.set(); - lights_flash = lights_pending = lights_current.reset(); -} - - -// Now that all this is bitsets, I don't see much -// need for these 4 to remain in the API - -void TranzportControlProtocol::light_validate (LightID light) -{ - lights_invalid.reset(light); -} - -void TranzportControlProtocol::light_invalidate (LightID light) -{ - lights_invalid.set(light); -} - -void TranzportControlProtocol::lights_validate () -{ - lights_invalid.reset(); -} - -void TranzportControlProtocol::lights_invalidate () -{ - lights_invalid.set(); -} - -int -TranzportControlProtocol::light_set (LightID light, bool offon) -{ - uint8_t cmd[8]; - cmd[0] = 0x00; cmd[1] = 0x00; cmd[2] = light; cmd[3] = offon; - cmd[4] = 0x00; cmd[5] = 0x00; cmd[6] = 0x00; cmd[7] = 0x00; - - if (write (cmd) == 0) { - lights_current[light] = offon; - lights_invalid.reset(light); - return 0; - } else { - return 1; - } -} diff --git a/libs/surfaces/tranzport/meter.cc b/libs/surfaces/tranzport/meter.cc deleted file mode 100644 index 5adc387a40..0000000000 --- a/libs/surfaces/tranzport/meter.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -/* Generic support for character based metering on a track */ diff --git a/libs/surfaces/tranzport/mode.cc b/libs/surfaces/tranzport/mode.cc deleted file mode 100644 index cc45c785ca..0000000000 --- a/libs/surfaces/tranzport/mode.cc +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -#include - -void -TranzportControlProtocol::normal_update () -{ - show_current_track (); - show_transport_time (); - show_track_gain (); - show_wheel_mode (); -} - -void -TranzportControlProtocol::next_display_mode () -{ - switch (display_mode) { - - case DisplayNormal: - enter_big_meter_mode(); - break; - - case DisplayBigMeter: - enter_normal_display_mode(); - break; - - case DisplayRecording: - enter_normal_display_mode(); - break; - - case DisplayRecordingMeter: - enter_big_meter_mode(); - break; - - case DisplayConfig: - case DisplayBling: - case DisplayBlingMeter: - enter_normal_display_mode(); - break; - } -} - -// FIXME: There should be both enter and exits -// EXIT would erase the portions of the screen being written -// to. -/* not sure going macro crazy is a good idea -#define DECLARE_ENTER_MODE(mode,modename) void TranzportControlProtocol::enter_##mode##_mode() \{\screen_clear(); lights_off(); display_mode=Display##modename;\; -*/ -void -TranzportControlProtocol::enter_recording_mode () -{ - screen_clear (); - lights_off (); - display_mode = DisplayRecording; -} - -void -TranzportControlProtocol::enter_bling_mode () -{ - screen_clear (); - lights_off (); - display_mode = DisplayBling; -} - -void -TranzportControlProtocol::enter_config_mode () -{ - lights_off (); - screen_clear (); - display_mode = DisplayConfig; -} - - -void -TranzportControlProtocol::enter_big_meter_mode () -{ - lights_off (); // it will clear the screen for you - last_meter_fill = 0; - display_mode = DisplayBigMeter; -} - -void -TranzportControlProtocol::enter_normal_display_mode () -{ - lights_off (); - screen_clear (); - display_mode = DisplayNormal; -} - diff --git a/libs/surfaces/tranzport/mode_loop.cc b/libs/surfaces/tranzport/mode_loop.cc deleted file mode 100644 index 527dd17c95..0000000000 --- a/libs/surfaces/tranzport/mode_loop.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -/* placeholder for Marker Mode: Edit Markers, Setup Loops, and Punch in points */ diff --git a/libs/surfaces/tranzport/mode_tuner.cc b/libs/surfaces/tranzport/mode_tuner.cc deleted file mode 100644 index 2d2a99adaf..0000000000 --- a/libs/surfaces/tranzport/mode_tuner.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -/* Placeholder for a tuner mode at some point */ diff --git a/libs/surfaces/tranzport/panner.cc b/libs/surfaces/tranzport/panner.cc deleted file mode 100644 index 9fd064a3b1..0000000000 --- a/libs/surfaces/tranzport/panner.cc +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include -#include - -void -TranzportControlProtocol::step_pan_right () -{ -} - -void -TranzportControlProtocol::step_pan_left () -{ -} - - diff --git a/libs/surfaces/tranzport/screen.cc b/libs/surfaces/tranzport/screen.cc deleted file mode 100644 index aa88817300..0000000000 --- a/libs/surfaces/tranzport/screen.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -#include -#include -#include - -void -TranzportControlProtocol::screen_clear () -{ - const char *blank = " "; - print(0,0,blank); - print(1,0,blank); -} - -void TranzportControlProtocol::screen_invalidate () -{ - screen_invalid.set(); - for(int row = 0; row < ROWS; row++) { - for(int col = 0; col < COLUMNS; col++) { - screen_current[row][col] = 0x7f; - screen_pending[row][col] = ' '; - screen_flash[row][col] = ' '; - } - } -} - -void TranzportControlProtocol::screen_validate () -{ -} - -void TranzportControlProtocol::screen_init () -{ - screen_invalidate(); -} - -// FIXME: Switch to a column oriented flush to make the redraw of the -// meters look better - -int -TranzportControlProtocol::screen_flush () -{ - int cell = 0, row=0, col_base, pending = 0; - const unsigned long CELL_BITS = 0x0F; - if ( _device_status == STATUS_OFFLINE) { return (-1); } - - std::bitset mask(CELL_BITS); - std::bitset imask(CELL_BITS); - for(cell = 0; cell < 10 && pending == 0; cell++) { - mask = imask << (cell*4); - if((screen_invalid & mask).any()) { - /* something in this cell is different, so dump the cell to the device. */ -#if DEBUG_TRANZPORT_SCREEN - printf("MASK : %s\n", mask.to_string().c_str()); -#endif - if(cell > 4) { row = 1; } else { row = 0; } - col_base = (cell*4)%COLUMNS; - - uint8_t cmd[8]; - cmd[0] = 0x00; - cmd[1] = 0x01; - cmd[2] = cell; - cmd[3] = screen_pending[row][col_base]; - cmd[4] = screen_pending[row][col_base+1]; - cmd[5] = screen_pending[row][col_base+2]; - cmd[6] = screen_pending[row][col_base+3]; - cmd[7] = 0x00; - - if((pending = lcd_write(cmd)) == 0) { - /* successful write: copy to current cached display */ - screen_invalid &= mask.flip(); - memcpy (&screen_current[row][col_base], &screen_pending[row][col_base], 4); - } - } - } - return pending; -} - diff --git a/libs/surfaces/tranzport/show.cc b/libs/surfaces/tranzport/show.cc deleted file mode 100644 index 624303888a..0000000000 --- a/libs/surfaces/tranzport/show.cc +++ /dev/null @@ -1,399 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -#include -#include -#include - -#define __STDC_FORMAT_MACROS -#include -#include -#include -#include - -#include "pbd/pthread_utils.h" - -#include "ardour/route.h" -#include "ardour/audio_track.h" -#include "ardour/session.h" -#include "ardour/tempo.h" -#include "ardour/location.h" -#include "ardour/dB.h" - -#include "tranzport_control_protocol.h" - -using namespace ARDOUR; -using namespace std; -using namespace sigc; -using namespace PBD; - -#include "pbd/i18n.h" - -#include "pbd/abstract_ui.cc" - -float -log_meter (float db) -{ - float def = 0.0f; /* Meter deflection %age */ - - if (db < -70.0f) return 0.0f; - if (db > 6.0f) return 1.0f; - - if (db < -60.0f) { - def = (db + 70.0f) * 0.25f; - } else if (db < -50.0f) { - def = (db + 60.0f) * 0.5f + 2.5f; - } else if (db < -40.0f) { - def = (db + 50.0f) * 0.75f + 7.5f; - } else if (db < -30.0f) { - def = (db + 40.0f) * 1.5f + 15.0f; - } else if (db < -20.0f) { - def = (db + 30.0f) * 2.0f + 30.0f; - } else if (db < 6.0f) { - def = (db + 20.0f) * 2.5f + 50.0f; - } - - /* 115 is the deflection %age that would be - when db=6.0. this is an arbitrary - endpoint for our scaling. - */ - - return def/115.0f; -} - -#define TRANZ_U 0x1 /* upper */ -#define TRANZ_BL 0x2 /* lower left */ -#define TRANZ_Q2 0x3 /* 2 quadrant block */ -#define TRANZ_ULB 0x4 /* Upper + lower left */ -#define TRANZ_L 0x5 /* lower */ -#define TRANZ_UBL 0x6 /* upper left + bottom all */ -#define TRANZ_Q4 0x7 /* 4 quadrant block */ -#define TRANZ_UL 0x08 /* upper left */ - -// Shift Space - switches your "view" -// Currently defined views are: -// BigMeter -// -// Shift Record - SAVE SNAPSHOT -// Somewhere I was rewriting this -// Other meters -// Inverted - show meters "inside out" For example 4 meters covering 2 cells each, and the -// -// each 4 character cell could be an 8 bar meter = 10 meters! -// Dual Meter mode - master and current track -// We have 16 rows of pixels so we COULD do a vertical meter -// BEAT BLOCKS - For each beat, flash a 8 block (could use the center for vertical meters) -// Could have something generic that could handle up to /20 time -// Odd times could flash the whole top bar for the first beat - - -// Vertical Meter _ .colon - + ucolon A P R I H FULLBLACK -// MV@$%&*()- - -// 3 char block rotating beat `\'/ -// 1 char rotating beat {/\} -// 4 char in block rotating beat {/\} -// {\/) - -void TranzportControlProtocol::show_mini_meter() -{ - // FIXME - show the current marker in passing - const int meter_buf_size = 41; - static uint32_t last_meter_fill_l = 0; - static uint32_t last_meter_fill_r = 0; - uint32_t meter_size; - - float speed = fabsf(get_transport_speed()); - char buf[meter_buf_size]; - - if (speed == 1.0) { - meter_size = 32; - } - - if (speed == 0.0) { - meter_size = 20; // not actually reached - } - - if (speed > 0.0 && (speed < 1.0)) { - meter_size = 20; // may shrink more one day - } - - if (speed > 1.0 && (speed < 2.0)) { - meter_size = 20; - } - - if (speed >= 2.0) { - meter_size = 24; - } - - - // you only seem to get a route_table[0] == 0 on moving forward - bug in next_track? - - if (route_table[0] == 0) { - // Principle of least surprise - print (1, 0, "NoAUDIO "); - return; - } - - float level_l = route_get_peak_input_power (0, 0); - float fraction_l = log_meter (level_l); - - // how to figure out if we are mono? - - float level_r = route_get_peak_input_power (0, 1); - float fraction_r = log_meter (level_r); - - uint32_t fill_left = (uint32_t) floor (fraction_l * ((int) meter_size)); - uint32_t fill_right = (uint32_t) floor (fraction_r * ((int) meter_size)); - - if (fill_left == last_meter_fill_l && fill_right == last_meter_fill_r && !lcd_isdamaged(1,0,meter_size/2)) { - /* nothing to do */ - return; - } - - last_meter_fill_l = fill_left; last_meter_fill_r = fill_right; - - // give some feedback when overdriving - override yellow and red lights - - if (fraction_l > 0.96 || fraction_r > 0.96) { - light_on (LightLoop); - } - - if (fraction_l == 1.0 || fraction_r == 1.0) { - light_on (LightTrackrec); - } - - const uint8_t char_map[16] = { ' ', TRANZ_UL, - TRANZ_U, TRANZ_U, - TRANZ_BL, TRANZ_Q2, - TRANZ_Q2, TRANZ_ULB, - TRANZ_L, TRANZ_UBL, - ' ',' ', - TRANZ_L, TRANZ_UBL, - TRANZ_Q4,TRANZ_Q4 - }; - unsigned int val,j,i; - - for(j = 1, i = 0; i < meter_size/2; i++, j+=2) { - val = (fill_left >= j) | ((fill_left >= j+1) << 1) | - ((fill_right >=j) << 2) | ((fill_right >= j+1) << 3); - buf[i] = char_map[val]; - } - - /* print() requires this */ - - buf[meter_size/2] = '\0'; - - print (1, 0, buf); - - /* Add a peak bar, someday do falloff */ - - // char peak[2]; peak[0] = ' '; peak[1] = '\0'; - // if(fraction_l == 1.0 || fraction_r == 1.0) peak[0] = 'P'; - // print (1,8,peak); // Put a peak meter - P in if we peaked. - -} - -void -TranzportControlProtocol::show_meter () -{ - // you only seem to get a route_table[0] on moving forward - bug elsewhere - if (route_table[0] == 0) { - // Principle of least surprise - print (0, 0, "No audio to meter!!!"); - print (1, 0, "Select another track"); - return; - } - - float level = route_get_peak_input_power (0, 0); - float fraction = log_meter (level); - - /* Someday add a peak bar*/ - - /* we draw using a choice of a sort of double colon-like character ("::") or a single, left-aligned ":". - the screen is 20 chars wide, so we can display 40 different levels. compute the level, - then figure out how many "::" to fill. if the answer is odd, make the last one a ":" - */ - - uint32_t fill = (uint32_t) floor (fraction * 40); - char buf[21]; - uint32_t i; - - if (fill == last_meter_fill) { - /* nothing to do */ - return; - } - - last_meter_fill = fill; - - bool add_single_level = (fill % 2 != 0); - fill /= 2; - - if (fraction > 0.96) { - light_on (LightLoop); - } - - - if (fraction == 1.0) { - light_on (LightTrackrec); - } - - - /* add all full steps */ - - for (i = 0; i < fill; ++i) { - buf[i] = 0x07; /* tranzport special code for 4 quadrant LCD block */ - } - - /* add a possible half-step */ - - if (i < 20 && add_single_level) { - buf[i] = 0x03; /* tranzport special code for 2 left quadrant LCD block */ - ++i; - } - - /* fill rest with space */ - - for (; i < 20; ++i) { - buf[i] = ' '; - } - - /* print() requires this */ - - buf[20] = '\0'; - - print (0, 0, buf); - print (1, 0, buf); -} - -void -TranzportControlProtocol::show_bbt (samplepos_t where) -{ - if (where != last_where) { - char buf[16]; - Temporal::BBT_Time bbt; - - // When recording or playing back < 1.0 speed do 1 or 2 - // FIXME - clean up state machine & break up logic - // this has to co-operate with the mini-meter and - // this is NOT the right way. - - session->tempo_map().bbt_time (where, bbt); - last_bars = bbt.bars; - last_beats = bbt.beats; - last_ticks = bbt.ticks; - last_where = where; - - float speed = fabsf(get_transport_speed()); - - if (speed == 1.0) { - sprintf (buf, "%03" PRIu32 "%1" PRIu32, bbt.bars,bbt.beats); // switch to hex one day - print (1, 16, buf); - } - - if (speed == 0.0) { - sprintf (buf, "%03" PRIu32 "|%1" PRIu32 "|%04" PRIu32, bbt.bars,bbt.beats,bbt.ticks); - print (1, 10, buf); - } - - if (speed > 0.0 && (speed < 1.0)) { - sprintf (buf, "%03" PRIu32 "|%1" PRIu32 "|%04" PRIu32, bbt.bars,bbt.beats,bbt.ticks); - print (1, 10, buf); - } - - if (speed > 1.0 && (speed < 2.0)) { - sprintf (buf, "%03" PRIu32 "|%1" PRIu32 "|%04" PRIu32, bbt.bars,bbt.beats,bbt.ticks); - print (1, 10, buf); - } - - if (speed >= 2.0) { - sprintf (buf, "%03" PRIu32 "|%1" PRIu32 "|%02" PRIu32, bbt.bars,bbt.beats,bbt.ticks); - print (1, 12, buf); - } - - TempoMap::Metric m (session->tempo_map().metric_at (where)); - - // the lights stop working well at above 100 bpm so don't bother - if(m.tempo().beats_per_minute() < 101.0 && (speed > 0.0)) { - - // something else can reset these, so we need to - - lights_pending[LightRecord] = false; - lights_pending[LightAnysolo] = false; - switch(last_beats) { - case 1: if(last_ticks < 250 || last_ticks >= 0) lights_pending[LightRecord] = true; break; - default: if(last_ticks < 250) lights_pending[LightAnysolo] = true; - } - } - } -} - -void -TranzportControlProtocol::show_transport_time () -{ - show_bbt (session->transport_sample ()); -} - -void -TranzportControlProtocol::show_timecode (samplepos_t where) -{ - if ((where != last_where) || lcd_isdamaged(1,9,10)) { - - char buf[5]; - Timecode::Time timecode; - - session->timecode_time (where, timecode); - - if (timecode.negative) { - sprintf (buf, "-%02" PRIu32 ":", timecode.hours); - } else { - sprintf (buf, " %02" PRIu32 ":", timecode.hours); - } - print (1, 8, buf); - - sprintf (buf, "%02" PRIu32 ":", timecode.minutes); - print (1, 12, buf); - - sprintf (buf, "%02" PRIu32 ":", timecode.seconds); - print (1, 15, buf); - - sprintf (buf, "%02" PRIu32, timecode.frames); - print_noretry (1, 18, buf); - - last_where = where; - } -} - -void -TranzportControlProtocol::show_track_gain () -{ -// FIXME last_track gain has to become meter/track specific - if (route_table[0]) { - gain_t g = route_get_gain (0); - if ((g != last_track_gain) || lcd_isdamaged(0,12,8)) { - char buf[16]; - snprintf (buf, sizeof (buf), "%6.1fdB", coefficient_to_dB (route_get_effective_gain (0))); - print (0, 12, buf); - last_track_gain = g; - } - } else { - print (0, 9, " "); - } -} diff --git a/libs/surfaces/tranzport/slider_gain.h b/libs/surfaces/tranzport/slider_gain.h deleted file mode 100644 index c85930001d..0000000000 --- a/libs/surfaces/tranzport/slider_gain.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -#ifndef ardour_slider_gain -#define ardour_slider_gain - -static inline double -gain_to_slider_position (ARDOUR::gain_t g) -{ - if (g == 0) return 0; - return pow((6.0*log(g)/log(2.0)+192.0)/198.0, 8.0); - -} - -static inline ARDOUR::gain_t -slider_position_to_gain (double pos) -{ - /* XXX Marcus writes: this doesn't seem right to me. but i don't have a better answer ... */ - if (pos == 0.0) return 0; - return pow (2.0,(sqrt(sqrt(sqrt(pos)))*198.0-192.0)/6.0); -} - -#endif diff --git a/libs/surfaces/tranzport/state.cc b/libs/surfaces/tranzport/state.cc deleted file mode 100644 index 3e86c0d7a8..0000000000 --- a/libs/surfaces/tranzport/state.cc +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include -#include -#include - -#define __STDC_FORMAT_MACROS -#include -#include -#include -#include -#include "ardour/route.h" -#include "ardour/audio_track.h" -#include "ardour/session.h" -#include "ardour/location.h" -#include "ardour/dB.h" - -using namespace ARDOUR; -using namespace std; -using namespace sigc; -using namespace PBD; - -#include "pbd/i18n.h" - -#include "pbd/abstract_ui.cc" - -#include "tranzport_control_protocol.h" - - -// FIXME: How to handle multiple tranzports in a system? - -XMLNode& -TranzportControlProtocol::get_state () const -{ - return ControlProtocol::get_state(); -} - -int -TranzportControlProtocol::set_state (const XMLNode& node) -{ - cout << "TranzportControlProtocol::set_state: active " << _active << endl; - int retval = 0; - -// I think I want to make these strings rather than numbers -#if 0 - // fetch current display mode - if ( node.property( X_("display_mode") ) != 0 ) - { - string display = node.property( X_("display_mode") )->value(); - try - { - set_active( true ); - int32_t new_display = atoi( display.c_str() ); - if ( display_mode != new_display ) display_mode = (DisplayMode)new_display; - } - catch ( exception & e ) - { - cout << "exception in TranzportControlProtocol::set_state: " << e.what() << endl; - return -1; - } - } - - if ( node.property( X_("wheel_mode") ) != 0 ) - { - string wheel = node.property( X_("wheel_mode") )->value(); - try - { - int32_t new_wheel = atoi( wheel.c_str() ); - if ( wheel_mode != new_wheel ) wheel_mode = (WheelMode) new_wheel; - } - catch ( exception & e ) - { - cout << "exception in TranzportControlProtocol::set_state: " << e.what() << endl; - return -1; - } - } - - // fetch current bling mode - if ( node.property( X_("bling") ) != 0 ) - { - string bling = node.property( X_("bling_mode") )->value(); - try - { - int32_t new_bling = atoi( bling.c_str() ); - if ( bling_mode != new_bling ) bling_mode = (BlingMode) new_bling; - } - catch ( exception & e ) - { - cout << "exception in TranzportControlProtocol::set_state: " << e.what() << endl; - return -1; - } - } -#endif - - return retval; - -} - -// These are intended for the day we have more options for tranzport modes -// And perhaps we could load up sessions this way, too - -int -TranzportControlProtocol::save (char *name) -{ - // Presently unimplemented - return 0; -} - -int -TranzportControlProtocol::load (char *name) -{ - // Presently unimplemented - return 0; -} - -int -TranzportControlProtocol::save_config (char *name) -{ - // Presently unimplemented - return 0; -} - -int -TranzportControlProtocol::load_config (char *name) -{ - // Presently unimplemented - return 0; -} diff --git a/libs/surfaces/tranzport/tranzport_base.h b/libs/surfaces/tranzport/tranzport_base.h deleted file mode 100644 index 84a5b680a8..0000000000 --- a/libs/surfaces/tranzport/tranzport_base.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -/* This header file is basically where all the tranzport debuggable options go. - Try to only check it in with minimal debugging enabled so production - systems don't have to fiddle with it. */ - -/* Design notes: The tranzport is a unique device, basically a - 20x2 character lcd gui with (almost) 22 shift keys and 8 blinking lights. - - As such it has several unique constraints. In the libusb driver, - the device exerts flow control - by having a usb write fail. It is pointless to retry madly at that point, - the device is busy, and it's not going to become unbusy very quickly. - - So writes need to be either "mandatory" or "unreliable", and therein - lies the rub, as the kernel can also drop writes, and missing an - interrupt in userspace is also generally bad. - - However, the kernel driver retries writes for you and also buffers and - compresses incoming wheel events - it will rarely, if ever, drop data. - - A more complex surface might have hundreds of lights and several displays. - - mike@taht.net -*/ - -#ifndef ardour_tranzport_base -#define ardour_tranzport_base - -#define DEFAULT_USB_TIMEOUT 10 -#define MAX_RETRY 1 -#define MAX_TRANZPORT_INFLIGHT 4 -#define DEBUG_TRANZPORT 0 - -#ifndef HAVE_TRANZPORT_KERNEL_DRIVER -#define HAVE_TRANZPORT_KERNEL_DRIVER 0 -#endif - -#ifndef HAVE_TRANZPORT_MIDI_DRIVER -#define HAVE_TRANZPORT_MIDI_DRIVER 0 -#endif - -// for now, this is what the device is called -#define TRANZPORT_DEVICE "/dev/tranzport0" - -#if DEBUG_TRANZPORT > 0 -#define DEBUG_TRANZPORT_SCREEN 10 -#define DEBUG_TRANZPORT_BITS 10 -#define DEBUG_TRANZPORT_LIGHTS 10 -#define DEBUG_TRANZPORT_STATE 10 -#else -#define DEBUG_TRANZPORT 0 -#define DEBUG_TRANZPORT_BITS 0 -#define DEBUG_TRANZPORT_SCREEN 0 -#define DEBUG_TRANZPORT_LIGHTS 0 -#define DEBUG_TRANZPORT_STATE 0 -#endif -#endif /* ardour_tranzport_base */ - diff --git a/libs/surfaces/tranzport/tranzport_common.h b/libs/surfaces/tranzport/tranzport_common.h deleted file mode 100644 index a0fe13d02b..0000000000 --- a/libs/surfaces/tranzport/tranzport_common.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -/* The most common header files that the tranzport uses */ - -#ifndef ardour_tranzport_common -#define ardour_tranzport_common -#include -#include -#include - -#define __STDC_FORMAT_MACROS -#include -#include -#include -#include - -#include "pbd/pthread_utils.h" - -#include "ardour/route.h" -#include "ardour/audio_track.h" -#include "ardour/rc_configuration.h" -#include "ardour/tempo.h" -#include "ardour/location.h" -#include "ardour/dB.h" - -#endif /* ardour_tranzport_common */ diff --git a/libs/surfaces/tranzport/tranzport_control_protocol.h b/libs/surfaces/tranzport/tranzport_control_protocol.h deleted file mode 100644 index 2353071aa9..0000000000 --- a/libs/surfaces/tranzport/tranzport_control_protocol.h +++ /dev/null @@ -1,380 +0,0 @@ -/* - Copyright (C) 2006 Paul Davis - Copyright (C) 2007 Mike Taht - - 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 - (at your option) 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. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - - -#ifndef ardour_tranzport_control_protocol_h -#define ardour_tranzport_control_protocol_h - -#include "tranzport_base.h" - -#include -#include -#include -#include - -#if !HAVE_TRANZPORT_KERNEL_DRIVER -#include -#endif - -#include -#include "ardour/types.h" - -#include "control_protocol/control_protocol.h" - -class TranzportControlProtocol : public ARDOUR::ControlProtocol -{ -public: - TranzportControlProtocol (ARDOUR::Session&); - virtual ~TranzportControlProtocol(); - - int set_active (bool yn); - - static bool available (); - - XMLNode& get_state () const; - int set_state (const XMLNode&); - -private: - static const int VENDORID = 0x165b; - static const int PRODUCTID = 0x8101; - static const int READ_ENDPOINT = 0x81; - static const int WRITE_ENDPOINT = 0x02; - const static int STATUS_OFFLINE = 0xff; - const static int STATUS_ONLINE = 0x01; - const static int STATUS_OK = 0x00; - - const static int LIGHTS = 7; - const static int ROWS = 2; - const static int COLUMNS = 20; - const static uint8_t WheelDirectionThreshold = 0x7f; - - enum LightID { - LightRecord = 0, - LightTrackrec, - LightTrackmute, - LightTracksolo, - LightAnysolo, - LightLoop, - LightPunch - }; - - enum ButtonID { - ButtonBattery = 0x00004000, - ButtonBacklight = 0x00008000, - ButtonTrackLeft = 0x04000000, - ButtonTrackRight = 0x40000000, - ButtonTrackRec = 0x00040000, - ButtonTrackMute = 0x00400000, - ButtonTrackSolo = 0x00000400, - ButtonUndo = 0x80000000, - ButtonIn = 0x02000000, - ButtonOut = 0x20000000, - ButtonPunch = 0x00800000, - ButtonLoop = 0x00080000, - ButtonPrev = 0x00020000, - ButtonAdd = 0x00200000, - ButtonNext = 0x00000200, - ButtonRewind = 0x01000000, - ButtonFastForward = 0x10000000, - ButtonStop = 0x00010000, - ButtonPlay = 0x00100000, - ButtonRecord = 0x00000100, - ButtonShift = 0x08000000, - ButtonFootswitch = 0x00001000 - }; - - enum WheelShiftMode { - WheelShiftGain, - WheelShiftPan, - WheelShiftMaster, - WheelShiftMarker - }; - - enum WheelMode { - WheelTimeline, - WheelScrub, - WheelShuttle - }; - - // FIXME - look at gtk2_ardour for snap settings - - enum WheelIncrement { - WheelIncrSlave, - WheelIncrScreen, - WheelIncrSample, - WheelIncrBeat, - WheelIncrBar, - WheelIncrSecond, - WheelIncrMinute - }; - - enum DisplayMode { - DisplayNormal, - DisplayRecording, - DisplayRecordingMeter, - DisplayBigMeter, - DisplayConfig, - DisplayBling, - DisplayBlingMeter - }; - - enum BlingMode { - BlingOff, - BlingKit, - BlingRotating, - BlingPairs, - BlingRows, - BlingFlashAll, - BlingEnter, - BlingExit - }; - - pthread_t thread; -#if HAVE_TRANZPORT_KERNEL_DRIVER - int udev; -#else - usb_dev_handle* udev; -#endif - - int last_read_error; - - uint32_t buttonmask; - uint32_t timeout; - uint32_t inflight; - uint32_t current_track_id; - int last_write_error; - uint8_t _datawheel; - uint8_t _device_status; - WheelMode wheel_mode; - WheelShiftMode wheel_shift_mode; - DisplayMode display_mode; - BlingMode bling_mode; - WheelIncrement wheel_increment; - - ARDOUR::gain_t gain_fraction; - - Glib::Threads::Mutex update_lock; - - std::bitset screen_invalid; - char screen_current[ROWS][COLUMNS]; - char screen_pending[ROWS][COLUMNS]; - char screen_flash[ROWS][COLUMNS]; - - std::bitset lights_invalid; - std::bitset lights_current; - std::bitset lights_pending; - std::bitset lights_flash; - - int32_t last_notify; - char last_notify_msg[COLUMNS+1]; - uint32_t last_bars; - uint32_t last_beats; - uint32_t last_ticks; - - bool last_negative; - uint32_t last_hrs; - uint32_t last_mins; - uint32_t last_secs; - uint32_t last_samples; - samplepos_t last_where; - ARDOUR::gain_t last_track_gain; - uint32_t last_meter_fill; - struct timeval last_wheel_motion; - int last_wheel_dir; - - Glib::Mutex io_lock; - - int open (); - int read (uint8_t *buf,uint32_t timeout_override = 0); - int write (uint8_t* cmd, uint32_t timeout_override = 0); - int write_noretry (uint8_t* cmd, uint32_t timeout_override = 0); - int close (); - int save_config(char *name = "default"); - int load_config(char *name = "default"); - int save(char *name); - int load(char *name); - void print (int row, int col, const char* text); - void print_noretry (int row, int col, const char* text); - void notify(const char *msg); - -#if HAVE_TRANZPORT_KERNEL_DRIVER - int rtpriority_set(int priority = 3); // we don't need serious rt privs anymore -#else - int rtpriority_set(int priority = 52); -#endif - int rtpriority_unset(int priority = 0); - - // I hate changing the api to do either but until I have clean io class what can you do? -#if !HAVE_TRANZPORT_KERNEL_DRIVER - int open_core (struct usb_device*); -#endif - static void* _monitor_work (void* arg); - void* monitor_work (); - - int process (uint8_t *); - int update_state(); - void invalidate(); - int flush(); - // bool isuptodate(); // think on this. It seems futile to update more than 30/sec - - // A screen is a cache of what should be on the lcd - - void screen_init(); - void screen_validate(); - void screen_invalidate(); - int screen_flush(); - void screen_clear(); - // bool screen_isuptodate(); // think on this - - int screen_show_bling(); - - // Commands to write to the lcd - - int lcd_init(); - bool lcd_damage(); - bool lcd_isdamaged(); - - bool lcd_damage(int row, int col = 0, int length = COLUMNS); - bool lcd_isdamaged(int row, int col = 0, int length = COLUMNS); - - int lcd_flush(); - int lcd_write(uint8_t* cmd, uint32_t timeout_override = 0); // pedantic alias for write - void lcd_fill (uint8_t fill_char); - void lcd_clear (); - void lcd_print (int row, int col, const char* text); - void lcd_print_noretry (int row, int col, const char* text); - - // Commands to write to the lights - // FIXME - on some devices lights can have intensity and colors - - void lights_init(); - void lights_validate(); - void lights_invalidate(); - void light_validate(LightID light); - void light_invalidate(LightID light); - int lights_flush(); - int lights_write(uint8_t* cmd,uint32_t timeout_override = 0); // pedantic alias to write - - // a cache of what should be lit - - void lights_off (); - void lights_on (); - int light_set(LightID, bool offon = true); - int light_on (LightID); - int light_off (LightID); - - // some modes for the lights, should probably be renamed - - int lights_show_normal(); - int lights_show_recording(); - int lights_show_tempo(); - int lights_show_bling(); - - void enter_big_meter_mode (); - void enter_normal_display_mode (); - void enter_config_mode(); - void enter_recording_mode(); - void enter_bling_mode(); - - void next_marker (); // basicui doesn't give me enough info - void prev_marker (); - - void next_display_mode (); - void normal_update (); - - void show_current_track (); - void show_track_gain (); - void show_transport_time (); - void show_bbt (samplepos_t where); - void show_timecode (samplepos_t where); - void show_wheel_mode (); - void show_gain (); - void show_pan (); - void show_meter (); - void show_mini_meter (); - void show_bling(); - void show_notify(); - - void datawheel (); - void scrub (); - void scroll (); - void shuttle (); - void config (); - - void next_wheel_mode (); - void next_wheel_shift_mode (); - - void set_current_track (ARDOUR::Route*); - void next_track (); - void prev_track (); - void step_gain_up (); - void step_gain_down (); - void step_pan_right (); - void step_pan_left (); - - - void button_event_battery_press (bool shifted); - void button_event_battery_release (bool shifted); - void button_event_backlight_press (bool shifted); - void button_event_backlight_release (bool shifted); - void button_event_trackleft_press (bool shifted); - void button_event_trackleft_release (bool shifted); - void button_event_trackright_press (bool shifted); - void button_event_trackright_release (bool shifted); - void button_event_trackrec_press (bool shifted); - void button_event_trackrec_release (bool shifted); - void button_event_trackmute_press (bool shifted); - void button_event_trackmute_release (bool shifted); - void button_event_tracksolo_press (bool shifted); - void button_event_tracksolo_release (bool shifted); - void button_event_undo_press (bool shifted); - void button_event_undo_release (bool shifted); - void button_event_in_press (bool shifted); - void button_event_in_release (bool shifted); - void button_event_out_press (bool shifted); - void button_event_out_release (bool shifted); - void button_event_punch_press (bool shifted); - void button_event_punch_release (bool shifted); - void button_event_loop_press (bool shifted); - void button_event_loop_release (bool shifted); - void button_event_prev_press (bool shifted); - void button_event_prev_release (bool shifted); - void button_event_add_press (bool shifted); - void button_event_add_release (bool shifted); - void button_event_next_press (bool shifted); - void button_event_next_release (bool shifted); - void button_event_rewind_press (bool shifted); - void button_event_rewind_release (bool shifted); - void button_event_fastforward_press (bool shifted); - void button_event_fastforward_release (bool shifted); - void button_event_stop_press (bool shifted); - void button_event_stop_release (bool shifted); - void button_event_play_press (bool shifted); - void button_event_play_release (bool shifted); - void button_event_record_press (bool shifted); - void button_event_record_release (bool shifted); - void button_event_footswitch_press(bool shifted); - void button_event_footswitch_release (bool shifted); - - // new api - still thinking about it - void button_event_mute (bool pressed, bool shifted); -}; - - -#endif // ardour_tranzport_control_protocol_h diff --git a/libs/surfaces/tranzport/view_automation.cc b/libs/surfaces/tranzport/view_automation.cc deleted file mode 100644 index ad9befd9b9..0000000000 --- a/libs/surfaces/tranzport/view_automation.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - - diff --git a/libs/surfaces/tranzport/view_bigmeter.cc b/libs/surfaces/tranzport/view_bigmeter.cc deleted file mode 100644 index ad9befd9b9..0000000000 --- a/libs/surfaces/tranzport/view_bigmeter.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - - diff --git a/libs/surfaces/tranzport/view_bling.cc b/libs/surfaces/tranzport/view_bling.cc deleted file mode 100644 index ad9befd9b9..0000000000 --- a/libs/surfaces/tranzport/view_bling.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - - diff --git a/libs/surfaces/tranzport/view_bus.cc b/libs/surfaces/tranzport/view_bus.cc deleted file mode 100644 index ad9befd9b9..0000000000 --- a/libs/surfaces/tranzport/view_bus.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - - diff --git a/libs/surfaces/tranzport/view_config.cc b/libs/surfaces/tranzport/view_config.cc deleted file mode 100644 index ad9befd9b9..0000000000 --- a/libs/surfaces/tranzport/view_config.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - - diff --git a/libs/surfaces/tranzport/view_layer.cc b/libs/surfaces/tranzport/view_layer.cc deleted file mode 100644 index a350c08687..0000000000 --- a/libs/surfaces/tranzport/view_layer.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -/* ultimately this view will let you: rotate layers (takes) on the currently selected track/region, do cross fades, and the like */ diff --git a/libs/surfaces/tranzport/view_loop.cc b/libs/surfaces/tranzport/view_loop.cc deleted file mode 100644 index ad9befd9b9..0000000000 --- a/libs/surfaces/tranzport/view_loop.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - - diff --git a/libs/surfaces/tranzport/view_manymeter.cc b/libs/surfaces/tranzport/view_manymeter.cc deleted file mode 100644 index ad9befd9b9..0000000000 --- a/libs/surfaces/tranzport/view_manymeter.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - - diff --git a/libs/surfaces/tranzport/view_marker.cc b/libs/surfaces/tranzport/view_marker.cc deleted file mode 100644 index ad9befd9b9..0000000000 --- a/libs/surfaces/tranzport/view_marker.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - - diff --git a/libs/surfaces/tranzport/view_master.cc b/libs/surfaces/tranzport/view_master.cc deleted file mode 100644 index ad9befd9b9..0000000000 --- a/libs/surfaces/tranzport/view_master.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - - diff --git a/libs/surfaces/tranzport/view_plugins.cc b/libs/surfaces/tranzport/view_plugins.cc deleted file mode 100644 index ad9befd9b9..0000000000 --- a/libs/surfaces/tranzport/view_plugins.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - - diff --git a/libs/surfaces/tranzport/view_std.cc b/libs/surfaces/tranzport/view_std.cc deleted file mode 100644 index ad9befd9b9..0000000000 --- a/libs/surfaces/tranzport/view_std.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - - diff --git a/libs/surfaces/tranzport/view_tempo.cc b/libs/surfaces/tranzport/view_tempo.cc deleted file mode 100644 index ad9befd9b9..0000000000 --- a/libs/surfaces/tranzport/view_tempo.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - - diff --git a/libs/surfaces/tranzport/view_tuner.cc b/libs/surfaces/tranzport/view_tuner.cc deleted file mode 100644 index ad9befd9b9..0000000000 --- a/libs/surfaces/tranzport/view_tuner.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - - diff --git a/libs/surfaces/tranzport/wheel.cc b/libs/surfaces/tranzport/wheel.cc deleted file mode 100644 index 9f193c5c5d..0000000000 --- a/libs/surfaces/tranzport/wheel.cc +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * */ - -#include -#include -#include - -#define __STDC_FORMAT_MACROS -#include -#include -#include -#include -#include "ardour/route.h" -#include "ardour/audio_track.h" -#include "ardour/session.h" -#include "ardour/location.h" -#include "ardour/dB.h" - -using namespace ARDOUR; -using namespace std; -using namespace sigc; -using namespace PBD; - -#include "pbd/i18n.h" - -#include "pbd/abstract_ui.cc" - -BaseUI::RequestType LEDChange = BaseUI::new_request_type (); -BaseUI::RequestType Print = BaseUI::new_request_type (); -BaseUI::RequestType SetCurrentTrack = BaseUI::new_request_type (); - - -#include "tranzport_control_protocol.h" - -void -TranzportControlProtocol::datawheel () -{ - if ((buttonmask & ButtonTrackRight) || (buttonmask & ButtonTrackLeft)) { - - /* track scrolling */ - - if (_datawheel < WheelDirectionThreshold) { - next_track (); - } else { - prev_track (); - } - - last_wheel_motion = 0; - - } else if ((buttonmask & ButtonPrev) || (buttonmask & ButtonNext)) { - - if (_datawheel < WheelDirectionThreshold) { - next_marker (); - } else { - prev_marker (); - } - - last_wheel_motion = 0; - - } else if (buttonmask & ButtonShift) { - - /* parameter control */ - - if (route_table[0]) { - switch (wheel_shift_mode) { - case WheelShiftGain: - if (_datawheel < WheelDirectionThreshold) { - step_gain_up (); - } else { - step_gain_down (); - } - break; - case WheelShiftPan: - if (_datawheel < WheelDirectionThreshold) { - step_pan_right (); - } else { - step_pan_left (); - } - break; - - case WheelShiftMarker: - break; - - case WheelShiftMaster: - break; - - } - } - - last_wheel_motion = 0; - - } else { - - switch (wheel_mode) { - case WheelTimeline: - scroll (); - break; - - case WheelScrub: - scrub (); - break; - - case WheelShuttle: - shuttle (); - break; - } - } -} - -void -TranzportControlProtocol::scroll () -{ - float m = 1.0; - if (_datawheel < WheelDirectionThreshold) { - m = 1.0; - } else { - m = -1.0; - } - switch(wheel_increment) { - case WheelIncrScreen: ScrollTimeline (0.2*m); break; - case WheelIncrSlave: - case WheelIncrSample: - case WheelIncrBeat: - case WheelIncrBar: - case WheelIncrSecond: - case WheelIncrMinute: - default: break; // other modes unimplemented as yet - } -} - -void -TranzportControlProtocol::scrub () -{ - float speed; - uint64_t now; - int dir; - - now = g_get_monotonic_time(); - - if (_datawheel < WheelDirectionThreshold) { - dir = 1; - } else { - dir = -1; - } - - if (dir != last_wheel_dir) { - /* changed direction, start over */ - speed = 0.1f; - } else { - if (last_wheel_motion != 0) { - /* 10 clicks per second => speed == 1.0 */ - - speed = 100000.0f / (float) (now - last_wheel_motion) - - } else { - - /* start at half-speed and see where we go from there */ - - speed = 0.5f; - } - } - - last_wheel_motion = now; - last_wheel_dir = dir; - - set_transport_speed (speed * dir); -} - -void -TranzportControlProtocol::shuttle () -{ - if (_datawheel < WheelDirectionThreshold) { - if (get_transport_speed() < 0) { - session->request_transport_speed (1.0); - } else { - session->request_transport_speed_nonzero (get_transport_speed() + 0.1); - } - } else { - if (session->get_transport_speed() > 0) { - session->request_transport_speed (-1.0); - } else { - session->request_transport_speed_nonzero (get_transport_speed() - 0.1); - } - } - session->request_roll (); -} diff --git a/libs/surfaces/tranzport/wheel_modes.cc b/libs/surfaces/tranzport/wheel_modes.cc deleted file mode 100644 index f235c1f348..0000000000 --- a/libs/surfaces/tranzport/wheel_modes.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2006 Paul Davis - * Copyright (C) 2007 Michael Taht - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include -#include -#include - -#define __STDC_FORMAT_MACROS -#include -#include -#include -#include - -#if HAVE_TRANZPORT_KERNEL_DRIVER -#include -#include -#endif - -#include "pbd/pthread_utils.h" - -#include "ardour/route.h" -#include "ardour/audio_track.h" -#include "ardour/tempo.h" -#include "ardour/location.h" -#include "ardour/dB.h" - -#include "tranzport_control_protocol.h" - -using namespace ARDOUR; -using namespace std; -using namespace sigc; -using namespace PBD; - -#include "pbd/i18n.h" - -#include - -void -TranzportControlProtocol::next_wheel_shift_mode () -{ -switch (wheel_shift_mode) { - case WheelShiftGain: - wheel_shift_mode = WheelShiftPan; - break; - case WheelShiftPan: - wheel_shift_mode = WheelShiftMaster; - break; - case WheelShiftMaster: - wheel_shift_mode = WheelShiftGain; - break; - case WheelShiftMarker: // Not done yet, disabled - wheel_shift_mode = WheelShiftGain; - break; - } - - show_wheel_mode (); -} - -void -TranzportControlProtocol::next_wheel_mode () -{ - switch (wheel_mode) { - case WheelTimeline: - wheel_mode = WheelScrub; - break; - case WheelScrub: - wheel_mode = WheelShuttle; - break; - case WheelShuttle: - wheel_mode = WheelTimeline; - } - - show_wheel_mode (); -} - -void -TranzportControlProtocol::show_wheel_mode () -{ - string text; - - // if(get_transport_speed() != 0) { - // if session-transport_speed() < 1.0) show_big_bar/beat - // if ? greater. dont - - if(get_transport_speed() != 0) { - show_mini_meter(); - } else { - - switch (wheel_mode) { - case WheelTimeline: - text = "Time"; - break; - case WheelScrub: - text = "Scrb"; - break; - case WheelShuttle: - text = "Shtl"; - break; - } - - switch (wheel_shift_mode) { - case WheelShiftGain: - text += ":Gain"; - break; - - case WheelShiftPan: - text += ":Pan "; - break; - - case WheelShiftMaster: - text += ":Mstr"; - break; - - case WheelShiftMarker: - text += ":Mrkr"; - break; - } - - print (1, 0, text.c_str()); - } -} diff --git a/libs/surfaces/tranzport/wscript b/libs/surfaces/tranzport/wscript deleted file mode 100644 index f58a8acc95..0000000000 --- a/libs/surfaces/tranzport/wscript +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python -import os - -def options(opt): - pass - -def configure(conf): - pass - -def build(bld): - obj = bld(features = 'cxx cxxshlib') - obj.source = ''' - button_events.cc - buttons.cc - general.cc - init.cc - interface.cc - io.cc - io_usb.cc - lcd.cc - lights.cc - mode.cc - panner.cc - screen.cc - show.cc - state.cc - wheel.cc - wheel_modes.cc - ''' - obj.defines = [ 'PACKAGE="ardour_tranzport"' ] - obj.defines += [ 'ARDOURSURFACE_DLL_EXPORTS' ] - obj.includes = ['.', './tranzport'] - obj.name = 'libardour_tranzport' - obj.target = 'ardour_tranzport' - obj.uselib = 'XML OSX' - obj.use = 'libardour libardour_cp' - obj.install_path = os.path.join(bld.env['LIBDIR'], 'surfaces') diff --git a/libs/surfaces/wscript b/libs/surfaces/wscript index 5a5fe03564..dc759484b7 100644 --- a/libs/surfaces/wscript +++ b/libs/surfaces/wscript @@ -34,9 +34,6 @@ def configure(conf): autowaf.set_recursive() - #if Options.options.tranzport and conf.is_defined('HAVE_USB'): - # conf.define('BUILD_TRANZPORT', 1) - if conf.is_defined('HAVE_USB'): children += [ 'push2' ] children += [ 'contourdesign' ] @@ -86,8 +83,6 @@ def build(bld): if bld.is_defined('BUILD_WIIMOTE'): bld.recurse('wiimote') - if bld.is_defined('BUILD_TRANZPORT'): - bld.recurse('tranzport') if bld.is_defined('HAVE_USB'): bld.recurse('push2') bld.recurse('contourdesign') diff --git a/wscript b/wscript index 5a23ef751b..3240836f4a 100644 --- a/wscript +++ b/wscript @@ -900,8 +900,6 @@ def options(opt): help="Run tests after build") opt.add_option('--single-tests', action='store_true', default=False, dest='single_tests', help="Build a single executable for each unit test") - #opt.add_option('--tranzport', action='store_true', default=False, dest='tranzport', - # help='Compile with support for Frontier Designs Tranzport (if libusb is available)') opt.add_option('--maschine', action='store_true', default=False, dest='maschine', help='Compile with support for NI-Maschine') opt.add_option('--generic', action='store_true', default=False, dest='generic', @@ -1348,8 +1346,6 @@ int main () { __int128 x = 0; return 0; } conf.env['RUN_TESTS'] = opts.run_tests if opts.single_tests: conf.env['SINGLE_TESTS'] = opts.single_tests - #if opts.tranzport: - # conf.env['TRANZPORT'] = 1 if not opts.no_windows_vst: if Options.options.dist_target == 'mingw': conf.define('WINDOWS_VST_SUPPORT', 1) @@ -1558,7 +1554,6 @@ const char* const ardour_config_info = "\\n\\ # write_config_text('Soundtouch', conf.is_defined('HAVE_SOUNDTOUCH')) write_config_text('Threaded WaveViews', not opts.no_threaded_waveviews) write_config_text('Translation', not opts.no_nls) -# write_config_text('Tranzport', opts.tranzport) write_config_text('Unit tests', conf.env['BUILD_TESTS']) write_config_text('Use LLD linker', opts.use_lld) write_config_text('VST3 support', conf.is_defined('VST3_SUPPORT')) From 140670541f310fff9eba3accca53cefc550b45b3 Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Sun, 20 Oct 2024 00:16:01 +0200 Subject: [PATCH 002/113] Use .inc.h for #include files that not are plain headers Regular .h files *should* be self-contained and independent of previous includes and guarded to only include once. Make it clear which files that *doesn't* apply for at all. --- MSVCardour3/Ardour3.vcproj | 8 ++--- .../{canvas_vars.h => canvas_vars.inc.h} | 0 ...etadata.h => configuration_metadata.inc.h} | 0 gtk2_ardour/cue_editor.h | 2 +- gtk2_ardour/editing.cc | 32 +++++++++---------- gtk2_ardour/editing.h | 28 ++++++++-------- gtk2_ardour/editing_context.h | 4 +-- .../{editing_syms.h => editing_syms.inc.h} | 0 gtk2_ardour/luainstance.cc | 12 +++---- gtk2_ardour/luasignal.h | 2 +- ...{luasignal_syms.h => luasignal_syms.inc.h} | 0 gtk2_ardour/note_base.cc | 4 +-- gtk2_ardour/preference-metadata | 9 ++++-- gtk2_ardour/ui_config.cc | 18 +++++------ gtk2_ardour/ui_config.h | 8 ++--- ...{ui_config_vars.h => ui_config_vars.inc.h} | 0 libs/ardour/MSVClibardour/ardour.vcproj | 4 +-- libs/ardour/ardour/rc_configuration.h | 4 +-- ...ion_vars.h => rc_configuration_vars.inc.h} | 0 libs/ardour/ardour/session_configuration.h | 4 +-- ...ars.h => session_configuration_vars.inc.h} | 0 libs/ardour/luabindings.cc | 4 +-- libs/ardour/midi_ui.cc | 2 +- libs/ardour/rc_configuration.cc | 10 +++--- libs/ardour/session_configuration.cc | 10 +++--- libs/ardour/test/test_ui.cc | 2 +- .../midi_surface/midi_surface.cc | 2 +- libs/gtkmm2ext/gtk_ui.cc | 2 +- .../{abstract_ui.cc => abstract_ui.inc.cc} | 0 libs/surfaces/cc121/cc121.cc | 2 +- libs/surfaces/console1/console1.cc | 2 +- libs/surfaces/contourdesign/contourdesign.cc | 2 +- libs/surfaces/faderport/faderport.cc | 2 +- libs/surfaces/faderport8/faderport8.cc | 2 +- .../generic_midi_control_protocol.cc | 2 +- .../launch_control_xl/launch_control_xl.cc | 2 +- libs/surfaces/launchkey_4/launchkey_4.cc | 2 +- libs/surfaces/launchpad_pro/lppro.cc | 2 +- libs/surfaces/launchpad_x/lpx.cc | 2 +- .../mackie/mackie_control_protocol.cc | 2 +- libs/surfaces/maschine2/maschine2.cc | 2 +- libs/surfaces/osc/osc.cc | 2 +- libs/surfaces/push2/push2.cc | 2 +- .../us2400/us2400_control_protocol.cc | 2 +- libs/surfaces/websockets/ardour_websockets.cc | 2 +- libs/surfaces/websockets/feedback.cc | 2 +- libs/surfaces/wiimote/wiimote.cc | 2 +- 47 files changed, 105 insertions(+), 102 deletions(-) rename gtk2_ardour/{canvas_vars.h => canvas_vars.inc.h} (100%) rename gtk2_ardour/{configuration_metadata.h => configuration_metadata.inc.h} (100%) rename gtk2_ardour/{editing_syms.h => editing_syms.inc.h} (100%) rename gtk2_ardour/{luasignal_syms.h => luasignal_syms.inc.h} (100%) rename gtk2_ardour/{ui_config_vars.h => ui_config_vars.inc.h} (100%) rename libs/ardour/ardour/{rc_configuration_vars.h => rc_configuration_vars.inc.h} (100%) rename libs/ardour/ardour/{session_configuration_vars.h => session_configuration_vars.inc.h} (100%) rename libs/pbd/pbd/{abstract_ui.cc => abstract_ui.inc.cc} (100%) diff --git a/MSVCardour3/Ardour3.vcproj b/MSVCardour3/Ardour3.vcproj index b757af6815..53738c6d7c 100644 --- a/MSVCardour3/Ardour3.vcproj +++ b/MSVCardour3/Ardour3.vcproj @@ -1606,7 +1606,7 @@ > c)); } } #define STATIC(n,c) else if (i == LuaSignal::n) { connect (LuaSignal::n, obj, c); } if (0) {} -# include "luasignal_syms.h" +# include "luasignal_syms.inc.h" else { PBD::fatal << string_compose (_("programming error: %1: %2"), "Impossible LuaSignal type", i) << endmsg; abort(); /*NOTREACHED*/ diff --git a/gtk2_ardour/luasignal.h b/gtk2_ardour/luasignal.h index 7193050dab..2293a7aeb0 100644 --- a/gtk2_ardour/luasignal.h +++ b/gtk2_ardour/luasignal.h @@ -24,7 +24,7 @@ namespace LuaSignal { #define SESSION(name,c) name, enum LuaSignal { -# include "luasignal_syms.h" +# include "luasignal_syms.inc.h" LAST_SIGNAL }; diff --git a/gtk2_ardour/luasignal_syms.h b/gtk2_ardour/luasignal_syms.inc.h similarity index 100% rename from gtk2_ardour/luasignal_syms.h rename to gtk2_ardour/luasignal_syms.inc.h diff --git a/gtk2_ardour/note_base.cc b/gtk2_ardour/note_base.cc index 3392ccf36d..4897e575e5 100644 --- a/gtk2_ardour/note_base.cc +++ b/gtk2_ardour/note_base.cc @@ -29,13 +29,13 @@ #include "note_base.h" #include "editing_context.h" -#include "editing_syms.h" +#include "editing_syms.inc.h" #include "keyboard.h" #include "midi_view.h" /* clang-format off */ // Include last, when GRIDTYPE has been defined by editing.h via midi_region_view.h -#include "editing_syms.h" +#include "editing_syms.inc.h" /* clang-format on */ using namespace std; diff --git a/gtk2_ardour/preference-metadata b/gtk2_ardour/preference-metadata index 5300fd6053..10e54307ee 100644 --- a/gtk2_ardour/preference-metadata +++ b/gtk2_ardour/preference-metadata @@ -10,9 +10,6 @@ # [never-do-that-thing] # thing that action prevent never stop otherthing # -# The file is processed via tools/process-metadata to create build/gtk2_ardour/configuration_metadata.h which is then incorporated via an #include directive -# within gtk2_ardour/ui_config.cc -# # Whenever a new preference variable is added to the source code, its name should also be added here. # # GUIDANCE: @@ -20,6 +17,12 @@ # use "synchronization" rather than sync, because that will match both "sync" and "synchronization". For languages that create plurals with a suffix, # prefer plural forms for the same reason. # +# This file is processed automatically when invoking a custom tool manually: +# +# tools/process-metadata gtk2_ardour/preference-metadata > gtk2_ardour/configuration_metadata.inc.h +# +# The generated file is incorporated via an #include directive within gtk2_ardour/ui_config.cc . + [SECTION:UI] [action-table-columns] diff --git a/gtk2_ardour/ui_config.cc b/gtk2_ardour/ui_config.cc index 6e42f750d9..37e716bd0f 100644 --- a/gtk2_ardour/ui_config.cc +++ b/gtk2_ardour/ui_config.cc @@ -84,8 +84,8 @@ UIConfiguration::UIConfiguration () #undef UI_CONFIG_VARIABLE #define UI_CONFIG_VARIABLE(Type,var,name,val) var (name,val), #define CANVAS_FONT_VARIABLE(var,name) var (name), -#include "ui_config_vars.h" -#include "canvas_vars.h" +#include "ui_config_vars.inc.h" +#include "canvas_vars.inc.h" #undef UI_CONFIG_VARIABLE #undef CANVAS_FONT_VARIABLE @@ -101,7 +101,7 @@ UIConfiguration::UIConfiguration () #undef UI_CONFIG_VARIABLE #define UI_CONFIG_VARIABLE(Type,var,name,value) _my_variables.insert (std::make_pair ((name), &(var))); #define CANVAS_FONT_VARIABLE(var,name) /* no need for metadata for these */ -#include "ui_config_vars.h" +#include "ui_config_vars.inc.h" #undef UI_CONFIG_VARIABLE #undef CANVAS_FONT_VARIABLE @@ -222,7 +222,7 @@ UIConfiguration::map_parameters (std::function& functor) { #undef UI_CONFIG_VARIABLE #define UI_CONFIG_VARIABLE(Type,var,Name,value) functor (Name); -#include "ui_config_vars.h" +#include "ui_config_vars.inc.h" #undef UI_CONFIG_VARIABLE } @@ -572,8 +572,8 @@ UIConfiguration::get_variables (std::string const & node_name) const #undef CANVAS_FONT_VARIABLE #define UI_CONFIG_VARIABLE(Type,var,Name,value) if (node->name() == "UI") { var.add_to_node (*node); } #define CANVAS_FONT_VARIABLE(var,Name) if (node->name() == "Canvas") { var.add_to_node (*node); } -#include "ui_config_vars.h" -#include "canvas_vars.h" +#include "ui_config_vars.inc.h" +#include "canvas_vars.inc.h" #undef UI_CONFIG_VARIABLE #undef CANVAS_FONT_VARIABLE @@ -707,8 +707,8 @@ UIConfiguration::set_variables (const XMLNode& node) #undef UI_CONFIG_VARIABLE #define UI_CONFIG_VARIABLE(Type,var,name,val) if (var.set_from_node (node)) { ParameterChanged (name); } #define CANVAS_FONT_VARIABLE(var,name) if (var.set_from_node (node)) { ParameterChanged (name); } -#include "ui_config_vars.h" -#include "canvas_vars.h" +#include "ui_config_vars.inc.h" +#include "canvas_vars.inc.h" #undef UI_CONFIG_VARIABLE #undef CANVAS_FONT_VARIABLE } @@ -867,4 +867,4 @@ UIConfiguration::color_to_hex_string_no_alpha (Gtkmm2ext::Color c) return buf; } -#include "configuration_metadata.h" +#include "configuration_metadata.inc.h" diff --git a/gtk2_ardour/ui_config.h b/gtk2_ardour/ui_config.h index d365eef0b4..2396a52141 100644 --- a/gtk2_ardour/ui_config.h +++ b/gtk2_ardour/ui_config.h @@ -114,13 +114,13 @@ public: #define UI_CONFIG_VARIABLE(Type,var,name,value) \ Type get_##var () const { return var.get(); } \ bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; } -#include "ui_config_vars.h" +#include "ui_config_vars.inc.h" #undef UI_CONFIG_VARIABLE #define CANVAS_FONT_VARIABLE(var,name) \ Pango::FontDescription get_##var () const { return ARDOUR_UI_UTILS::sanitized_font (var.get()); } \ Pango::FontDescription get_Ardour##var () const { return ARDOUR_UI_UTILS::ardour_font (var.get()); } \ bool set_##var (const std::string& val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; } -#include "canvas_vars.h" +#include "canvas_vars.inc.h" #undef CANVAS_FONT_VARIABLE private: @@ -128,11 +128,11 @@ private: #undef UI_CONFIG_VARIABLE #define UI_CONFIG_VARIABLE(Type,var,name,value) PBD::ConfigVariable var; -#include "ui_config_vars.h" +#include "ui_config_vars.inc.h" #undef UI_CONFIG_VARIABLE #define CANVAS_FONT_VARIABLE(var,name) PBD::ConfigVariable var; -#include "canvas_vars.h" +#include "canvas_vars.inc.h" #undef CANVAS_FONT_VARIABLE XMLNode& state () const; diff --git a/gtk2_ardour/ui_config_vars.h b/gtk2_ardour/ui_config_vars.inc.h similarity index 100% rename from gtk2_ardour/ui_config_vars.h rename to gtk2_ardour/ui_config_vars.inc.h diff --git a/libs/ardour/MSVClibardour/ardour.vcproj b/libs/ardour/MSVClibardour/ardour.vcproj index 33c8ddb70c..5b131ef0b9 100644 --- a/libs/ardour/MSVClibardour/ardour.vcproj +++ b/libs/ardour/MSVClibardour/ardour.vcproj @@ -2350,7 +2350,7 @@ > var; #define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) PBD::ConfigVariableWithMutation var; -#include "ardour/rc_configuration_vars.h" +#include "ardour/rc_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL diff --git a/libs/ardour/ardour/rc_configuration_vars.h b/libs/ardour/ardour/rc_configuration_vars.inc.h similarity index 100% rename from libs/ardour/ardour/rc_configuration_vars.h rename to libs/ardour/ardour/rc_configuration_vars.inc.h diff --git a/libs/ardour/ardour/session_configuration.h b/libs/ardour/ardour/session_configuration.h index 88474b6114..d592234390 100644 --- a/libs/ardour/ardour/session_configuration.h +++ b/libs/ardour/ardour/session_configuration.h @@ -53,7 +53,7 @@ public: #define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) \ Type get_##var () const { return var.get(); } \ bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; } -#include "ardour/session_configuration_vars.h" +#include "ardour/session_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL /* clang-format on */ @@ -67,7 +67,7 @@ public: #undef CONFIG_VARIABLE_SPECIAL #define CONFIG_VARIABLE(Type,var,name,value) PBD::ConfigVariable var; #define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) PBD::ConfigVariableWithMutation var; -#include "ardour/session_configuration_vars.h" +#include "ardour/session_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL /* clang-format on */ diff --git a/libs/ardour/ardour/session_configuration_vars.h b/libs/ardour/ardour/session_configuration_vars.inc.h similarity index 100% rename from libs/ardour/ardour/session_configuration_vars.h rename to libs/ardour/ardour/session_configuration_vars.inc.h diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index 5b90afc00c..38843d263f 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -3006,7 +3006,7 @@ LuaBindings::common (lua_State* L) .addFunction ("set_" # var, &RCConfiguration::set_##var) \ .addProperty (#var, &RCConfiguration::get_##var, &RCConfiguration::set_##var) -#include "ardour/rc_configuration_vars.h" +#include "ardour/rc_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL @@ -3025,7 +3025,7 @@ LuaBindings::common (lua_State* L) .addFunction ("set_" # var, &SessionConfiguration::set_##var) \ .addProperty (#var, &SessionConfiguration::get_##var, &SessionConfiguration::set_##var) -#include "ardour/session_configuration_vars.h" +#include "ardour/session_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL diff --git a/libs/ardour/midi_ui.cc b/libs/ardour/midi_ui.cc index 81a865934e..60d1c20313 100644 --- a/libs/ardour/midi_ui.cc +++ b/libs/ardour/midi_ui.cc @@ -43,7 +43,7 @@ using namespace Glib; MidiControlUI* MidiControlUI::_instance = 0; -#include "pbd/abstract_ui.cc" /* instantiate the template */ +#include "pbd/abstract_ui.inc.cc" /* instantiate the template */ MidiControlUI::MidiControlUI (Session& s) : AbstractUI (X_("midiUI")) diff --git a/libs/ardour/rc_configuration.cc b/libs/ardour/rc_configuration.cc index ebbf028bda..7c8f7f3f86 100644 --- a/libs/ardour/rc_configuration.cc +++ b/libs/ardour/rc_configuration.cc @@ -70,7 +70,7 @@ RCConfiguration::RCConfiguration () #undef CONFIG_VARIABLE_SPECIAL #define CONFIG_VARIABLE(Type,var,name,value) var (name,value), #define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) var (name,value,mutator), -#include "ardour/rc_configuration_vars.h" +#include "ardour/rc_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL _control_protocol_state (0) @@ -84,7 +84,7 @@ RCConfiguration::RCConfiguration () #undef CONFIG_VARIABLE_SPECIAL #define CONFIG_VARIABLE(Type,var,name,value) _my_variables.insert (std::make_pair ((name), &(var))); #define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) _my_variables.insert (std::make_pair ((name), &(var))); -#include "ardour/rc_configuration_vars.h" +#include "ardour/rc_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL @@ -243,7 +243,7 @@ RCConfiguration::get_variables (std::string const & node_name) const var.add_to_node (*node); #define CONFIG_VARIABLE_SPECIAL(type,var,Name,value,mutator) \ var.add_to_node (*node); -#include "ardour/rc_configuration_vars.h" +#include "ardour/rc_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL @@ -299,7 +299,7 @@ RCConfiguration::set_variables (const XMLNode& node) ParameterChanged (name); \ } -#include "ardour/rc_configuration_vars.h" +#include "ardour/rc_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL @@ -311,7 +311,7 @@ RCConfiguration::map_parameters (std::function& functor) #undef CONFIG_VARIABLE_SPECIAL #define CONFIG_VARIABLE(type,var,name,value) functor (name); #define CONFIG_VARIABLE_SPECIAL(type,var,name,value,mutator) functor (name); -#include "ardour/rc_configuration_vars.h" +#include "ardour/rc_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL } diff --git a/libs/ardour/session_configuration.cc b/libs/ardour/session_configuration.cc index 8d908dc927..4222975f22 100644 --- a/libs/ardour/session_configuration.cc +++ b/libs/ardour/session_configuration.cc @@ -50,7 +50,7 @@ SessionConfiguration::SessionConfiguration () #undef CONFIG_VARIABLE_SPECIAL #define CONFIG_VARIABLE(Type,var,name,value) var (name,value), #define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) var (name,value,mutator), -#include "ardour/session_configuration_vars.h" +#include "ardour/session_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL foo (0) // needed because above macros end in a comma @@ -62,7 +62,7 @@ SessionConfiguration::SessionConfiguration () #undef CONFIG_VARIABLE_SPECIAL #define CONFIG_VARIABLE(Type,var,name,value) _my_variables.insert (std::make_pair ((name), &(var))); #define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) _my_variables.insert (std::make_pair ((name), &(var))); -#include "ardour/session_configuration_vars.h" +#include "ardour/session_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL @@ -97,7 +97,7 @@ SessionConfiguration::get_variables (std::string const & node_name) const var.add_to_node (*node); #define CONFIG_VARIABLE_SPECIAL(type,var,Name,value,mutator) \ var.add_to_node (*node); -#include "ardour/session_configuration_vars.h" +#include "ardour/session_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL @@ -136,7 +136,7 @@ SessionConfiguration::set_variables (const XMLNode& node) ParameterChanged (name); \ } -#include "ardour/session_configuration_vars.h" +#include "ardour/session_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL @@ -148,7 +148,7 @@ SessionConfiguration::map_parameters (std::function& functor #undef CONFIG_VARIABLE_SPECIAL #define CONFIG_VARIABLE(type,var,name,value) functor (name); #define CONFIG_VARIABLE_SPECIAL(type,var,name,value,mutator) functor (name); -#include "ardour/session_configuration_vars.h" +#include "ardour/session_configuration_vars.inc.h" #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL } diff --git a/libs/ardour/test/test_ui.cc b/libs/ardour/test/test_ui.cc index 867eafba7d..bc1406f016 100644 --- a/libs/ardour/test/test_ui.cc +++ b/libs/ardour/test/test_ui.cc @@ -25,7 +25,7 @@ #include "ardour/session_event.h" #include "ardour/rc_configuration.h" -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template using namespace ARDOUR; diff --git a/libs/ctrl-interface/midi_surface/midi_surface.cc b/libs/ctrl-interface/midi_surface/midi_surface.cc index a295ac3df2..f77a91a572 100644 --- a/libs/ctrl-interface/midi_surface/midi_surface.cc +++ b/libs/ctrl-interface/midi_surface/midi_surface.cc @@ -35,7 +35,7 @@ using namespace ARDOUR; using namespace Glib; using namespace PBD; -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template MIDISurface::MIDISurface (ARDOUR::Session& s, std::string const & namestr, std::string const & port_prefix, bool use_pad_filter) : ControlProtocol (s, namestr) diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index af9d2bd198..2459fa32ae 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -69,7 +69,7 @@ BaseUI::RequestType Gtkmm2ext::SetTip = BaseUI::new_request_type(); BaseUI::RequestType Gtkmm2ext::AddIdle = BaseUI::new_request_type(); BaseUI::RequestType Gtkmm2ext::AddTimeout = BaseUI::new_request_type(); -#include "pbd/abstract_ui.cc" /* instantiate the template */ +#include "pbd/abstract_ui.inc.cc" /* instantiate the template */ template class AbstractUI; diff --git a/libs/pbd/pbd/abstract_ui.cc b/libs/pbd/pbd/abstract_ui.inc.cc similarity index 100% rename from libs/pbd/pbd/abstract_ui.cc rename to libs/pbd/pbd/abstract_ui.inc.cc diff --git a/libs/surfaces/cc121/cc121.cc b/libs/surfaces/cc121/cc121.cc index f7e34cfec6..a3117ec4a3 100644 --- a/libs/surfaces/cc121/cc121.cc +++ b/libs/surfaces/cc121/cc121.cc @@ -69,7 +69,7 @@ using namespace std; #include "pbd/i18n.h" -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template CC121::CC121 (Session& s) : ControlProtocol (s, _("Steinberg CC121")) diff --git a/libs/surfaces/console1/console1.cc b/libs/surfaces/console1/console1.cc index 6269cf88d0..84336229be 100644 --- a/libs/surfaces/console1/console1.cc +++ b/libs/surfaces/console1/console1.cc @@ -18,7 +18,7 @@ #include -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template #include "pbd/controllable.h" #include "pbd/i18n.h" diff --git a/libs/surfaces/contourdesign/contourdesign.cc b/libs/surfaces/contourdesign/contourdesign.cc index 21f13d856f..793e15547d 100644 --- a/libs/surfaces/contourdesign/contourdesign.cc +++ b/libs/surfaces/contourdesign/contourdesign.cc @@ -38,7 +38,7 @@ using namespace Glib; using namespace std; using namespace ArdourSurface; -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template static const uint16_t ContourDesign = 0x0b33; static const uint16_t ShuttlePRO_id = 0x0010; diff --git a/libs/surfaces/faderport/faderport.cc b/libs/surfaces/faderport/faderport.cc index 5e298c4e59..e9d569768b 100644 --- a/libs/surfaces/faderport/faderport.cc +++ b/libs/surfaces/faderport/faderport.cc @@ -63,7 +63,7 @@ using namespace std; #include "pbd/i18n.h" -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template FaderPort::FaderPort (Session& s) : MIDISurface (s, X_("PreSonus FaderPort"), X_("FaderPort"), false) diff --git a/libs/surfaces/faderport8/faderport8.cc b/libs/surfaces/faderport8/faderport8.cc index 7854acb8da..f962a9458e 100644 --- a/libs/surfaces/faderport8/faderport8.cc +++ b/libs/surfaces/faderport8/faderport8.cc @@ -62,7 +62,7 @@ using namespace ArdourSurface::FP_NAMESPACE::FP8Types; #include "pbd/i18n.h" -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template #ifndef NDEBUG //#define VERBOSE_DEBUG diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc index c1bf68a5bb..08e88716d1 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc @@ -66,7 +66,7 @@ #include "midifunction.h" #include "midiaction.h" -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template #include "pbd/i18n.h" diff --git a/libs/surfaces/launch_control_xl/launch_control_xl.cc b/libs/surfaces/launch_control_xl/launch_control_xl.cc index af77e5f225..732cc344fa 100644 --- a/libs/surfaces/launch_control_xl/launch_control_xl.cc +++ b/libs/surfaces/launch_control_xl/launch_control_xl.cc @@ -65,7 +65,7 @@ using namespace std; using namespace PBD; using namespace Glib; using namespace ArdourSurface; -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template /* init global object */ LaunchControlXL* lcxl = 0; diff --git a/libs/surfaces/launchkey_4/launchkey_4.cc b/libs/surfaces/launchkey_4/launchkey_4.cc index ab5dfe218e..b03f52ad7b 100644 --- a/libs/surfaces/launchkey_4/launchkey_4.cc +++ b/libs/surfaces/launchkey_4/launchkey_4.cc @@ -78,7 +78,7 @@ using namespace ArdourSurface; using namespace ArdourSurface::LAUNCHPAD_NAMESPACE; using namespace Gtkmm2ext; -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template /* USB IDs */ diff --git a/libs/surfaces/launchpad_pro/lppro.cc b/libs/surfaces/launchpad_pro/lppro.cc index 913bfc17e2..e9ee1ca58d 100644 --- a/libs/surfaces/launchpad_pro/lppro.cc +++ b/libs/surfaces/launchpad_pro/lppro.cc @@ -73,7 +73,7 @@ using namespace Glib; using namespace ArdourSurface; using namespace Gtkmm2ext; -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template #define NOVATION 0x1235 #define LAUNCHPADPROMK3 0x0123 diff --git a/libs/surfaces/launchpad_x/lpx.cc b/libs/surfaces/launchpad_x/lpx.cc index c2393f6df7..e21f9bf970 100644 --- a/libs/surfaces/launchpad_x/lpx.cc +++ b/libs/surfaces/launchpad_x/lpx.cc @@ -80,7 +80,7 @@ using namespace ArdourSurface; using namespace ArdourSurface::LAUNCHPAD_NAMESPACE; using namespace Gtkmm2ext; -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template #define NOVATION 0x1235 diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 61d8f70807..a527f9c5f1 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -98,7 +98,7 @@ using namespace ArdourSurface::MACKIE_NAMESPACE; #include "pbd/i18n.h" -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template const int MACKIE_NAMESPACE::MackieControlProtocol::MODIFIER_OPTION = 0x1; const int MACKIE_NAMESPACE::MackieControlProtocol::MODIFIER_CONTROL = 0x2; diff --git a/libs/surfaces/maschine2/maschine2.cc b/libs/surfaces/maschine2/maschine2.cc index 616f3eab2e..114cf5f74e 100644 --- a/libs/surfaces/maschine2/maschine2.cc +++ b/libs/surfaces/maschine2/maschine2.cc @@ -42,7 +42,7 @@ #include "canvas.h" -#include "pbd/abstract_ui.cc" // instantiate template, includes i18n +#include "pbd/abstract_ui.inc.cc" // instantiate template, includes i18n using namespace ARDOUR; using namespace PBD; diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 78f3e1943d..de1246074f 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -84,7 +84,7 @@ using namespace std; using namespace Glib; using namespace ArdourSurface; -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template OSC* OSC::_instance = 0; diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index c7f45fc1ff..c666cc9be2 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -74,7 +74,7 @@ using namespace Glib; using namespace ArdourSurface; using namespace Gtkmm2ext; -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template #define ABLETON 0x2982 #define PUSH2 0x1967 diff --git a/libs/surfaces/us2400/us2400_control_protocol.cc b/libs/surfaces/us2400/us2400_control_protocol.cc index e025526660..0a922ef280 100644 --- a/libs/surfaces/us2400/us2400_control_protocol.cc +++ b/libs/surfaces/us2400/us2400_control_protocol.cc @@ -83,7 +83,7 @@ using namespace US2400; #include "pbd/i18n.h" -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template const int US2400Protocol::MODIFIER_OPTION = 0x1; const int US2400Protocol::MODIFIER_CONTROL = 0x2; diff --git a/libs/surfaces/websockets/ardour_websockets.cc b/libs/surfaces/websockets/ardour_websockets.cc index 5fec5d5819..962845bd84 100644 --- a/libs/surfaces/websockets/ardour_websockets.cc +++ b/libs/surfaces/websockets/ardour_websockets.cc @@ -32,7 +32,7 @@ using namespace ARDOUR; using namespace ArdourSurface; -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template ArdourWebsockets::ArdourWebsockets (Session& s) : ControlProtocol (s, X_ (surface_name)) diff --git a/libs/surfaces/websockets/feedback.cc b/libs/surfaces/websockets/feedback.cc index dd094052b8..3ca284460b 100644 --- a/libs/surfaces/websockets/feedback.cc +++ b/libs/surfaces/websockets/feedback.cc @@ -20,7 +20,7 @@ #include "ardour/session.h" #include "ardour/tempo.h" -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template #include "feedback.h" #include "transport.h" diff --git a/libs/surfaces/wiimote/wiimote.cc b/libs/surfaces/wiimote/wiimote.cc index 0578d0c42d..a6ab558685 100644 --- a/libs/surfaces/wiimote/wiimote.cc +++ b/libs/surfaces/wiimote/wiimote.cc @@ -31,7 +31,7 @@ using namespace ARDOUR; using namespace PBD; using namespace std; -#include "pbd/abstract_ui.cc" // instantiate template +#include "pbd/abstract_ui.inc.cc" // instantiate template void wiimote_control_protocol_mesg_callback (cwiid_wiimote_t *wiimote, int mesg_count, union cwiid_mesg mesg[], timespec *t); From 8a5f21d8e3072394d7868396166bd36dd588eb89 Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Sun, 20 Oct 2024 00:34:07 +0200 Subject: [PATCH 003/113] Drop some unused files - avoid trying to maintain stuff that can't be tested --- MSVCardour3/Ardour3.vcproj | 12 - gtk2_ardour/crossfade_view.h | 87 ------- gtk2_ardour/patch_change_dialog.h | 1 - gtk2_ardour/tempo_lines.cc | 188 -------------- gtk2_ardour/tempo_lines.h | 51 ---- libs/ardour/MSVClibardour/ardour.vcproj | 8 - libs/ardour/ardour/automation_list.h | 1 - libs/ardour/ardour/export_multiplication.h | 207 --------------- libs/ardour/ardour/midi_playlist.h | 1 - libs/ardour/ardour/soundseq.h | 50 ---- libs/evoral/MSVCevoral/evoral.vcproj | 8 - libs/evoral/SMFReader.cc | 285 --------------------- libs/evoral/evoral/MIDIXML.h | 96 ------- libs/evoral/evoral/SMFReader.h | 88 ------- libs/pbd/MSVCpbd/pbd.vcproj | 4 - libs/pbd/pbd/functor_command.h | 116 --------- 16 files changed, 1203 deletions(-) delete mode 100644 gtk2_ardour/crossfade_view.h delete mode 100644 gtk2_ardour/tempo_lines.cc delete mode 100644 gtk2_ardour/tempo_lines.h delete mode 100644 libs/ardour/ardour/export_multiplication.h delete mode 100644 libs/ardour/ardour/soundseq.h delete mode 100644 libs/evoral/SMFReader.cc delete mode 100644 libs/evoral/evoral/MIDIXML.h delete mode 100644 libs/evoral/evoral/SMFReader.h delete mode 100644 libs/pbd/pbd/functor_command.h diff --git a/MSVCardour3/Ardour3.vcproj b/MSVCardour3/Ardour3.vcproj index 53738c6d7c..67098011cf 100644 --- a/MSVCardour3/Ardour3.vcproj +++ b/MSVCardour3/Ardour3.vcproj @@ -1323,10 +1323,6 @@ RelativePath="..\gtk2_ardour\tempo_dialog.cc" > - - @@ -1645,10 +1641,6 @@ RelativePath="..\gtk2_ardour\crossfade_edit.h" > - - @@ -2537,10 +2529,6 @@ RelativePath="..\gtk2_ardour\tempo_dialog.h" > - - diff --git a/gtk2_ardour/crossfade_view.h b/gtk2_ardour/crossfade_view.h deleted file mode 100644 index 95a3883aec..0000000000 --- a/gtk2_ardour/crossfade_view.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2005-2014 Paul Davis - * Copyright (C) 2005 Nick Mainsbridge - * Copyright (C) 2005 Taybin Rutkin - * Copyright (C) 2006-2011 David Robillard - * Copyright (C) 2007-2011 Carl Hetherington - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#include -#include "pbd/signals.h" -#include "ardour/crossfade.h" - -#include "time_axis_view_item.h" - -class RouteTimeAxisView; -class AudioRegionView; - -namespace ArdourCanvas { - class PolyLine; -} - -class CrossfadeView : public TimeAxisViewItem -{ -public: - CrossfadeView (ArdourCanvas::Container*, - RouteTimeAxisView&, - std::shared_ptr, - double initial_samples_per_pixel, - Gdk::Color& basic_color, - AudioRegionView& leftview, - AudioRegionView& rightview); - - ~CrossfadeView (); - - std::shared_ptr crossfade; // ok, let 'em have it - - AudioRegionView& left_view; // and these too - AudioRegionView& right_view; - - void set_heights (double, double); - - bool valid() const { return _valid; } - bool visible() const { return _visible; } - void set_valid (bool yn); - - static PBD::Signal CatchDeletion; - - void fake_hide (); - void hide (); - void show (); - void horizontal_position_changed (); - -protected: - void reset_width_dependent_items (double pixel_width); - -private: - bool _valid; - bool _visible; - bool _all_in_view; - double _child_height; - - ArdourCanvas::PolyLine *fade_in; - ArdourCanvas::PolyLine *fade_out; - - void crossfade_changed (const PBD::PropertyChange&); - void crossfade_fades_changed (); - void active_changed (); - void redraw_curves (); - void color_handler (); -}; - diff --git a/gtk2_ardour/patch_change_dialog.h b/gtk2_ardour/patch_change_dialog.h index 261672a945..d3b1478e75 100644 --- a/gtk2_ardour/patch_change_dialog.h +++ b/gtk2_ardour/patch_change_dialog.h @@ -27,7 +27,6 @@ #include "audio_clock.h" namespace ARDOUR { - class BeatsSamplesConverter; class Session; class InstrumentInfo; } diff --git a/gtk2_ardour/tempo_lines.cc b/gtk2_ardour/tempo_lines.cc deleted file mode 100644 index 0f1aa8d7af..0000000000 --- a/gtk2_ardour/tempo_lines.cc +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2007-2015 David Robillard - * Copyright (C) 2010-2017 Paul Davis - * Copyright (C) 2012 Carl Hetherington - * Copyright (C) 2014-2017 Nick Mainsbridge - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "pbd/compose.h" - -#include "canvas/canvas.h" -#include "canvas/debug.h" - -#include "tempo_lines.h" -#include "public_editor.h" -#include "rgb_macros.h" -#include "ui_config.h" - -using namespace std; - -TempoLines::TempoLines (ArdourCanvas::Container* group, double, ARDOUR::BeatsSamplesConverter* bfc) - : lines (group, ArdourCanvas::LineSet::Vertical) - , _bfc (bfc) -{ - lines.set_extent (ArdourCanvas::COORD_MAX); -} - -TempoLines::~TempoLines () -{ - delete _bfc; - _bfc = 0; -} - -void -TempoLines::tempo_map_changed (samplepos_t new_origin) -{ - lines.clear (); - _bfc->set_origin_b (new_origin); -} - -void -TempoLines::show () -{ - lines.show (); -} - -void -TempoLines::hide () -{ - lines.hide (); -} - -void -TempoLines::draw_ticks (std::vector& grid, - unsigned divisions, - samplecnt_t leftmost_sample, - samplecnt_t sample_rate) -{ - const uint32_t base = UIConfiguration::instance().color_mod("measure line beat", "measure line beat"); - - for (unsigned l = 1; l < divisions; ++l) { - /* find the coarsest division level this tick falls on */ - unsigned level = divisions; - for (unsigned d = divisions; d >= 4; d /= 2) { - if (l % (divisions / d) == 0) { - level = d; - } - } - /* draw line with alpha corresponding to coarsest level */ - const uint8_t a = max(8, (int)rint(UINT_RGBA_A(base) / (0.8 * log2(level)))); - const uint32_t c = UINT_RGBA_CHANGE_A(base, a); - const samplepos_t f = _bfc->to (Temporal::Beats (grid.begin()->qn + (l / (double) divisions))) + _bfc->origin_b(); - - if (f > leftmost_sample) { - lines.add (PublicEditor::instance().sample_to_pixel_unrounded (f), 1.0, c); - } - } -} - -void -TempoLines::draw (std::vector& grid, - unsigned divisions, - samplecnt_t leftmost_sample, - samplecnt_t sample_rate) -{ - std::vector::const_iterator i; - double beat_density; - - uint32_t beats = 0; - uint32_t bars = 0; - const uint32_t bar_color = UIConfiguration::instance().color ("measure line bar"); - const uint32_t beat_color = UIConfiguration::instance().color_mod ("measure line beat", "measure line beat"); - uint32_t color; - - bool all_bars = false; - /* get the first bar spacing */ - - i = grid.end(); - i--; - bars = (*i).bar - (*grid.begin()).bar; - - int32_t bar_mod = 4; - - if (bars < distance (grid.begin(), grid.end()) - 1) { - /* grid contains beats and bars */ - beats = distance (grid.begin(), grid.end()) - bars; - } else { - /* grid contains only bars */ - beats = distance (grid.begin(), grid.end()); - - if (i != grid.begin()) { - const int32_t last_bar = (*i).bar; - i--; - bar_mod = (last_bar - (*i).bar) * 4; - } - - all_bars = true; - } - - double canvas_width_used = 1.0; - if (leftmost_sample < grid.front().sample) { - const samplecnt_t sample_distance = max ((samplecnt_t) 1, grid.back().sample - grid.front().sample); - canvas_width_used = 1.0 - ((grid.front().sample - leftmost_sample) / (double) (sample_distance + grid.front().sample)); - } - - beat_density = (beats * 10.0f) / (lines.canvas()->width() * canvas_width_used); - - if (beat_density > 2.0f) { - /* if the lines are too close together, they become useless */ - lines.clear (); - return; - } - - /* constrain divisions to a log2 factor to cap line density */ - while (divisions > 3 && beat_density * divisions > 0.4) { - divisions /= 2; - } - - lines.clear (); - if (beat_density <= 0.12 && grid.begin() != grid.end() && grid.begin()->sample > 0 && !all_bars) { - /* draw subdivisions of the beat before the first visible beat line XX this shouldn't happen now */ - std::vector vec; - vec.push_back (*i); - draw_ticks (vec, divisions, leftmost_sample, sample_rate); - } - - for (i = grid.begin(); i != grid.end(); ++i) { - - if ((*i).is_bar()) { - /* keep all_bar beat density down */ - if (all_bars && beat_density > 0.3 && ((*i).bar % bar_mod) != 1) { - continue; - } - - color = bar_color; - } else { - if (beat_density > 0.3) { - continue; /* only draw beat lines if the gaps between beats are large. */ - } - color = beat_color; - } - - ArdourCanvas::Coord xpos = PublicEditor::instance().sample_to_pixel_unrounded ((*i).sample); - - lines.add (xpos, 1.0, color); - - if (beat_density <= 0.12 && !all_bars) { - /* draw subdivisions of this beat */ - std::vector vec; - vec.push_back (*i); - draw_ticks (vec, divisions, leftmost_sample, sample_rate); - } - } -} - diff --git a/gtk2_ardour/tempo_lines.h b/gtk2_ardour/tempo_lines.h deleted file mode 100644 index 7a84f705f4..0000000000 --- a/gtk2_ardour/tempo_lines.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2007-2015 David Robillard - * Copyright (C) 2012-2017 Paul Davis - * Copyright (C) 2015-2017 Nick Mainsbridge - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#include "ardour/tempo.h" - -#include "canvas/line_set.h" - -class TempoLines { -public: - TempoLines (ArdourCanvas::Container* group, double screen_height, ARDOUR::BeatsSamplesConverter* bfc); - ~TempoLines (); - - void tempo_map_changed(samplepos_t new_origin); - - void draw (std::vector& grid, - unsigned divisions, - ARDOUR::samplecnt_t leftmost_sample, - ARDOUR::samplecnt_t sample_rate); - - void show(); - void hide(); - -private: - void draw_ticks (std::vector& grid, - unsigned divisions, - ARDOUR::samplecnt_t leftmost_sample, - ARDOUR::samplecnt_t sample_rate); - - ArdourCanvas::LineSet lines; - ARDOUR::BeatsSamplesConverter* _bfc; -}; - diff --git a/libs/ardour/MSVClibardour/ardour.vcproj b/libs/ardour/MSVClibardour/ardour.vcproj index 5b131ef0b9..e9cb15288d 100644 --- a/libs/ardour/MSVClibardour/ardour.vcproj +++ b/libs/ardour/MSVClibardour/ardour.vcproj @@ -1881,10 +1881,6 @@ RelativePath="..\ardour\export_handler.h" > - - @@ -2545,10 +2541,6 @@ RelativePath="..\ardour\soundcloud_upload.h" > - - diff --git a/libs/ardour/ardour/automation_list.h b/libs/ardour/ardour/automation_list.h index b8ad0632d7..952bd1007f 100644 --- a/libs/ardour/ardour/automation_list.h +++ b/libs/ardour/ardour/automation_list.h @@ -43,7 +43,6 @@ namespace ARDOUR { class AutomationList; -class BeatsSamplesConverter; /** A SharedStatefulProperty for AutomationLists */ class LIBARDOUR_API AutomationListProperty : public PBD::SharedStatefulProperty diff --git a/libs/ardour/ardour/export_multiplication.h b/libs/ardour/ardour/export_multiplication.h deleted file mode 100644 index 35979aab04..0000000000 --- a/libs/ardour/ardour/export_multiplication.h +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2008-2015 Paul Davis - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* This file is not used at the moment. It includes code related to export a - * multiplication graph system that can be used together with the ExportMultiplicator - * class in the gtk2_ardour folder. - * - Sakari Bergen 6.8.2008 - - */ - -/*** Graph classes ***/ - public: - - /// A node in the hierarchical graph that represents a multiplicatable export item - class GraphNode { - public: - GraphNode (); - virtual ~GraphNode (); - - uint32_t id() const { return _id; } - - /* Children and parents. Note: only children are kept in order! */ - - list const & get_parents () const { return parents; } - - void add_child (GraphNode * child, GraphNode * left_sibling); - void remove_child (GraphNode * child); - GraphNode * first_child () const { return children.front(); } - GraphNode * last_child () const { return children.back(); } - list const & get_children () const { return children; } - - /* Relation functions */ - - bool is_ancestor_of (GraphNode const * node) const; - bool is_descendant_of (GraphNode const * node) const; - bool equals (GraphNode const * node) const { return node == this; } - - /* Selection functions */ - - bool selected () const { return _selected; } - void select (bool value); - - PBD::Signal SelectChanged; - - protected: - - /* Parent manipulation functions should be used only from child manipulation functions! */ - - void add_parent (GraphNode * parent); - void remove_parent (GraphNode * parent); - - list parents; - list children; - - bool _selected; - uint32_t _id; - static uint32_t id_counter; - }; - - /// A graph node that contains data - template - class DataNode : public GraphNode { - private: - typedef std::shared_ptr DataPtr; - typedef std::shared_ptr > SelfPtr; - typedef std::weak_ptr > WeakSelfPtr; - - DataNode (DataPtr data) : _data (data) {} - void set_self_ptr (std::shared_ptr > ptr) { _self_ptr = ptr; } - - public: - static SelfPtr create (T * data) - { - SelfPtr ptr = SelfPtr (new DataNode (DataPtr (data))); - ptr->set_self_ptr (ptr); - return ptr; - } - - static SelfPtr create (DataPtr data) - { - SelfPtr ptr = SelfPtr (new DataNode (data)); - ptr->set_self_ptr (ptr); - return ptr; - } - - DataPtr data() { return _data; } - SelfPtr self_ptr () { return _self_ptr.lock(); } - - template // Parent's data type - void sort_parents (list > > const & sort_list) - { - parents.sort (NodeSorter

(sort_list)); - } - - private: - DataPtr _data; - WeakSelfPtr _self_ptr; - }; - - private: - /* Sorts GraphNodes according to a list of DataNodes */ - - template - class NodeSorter { - public: - typedef list > > ListType; - - NodeSorter (ListType const & list) : list (list) {} - - bool operator() (GraphNode * one, GraphNode * other) // '<' operator - { - if (one == other) { return false; } // Strict weak ordering - for (typename ListType::const_iterator it = list.begin(); it != list.end(); ++it) { - if (it->get() == one) { - return true; - } - if (it->get() == other) { - return false; - } - } - - std::cerr << "Invalid comparison list given to NodeSorter" << std::endl; - - abort(); - } - - private: - ListType const & list; - }; - -/*** Multiplication management ***/ - public: - - typedef DataNode TimespanNode; - typedef std::shared_ptr TimespanNodePtr; - - typedef DataNode ChannelConfigNode; - typedef std::shared_ptr ChannelConfigNodePtr; - - typedef DataNode FormatNode; - typedef std::shared_ptr FormatNodePtr; - - typedef DataNode FilenameNode; - typedef std::shared_ptr FilenameNodePtr; - - struct MultiplicationGraph { - list timespans; - list channel_configs; - list formats; - list filenames; - }; - - MultiplicationGraph const & get_graph () { return graph; } - - void split_node (GraphNode * node, float position); - void remove_node (GraphNode * node); - - PBD::Signal GraphChanged; - - private: - - void purge_graph (); - - template - static void insert_after (list & the_list, T const & position, T const & element); - - template - static void remove_by_element (list & the_list, T const & element); - - bool nodes_have_one_common_child (list const & the_list); - list::const_iterator end_of_common_child_range (list const & the_list, list::const_iterator beginning); - void split_node_at_position (GraphNode * old_node, GraphNode * new_node, float position); - - void split_timespan (TimespanNodePtr node, float position = 0.5); - void split_channel_config (ChannelConfigNodePtr node, float position = 0.5); - void split_format (FormatNodePtr node, float position = 0.5); - void split_filename (FilenameNodePtr node, float position = 0.5); - - void duplicate_timespan_children (TimespanNodePtr source, TimespanNodePtr target, GraphNode * insertion_point = 0); - void duplicate_channel_config_children (ChannelConfigNodePtr source, ChannelConfigNodePtr target, GraphNode * insertion_point = 0); - void duplicate_format_children (FormatNodePtr source, FormatNodePtr target, GraphNode * insertion_point = 0); - - TimespanNodePtr duplicate_timespan_node (TimespanNodePtr node); - ChannelConfigNodePtr duplicate_channel_config_node (ChannelConfigNodePtr node); - FormatNodePtr duplicate_format_node (FormatNodePtr node); - FilenameNodePtr duplicate_filename_node (FilenameNodePtr node); - - void remove_timespan (TimespanNodePtr node); - void remove_channel_config (ChannelConfigNodePtr node); - void remove_format (FormatNodePtr node); - void remove_filename (FilenameNodePtr node); - - MultiplicationGraph graph; \ No newline at end of file diff --git a/libs/ardour/ardour/midi_playlist.h b/libs/ardour/ardour/midi_playlist.h index 1da9061a0e..7287c3dc35 100644 --- a/libs/ardour/ardour/midi_playlist.h +++ b/libs/ardour/ardour/midi_playlist.h @@ -44,7 +44,6 @@ class Beats; namespace ARDOUR { -class BeatsSamplesConverter; class MidiChannelFilter; class MidiRegion; class Session; diff --git a/libs/ardour/ardour/soundseq.h b/libs/ardour/ardour/soundseq.h deleted file mode 100644 index 2cf8bcc866..0000000000 --- a/libs/ardour/ardour/soundseq.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2007-2017 Paul Davis - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#include "edl.h" - -namespace ARDOUR { - -typedef gint16 peak_datum; - -struct LIBARDOUR_API peak_data_t { - peak_datum min; - peak_datum max; -}; - -const uint32_t samples_per_peak = 2048; - -class LIBARDOUR_API Sound : public EDL::Piece { - public: - int peak (peak_data_t& pk, uint32_t start, uint32_t cnt); - int read_peaks (peak_data_t *, uint32_t npeaks, uint32_t start, uint32_t cnt); - int build_peak (uint32_t first_sample, uint32_t cnt); -}; - -class LIBARDOUR_API SoundPlaylist : public EDL::Playlist { - public: - int read_peaks (peak_data_t *, uint32_t npeaks, uint32_t start, uint32_t cnt); -}; - -} /* namespace ARDOUR */ - - - - diff --git a/libs/evoral/MSVCevoral/evoral.vcproj b/libs/evoral/MSVCevoral/evoral.vcproj index 792a34cec9..00f8a2d041 100644 --- a/libs/evoral/MSVCevoral/evoral.vcproj +++ b/libs/evoral/MSVCevoral/evoral.vcproj @@ -483,10 +483,6 @@ RelativePath="..\evoral\midi_util.h" > - - @@ -523,10 +519,6 @@ RelativePath="..\libsmf\smf_private.h" > - - diff --git a/libs/evoral/SMFReader.cc b/libs/evoral/SMFReader.cc deleted file mode 100644 index b0350e7956..0000000000 --- a/libs/evoral/SMFReader.cc +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright (C) 2008-2011 David Robillard - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include - -#include -#include - -#include "evoral/midi_util.h" -#include "evoral/SMFReader.h" - -using namespace std; - -namespace Evoral { - - -SMFReader::SMFReader(const string& filename) - : _fd(NULL) - , _ppqn(0) - , _track(0) - , _track_size(0) -{ - if (filename.length() > 0) { - open(filename); - } -} - - -SMFReader::~SMFReader() -{ - if (_fd) - close(); -} - - -bool -SMFReader::open(const string& filename) throw (logic_error, UnsupportedTime) -{ - if (_fd) - throw logic_error("Attempt to start new read while write in progress."); - - cout << "Opening SMF file " << filename << " for reading." << endl; - - _fd = g_fopen(filename.c_str(), "r+b"); - - if (_fd) { - // Read type (bytes 8..9) - fseek(_fd, 0, SEEK_SET); - char mthd[5]; - mthd[4] = '\0'; - fread(mthd, 1, 4, _fd); - if (strcmp(mthd, "MThd")) { - cerr << filename << " is not an SMF file, aborting." << endl; - fclose(_fd); - _fd = NULL; - return false; - } - - // Read type (bytes 8..9) - fseek(_fd, 8, SEEK_SET); - uint16_t type_be = 0; - fread(&type_be, 2, 1, _fd); - _type = GUINT16_FROM_BE(type_be); - - // Read number of tracks (bytes 10..11) - uint16_t num_tracks_be = 0; - fread(&num_tracks_be, 2, 1, _fd); - _num_tracks = GUINT16_FROM_BE(num_tracks_be); - - // Read PPQN (bytes 12..13) - uint16_t ppqn_be = 0; - fread(&ppqn_be, 2, 1, _fd); - _ppqn = GUINT16_FROM_BE(ppqn_be); - - // TODO: Absolute (SMPTE seconds) time support - if ((_ppqn & 0x8000) != 0) - throw UnsupportedTime(); - - seek_to_track(1); - - return true; - } else { - return false; - } -} - - -/** Seek to the start of a given track, starting from 1. - * Returns true if specified track was found. - */ -bool -SMFReader::seek_to_track(unsigned track) throw (std::logic_error) -{ - if (track == 0) - throw logic_error("Seek to track 0 out of range (must be >= 1)"); - - if (!_fd) - throw logic_error("Attempt to seek to track on unopened SMF file."); - - unsigned track_pos = 0; - - fseek(_fd, 14, SEEK_SET); - char id[5]; - id[4] = '\0'; - uint32_t chunk_size = 0; - - while (!feof(_fd)) { - fread(id, 1, 4, _fd); - - if (!strcmp(id, "MTrk")) { - ++track_pos; - } else { - std::cerr << "Unknown chunk ID " << id << endl; - } - - uint32_t chunk_size_be; - fread(&chunk_size_be, 4, 1, _fd); - chunk_size = GUINT32_FROM_BE(chunk_size_be); - - if (track_pos == track) - break; - - fseek(_fd, chunk_size, SEEK_CUR); - } - - if (!feof(_fd) && track_pos == track) { - _track = track; - _track_size = chunk_size; - return true; - } else { - return false; - } -} - - -/** Read an event from the current position in file. - * - * File position MUST be at the beginning of a delta time, or this will die very messily. - * ev.buffer must be of size ev.size, and large enough for the event. The returned event - * will have it's time field set to it's delta time (so it's the caller's responsibility - * to keep track of delta time, even for ignored events). - * - * Returns event length (including status byte) on success, 0 if event was - * skipped (eg a meta event), or -1 on EOF (or end of track). - * - * If @a buf is not large enough to hold the event, 0 will be returned, but ev_size - * set to the actual size of the event. - */ -int -SMFReader::read_event(size_t buf_len, - uint8_t* buf, - uint32_t* ev_size, - uint32_t* delta_time) - throw (std::logic_error, PrematureEOF, CorruptFile) -{ - if (_track == 0) - throw logic_error("Attempt to read from unopened SMF file"); - - if (!_fd || feof(_fd)) { - return -1; - } - - assert(buf_len > 0); - assert(buf); - assert(ev_size); - assert(delta_time); - - // Running status state - static uint8_t last_status = 0; - static uint32_t last_size = 0; - - *delta_time = read_var_len(_fd); - int status = fgetc(_fd); - if (status == EOF) - throw PrematureEOF(); - else if (status > 0xFF) - throw CorruptFile(); - - if (status < 0x80) { - if (last_status == 0) - throw CorruptFile(); - status = last_status; - *ev_size = last_size; - fseek(_fd, -1, SEEK_CUR); - } else { - last_status = status; - *ev_size = midi_event_size(status); - last_size = *ev_size; - } - - buf[0] = (uint8_t)status; - - if (status == 0xFF) { - *ev_size = 0; - if (feof(_fd)) - throw PrematureEOF(); - uint8_t type = fgetc(_fd); - const uint32_t size = read_var_len(_fd); - /*cerr.flags(ios::hex); - cerr << "SMF - meta 0x" << (int)type << ", size = "; - cerr.flags(ios::dec); - cerr << size << endl;*/ - - if ((uint8_t)type == 0x2F) { - return -1; // we hit the logical EOF anyway... - } else { - fseek(_fd, size, SEEK_CUR); - return 0; - } - } - - if (*ev_size > buf_len || *ev_size == 0 || feof(_fd)) { - //cerr << "SMF - Skipping event" << endl; - // Skip event, return 0 - fseek(_fd, *ev_size - 1, SEEK_CUR); - return 0; - } else { - // Read event, return size - if (ferror(_fd)) - throw CorruptFile(); - - fread(buf+1, 1, *ev_size - 1, _fd); - - if ((buf[0] & 0xF0) == 0x90 && buf[2] == 0) { - buf[0] = (0x80 | (buf[0] & 0x0F)); - buf[2] = 0x40; - } - - return *ev_size; - } -} - - -void -SMFReader::close() -{ - if (_fd) - fclose(_fd); - - _fd = NULL; -} - - -uint32_t -SMFReader::read_var_len(FILE* fd) throw (PrematureEOF) -{ - if (feof(fd)) - throw PrematureEOF(); - - uint32_t value; - uint8_t c; - - if ( (value = getc(fd)) & 0x80 ) { - value &= 0x7F; - do { - if (feof(fd)) - throw PrematureEOF(); - value = (value << 7) + ((c = getc(fd)) & 0x7F); - } while (c & 0x80); - } - - return value; -} - - -} // namespace Evoral - diff --git a/libs/evoral/evoral/MIDIXML.h b/libs/evoral/evoral/MIDIXML.h deleted file mode 100644 index 6d2dfaabee..0000000000 --- a/libs/evoral/evoral/MIDIXML.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2016 David Robillard - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef EVORAL_MIDI_XML_HPP -#define EVORAL_MIDI_XML_HPP - -#include "evoral/Event.h" -#include "pbd/xml++.h" - -namespace Evoral { -namespace MIDIXML { - -template -bool -xml_to_midi(const XMLNode& node, Evoral::Event - - diff --git a/libs/pbd/pbd/functor_command.h b/libs/pbd/pbd/functor_command.h deleted file mode 100644 index e00bd8a5f8..0000000000 --- a/libs/pbd/pbd/functor_command.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2007-2015 Paul Davis - * - * 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 - * (at your option) 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#include -#include -#include -#include - -#include "pbd/libpbd_visibility.h" -#include "pbd/xml++.h" -#include "pbd/shiva.h" -#include "pbd/command.h" -#include "pbd/failed_constructor.h" - -/** This command class is initialized - */ - -namespace PBD { - -template -class /*LIBPBD_API*/ FunctorCommand : public PBD::Command -{ - private: - typedef void (obj_type::*functor_type)(arg_type); - typedef std::map< std::string, functor_type > FunctorMap; - typedef typename FunctorMap::iterator FunctorMapIterator; - - public: - FunctorCommand(std::string functor, obj_type& object, arg_type b, arg_type a) - : functor_name(functor) - , object(object) - , before(b) - , after(a) - { - method = find_functor(functor); - - /* catch destruction of the object */ - new PBD::Shiva< obj_type, FunctorCommand > (object, *this); - } - - ~FunctorCommand() { - GoingAway(); - } - - void operator() () { - (object.*method) (after); - } - - void undo() { - (object.*method) (before); - } - - virtual XMLNode &get_state() { - std::stringstream ss; - - XMLNode *node = new XMLNode("FunctorCommand"); - node->add_property("type_name", typeid(obj_type).name()); - node->add_property("functor", functor_name); - ss << before; - node->add_property("before", ss.str()); - ss.clear (); - ss << after; - node->add_property("after", ss.str()); - - return *node; - } - - static void register_functor(std::string name, functor_type f) { - functor_map[name] = f; - } - - private: - static functor_type find_functor(std::string name) { - FunctorMapIterator iter; - - if((iter = functor_map.find(name)) == functor_map.end()) { - throw failed_constructor(); - } - - return iter->second; - } - - protected: - std::string functor_name; - obj_type &object; - arg_type before; - arg_type after; - functor_type method; - static FunctorMap functor_map; -}; - -// static initialization of functor_map... -template -typename FunctorCommand::FunctorMap -FunctorCommand::functor_map; - -}; - - From 955e63437189aecf395baff600c21ccbfe0a923a Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Sun, 20 Oct 2024 00:46:31 +0200 Subject: [PATCH 004/113] Make header files more self-contained - add missing std includes --- gtk2_ardour/ghost_event.h | 1 + gtk2_ardour/loudness_settings.h | 5 +++++ gtk2_ardour/luasignal.h | 3 +++ gtk2_ardour/midi_util.h | 2 ++ gtk2_ardour/mouse_cursors.h | 2 ++ gtk2_ardour/patch_change_dialog.h | 3 +++ gtk2_ardour/pingback.h | 2 ++ gtk2_ardour/strip_selection.h | 2 +- libs/ardour/ardour/comparable_shared_ptr.h | 2 ++ libs/ardour/ardour/control_group_member.h | 2 ++ libs/ardour/ardour/event_ring_buffer.h | 1 + libs/ardour/ardour/export_smf_writer.h | 2 ++ libs/ardour/ardour/library.h | 1 + libs/ardour/ardour/logcurve.h | 2 ++ libs/ardour/ardour/spline.h | 2 ++ libs/ardour/ardour/vst3_scan.h | 1 + libs/backends/alsa/select_sleep.h | 2 ++ libs/backends/portaudio/midi_device_info.h | 3 +++ libs/backends/portaudio/midi_util.h | 1 + .../ctrl-interface/control_protocol/control_protocol/types.h | 1 + libs/evoral/evoral/SMF.h | 2 ++ libs/surfaces/mackie/timer.h | 2 ++ libs/surfaces/maschine2/images.h | 2 ++ libs/surfaces/maschine2/m2_pad.h | 4 +++- libs/surfaces/maschine2/m2device.h | 4 +++- libs/surfaces/us2400/timer.h | 2 ++ libs/surfaces/websockets/json.h | 2 ++ libs/temporal/temporal/types.h | 2 ++ 28 files changed, 57 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/ghost_event.h b/gtk2_ardour/ghost_event.h index ed702973b5..76db97abff 100644 --- a/gtk2_ardour/ghost_event.h +++ b/gtk2_ardour/ghost_event.h @@ -1,6 +1,7 @@ #ifndef __gtk2_ardour_ghost_event_h__ #define __gtk2_ardour_ghost_event_h__ +#include #include #include diff --git a/gtk2_ardour/loudness_settings.h b/gtk2_ardour/loudness_settings.h index 83a9d21a24..e270dc4f9f 100644 --- a/gtk2_ardour/loudness_settings.h +++ b/gtk2_ardour/loudness_settings.h @@ -19,6 +19,11 @@ #ifndef _gtkardour_loudness_settings_h_ #define _gtkardour_loudness_settings_h_ +#include +#include +#include +#include + class XMLNode; struct CLoudnessPreset diff --git a/gtk2_ardour/luasignal.h b/gtk2_ardour/luasignal.h index 2293a7aeb0..0196625b1f 100644 --- a/gtk2_ardour/luasignal.h +++ b/gtk2_ardour/luasignal.h @@ -17,6 +17,9 @@ */ #ifndef _luasignal_h_ #define _luasignal_h_ + +#include + namespace LuaSignal { #define ENGINE(name,c) name, diff --git a/gtk2_ardour/midi_util.h b/gtk2_ardour/midi_util.h index aac285fb25..14619a76ff 100644 --- a/gtk2_ardour/midi_util.h +++ b/gtk2_ardour/midi_util.h @@ -19,6 +19,8 @@ #pragma once +#include + inline static void clamp_to_0_127(uint8_t &val) { if ((127 < val) && (val < 192)) { diff --git a/gtk2_ardour/mouse_cursors.h b/gtk2_ardour/mouse_cursors.h index 6d3101a237..07304a9795 100644 --- a/gtk2_ardour/mouse_cursors.h +++ b/gtk2_ardour/mouse_cursors.h @@ -26,6 +26,8 @@ * Held centrally by the Editor because some cursors are used in several places. */ +#include + class MouseCursors { public: diff --git a/gtk2_ardour/patch_change_dialog.h b/gtk2_ardour/patch_change_dialog.h index d3b1478e75..b841ec4159 100644 --- a/gtk2_ardour/patch_change_dialog.h +++ b/gtk2_ardour/patch_change_dialog.h @@ -19,6 +19,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#pragma once + +#include #include #include diff --git a/gtk2_ardour/pingback.h b/gtk2_ardour/pingback.h index d83bafce55..e55057d9fd 100644 --- a/gtk2_ardour/pingback.h +++ b/gtk2_ardour/pingback.h @@ -18,6 +18,8 @@ #pragma once +#include + namespace ARDOUR { void pingback (const std::string& this_version, const std::string& announce_path); diff --git a/gtk2_ardour/strip_selection.h b/gtk2_ardour/strip_selection.h index 05602fddb7..51f62b4c63 100644 --- a/gtk2_ardour/strip_selection.h +++ b/gtk2_ardour/strip_selection.h @@ -24,5 +24,5 @@ class MixerStrip; -struct MixerStripSelection : list {}; +struct MixerStripSelection : std::list {}; diff --git a/libs/ardour/ardour/comparable_shared_ptr.h b/libs/ardour/ardour/comparable_shared_ptr.h index e670225575..dd68c816f3 100644 --- a/libs/ardour/ardour/comparable_shared_ptr.h +++ b/libs/ardour/ardour/comparable_shared_ptr.h @@ -22,6 +22,8 @@ #include "ardour/libardour_visibility.h" +#include + namespace ARDOUR { template diff --git a/libs/ardour/ardour/control_group_member.h b/libs/ardour/ardour/control_group_member.h index ca7e013efb..0504b95b36 100644 --- a/libs/ardour/ardour/control_group_member.h +++ b/libs/ardour/ardour/control_group_member.h @@ -18,6 +18,8 @@ #pragma once +#include + namespace ARDOUR { class ControlGroup; diff --git a/libs/ardour/ardour/event_ring_buffer.h b/libs/ardour/ardour/event_ring_buffer.h index 555a2b293d..c3fecd9540 100644 --- a/libs/ardour/ardour/event_ring_buffer.h +++ b/libs/ardour/ardour/event_ring_buffer.h @@ -19,6 +19,7 @@ #pragma once #include +#include #include #include "pbd/ringbufferNPT.h" diff --git a/libs/ardour/ardour/export_smf_writer.h b/libs/ardour/ardour/export_smf_writer.h index 9d86d1b832..ea58b4b099 100644 --- a/libs/ardour/ardour/export_smf_writer.h +++ b/libs/ardour/ardour/export_smf_writer.h @@ -25,6 +25,8 @@ #include "ardour/midi_state_tracker.h" #include "ardour/types.h" +#include + namespace ARDOUR { class MidiBuffer; diff --git a/libs/ardour/ardour/library.h b/libs/ardour/ardour/library.h index e24aafd7d2..23f79fa461 100644 --- a/libs/ardour/ardour/library.h +++ b/libs/ardour/ardour/library.h @@ -20,6 +20,7 @@ #include #include +#include #include #include diff --git a/libs/ardour/ardour/logcurve.h b/libs/ardour/ardour/logcurve.h index bfab98533f..f78a68159f 100644 --- a/libs/ardour/ardour/logcurve.h +++ b/libs/ardour/ardour/logcurve.h @@ -23,6 +23,8 @@ #include "pbd/fastlog.h" #include +#include + namespace ARDOUR { class LIBARDOUR_API LogCurve { diff --git a/libs/ardour/ardour/spline.h b/libs/ardour/ardour/spline.h index c0f02180b7..7af17ff986 100644 --- a/libs/ardour/ardour/spline.h +++ b/libs/ardour/ardour/spline.h @@ -19,6 +19,8 @@ #pragma once +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/libs/ardour/ardour/vst3_scan.h b/libs/ardour/ardour/vst3_scan.h index 0bd842cc2e..d3dc68964e 100644 --- a/libs/ardour/ardour/vst3_scan.h +++ b/libs/ardour/ardour/vst3_scan.h @@ -19,6 +19,7 @@ #ifndef _ardour_vst3_scan_h_ #define _ardour_vst3_scan_h_ +#include #include #include #include diff --git a/libs/backends/alsa/select_sleep.h b/libs/backends/alsa/select_sleep.h index adcdac2ccd..d370284c94 100644 --- a/libs/backends/alsa/select_sleep.h +++ b/libs/backends/alsa/select_sleep.h @@ -19,6 +19,8 @@ #include #include +#include + /* select() sleeps _at most_ a given time. * (compared to usleep() or nanosleep() which sleep at least a given time) */ diff --git a/libs/backends/portaudio/midi_device_info.h b/libs/backends/portaudio/midi_device_info.h index 7b470df891..763a6abbf8 100644 --- a/libs/backends/portaudio/midi_device_info.h +++ b/libs/backends/portaudio/midi_device_info.h @@ -1,6 +1,9 @@ #ifndef MIDI_DEVICE_INFO_H #define MIDI_DEVICE_INFO_H +#include +#include + /* midi settings */ struct MidiDeviceInfo { MidiDeviceInfo(const std::string& dev_name) diff --git a/libs/backends/portaudio/midi_util.h b/libs/backends/portaudio/midi_util.h index 0bb10839e2..65b13c69b4 100644 --- a/libs/backends/portaudio/midi_util.h +++ b/libs/backends/portaudio/midi_util.h @@ -19,6 +19,7 @@ #ifndef MIDI_UTIL_H #define MIDI_UTIL_H +#include #include struct MidiEventHeader { diff --git a/libs/ctrl-interface/control_protocol/control_protocol/types.h b/libs/ctrl-interface/control_protocol/control_protocol/types.h index 7285fc1bde..a654be2ad1 100644 --- a/libs/ctrl-interface/control_protocol/control_protocol/types.h +++ b/libs/ctrl-interface/control_protocol/control_protocol/types.h @@ -19,6 +19,7 @@ #ifndef __ardour_control_protocol_types_h__ #define __ardour_control_protocol_types_h__ +#include #include namespace ARDOUR { diff --git a/libs/evoral/evoral/SMF.h b/libs/evoral/evoral/SMF.h index 42ff9c6f0c..0c9908cf63 100644 --- a/libs/evoral/evoral/SMF.h +++ b/libs/evoral/evoral/SMF.h @@ -23,6 +23,8 @@ #define EVORAL_SMF_HPP #include + +#include #include #include "evoral/visibility.h" diff --git a/libs/surfaces/mackie/timer.h b/libs/surfaces/mackie/timer.h index 4d25ec6ce7..6afda5ed33 100644 --- a/libs/surfaces/mackie/timer.h +++ b/libs/surfaces/mackie/timer.h @@ -25,6 +25,8 @@ #include "types.h" +#include + namespace ArdourSurface { namespace MACKIE_NAMESPACE { /** diff --git a/libs/surfaces/maschine2/images.h b/libs/surfaces/maschine2/images.h index 99ff7486d0..28736b5cde 100644 --- a/libs/surfaces/maschine2/images.h +++ b/libs/surfaces/maschine2/images.h @@ -16,6 +16,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + static const uint8_t maschine_png[] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x40, diff --git a/libs/surfaces/maschine2/m2_pad.h b/libs/surfaces/maschine2/m2_pad.h index e93084ad34..55722cc40b 100644 --- a/libs/surfaces/maschine2/m2_pad.h +++ b/libs/surfaces/maschine2/m2_pad.h @@ -22,6 +22,8 @@ #include #include "pbd/signals.h" +#include + namespace ArdourSurface { class M2PadInterface @@ -106,7 +108,7 @@ class M2Pad : public M2PadInterface released (); /* EMIT SIGNAL */ event (_pressure, true); /* EMIT SIGNAL */ } else { - if (fabsf (_last - _pressure) > mindelta) { + if (std::fabsf (_last - _pressure) > mindelta) { _last = _pressure; aftertouch (_pressure); /* EMIT SIGNAL */ event (_pressure, false); /* EMIT SIGNAL */ diff --git a/libs/surfaces/maschine2/m2device.h b/libs/surfaces/maschine2/m2device.h index 0690325049..ef8756c99e 100644 --- a/libs/surfaces/maschine2/m2device.h +++ b/libs/surfaces/maschine2/m2device.h @@ -24,6 +24,8 @@ #include #include "pbd/signals.h" +#include + namespace ArdourSurface { class M2Contols; @@ -63,7 +65,7 @@ class M2Device protected: void bump_blink () { _blink_counter = (_blink_counter + 1) % 12; - _blink_shade = fabsf (1.f - _blink_counter / 6.f); + _blink_shade = std::fabsf (1.f - _blink_counter / 6.f); } uint32_t _splashcnt; diff --git a/libs/surfaces/us2400/timer.h b/libs/surfaces/us2400/timer.h index c2e5f04285..01b5878899 100644 --- a/libs/surfaces/us2400/timer.h +++ b/libs/surfaces/us2400/timer.h @@ -19,6 +19,8 @@ #ifndef timer_h #define timer_h +#include + #ifdef _WIN32 #include "windows.h" #else diff --git a/libs/surfaces/websockets/json.h b/libs/surfaces/websockets/json.h index 65cdfabd1b..9f11fca9f9 100644 --- a/libs/surfaces/websockets/json.h +++ b/libs/surfaces/websockets/json.h @@ -19,6 +19,8 @@ #ifndef _ardour_surface_websockets_json_h_ #define _ardour_surface_websockets_json_h_ +#include + namespace ArdourSurface { namespace WebSocketsJSON diff --git a/libs/temporal/temporal/types.h b/libs/temporal/temporal/types.h index 0079f67bfb..ba81e361af 100644 --- a/libs/temporal/temporal/types.h +++ b/libs/temporal/temporal/types.h @@ -18,7 +18,9 @@ #pragma once +#include #include +#include #include #include "pbd/integer_division.h" From b4ff4f356c6bca12ccc2468d4a0a7b1f4e57ae16 Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Sat, 19 Oct 2024 15:54:24 +0200 Subject: [PATCH 005/113] Make header files more self-contained - add missing Ardour and lib includes --- gtk2_ardour/audio_trigger_properties_box.h | 1 + gtk2_ardour/axis_view.h | 1 + gtk2_ardour/bundle_manager.h | 1 + gtk2_ardour/crossfade_edit.h | 5 +++++ gtk2_ardour/cuebox_ui.h | 1 + gtk2_ardour/editor_route_groups.h | 5 +++++ gtk2_ardour/editor_summary.h | 6 ++++++ gtk2_ardour/grid_lines.h | 1 + gtk2_ardour/io_button.h | 1 + gtk2_ardour/keyeditor.h | 1 + gtk2_ardour/luawindow.h | 2 ++ gtk2_ardour/mouse_cursors.h | 2 ++ gtk2_ardour/normalize_dialog.h | 1 + gtk2_ardour/panner_ui.h | 1 + gtk2_ardour/patch_change.h | 5 +++++ gtk2_ardour/playlist_selector.h | 2 ++ gtk2_ardour/plugin_scan_dialog.h | 1 + gtk2_ardour/port_matrix_labels.h | 6 ++---- gtk2_ardour/prh.h | 2 ++ gtk2_ardour/region_layering_order_editor.h | 2 ++ gtk2_ardour/region_peak_cursor.h | 2 +- gtk2_ardour/route_group_menu.h | 3 +++ gtk2_ardour/route_processor_selection.h | 2 ++ gtk2_ardour/session_dialog.h | 1 + gtk2_ardour/simple_progress_dialog.h | 2 +- gtk2_ardour/soundcloud_export_selector.h | 2 ++ gtk2_ardour/startup_fsm.h | 5 +++++ gtk2_ardour/step_editor.h | 2 ++ gtk2_ardour/strip_selection.h | 2 ++ gtk2_ardour/strip_silence_dialog.h | 3 +++ gtk2_ardour/sys_ex.h | 2 ++ gtk2_ardour/tempo_curve.h | 1 + gtk2_ardour/time_axis_view_item.h | 1 + gtk2_ardour/track_record_axis.h | 1 + gtk2_ardour/trigger_page.h | 1 + gtk2_ardour/visibility_group.h | 2 ++ gtk2_ardour/window_manager.h | 2 ++ libs/ardour/ardour/comparable_shared_ptr.h | 2 ++ libs/ardour/ardour/control_group_member.h | 2 ++ libs/ardour/ardour/convolver.h | 1 + libs/ardour/ardour/logcurve.h | 2 ++ libs/ardour/ardour/midi_scene_changer.h | 1 + libs/ardour/ardour/midi_ui.h | 2 ++ libs/ardour/ardour/mixer_scene.h | 5 +---- libs/ardour/ardour/monitor_port.h | 1 + libs/ardour/ardour/movable.h | 2 ++ libs/ardour/ardour/panner_shell.h | 2 ++ libs/ardour/ardour/peak.h | 2 +- libs/ardour/ardour/proxy_controllable.h | 2 ++ libs/ardour/ardour/session_playlists.h | 4 ++++ libs/ardour/ardour/spline.h | 2 ++ libs/ardour/ardour/step_sequencer.h | 7 +++++-- libs/ardour/ardour/transport_fsm.h | 1 + libs/ardour/ardour/trimmable.h | 2 ++ libs/audiographer/audiographer/general/threader.h | 1 + libs/backends/alsa/alsa_slave.h | 1 + libs/canvas/canvas/stateful_image.h | 2 ++ libs/evoral/libsmf/smf_private.h | 2 ++ libs/gtkmm2ext/gtkmm2ext/dndvbox.h | 2 ++ libs/gtkmm2ext/gtkmm2ext/gtkutils.h | 2 ++ libs/gtkmm2ext/gtkmm2ext/visibility_tracker.h | 3 +++ libs/gtkmm2ext/gtkmm2ext/window_proxy.h | 2 ++ libs/pbd/pbd/atomic_counter.h | 2 ++ libs/pbd/pbd/property_basics_impl.h | 2 ++ libs/pbd/pbd/scoped_file_descriptor.h | 2 ++ libs/surfaces/maschine2/ui_menu.h | 1 + libs/surfaces/osc/osc_cue_observer.h | 2 ++ libs/surfaces/osc/osc_global_observer.h | 5 +++++ libs/surfaces/osc/osc_gui.h | 4 ++++ libs/surfaces/osc/osc_select_observer.h | 4 +++- libs/surfaces/push2/follow_action.h | 4 ++++ libs/surfaces/push2/level_meter.h | 3 +++ libs/surfaces/push2/scale.h | 2 ++ libs/surfaces/push2/track_mix.h | 3 +++ libs/surfaces/us2400/gui.h | 2 ++ libs/surfaces/us2400/surface_port.h | 1 + libs/surfaces/us2400/timer.h | 2 ++ libs/widgets/widgets/binding_proxy.h | 2 ++ libs/zita-convolver/zita-convolver/zita-convolver.h | 6 ++++-- 79 files changed, 167 insertions(+), 16 deletions(-) diff --git a/gtk2_ardour/audio_trigger_properties_box.h b/gtk2_ardour/audio_trigger_properties_box.h index 94e061f231..8b03b17836 100644 --- a/gtk2_ardour/audio_trigger_properties_box.h +++ b/gtk2_ardour/audio_trigger_properties_box.h @@ -22,6 +22,7 @@ #include #include +#include #include #include "ardour/ardour.h" diff --git a/gtk2_ardour/axis_view.h b/gtk2_ardour/axis_view.h index 3caa3ced87..5a59959355 100644 --- a/gtk2_ardour/axis_view.h +++ b/gtk2_ardour/axis_view.h @@ -33,6 +33,7 @@ #include "pbd/xml++.h" #include "pbd/signals.h" +#include "ardour/automation_control.h" #include "ardour/session_handle.h" #include "gui_object.h" diff --git a/gtk2_ardour/bundle_manager.h b/gtk2_ardour/bundle_manager.h index 33b9dfdccd..6470dcfa49 100644 --- a/gtk2_ardour/bundle_manager.h +++ b/gtk2_ardour/bundle_manager.h @@ -20,6 +20,7 @@ #pragma once +#include #include #include #include diff --git a/gtk2_ardour/crossfade_edit.h b/gtk2_ardour/crossfade_edit.h index dea7c37642..8daa8d5f36 100644 --- a/gtk2_ardour/crossfade_edit.h +++ b/gtk2_ardour/crossfade_edit.h @@ -28,12 +28,17 @@ #include #include #include +#include #include "canvas/canvas.h" +#include "canvas/poly_line.h" #include "evoral/Curve.h" +#include "ardour/automation_list.h" #include "ardour/session_handle.h" +#include "waveview/wave_view.h" + #include "ardour_dialog.h" namespace ARDOUR diff --git a/gtk2_ardour/cuebox_ui.h b/gtk2_ardour/cuebox_ui.h index 2cb17babd5..be384c244a 100644 --- a/gtk2_ardour/cuebox_ui.h +++ b/gtk2_ardour/cuebox_ui.h @@ -22,6 +22,7 @@ #include #include +#include #include "pbd/properties.h" diff --git a/gtk2_ardour/editor_route_groups.h b/gtk2_ardour/editor_route_groups.h index b99f7ce178..28c97ea92e 100644 --- a/gtk2_ardour/editor_route_groups.h +++ b/gtk2_ardour/editor_route_groups.h @@ -20,6 +20,8 @@ #pragma once +#include +#include #include #include #include @@ -27,6 +29,9 @@ #include "editor_component.h" +#include "ardour/route_group.h" +#include "ardour/session_handle.h" + class EditorRouteGroups : public EditorComponent, public ARDOUR::SessionHandlePtr { public: diff --git a/gtk2_ardour/editor_summary.h b/gtk2_ardour/editor_summary.h index 5de5189b3b..8d259e4e20 100644 --- a/gtk2_ardour/editor_summary.h +++ b/gtk2_ardour/editor_summary.h @@ -21,7 +21,11 @@ #pragma once +#include "ardour/session_handle.h" +#include "ardour/types.h" #include "gtkmm2ext/cairo_widget.h" +#include "pbd/property_basics.h" + #include "editor_component.h" namespace ARDOUR { @@ -29,6 +33,8 @@ namespace ARDOUR { } class Editor; +class RegionView; +class RouteTimeAxisView; /** Class to provide a visual summary of the contents of an editor window; represents * the whole session as a set of lines, one per region view. diff --git a/gtk2_ardour/grid_lines.h b/gtk2_ardour/grid_lines.h index 62de80a9ad..179e2298d4 100644 --- a/gtk2_ardour/grid_lines.h +++ b/gtk2_ardour/grid_lines.h @@ -18,6 +18,7 @@ #pragma once +#include "canvas/container.h" #include "canvas/line_set.h" #include "canvas/ruler.h" #include "ardour/tempo.h" diff --git a/gtk2_ardour/io_button.h b/gtk2_ardour/io_button.h index 4cc87abfb7..d246d98cd0 100644 --- a/gtk2_ardour/io_button.h +++ b/gtk2_ardour/io_button.h @@ -26,6 +26,7 @@ #include #include "ardour/data_type.h" +#include "ardour/types.h" #include "widgets/ardour_button.h" diff --git a/gtk2_ardour/keyeditor.h b/gtk2_ardour/keyeditor.h index cc4c32a9b3..da6b815e1d 100644 --- a/gtk2_ardour/keyeditor.h +++ b/gtk2_ardour/keyeditor.h @@ -22,6 +22,7 @@ #include +#include #include #include #include diff --git a/gtk2_ardour/luawindow.h b/gtk2_ardour/luawindow.h index 2f9be48f7c..eb42842da7 100644 --- a/gtk2_ardour/luawindow.h +++ b/gtk2_ardour/luawindow.h @@ -40,6 +40,8 @@ #include "widgets/ardour_button.h" #include "widgets/ardour_dropdown.h" +#include "ardour_window.h" + class LuaWindow : public ArdourWindow, public PBD::ScopedConnectionList diff --git a/gtk2_ardour/mouse_cursors.h b/gtk2_ardour/mouse_cursors.h index 07304a9795..d9bb3fa47b 100644 --- a/gtk2_ardour/mouse_cursors.h +++ b/gtk2_ardour/mouse_cursors.h @@ -26,6 +26,8 @@ * Held centrally by the Editor because some cursors are used in several places. */ +#include + #include class MouseCursors diff --git a/gtk2_ardour/normalize_dialog.h b/gtk2_ardour/normalize_dialog.h index ce2c9aa56a..b5c9bd913b 100644 --- a/gtk2_ardour/normalize_dialog.h +++ b/gtk2_ardour/normalize_dialog.h @@ -21,6 +21,7 @@ #include "progress_reporter.h" namespace Gtk { + class CheckButton; class RadioButton; class SpinButton; class ProgressBar; diff --git a/gtk2_ardour/panner_ui.h b/gtk2_ardour/panner_ui.h index 58bf916dc2..6d7971f824 100644 --- a/gtk2_ardour/panner_ui.h +++ b/gtk2_ardour/panner_ui.h @@ -49,6 +49,7 @@ namespace ARDOUR { } namespace Gtk { + class CheckMenuItem; class Menu; class Menuitem; } diff --git a/gtk2_ardour/patch_change.h b/gtk2_ardour/patch_change.h index c436a92cbe..4196a9a565 100644 --- a/gtk2_ardour/patch_change.h +++ b/gtk2_ardour/patch_change.h @@ -23,6 +23,11 @@ #include "canvas/flag.h" +#include + +#include "midi_view.h" +#include "patch_change_dialog.h" + class MidiRegionView; namespace MIDI { diff --git a/gtk2_ardour/playlist_selector.h b/gtk2_ardour/playlist_selector.h index 43b861cfc1..7d2f48dbbc 100644 --- a/gtk2_ardour/playlist_selector.h +++ b/gtk2_ardour/playlist_selector.h @@ -28,6 +28,8 @@ #include #include +#include "widgets/ardour_button.h" + #include "ardour/playlist.h" #include "ardour/session_handle.h" #include "ardour_dialog.h" diff --git a/gtk2_ardour/plugin_scan_dialog.h b/gtk2_ardour/plugin_scan_dialog.h index e9c2db16b2..b6688212c9 100644 --- a/gtk2_ardour/plugin_scan_dialog.h +++ b/gtk2_ardour/plugin_scan_dialog.h @@ -21,6 +21,7 @@ #include #include +#include #include #include #include diff --git a/gtk2_ardour/port_matrix_labels.h b/gtk2_ardour/port_matrix_labels.h index be64e6b306..c3e7161793 100644 --- a/gtk2_ardour/port_matrix_labels.h +++ b/gtk2_ardour/port_matrix_labels.h @@ -18,11 +18,9 @@ #pragma once -#include "port_matrix_component.h" +#include "ardour/bundle.h" -namespace ARDOUR { - class BundleChannel; -} +#include "port_matrix_component.h" class PortMatrixLabels : public PortMatrixComponent { diff --git a/gtk2_ardour/prh.h b/gtk2_ardour/prh.h index fc9a7f6215..f80c6f4477 100644 --- a/gtk2_ardour/prh.h +++ b/gtk2_ardour/prh.h @@ -26,6 +26,8 @@ #include "canvas/rectangle.h" +#include + namespace ARDOUR { class MidiTrack; } diff --git a/gtk2_ardour/region_layering_order_editor.h b/gtk2_ardour/region_layering_order_editor.h index 687f0ccace..eb988a944f 100644 --- a/gtk2_ardour/region_layering_order_editor.h +++ b/gtk2_ardour/region_layering_order_editor.h @@ -31,6 +31,8 @@ #include "ardour_window.h" #include "audio_clock.h" +#include "region_view.h" +#include "time_axis_view.h" class PublicEditor; diff --git a/gtk2_ardour/region_peak_cursor.h b/gtk2_ardour/region_peak_cursor.h index a7d9497479..555ddbbf4e 100644 --- a/gtk2_ardour/region_peak_cursor.h +++ b/gtk2_ardour/region_peak_cursor.h @@ -36,7 +36,7 @@ public: RegionPeakCursor (ArdourCanvas::Item*); ~RegionPeakCursor (); - void set (AudioRegionView*, samplepos_t, samplecnt_t); + void set (AudioRegionView*, samplepos_t, ARDOUR::samplecnt_t); void hide (); bool visible () const; diff --git a/gtk2_ardour/route_group_menu.h b/gtk2_ardour/route_group_menu.h index 1f9b201abe..58abbec078 100644 --- a/gtk2_ardour/route_group_menu.h +++ b/gtk2_ardour/route_group_menu.h @@ -22,6 +22,9 @@ #include "ardour/route_group.h" #include "ardour/session_handle.h" +#include +#include + class RouteGroupDialog; class RouteGroupMenu : public ARDOUR::SessionHandlePtr diff --git a/gtk2_ardour/route_processor_selection.h b/gtk2_ardour/route_processor_selection.h index 8c2699d3d2..da0af00b49 100644 --- a/gtk2_ardour/route_processor_selection.h +++ b/gtk2_ardour/route_processor_selection.h @@ -21,6 +21,8 @@ #pragma once #include + +#include "pbd/property_basics.h" #include "pbd/signals.h" #include "processor_selection.h" diff --git a/gtk2_ardour/session_dialog.h b/gtk2_ardour/session_dialog.h index 6f9c66e469..dfcde754d4 100644 --- a/gtk2_ardour/session_dialog.h +++ b/gtk2_ardour/session_dialog.h @@ -40,6 +40,7 @@ #include #include #include +#include #include "temporal/domain_provider.h" diff --git a/gtk2_ardour/simple_progress_dialog.h b/gtk2_ardour/simple_progress_dialog.h index f9d50a9f6c..2adeb55e22 100644 --- a/gtk2_ardour/simple_progress_dialog.h +++ b/gtk2_ardour/simple_progress_dialog.h @@ -44,7 +44,7 @@ public: get_vbox()->pack_start (*cancel_button, Gtk::PACK_SHRINK); } - void update_progress (samplecnt_t c, samplecnt_t t) { + void update_progress (ARDOUR::samplecnt_t c, ARDOUR::samplecnt_t t) { pbar->set_fraction ((float) c / (float) t); // see also ARDOUR_UI::gui_idle_handler(); int timeout = 30; diff --git a/gtk2_ardour/soundcloud_export_selector.h b/gtk2_ardour/soundcloud_export_selector.h index 78688d17dd..3d22b22424 100644 --- a/gtk2_ardour/soundcloud_export_selector.h +++ b/gtk2_ardour/soundcloud_export_selector.h @@ -19,6 +19,8 @@ #include #include +#include "ardour/session_handle.h" + class SoundcloudExportSelector : public Gtk::VBox, public ARDOUR::SessionHandlePtr { public: diff --git a/gtk2_ardour/startup_fsm.h b/gtk2_ardour/startup_fsm.h index 48f7e832a0..74a2a9267f 100644 --- a/gtk2_ardour/startup_fsm.h +++ b/gtk2_ardour/startup_fsm.h @@ -25,6 +25,11 @@ #include "ardour/types.h" +namespace Gtk +{ +class Window; +} // namespace Gtk + class ArdourDialog; class NewUserWizard; class EngineControl; diff --git a/gtk2_ardour/step_editor.h b/gtk2_ardour/step_editor.h index 4c7f966cfa..7376a9709a 100644 --- a/gtk2_ardour/step_editor.h +++ b/gtk2_ardour/step_editor.h @@ -28,10 +28,12 @@ #include "pbd/signals.h" #include "temporal/beats.h" +#include "temporal/timeline.h" namespace ARDOUR { class MidiTrack; class MidiRegion; +class Region; } class MidiRegionView; diff --git a/gtk2_ardour/strip_selection.h b/gtk2_ardour/strip_selection.h index 51f62b4c63..6ccfa809c4 100644 --- a/gtk2_ardour/strip_selection.h +++ b/gtk2_ardour/strip_selection.h @@ -20,6 +20,8 @@ #pragma once +#include "mixer_strip.h" + #include class MixerStrip; diff --git a/gtk2_ardour/strip_silence_dialog.h b/gtk2_ardour/strip_silence_dialog.h index 7d3409bf66..c0abb40109 100644 --- a/gtk2_ardour/strip_silence_dialog.h +++ b/gtk2_ardour/strip_silence_dialog.h @@ -19,11 +19,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include +#include #include #include #include +#include "ardour/interthread_info.h" #include "ardour/types.h" #include "ardour_dialog.h" #include "progress_reporter.h" diff --git a/gtk2_ardour/sys_ex.h b/gtk2_ardour/sys_ex.h index dd150767f7..888e7f875e 100644 --- a/gtk2_ardour/sys_ex.h +++ b/gtk2_ardour/sys_ex.h @@ -22,6 +22,8 @@ #include "canvas/flag.h" +#include "ardour/midi_model.h" + class MidiView; class SysEx diff --git a/gtk2_ardour/tempo_curve.h b/gtk2_ardour/tempo_curve.h index f9c4785f91..0b274d71ca 100644 --- a/gtk2_ardour/tempo_curve.h +++ b/gtk2_ardour/tempo_curve.h @@ -27,6 +27,7 @@ #include "ardour/ardour.h" #include "pbd/signals.h" +#include "canvas/container.h" #include "canvas/types.h" #include "canvas/framed_curve.h" #include "canvas/text.h" diff --git a/gtk2_ardour/time_axis_view_item.h b/gtk2_ardour/time_axis_view_item.h index 192ed49cda..1d403c3b91 100644 --- a/gtk2_ardour/time_axis_view_item.h +++ b/gtk2_ardour/time_axis_view_item.h @@ -28,6 +28,7 @@ #include #include #include +#include "ardour/types.h" #include "pbd/signals.h" #include "selectable.h" diff --git a/gtk2_ardour/track_record_axis.h b/gtk2_ardour/track_record_axis.h index 920bf5c96b..31cda5ae25 100644 --- a/gtk2_ardour/track_record_axis.h +++ b/gtk2_ardour/track_record_axis.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/gtk2_ardour/trigger_page.h b/gtk2_ardour/trigger_page.h index 36e9632c76..cdf94ad44c 100644 --- a/gtk2_ardour/trigger_page.h +++ b/gtk2_ardour/trigger_page.h @@ -31,6 +31,7 @@ #include "audio_region_operations_box.h" #include "audio_region_properties_box.h" #include "audio_trigger_properties_box.h" +#include "axis_provider.h" #include "cuebox_ui.h" #include "fitted_canvas_widget.h" #include "midi_region_operations_box.h" diff --git a/gtk2_ardour/visibility_group.h b/gtk2_ardour/visibility_group.h index 0dbb75e85e..7dc2005ba7 100644 --- a/gtk2_ardour/visibility_group.h +++ b/gtk2_ardour/visibility_group.h @@ -21,6 +21,8 @@ #define __ardour_visibility_group__ #include +#include + #include "pbd/signals.h" class XMLNode; diff --git a/gtk2_ardour/window_manager.h b/gtk2_ardour/window_manager.h index 0670b39dfa..f3775320e9 100644 --- a/gtk2_ardour/window_manager.h +++ b/gtk2_ardour/window_manager.h @@ -30,6 +30,8 @@ #include "gtkmm2ext/bindings.h" #include "gtkmm2ext/window_proxy.h" +#include "ardour/session_handle.h" + class XMLNode; namespace Gtk { diff --git a/libs/ardour/ardour/comparable_shared_ptr.h b/libs/ardour/ardour/comparable_shared_ptr.h index dd68c816f3..3194c3c891 100644 --- a/libs/ardour/ardour/comparable_shared_ptr.h +++ b/libs/ardour/ardour/comparable_shared_ptr.h @@ -22,6 +22,8 @@ #include "ardour/libardour_visibility.h" +#include + #include namespace ARDOUR { diff --git a/libs/ardour/ardour/control_group_member.h b/libs/ardour/ardour/control_group_member.h index 0504b95b36..3bf4e61849 100644 --- a/libs/ardour/ardour/control_group_member.h +++ b/libs/ardour/ardour/control_group_member.h @@ -18,6 +18,8 @@ #pragma once +#include "ardour/libardour_visibility.h" + #include namespace ARDOUR { diff --git a/libs/ardour/ardour/convolver.h b/libs/ardour/ardour/convolver.h index e4934034f0..0f779bbf53 100644 --- a/libs/ardour/ardour/convolver.h +++ b/libs/ardour/ardour/convolver.h @@ -27,6 +27,7 @@ #include "ardour/buffer_set.h" #include "ardour/chan_mapping.h" #include "ardour/readable.h" +#include "ardour/session_handle.h" namespace ARDOUR { namespace DSP { diff --git a/libs/ardour/ardour/logcurve.h b/libs/ardour/ardour/logcurve.h index f78a68159f..d64ee0d78e 100644 --- a/libs/ardour/ardour/logcurve.h +++ b/libs/ardour/ardour/logcurve.h @@ -23,6 +23,8 @@ #include "pbd/fastlog.h" #include +#include "ardour/libardour_visibility.h" + #include namespace ARDOUR { diff --git a/libs/ardour/ardour/midi_scene_changer.h b/libs/ardour/ardour/midi_scene_changer.h index f7ff8f424c..27eb489254 100644 --- a/libs/ardour/ardour/midi_scene_changer.h +++ b/libs/ardour/ardour/midi_scene_changer.h @@ -21,6 +21,7 @@ #include +#include "ardour/midi_port.h" #include "ardour/scene_changer.h" namespace ARDOUR diff --git a/libs/ardour/ardour/midi_ui.h b/libs/ardour/ardour/midi_ui.h index 2d0885aa8e..dcc55e02be 100644 --- a/libs/ardour/ardour/midi_ui.h +++ b/libs/ardour/ardour/midi_ui.h @@ -25,6 +25,8 @@ #include "pbd/abstract_ui.h" #include "pbd/signals.h" +#include "ardour/libardour_visibility.h" + namespace ARDOUR { class Session; diff --git a/libs/ardour/ardour/mixer_scene.h b/libs/ardour/ardour/mixer_scene.h index 8341f6cb83..eb5038c6f5 100644 --- a/libs/ardour/ardour/mixer_scene.h +++ b/libs/ardour/ardour/mixer_scene.h @@ -19,16 +19,13 @@ #ifndef _libardour_mixer_scene_h_ #define _libardour_mixer_scene_h_ +#include "pbd/controllable.h" #include "pbd/stateful.h" #include "ardour/libardour_visibility.h" #include "ardour/session_handle.h" #include "ardour/types.h" -namespace PBD { - class Controllable; -} - namespace ARDOUR { class LIBARDOUR_API MixerScene : public SessionHandleRef, public PBD::Stateful diff --git a/libs/ardour/ardour/monitor_port.h b/libs/ardour/ardour/monitor_port.h index 2d8c6c42f7..9cc3176941 100644 --- a/libs/ardour/ardour/monitor_port.h +++ b/libs/ardour/ardour/monitor_port.h @@ -25,6 +25,7 @@ #include "zita-resampler/vmresampler.h" #include "pbd/rcu.h" +#include #include "ardour/audio_buffer.h" #include "ardour/port_engine.h" diff --git a/libs/ardour/ardour/movable.h b/libs/ardour/ardour/movable.h index 64ad637f2d..d4fe89a7e6 100644 --- a/libs/ardour/ardour/movable.h +++ b/libs/ardour/ardour/movable.h @@ -18,6 +18,8 @@ #pragma once +#include "ardour/libardour_visibility.h" + namespace ARDOUR { class LIBARDOUR_API Movable { diff --git a/libs/ardour/ardour/panner_shell.h b/libs/ardour/ardour/panner_shell.h index 250656679e..74df576544 100644 --- a/libs/ardour/ardour/panner_shell.h +++ b/libs/ardour/ardour/panner_shell.h @@ -26,7 +26,9 @@ #include #include +#include "evoral/Parameter.h" #include "pbd/cartesian.h" +#include "temporal/domain_provider.h" #include "ardour/libardour_visibility.h" #include "ardour/types.h" diff --git a/libs/ardour/ardour/peak.h b/libs/ardour/ardour/peak.h index 47668177e2..26b86b7cd0 100644 --- a/libs/ardour/ardour/peak.h +++ b/libs/ardour/ardour/peak.h @@ -28,7 +28,7 @@ static inline float default_compute_peak (const ARDOUR::Sample * const buf, ARDOUR::pframes_t nsamples, float current) { for (ARDOUR::pframes_t i = 0; i < nsamples; ++i) { - current = f_max (current, fabsf (buf[i])); + current = ARDOUR::f_max (current, fabsf (buf[i])); } return current; } diff --git a/libs/ardour/ardour/proxy_controllable.h b/libs/ardour/ardour/proxy_controllable.h index 61137ae0ab..c6e61dd1e9 100644 --- a/libs/ardour/ardour/proxy_controllable.h +++ b/libs/ardour/ardour/proxy_controllable.h @@ -23,6 +23,8 @@ #include #include "pbd/controllable.h" + +#include "ardour/dB.h" #include "ardour/libardour_visibility.h" namespace ARDOUR { diff --git a/libs/ardour/ardour/session_playlists.h b/libs/ardour/ardour/session_playlists.h index 1ee1faddd3..8045e4fe0e 100644 --- a/libs/ardour/ardour/session_playlists.h +++ b/libs/ardour/ardour/session_playlists.h @@ -27,6 +27,10 @@ #include +#include "ardour/libardour_visibility.h" +#include "ardour/types.h" + +#include "temporal/domain_swap.h" #include "pbd/signals.h" diff --git a/libs/ardour/ardour/spline.h b/libs/ardour/ardour/spline.h index 7af17ff986..47a80ad036 100644 --- a/libs/ardour/ardour/spline.h +++ b/libs/ardour/ardour/spline.h @@ -19,6 +19,8 @@ #pragma once +#include "ardour/libardour_visibility.h" + #include #ifdef __cplusplus diff --git a/libs/ardour/ardour/step_sequencer.h b/libs/ardour/ardour/step_sequencer.h index 9063a45e27..533f71021c 100644 --- a/libs/ardour/ardour/step_sequencer.h +++ b/libs/ardour/ardour/step_sequencer.h @@ -22,6 +22,7 @@ #include #include +#include #include @@ -38,6 +39,8 @@ #include "ardour/midi_state_tracker.h" #include "ardour/types.h" +#include "midi++/types.h" + namespace ARDOUR { class MidiBuffer; @@ -299,7 +302,7 @@ class StepSequencer : public PBD::Stateful size_t start_step; size_t end_step; - static MultiAllocSingleReleasePool pool; + static PBD::MultiAllocSingleReleasePool pool; void *operator new (size_t) { return pool.alloc (); @@ -322,7 +325,7 @@ class StepSequencer : public PBD::Stateful Temporal::Beats when; uint8_t buf[3]; - static Pool pool; + static PBD::Pool pool; void *operator new (size_t) { return pool.alloc (); diff --git a/libs/ardour/ardour/transport_fsm.h b/libs/ardour/ardour/transport_fsm.h index 94b660f59f..9dc2c2cac9 100644 --- a/libs/ardour/ardour/transport_fsm.h +++ b/libs/ardour/ardour/transport_fsm.h @@ -12,6 +12,7 @@ #include #include "pbd/demangle.h" +#include "pbd/pool.h" #include "ardour/debug.h" #include "ardour/types.h" diff --git a/libs/ardour/ardour/trimmable.h b/libs/ardour/ardour/trimmable.h index 357f812277..f2c7601a2b 100644 --- a/libs/ardour/ardour/trimmable.h +++ b/libs/ardour/ardour/trimmable.h @@ -18,6 +18,8 @@ #pragma once +#include "ardour/libardour_visibility.h" + namespace ARDOUR { class LIBARDOUR_API Trimmable { diff --git a/libs/audiographer/audiographer/general/threader.h b/libs/audiographer/audiographer/general/threader.h index 828643def0..df21125905 100644 --- a/libs/audiographer/audiographer/general/threader.h +++ b/libs/audiographer/audiographer/general/threader.h @@ -5,6 +5,7 @@ #include #include +#include "glibmm/threads.h" #include #include #include diff --git a/libs/backends/alsa/alsa_slave.h b/libs/backends/alsa/alsa_slave.h index e2c0a0b2b5..159b501936 100644 --- a/libs/backends/alsa/alsa_slave.h +++ b/libs/backends/alsa/alsa_slave.h @@ -24,6 +24,7 @@ #include #include "pbd/ringbuffer.h" +#include "pbd/signals.h" #include "zita-resampler/vresampler.h" #include "zita-alsa-pcmi.h" diff --git a/libs/canvas/canvas/stateful_image.h b/libs/canvas/canvas/stateful_image.h index 8b1bec5f58..a2a0570c23 100644 --- a/libs/canvas/canvas/stateful_image.h +++ b/libs/canvas/canvas/stateful_image.h @@ -25,6 +25,8 @@ #include +#include "pbd/search_path.h" + #include "canvas/item.h" class XMLNode; diff --git a/libs/evoral/libsmf/smf_private.h b/libs/evoral/libsmf/smf_private.h index 41ac7238fc..71958e4982 100644 --- a/libs/evoral/libsmf/smf_private.h +++ b/libs/evoral/libsmf/smf_private.h @@ -31,6 +31,8 @@ #include #include +#include "smf.h" + //#include "config.h" //#define SMF_VERSION PACKAGE_VERSION diff --git a/libs/gtkmm2ext/gtkmm2ext/dndvbox.h b/libs/gtkmm2ext/gtkmm2ext/dndvbox.h index a081d42077..27c10b79b6 100644 --- a/libs/gtkmm2ext/gtkmm2ext/dndvbox.h +++ b/libs/gtkmm2ext/gtkmm2ext/dndvbox.h @@ -23,6 +23,8 @@ #include #include +#include +#include #include "gtkmm2ext/visibility.h" #include "gtkmm2ext/widget_state.h" diff --git a/libs/gtkmm2ext/gtkmm2ext/gtkutils.h b/libs/gtkmm2ext/gtkmm2ext/gtkutils.h index e9734e520f..346bfe7422 100644 --- a/libs/gtkmm2ext/gtkmm2ext/gtkutils.h +++ b/libs/gtkmm2ext/gtkmm2ext/gtkutils.h @@ -22,6 +22,8 @@ #include "gtkmm2ext/visibility.h" +#include + namespace Gtk { class Widget; } diff --git a/libs/gtkmm2ext/gtkmm2ext/visibility_tracker.h b/libs/gtkmm2ext/gtkmm2ext/visibility_tracker.h index 1e0aea7a4b..9bcb7deaac 100644 --- a/libs/gtkmm2ext/gtkmm2ext/visibility_tracker.h +++ b/libs/gtkmm2ext/gtkmm2ext/visibility_tracker.h @@ -22,6 +22,9 @@ #include #include "gtkmm2ext/visibility.h" +#include "gtkmm2ext/visibility_tracker.h" + +#include namespace Gtk { class Window; diff --git a/libs/gtkmm2ext/gtkmm2ext/window_proxy.h b/libs/gtkmm2ext/gtkmm2ext/window_proxy.h index aa4cad5a5e..f613ad4b6f 100644 --- a/libs/gtkmm2ext/gtkmm2ext/window_proxy.h +++ b/libs/gtkmm2ext/gtkmm2ext/window_proxy.h @@ -26,6 +26,8 @@ #include "pbd/statefuldestructible.h" +#include + #include "gtkmm2ext/visibility.h" namespace Gtk { diff --git a/libs/pbd/pbd/atomic_counter.h b/libs/pbd/pbd/atomic_counter.h index 21023f1c56..1d5c517215 100644 --- a/libs/pbd/pbd/atomic_counter.h +++ b/libs/pbd/pbd/atomic_counter.h @@ -20,6 +20,8 @@ #ifndef PBD_ATOMIC_COUNTER_H #define PBD_ATOMIC_COUNTER_H +#include "pbd/atomic.h" + #include #include diff --git a/libs/pbd/pbd/property_basics_impl.h b/libs/pbd/pbd/property_basics_impl.h index 5881b13d61..d557dbaafd 100644 --- a/libs/pbd/pbd/property_basics_impl.h +++ b/libs/pbd/pbd/property_basics_impl.h @@ -18,6 +18,8 @@ #pragma once +#include "pbd/property_basics.h" + namespace PBD { template diff --git a/libs/pbd/pbd/scoped_file_descriptor.h b/libs/pbd/pbd/scoped_file_descriptor.h index 06c53d15fe..0d525275aa 100644 --- a/libs/pbd/pbd/scoped_file_descriptor.h +++ b/libs/pbd/pbd/scoped_file_descriptor.h @@ -18,6 +18,8 @@ #pragma once +#include + namespace PBD { struct ScopedFileDescriptor { diff --git a/libs/surfaces/maschine2/ui_menu.h b/libs/surfaces/maschine2/ui_menu.h index e71a38c5d6..57ac3d9f1e 100644 --- a/libs/surfaces/maschine2/ui_menu.h +++ b/libs/surfaces/maschine2/ui_menu.h @@ -24,6 +24,7 @@ #include "pbd/signals.h" #include "canvas/container.h" +#include "canvas/rectangle.h" namespace ArdourCanvas { class Text; diff --git a/libs/surfaces/osc/osc_cue_observer.h b/libs/surfaces/osc/osc_cue_observer.h index dfe13651da..ecde92f30d 100644 --- a/libs/surfaces/osc/osc_cue_observer.h +++ b/libs/surfaces/osc/osc_cue_observer.h @@ -19,6 +19,8 @@ #ifndef __osc_osccueobserver_h__ #define __osc_osccueobserver_h__ +#include "osc.h" + #include #include diff --git a/libs/surfaces/osc/osc_global_observer.h b/libs/surfaces/osc/osc_global_observer.h index a9fa201a3c..4c08ae6e0c 100644 --- a/libs/surfaces/osc/osc_global_observer.h +++ b/libs/surfaces/osc/osc_global_observer.h @@ -19,6 +19,8 @@ #ifndef __osc_oscglobalobserver_h__ #define __osc_oscglobalobserver_h__ +#include "osc.h" + #include #include @@ -27,6 +29,9 @@ #include "pbd/controllable.h" #include "pbd/stateful.h" + +#include "ardour/route_group.h" +#include "ardour/session.h" #include "ardour/types.h" class OSCGlobalObserver diff --git a/libs/surfaces/osc/osc_gui.h b/libs/surfaces/osc/osc_gui.h index a78935953b..ed5d2bfab1 100644 --- a/libs/surfaces/osc/osc_gui.h +++ b/libs/surfaces/osc/osc_gui.h @@ -18,6 +18,10 @@ #ifndef osc_gui_h #define osc_gui_h +#include +#include +#include +#include #include "osc.h" diff --git a/libs/surfaces/osc/osc_select_observer.h b/libs/surfaces/osc/osc_select_observer.h index 0206bec2c6..9691d3fe53 100644 --- a/libs/surfaces/osc/osc_select_observer.h +++ b/libs/surfaces/osc/osc_select_observer.h @@ -28,8 +28,10 @@ #include "pbd/controllable.h" #include "pbd/stateful.h" -#include "ardour/types.h" + #include "ardour/processor.h" +#include "ardour/route_group.h" +#include "ardour/types.h" #include "osc.h" diff --git a/libs/surfaces/push2/follow_action.h b/libs/surfaces/push2/follow_action.h index 3c4e6d18d4..03ddcef793 100644 --- a/libs/surfaces/push2/follow_action.h +++ b/libs/surfaces/push2/follow_action.h @@ -25,8 +25,12 @@ * correctly. */ +#include "ardour/triggerbox.h" + #include "canvas/rectangle.h" +#include + namespace ArdourCanvas { class FollowActionIcon : public ArdourCanvas::Rectangle diff --git a/libs/surfaces/push2/level_meter.h b/libs/surfaces/push2/level_meter.h index 227d63bccc..a420c2c6c0 100644 --- a/libs/surfaces/push2/level_meter.h +++ b/libs/surfaces/push2/level_meter.h @@ -23,6 +23,9 @@ #include "canvas/container.h" #include "canvas/meter.h" +#include "ardour/chan_count.h" +#include "ardour/types.h" + namespace ARDOUR { class PeakMeter; } diff --git a/libs/surfaces/push2/scale.h b/libs/surfaces/push2/scale.h index 67e0a2b7cf..8a6cb193ff 100644 --- a/libs/surfaces/push2/scale.h +++ b/libs/surfaces/push2/scale.h @@ -22,9 +22,11 @@ #include #include "layout.h" +#include "push2.h" namespace ArdourCanvas { class Rectangle; + class Text; } namespace ArdourSurface { diff --git a/libs/surfaces/push2/track_mix.h b/libs/surfaces/push2/track_mix.h index 69f4f7f356..f6b564ec44 100644 --- a/libs/surfaces/push2/track_mix.h +++ b/libs/surfaces/push2/track_mix.h @@ -21,7 +21,10 @@ #include +#include "pbd/property_basics.h" + #include "layout.h" +#include "push2.h" namespace ARDOUR { class Stripable; diff --git a/libs/surfaces/us2400/gui.h b/libs/surfaces/us2400/gui.h index ff6ca5088e..22eb347ef2 100644 --- a/libs/surfaces/us2400/gui.h +++ b/libs/surfaces/us2400/gui.h @@ -20,9 +20,11 @@ #include #include +#include #include #include #include +#include #include #include #include diff --git a/libs/surfaces/us2400/surface_port.h b/libs/surfaces/us2400/surface_port.h index 8dc517825e..082a2828ef 100644 --- a/libs/surfaces/us2400/surface_port.h +++ b/libs/surfaces/us2400/surface_port.h @@ -21,6 +21,7 @@ #include #include "pbd/signals.h" +#include "pbd/xml++.h" #include "midi_byte_array.h" diff --git a/libs/surfaces/us2400/timer.h b/libs/surfaces/us2400/timer.h index 01b5878899..9c0cfa1a76 100644 --- a/libs/surfaces/us2400/timer.h +++ b/libs/surfaces/us2400/timer.h @@ -19,6 +19,8 @@ #ifndef timer_h #define timer_h +#include + #include #ifdef _WIN32 diff --git a/libs/widgets/widgets/binding_proxy.h b/libs/widgets/widgets/binding_proxy.h index 438b893447..8f15abe324 100644 --- a/libs/widgets/widgets/binding_proxy.h +++ b/libs/widgets/widgets/binding_proxy.h @@ -25,6 +25,8 @@ #include "pbd/signals.h" +#include "gdk/gdkevents.h" + #include "widgets/visibility.h" namespace PBD { diff --git a/libs/zita-convolver/zita-convolver/zita-convolver.h b/libs/zita-convolver/zita-convolver/zita-convolver.h index 74f8e41c5b..1b0e6ca3f9 100644 --- a/libs/zita-convolver/zita-convolver/zita-convolver.h +++ b/libs/zita-convolver/zita-convolver/zita-convolver.h @@ -27,6 +27,10 @@ #include "zita-convolver/zconvolver_visibility.h" +#if defined(__linux__) || defined(__GNU__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(PTW32_VERSION) || defined(__WINPTHREADS_VERSION) +#include +#endif + namespace ArdourZita { #ifdef ZCSEMA_IS_IMPLEMENTED @@ -36,8 +40,6 @@ namespace ArdourZita { /* note: mingw and msvc actually use PTW32's implementation of semaphores */ #if defined(__linux__) || defined(__GNU__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(PTW32_VERSION) || defined (__WINPTHREADS_VERSION) -#include - class LIBZCONVOLVER_API ZCsema { public: From 05699c2d1ad709fe2f4ca1e18ec7a9c0432080f1 Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Sun, 20 Oct 2024 01:06:48 +0200 Subject: [PATCH 006/113] Fix invalid beatbox #include syntax ... but it still doesn't compile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It has been broken for 2½ year. --- libs/ardour/ardour/beatbox.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ardour/ardour/beatbox.h b/libs/ardour/ardour/beatbox.h index a9e57dd8af..933c2f280e 100644 --- a/libs/ardour/ardour/beatbox.h +++ b/libs/ardour/ardour/beatbox.h @@ -30,7 +30,7 @@ #include "pbd/ringbuffer.h" #include "temporal/bbt_time.h" -#include "temporal/superclock.h +#include "temporal/superclock.h" #include "ardour/midi_state_tracker.h" #include "ardour/processor.h" From dab3cc35016d9796ecceddff48b7cf78c7273131 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 21 Oct 2024 02:27:06 +0200 Subject: [PATCH 007/113] Disable RegionFX plugins in safe-mode --- libs/ardour/region_fx_plugin.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/ardour/region_fx_plugin.cc b/libs/ardour/region_fx_plugin.cc index c67729917a..984c9e7c5b 100644 --- a/libs/ardour/region_fx_plugin.cc +++ b/libs/ardour/region_fx_plugin.cc @@ -300,7 +300,11 @@ RegionFxPlugin::set_state (const XMLNode& node, int version) node.get_property ("count", count); if (_plugins.empty()) { - std::shared_ptr plugin = find_and_load_plugin (_session, node, type, unique_id, any_vst); + std::shared_ptr plugin; + + if (!_session.get_disable_all_loaded_plugins ()) { + plugin = find_and_load_plugin (_session, node, type, unique_id, any_vst); + } if (!plugin) { delete _state; From 48fcb306087b14366f3d2c68b588566dc319974f Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Wed, 24 Jul 2024 01:35:07 +0200 Subject: [PATCH 008/113] wscript: fix whitespace formatting No tabs and no trailing spaces. --- gtk2_ardour/wscript | 4 ++-- libs/aaf/wscript | 32 ++++++++++++++--------------- libs/surfaces/launchpad_pro/wscript | 6 +++--- libs/surfaces/launchpad_x/wscript | 2 +- libs/tk/ytk/wscript | 6 +++--- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 3a9e8a118b..ae7f48c497 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -156,7 +156,7 @@ gtk2_ardour_sources = [ 'main.cc', 'main_clock.cc', 'marker.cc', - 'mergeable_line.cc', + 'mergeable_line.cc', 'midi_automation_line.cc', 'midi_channel_dialog.cc', 'midi_channel_selector.cc', @@ -876,7 +876,7 @@ def build(bld): obj.stdin = 'livetrax.menus.in' else: obj.stdin = 'ardour.menus.in' - obj.stdout = 'ardour.menus' + obj.stdout = 'ardour.menus' bld.install_files (bld.env['CONFDIR'], 'ardour.menus') # Freedesktop diff --git a/libs/aaf/wscript b/libs/aaf/wscript index e6a1337b5a..491c3b8c97 100644 --- a/libs/aaf/wscript +++ b/libs/aaf/wscript @@ -16,22 +16,22 @@ top = '.' out = 'build' libaaf_sources = [ - 'AAFClass.c', - 'AAFCore.c', - 'AAFDump.c', - 'AAFIEssenceFile.c', - 'AAFIface.c', - 'AAFIParser.c', - 'AAFToText.c', - 'CFBDump.c', - 'LibCFB.c', - 'ProTools.c', - 'MediaComposer.c', - 'Resolve.c', - 'RIFFParser.c', - 'URIParser.c', - 'utils.c', - 'log.c', + 'AAFClass.c', + 'AAFCore.c', + 'AAFDump.c', + 'AAFIEssenceFile.c', + 'AAFIface.c', + 'AAFIParser.c', + 'AAFToText.c', + 'CFBDump.c', + 'LibCFB.c', + 'ProTools.c', + 'MediaComposer.c', + 'Resolve.c', + 'RIFFParser.c', + 'URIParser.c', + 'utils.c', + 'log.c', ] def options(opt): diff --git a/libs/surfaces/launchpad_pro/wscript b/libs/surfaces/launchpad_pro/wscript index 4586eca48c..4c6bb57a7c 100644 --- a/libs/surfaces/launchpad_pro/wscript +++ b/libs/surfaces/launchpad_pro/wscript @@ -12,9 +12,9 @@ def configure(conf): def build(bld): obj = bld(features = 'cxx cxxshlib') obj.source = ''' - lppro.cc - interface.cc - gui.cc + lppro.cc + interface.cc + gui.cc ''' obj.defines = [ 'PACKAGE="ardour_launchpad_pro"' ] obj.defines += [ 'ARDOURSURFACE_DLL_EXPORTS' ] diff --git a/libs/surfaces/launchpad_x/wscript b/libs/surfaces/launchpad_x/wscript index f5588ce632..4473ed1f91 100644 --- a/libs/surfaces/launchpad_x/wscript +++ b/libs/surfaces/launchpad_x/wscript @@ -5,7 +5,7 @@ import os lpxm_sources = [ 'lpx.cc', 'gui.cc', -] +] def options(opt): pass diff --git a/libs/tk/ytk/wscript b/libs/tk/ytk/wscript index 63e1c2afc5..ea5484b258 100644 --- a/libs/tk/ytk/wscript +++ b/libs/tk/ytk/wscript @@ -286,9 +286,9 @@ def build(bld): 'GTK_VERSION="2.24.23"', 'GTK_BINARY_VERSION="2.10.0"', 'GTK_HOST="ardour"', 'PACKAGE="' + I18N_PACKAGE + '"', 'GETTEXT_PACKAGE="' + I18N_PACKAGE + '"', - 'GTK_DATA_PREFIX="' + bld.env['PREFIX'] + '"', - 'GTK_SYSCONFDIR="' + bld.env['SYSCONFDIR'] + '"', - 'GTK_DATA_DIR="' + bld.env['DATADIR'] + '"', + 'GTK_DATA_PREFIX="' + bld.env['PREFIX'] + '"', + 'GTK_SYSCONFDIR="' + bld.env['SYSCONFDIR'] + '"', + 'GTK_DATA_DIR="' + bld.env['DATADIR'] + '"', 'GTK_LIBDIR="' + bld.env['LIBDIR'] + '"', ] obj.vnum = LIBYDK_VERSION From c78b3289d55ae913990435553662565a1bf9e4c2 Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Sun, 14 Jan 2024 01:08:10 +0100 Subject: [PATCH 009/113] wscript: set PROGRAM_NAME in env early, not as set_compiler_flags side effect --- wscript | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wscript b/wscript index 3240836f4a..c123bc191d 100644 --- a/wscript +++ b/wscript @@ -784,8 +784,6 @@ int main() { return 0; }''', compiler_flags.append ('-DPROGRAM_NAME="' + Options.options.program_name + '"') compiler_flags.append ('-DPROGRAM_VERSION="' + PROGRAM_VERSION + '"') - conf.env['PROGRAM_NAME'] = Options.options.program_name - if opt.debug: conf.env.append_value('CFLAGS', debug_flags) conf.env.append_value('CXXFLAGS', debug_flags) @@ -806,9 +804,9 @@ int main() { return 0; }''', conf.env.append_value('CXXFLAGS', cxx_flags) conf.env.append_value('LINKFLAGS', linker_flags) -def create_resource_file(icon): +def create_resource_file(name): try: - text = 'IDI_ICON1 ICON DISCARDABLE "icons/' + icon + '.ico"\n' + text = 'IDI_ICON1 ICON DISCARDABLE "icons/' + name + '.ico"\n' o = open('gtk2_ardour/windows_icon.rc', 'w') o.write(text) o.close() @@ -983,6 +981,8 @@ def configure(conf): if itstool != "itstool" or version[0] < "2": conf.fatal("--freedesktop requires itstool > 2.0.0 to translate files.") + conf.env['PROGRAM_NAME'] = Options.options.program_name or 'Ardour' + conf.env['VERSION'] = VERSION conf.env['MAJOR'] = MAJOR conf.env['MINOR'] = MINOR From 27acda4ccd7700d442482cd97b8b776ce5b58c15 Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Tue, 25 Jan 2022 21:05:50 +0100 Subject: [PATCH 010/113] wscript: the i18n class names do not define the i18n waf command names Try to make it a bit more clear what is going on with class and def for i18n commands. It was confusing that we first defined i18n classes in the beginning of the wscript file, and then replaced them with "plain" functions with the same name at the end. pyflakes also didn't like it. It seemed magic. The i18n functionality easily broke if trying to touch that. It deserves an explanation to make it maintainable ... and some cleanup. Simple functions in the top level wscript file are generally exposed as custom waf commands. The command will have the same name as the function and will get a plain Context. But that simple method doesn't work for these i18n commands. They have to be declared in a different way with a custom BuildContext, as seen and described in the comment. The name of the BuildContext classes doesn't matter, so we change the name to avoid the name collision and to give a hint how they actually just are contexts for the commands - they are not the command itself. We also place the classes next to the corresponding functions so it is more obvious that they are related. --- wscript | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/wscript b/wscript index c123bc191d..6cf190e344 100644 --- a/wscript +++ b/wscript @@ -16,22 +16,6 @@ from waflib.Tools.compiler_cxx import cxx_compiler c_compiler['darwin'] = ['gcc', 'clang' ] cxx_compiler['darwin'] = ['g++', 'clang++' ] -class i18n(BuildContext): - cmd = 'i18n' - fun = 'i18n' - -class i18n_pot(BuildContext): - cmd = 'i18n_pot' - fun = 'i18n_pot' - -class i18n_po(BuildContext): - cmd = 'i18n_po' - fun = 'i18n_po' - -class i18n_mo(BuildContext): - cmd = 'i18n_mo' - fun = 'i18n_mo' - compiler_flags_dictionaries= { 'gcc' : { # Flags required when building a debug build @@ -1648,16 +1632,36 @@ def build(bld): if bld.env['RUN_TESTS']: bld.add_post_fun(test) +# The following i18n command implementations need a BuildContext (with .env), +# and we thus create BuildContext subclasses that define the `cmd` command to +# execute the `fun` function (which often will recurse). + +class _i18n_build_context(BuildContext): + cmd = 'i18n' + fun = 'i18n' + def i18n(bld): print(bld.env) bld.recurse (i18n_children) +class _i18n_pot_build_context(BuildContext): + cmd = 'i18n_pot' + fun = 'i18n_pot' + def i18n_pot(bld): bld.recurse (i18n_children) +class _i18n_po_build_context(BuildContext): + cmd = 'i18n_po' + fun = 'i18n_po' + def i18n_po(bld): bld.recurse (i18n_children) +class _i18n_mo_build_context(BuildContext): + cmd = 'i18n_mo' + fun = 'i18n_mo' + def i18n_mo(bld): bld.recurse (i18n_children) From 3228a61e62f4136db0e8c69c8b1a503af9c536dc Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Tue, 25 Jan 2022 21:28:12 +0100 Subject: [PATCH 011/113] wscript: the i18n worker functions do not define the i18n waf commands Rename the worker functions to make it clear that their name in this case isn't magic. These functions "are not" the waf commands. It is the custom build context class definitions that define the i18n commands ... which will invoke these top level worker functions which in turn invoke the others recursively. The bare printing of the build environment in the top level i18n command seems to be old debug code that safely can be removed. --- gtk2_ardour/wscript | 8 ++++---- libs/appleutility/wscript | 3 --- libs/ardour/wscript | 8 ++++---- libs/gtkmm2ext/wscript | 8 ++++---- wscript | 17 ++++++++--------- 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index ae7f48c497..1054cc94b9 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -968,26 +968,26 @@ def build(bld): bld.install_as (os.path.join(os.path.normpath(bld.env['LOCALEDIR']), lang, 'LC_MESSAGES', I18N_PACKAGE + '.mo'), mo) -def i18n(bld): +def i18n_func(bld): I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR'] autowaf.build_i18n(bld, '.', 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources, 'Paul Davis') appdata_i18n_pot(bld) appdata_i18n_po(bld) -def i18n_pot(bld): +def i18n_pot_func(bld): I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR'] autowaf.build_i18n_pot(bld, '.', 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources, 'Paul Davis') appdata_i18n_pot(bld) -def i18n_po(bld): +def i18n_po_func(bld): I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR'] autowaf.build_i18n_po(bld, '.', 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources, 'Paul Davis') appdata_i18n_po(bld) -def i18n_mo(bld): +def i18n_mo_func(bld): I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR'] autowaf.build_i18n_mo(bld, '.', 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources, 'Paul Davis') diff --git a/libs/appleutility/wscript b/libs/appleutility/wscript index 51be798e82..6136aafc71 100644 --- a/libs/appleutility/wscript +++ b/libs/appleutility/wscript @@ -42,6 +42,3 @@ def build(bld): obj.name = 'libappleutility' obj.target = 'appleutility' obj.install_path = os.path.join(bld.env['LIBDIR'], 'appleutility') - -def i18n(bld): - pass diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 30f6e861a3..b45efb06c3 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -736,18 +736,18 @@ def create_ardour_test_program(bld, includes, name, target, sources): 'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"', ] -def i18n(bld): +def i18n_func(bld): autowaf.build_i18n(bld, '.', 'libs/ardour', I18N_PACKAGE + bld.env['MAJOR'], libardour_sources, 'Paul Davis') -def i18n_pot(bld): +def i18n_pot_func(bld): autowaf.build_i18n(bld, '.', 'libs/ardour', I18N_PACKAGE + bld.env['MAJOR'], libardour_sources, 'Paul Davis') -def i18n_po(bld): +def i18n_po_func(bld): autowaf.build_i18n_po(bld, '.', 'libs/ardour', I18N_PACKAGE + bld.env['MAJOR'], libardour_sources, 'Paul Davis') -def i18n_mo(bld): +def i18n_mo_func(bld): autowaf.build_i18n_mo(bld, '.', 'libs/ardour', I18N_PACKAGE + bld.env['MAJOR'], libardour_sources, 'Paul Davis') diff --git a/libs/gtkmm2ext/wscript b/libs/gtkmm2ext/wscript index 67e4cade26..d47ee0465a 100644 --- a/libs/gtkmm2ext/wscript +++ b/libs/gtkmm2ext/wscript @@ -99,18 +99,18 @@ def build(bld): bld.install_as (os.path.join(os.path.normpath(bld.env['LOCALEDIR']), lang, 'LC_MESSAGES', I18N_PACKAGE + '.mo'), mo) -def i18n(bld): +def i18n_func(bld): autowaf.build_i18n(bld, '.', 'libs/gtkmm2ext', I18N_PACKAGE, gtkmm2ext_sources, 'Paul Davis') -def i18n_pot(bld): +def i18n_pot_func(bld): autowaf.build_i18n_pot(bld, '.', 'libs/gtkmm2ext', I18N_PACKAGE, gtkmm2ext_sources, 'Paul Davis') -def i18n_po(bld): +def i18n_po_func(bld): autowaf.build_i18n_po(bld, '.', 'libs/gtkmm2ext', I18N_PACKAGE, gtkmm2ext_sources, 'Paul Davis') -def i18n_mo(bld): +def i18n_mo_func(bld): autowaf.build_i18n_mo(bld, '.', 'libs/gtkmm2ext', I18N_PACKAGE, gtkmm2ext_sources, 'Paul Davis') diff --git a/wscript b/wscript index 6cf190e344..44702d2e9b 100644 --- a/wscript +++ b/wscript @@ -1638,31 +1638,30 @@ def build(bld): class _i18n_build_context(BuildContext): cmd = 'i18n' - fun = 'i18n' + fun = 'i18n_func' -def i18n(bld): - print(bld.env) +def i18n_func(bld): bld.recurse (i18n_children) class _i18n_pot_build_context(BuildContext): cmd = 'i18n_pot' - fun = 'i18n_pot' + fun = 'i18n_pot_func' -def i18n_pot(bld): +def i18n_pot_func(bld): bld.recurse (i18n_children) class _i18n_po_build_context(BuildContext): cmd = 'i18n_po' - fun = 'i18n_po' + fun = 'i18n_po_func' -def i18n_po(bld): +def i18n_po_func(bld): bld.recurse (i18n_children) class _i18n_mo_build_context(BuildContext): cmd = 'i18n_mo' - fun = 'i18n_mo' + fun = 'i18n_mo_func' -def i18n_mo(bld): +def i18n_mo_func(bld): bld.recurse (i18n_children) def tarball(bld): From 590400a95f25c7a953b426834f8e61ce250e9d23 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 21 Oct 2024 10:45:47 -0600 Subject: [PATCH 012/113] trigger arming must be mutually exclusive within a triggerbox --- libs/ardour/ardour/triggerbox.h | 1 + libs/ardour/triggerbox.cc | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index ee01cce0db..a2fc984d04 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -814,6 +814,7 @@ class LIBARDOUR_API TriggerBox : public Processor, public std::enable_shared_fro void arm_from_another_thread (Trigger& slot, samplepos_t, uint32_t chans); void disarm(); + void disarm_all(); bool armed() const { return (bool) _arm_info.load(); } PBD::Signal ArmedChanged; diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 09adf400c6..90be239bec 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -290,8 +290,20 @@ Trigger::request_trigger_delete (Trigger* t) void Trigger::arm () { -#warning paul need channel count here, somehow - _box.arm_from_another_thread (*this, _box.session().transport_sample(), 2); + /* trigger arming is mutually exclusive within a given TriggerBox */ + + _box.disarm_all (); + + Track* trk = static_cast (_box.owner()); + int chns; + + if (trk->data_type() == DataType::AUDIO) { + chns = dynamic_cast (trk)->input()->n_ports().n_audio(); + } else { + chns = 0; + } + + _box.arm_from_another_thread (*this, _box.session().transport_sample(), chns); _armed = true; ArmChanged(); /* EMIT SIGNAL */ TriggerArmChanged (this); @@ -3569,6 +3581,16 @@ TriggerBox::arm_from_another_thread (Trigger& slot, samplepos_t now, uint32_t ch void TriggerBox::disarm () { + delete _arm_info; + _arm_info = nullptr; +} + +void +TriggerBox::disarm_all () +{ + for (auto & t : all_triggers) { + t->disarm (); + } } void From b5d6b97fd294aae7099969be146a6480a061dbcb Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 22 Oct 2024 00:34:29 +0200 Subject: [PATCH 013/113] Keep inline control state in sync with editor-mixer --- gtk2_ardour/processor_box.cc | 16 +++++++++++----- gtk2_ardour/processor_box.h | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index ad3666c006..514d7ede13 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -715,7 +715,7 @@ ProcessorEntry::show_all_controls () (*i)->set_visible (true); } - _parent->update_gui_object_state (this); + _parent->update_gui_object_state (this, true); } void @@ -725,7 +725,7 @@ ProcessorEntry::hide_all_controls () (*i)->set_visible (false); } - _parent->update_gui_object_state (this); + _parent->update_gui_object_state (this, true); } void @@ -942,14 +942,14 @@ ProcessorEntry::toggle_inline_display_visibility () } else { _plugin_display->show(); } - _parent->update_gui_object_state (this); + _parent->update_gui_object_state (this, true); } void ProcessorEntry::toggle_control_visibility (Control* c) { c->set_visible (!c->visible ()); - _parent->update_gui_object_state (this); + _parent->update_gui_object_state (this, true); } Menu* @@ -4691,7 +4691,7 @@ ProcessorBox::entry_gui_object_state (ProcessorEntry* entry) } void -ProcessorBox::update_gui_object_state (ProcessorEntry* entry) +ProcessorBox::update_gui_object_state (ProcessorEntry* entry, bool emit) { XMLNode* proc = entry_gui_object_state (entry); if (!proc) { @@ -4701,6 +4701,12 @@ ProcessorBox::update_gui_object_state (ProcessorEntry* entry) /* XXX: this is a bit inefficient; we just remove all child nodes and re-add them */ proc->remove_nodes_and_delete (X_("Object")); entry->add_control_state (proc); + + /* notify other strips to update */ + if (emit && _route) { + PBD::Unwinder uw (no_processor_redisplay, true); + _route->processors_changed (RouteProcessorChange ()); + } } bool diff --git a/gtk2_ardour/processor_box.h b/gtk2_ardour/processor_box.h index 7e0b09b199..1391a99e6c 100644 --- a/gtk2_ardour/processor_box.h +++ b/gtk2_ardour/processor_box.h @@ -461,7 +461,7 @@ public: void edit_processor (std::shared_ptr); void generic_edit_processor (std::shared_ptr); - void update_gui_object_state (ProcessorEntry *); + void update_gui_object_state (ProcessorEntry *, bool emit = false); sigc::signal > ProcessorSelected; sigc::signal > ProcessorUnselected; From 8e2a9dfd9116f36523828b5f68fbc97ad52f0d3f Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Mon, 21 Oct 2024 22:12:23 +0200 Subject: [PATCH 014/113] wscript: Fix i18n names for tk --- libs/tk/ytk/wscript | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/tk/ytk/wscript b/libs/tk/ytk/wscript index ea5484b258..1e34ec4187 100644 --- a/libs/tk/ytk/wscript +++ b/libs/tk/ytk/wscript @@ -314,14 +314,14 @@ def build(bld): lang = os.path.basename(mo.srcpath()).replace('.mo', '') bld.install_as(os.path.join(bld.env['LOCALEDIR'], lang, 'LC_MESSAGES', I18N_PACKAGE + bld.env['MAJOR'] + '.mo'), mo) -def i18n(bld): +def i18n_func(bld): autowaf.build_i18n(bld, '.', 'libs/tk/ytk', I18N_PACKAGE + bld.env['MAJOR'], libytk_sources) -def i18n_pot(bld): +def i18n_pot_func(bld): autowaf.build_i18n(bld, '.', 'libs/tk/ytk', I18N_PACKAGE + bld.env['MAJOR'], libytk_sources) -def i18n_po(bld): +def i18n_po_func(bld): autowaf.build_i18n_po(bld, '.', 'libs/tk/ytk', I18N_PACKAGE + bld.env['MAJOR'], libytk_sources) -def i18n_mo(bld): +def i18n_mo_func(bld): autowaf.build_i18n_mo(bld, '.', 'libs/tk/ytk', I18N_PACKAGE + bld.env['MAJOR'], libytk_sources) From e520cf6bac46bb7943375031eb520d9f49c6f5ae Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Mon, 21 Oct 2024 22:16:59 +0200 Subject: [PATCH 015/113] wscript: Actually invoke autowaf.build_i18n_pot in i18n_pot_func --- libs/ardour/wscript | 2 +- libs/tk/ytk/wscript | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/ardour/wscript b/libs/ardour/wscript index b45efb06c3..780d5f876a 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -741,7 +741,7 @@ def i18n_func(bld): 'Paul Davis') def i18n_pot_func(bld): - autowaf.build_i18n(bld, '.', 'libs/ardour', I18N_PACKAGE + bld.env['MAJOR'], libardour_sources, + autowaf.build_i18n_pot(bld, '.', 'libs/ardour', I18N_PACKAGE + bld.env['MAJOR'], libardour_sources, 'Paul Davis') def i18n_po_func(bld): diff --git a/libs/tk/ytk/wscript b/libs/tk/ytk/wscript index 1e34ec4187..365e4eaec4 100644 --- a/libs/tk/ytk/wscript +++ b/libs/tk/ytk/wscript @@ -318,7 +318,7 @@ def i18n_func(bld): autowaf.build_i18n(bld, '.', 'libs/tk/ytk', I18N_PACKAGE + bld.env['MAJOR'], libytk_sources) def i18n_pot_func(bld): - autowaf.build_i18n(bld, '.', 'libs/tk/ytk', I18N_PACKAGE + bld.env['MAJOR'], libytk_sources) + autowaf.build_i18n_pot(bld, '.', 'libs/tk/ytk', I18N_PACKAGE + bld.env['MAJOR'], libytk_sources) def i18n_po_func(bld): autowaf.build_i18n_po(bld, '.', 'libs/tk/ytk', I18N_PACKAGE + bld.env['MAJOR'], libytk_sources) From 6742c1e4b4db450b0ce555ad5b19f231d489d071 Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Mon, 21 Oct 2024 22:28:48 +0200 Subject: [PATCH 016/113] wscript: `waf i18n` should generate gtk2_ardour/appdata/ardour.appdata.pot when invoking appdata_i18n_pot --- gtk2_ardour/wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 1054cc94b9..3d814cb234 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -995,7 +995,7 @@ def i18n_mo_func(bld): def appdata_i18n_pot(bld): potfile = os.path.join(bld.top_dir, 'gtk2_ardour', 'appdata', 'ardour.appdata.pot') - if bld.cmd == 'i18n_pot': + if bld.cmd in ('i18n_pot', 'i18n'): Logs.info('Generating pot file from Ardour appdata') itsfile = os.path.join(bld.top_dir, 'tools', 'as-metainfo.its') adsource = os.path.join(bld.top_dir, 'gtk2_ardour', From 7a4fe02d53a77a6506fc85e6b9ad3cb952420fea Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Mon, 21 Oct 2024 22:38:59 +0200 Subject: [PATCH 017/113] wscript: `waf i18n` is usually running pot&po&mo and should thus also run appdata_i18n_mo --- gtk2_ardour/wscript | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 3d814cb234..505876e172 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -974,6 +974,7 @@ def i18n_func(bld): 'Paul Davis') appdata_i18n_pot(bld) appdata_i18n_po(bld) + appdata_i18n_mo(bld) def i18n_pot_func(bld): I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR'] From 769920d337de74176c6a37830bb5a6bf0e05ad4d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 21 Oct 2024 17:28:25 -0600 Subject: [PATCH 018/113] add a "region" property so that we can properly signal when it has changed inside a Trigger --- libs/ardour/ardour/triggerbox.h | 1 + libs/ardour/triggerbox.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index a2fc984d04..ece9a8d18b 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -1100,6 +1100,7 @@ namespace Properties { LIBARDOUR_API extern PBD::PropertyDescriptor patch_change; /* type not important */ LIBARDOUR_API extern PBD::PropertyDescriptor channel_map; /* type not important */ LIBARDOUR_API extern PBD::PropertyDescriptor used_channels; /* type not important */ + LIBARDOUR_API extern PBD::PropertyDescriptor region; /* type not important */ LIBARDOUR_API extern PBD::PropertyDescriptor tempo_meter; /* only used to transmit changes, not storage */ } diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 90be239bec..25eadacb0a 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -97,6 +97,7 @@ namespace ARDOUR { PBD::PropertyDescriptor patch_change; /* only to transmit updates, not storage */ PBD::PropertyDescriptor channel_map; /* only to transmit updates, not storage */ PBD::PropertyDescriptor used_channels; /* only to transmit updates, not storage */ + PBD::PropertyDescriptor region; /* only to transmit updates, not storage */ } } From aa2fb8c1d46abc4a24934f9b63610fcb05fbdbbd Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 22 Oct 2024 14:35:31 -0600 Subject: [PATCH 019/113] SMF: add a set_length() method which will place TrkEnd meta-events --- libs/evoral/SMF.cc | 16 ++++++++++++++++ libs/evoral/evoral/SMF.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/libs/evoral/SMF.cc b/libs/evoral/SMF.cc index d5af69dc58..f8af97be0b 100644 --- a/libs/evoral/SMF.cc +++ b/libs/evoral/SMF.cc @@ -34,6 +34,7 @@ #include "libsmf/smf.h" #include "temporal/tempo.h" +#include "temporal/beats.h" #include "evoral/Event.h" #include "evoral/SMF.h" @@ -528,6 +529,21 @@ SMF::end_write(string const & path) fclose(f); } +void +SMF::set_length (Temporal::Beats const & b) +{ + if (!_smf) { + return; + } + + for (uint16_t n = 0; n < _smf->number_of_tracks; ++n) { + smf_track_t* trk = smf_get_track_by_number (_smf, n+1); + if (trk) { + smf_track_add_eot_pulses (trk, (int) floor (b.get_ticks() * ((double) ppqn() / Temporal::ticks_per_beat))); + } + } +} + double SMF::round_to_file_precision (double val) const { diff --git a/libs/evoral/evoral/SMF.h b/libs/evoral/evoral/SMF.h index 0c9908cf63..656a63b2ab 100644 --- a/libs/evoral/evoral/SMF.h +++ b/libs/evoral/evoral/SMF.h @@ -39,6 +39,7 @@ typedef smf_tempo_struct smf_tempo_t; namespace Temporal { class TempoMap; + class Beats; } namespace Evoral { @@ -89,6 +90,7 @@ public: void end_write(std::string const &); void flush() {}; + void set_length (Temporal::Beats const &); double round_to_file_precision (double val) const; From e11caf2dea61b2105bbbee6bcdcc69d086b1b325 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 22 Oct 2024 14:41:40 -0600 Subject: [PATCH 020/113] various changes to get MIDI clip recording to display the post-capture region --- gtk2_ardour/midi_cue_editor.cc | 164 +++++++++++++++++++-------------- gtk2_ardour/midi_cue_editor.h | 10 +- gtk2_ardour/midi_cue_view.cc | 2 +- gtk2_ardour/midi_view.cc | 30 +++--- gtk2_ardour/trigger_page.cc | 32 +------ gtk2_ardour/view_background.h | 1 + libs/ardour/triggerbox.cc | 23 ++++- 7 files changed, 143 insertions(+), 119 deletions(-) diff --git a/gtk2_ardour/midi_cue_editor.cc b/gtk2_ardour/midi_cue_editor.cc index a4f9054607..158472fc1f 100644 --- a/gtk2_ardour/midi_cue_editor.cc +++ b/gtk2_ardour/midi_cue_editor.cc @@ -494,20 +494,6 @@ MidiCueEditor::idle_data_captured () return false; } -void -MidiCueEditor::set_box (std::shared_ptr b) -{ - capture_connections.drop_connections (); - idle_update_queued.store (0); - - if (b) { - b->Captured.connect (capture_connections, invalidator (*this), std::bind (&MidiCueEditor::data_captured, this, _1), gui_context()); - /* Don't bind a shared_ptr within the lambda */ - TriggerBox* tb (b.get()); - b->RecEnableChanged.connect (capture_connections, invalidator (*this), [&, tb]() { box_rec_enable_change (*tb); }, gui_context()); - } -} - void MidiCueEditor::box_rec_enable_change (ARDOUR::TriggerBox const & b) { @@ -528,61 +514,6 @@ MidiCueEditor::trigger_rec_enable_change (ARDOUR::Trigger const & t) } } -void -MidiCueEditor::set_track (std::shared_ptr t) -{ - _track = t; - - view->set_track (t); - - _update_connection.disconnect (); - capture_connections.drop_connections (); - - if (t) { - set_box (t->triggerbox()); - _update_connection = Timers::rapid_connect (sigc::mem_fun (*this, &MidiCueEditor::maybe_update)); - _track->DropReferences.connect (track_connection, invalidator (*this), std::bind (&MidiCueEditor::set_track, this, nullptr), gui_context()); - } else { - set_box (nullptr); - } -} - -void -MidiCueEditor::set_region (std::shared_ptr r) -{ - if (!r) { - view->set_region (nullptr); - return; - } - - view->set_region (r); - - /* Compute zoom level to show entire source plus some margin if possible */ - - Temporal::timecnt_t duration = Temporal::timecnt_t (r->midi_source()->length().beats()); - - bool provided = false; - std::shared_ptr map; - std::shared_ptr smf (std::dynamic_pointer_cast (r->midi_source())); - - if (smf) { - map = smf->tempo_map (provided); - } - - if (!provided) { - map.reset (new Temporal::TempoMap (Temporal::Tempo (120, 4), Temporal::Meter (4, 4))); - } - - { - EditingContext::TempoMapScope tms (*this, map); - double width = bg->width(); - samplecnt_t samples = duration.samples(); - - samplecnt_t spp = floor (samples / width); - reset_zoom (spp); - } -} - bool MidiCueEditor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type) { @@ -1761,3 +1692,98 @@ MidiCueEditor::selectable_owners() return std::list (); } + +void +MidiCueEditor::trigger_prop_change (PBD::PropertyChange const & what_changed) +{ + if (what_changed.contains (Properties::region)) { + std::shared_ptr mr = std::dynamic_pointer_cast (ref.trigger()->the_region()); + if (mr) { + set_region (mr); + } + } +} + +void +MidiCueEditor::set (TriggerReference & tref) +{ + _update_connection.disconnect (); + object_connections.drop_connections (); + + ref = tref; + + idle_update_queued.store (0); + + ref.box()->Captured.connect (object_connections, invalidator (*this), std::bind (&MidiCueEditor::data_captured, this, _1), gui_context()); + /* Don't bind a shared_ptr within the lambda */ + TriggerBox* tb (ref.box().get()); + tb->RecEnableChanged.connect (object_connections, invalidator (*this), [&, tb]() { box_rec_enable_change (*tb); }, gui_context()); + + Stripable* st = dynamic_cast (ref.box()->owner()); + assert (st); + _track = std::dynamic_pointer_cast (st->shared_from_this()); + assert (_track); + + view->set_track (_track); + + _update_connection = Timers::rapid_connect (sigc::mem_fun (*this, &MidiCueEditor::maybe_update)); + _track->DropReferences.connect (object_connections, invalidator (*this), std::bind (&MidiCueEditor::unset, this), gui_context()); + ref.trigger()->PropertyChanged.connect (object_connections, invalidator (*this), std::bind (&MidiCueEditor::trigger_prop_change, this, _1), gui_context()); + + if (ref.trigger()->the_region()) { + + std::shared_ptr mr = std::dynamic_pointer_cast (ref.trigger()->the_region()); + + if (mr) { + set_region (mr); + } + } +} + +void +MidiCueEditor::unset () +{ + _update_connection.disconnect(); + object_connections.drop_connections (); + _track.reset (); + view->set_region (nullptr); + ref = TriggerReference (); +} + +void +MidiCueEditor::set_region (std::shared_ptr r) +{ + if (!r) { + view->set_region (nullptr); + return; + } + + view->set_region (r); + + /* Compute zoom level to show entire source plus some margin if possible */ + + Temporal::timecnt_t duration = Temporal::timecnt_t (r->midi_source()->length().beats()); + + std::cerr << "new region: " << duration << std::endl; + + bool provided = false; + std::shared_ptr map; + std::shared_ptr smf (std::dynamic_pointer_cast (r->midi_source())); + + if (smf) { + map = smf->tempo_map (provided); + } + + if (!provided) { + map.reset (new Temporal::TempoMap (Temporal::Tempo (120, 4), Temporal::Meter (4, 4))); + } + + { + EditingContext::TempoMapScope tms (*this, map); + double width = bg->width(); + samplecnt_t samples = duration.samples(); + std::cerr << "new spp from " << samples << " / " << width << std::endl; + samplecnt_t spp = floor (samples / width); + reset_zoom (spp); + } +} diff --git a/gtk2_ardour/midi_cue_editor.h b/gtk2_ardour/midi_cue_editor.h index c541e7175e..b77e4da53e 100644 --- a/gtk2_ardour/midi_cue_editor.h +++ b/gtk2_ardour/midi_cue_editor.h @@ -72,9 +72,8 @@ class MidiCueEditor : public CueEditor int32_t get_grid_beat_divisions (Editing::GridType gt) const { return 1; } int32_t get_grid_music_divisions (Editing::GridType gt, uint32_t event_state) const { return 1; } + void set (ARDOUR::TriggerReference&); void set_region (std::shared_ptr); - void set_box (std::shared_ptr); - void set_track (std::shared_ptr); ArdourCanvas::ScrollGroup* get_hscroll_group () const { return h_scroll_group; } ArdourCanvas::ScrollGroup* get_cursor_scroll_group () const { return cursor_scroll_group; } @@ -140,6 +139,7 @@ class MidiCueEditor : public CueEditor void on_samples_per_pixel_changed (); private: + ARDOUR::TriggerReference ref; std::shared_ptr _track; ArdourCanvas::GtkCanvasViewport* _canvas_viewport; ArdourCanvas::GtkCanvas* _canvas; @@ -208,8 +208,11 @@ class MidiCueEditor : public CueEditor void stop_canvas_autoscroll (); sigc::connection _update_connection; - PBD::ScopedConnection track_connection; + PBD::ScopedConnectionList object_connections; void maybe_update (); + void trigger_prop_change (PBD::PropertyChange const &); + + void unset (); void visual_changer (const VisualChange&); void bindings_changed (); @@ -217,7 +220,6 @@ class MidiCueEditor : public CueEditor void data_captured (Temporal::timecnt_t); bool idle_data_captured (); std::atomic idle_update_queued; - PBD::ScopedConnectionList capture_connections; Temporal::timecnt_t data_capture_duration; }; diff --git a/gtk2_ardour/midi_cue_view.cc b/gtk2_ardour/midi_cue_view.cc index 374b39a15a..51300ad131 100644 --- a/gtk2_ardour/midi_cue_view.cc +++ b/gtk2_ardour/midi_cue_view.cc @@ -95,7 +95,7 @@ MidiCueView::set_height (double h) double automation_height = h - note_area_height - velocity_height; event_rect->set (ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, note_area_height)); - midi_context().set_size (ArdourCanvas::COORD_MAX, note_area_height); + midi_context().set_size (midi_context().width(), note_area_height); velocity_base->set_position (ArdourCanvas::Duple (0., note_area_height)); velocity_base->set (ArdourCanvas::Rect (0., 0., ArdourCanvas::COORD_MAX, velocity_height)); diff --git a/gtk2_ardour/midi_view.cc b/gtk2_ardour/midi_view.cc index deb9aa159d..5e0329a57d 100644 --- a/gtk2_ardour/midi_view.cc +++ b/gtk2_ardour/midi_view.cc @@ -236,8 +236,18 @@ MidiView::set_model (std::shared_ptr m) assert (_midi_track); assert (_midi_region); + clear_events (); + connections_requiring_model.drop_connections (); + _model = m; + if (!_model) { + std::cerr << "no model!\n"; + return; + } + + std::cerr << "model set to " << _model << std::endl; + //set_height (trackview.current_height()); #warning paul pianorule needs these fixed @@ -251,8 +261,6 @@ MidiView::set_model (std::shared_ptr m) reset_width_dependent_items (_pixel_width); */ - connections_requiring_model.drop_connections (); - _model->ContentsChanged.connect (connections_requiring_model, invalidator (*this), std::bind (&MidiView::model_changed, this), gui_context()); _midi_track->playback_filter().ChannelModeChanged.connect (connections_requiring_model, invalidator (*this), @@ -849,9 +857,8 @@ MidiView::clear_events () { // clear selection without signaling or trying to change state of event objects _selection.clear (); - clear_ghost_events (); - + /* This will delete all the NoteBase* in the _events map */ _note_group->clear (true); _events.clear(); _patch_changes.clear(); @@ -863,8 +870,6 @@ void MidiView::display_model (std::shared_ptr model) { set_model (_model); - /* Don't signal as nobody else needs to know until selection has been altered. */ - clear_events(); model_changed (); } @@ -1099,12 +1104,14 @@ MidiView::model_changed() return; } - if (!_model) { - return; + for (_optimization_iterator = _events.begin(); _optimization_iterator != _events.end(); ++_optimization_iterator) { + _optimization_iterator->second->invalidate (); } - for (_optimization_iterator = _events.begin(); _optimization_iterator != _events.end(); ++_optimization_iterator) { - _optimization_iterator->second->invalidate(); + /* note that _optimization_iterator now points to _events.end() */ + + if (!_model) { + return; } bool empty_when_starting = _events.empty(); @@ -1588,6 +1595,7 @@ void MidiView::end_write() { if (_active_notes) { + std::cerr << "active notes deleted in end_write\n"; for (unsigned i = 0; i < 128; ++i) { delete _active_notes[i]; } @@ -2271,7 +2279,7 @@ MidiView::clear_selection_internal () DEBUG_TRACE(DEBUG::Selection, "MRV::clear_selection_internal\n"); for (auto & sel : _selection) { - sel->set_selected(false); + sel->set_selected (false); sel->hide_velocity(); ghost_sync_selection (sel); } diff --git a/gtk2_ardour/trigger_page.cc b/gtk2_ardour/trigger_page.cc index defd01699d..f1d4c0243b 100644 --- a/gtk2_ardour/trigger_page.cc +++ b/gtk2_ardour/trigger_page.cc @@ -419,23 +419,7 @@ TriggerPage::rec_enable_changed (Trigger const * trigger) _midi_trig_box.set_trigger (ref); _midi_trig_box.show (); - _midi_editor->set_box (trigger->boxptr()); - - Stripable* st = dynamic_cast (box.owner()); - assert (st); - std::shared_ptr mt = std::dynamic_pointer_cast (st->shared_from_this()); - assert (mt); - _midi_editor->set_track (mt); - - if (trigger->the_region()) { - - std::shared_ptr mr = std::dynamic_pointer_cast (trigger->the_region()); - - if (mr) { - _midi_editor->set_region (mr); - } - } - + _midi_editor->set (ref); _midi_editor->viewport().show (); } @@ -475,19 +459,7 @@ TriggerPage::selection_changed () _midi_trig_box.set_trigger (ref); _midi_trig_box.show (); - std::shared_ptr mt = std::dynamic_pointer_cast (entry->strip().stripable()); - assert (mt); - _midi_editor->set_track (mt); - - if (trigger->the_region()) { - - std::shared_ptr mr = std::dynamic_pointer_cast (trigger->the_region()); - - if (mr) { - _midi_editor->set_region (mr); - } - } - + _midi_editor->set (ref); _midi_editor->viewport().show (); } diff --git a/gtk2_ardour/view_background.h b/gtk2_ardour/view_background.h index 80d59d84e5..1a11555419 100644 --- a/gtk2_ardour/view_background.h +++ b/gtk2_ardour/view_background.h @@ -41,6 +41,7 @@ class ViewBackground virtual ~ViewBackground (); virtual double height() const { return 0.; } + virtual double width() const { return 0.; } virtual double contents_height() const { return 0.; } /** @return y position, or -1 if hidden */ diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 25eadacb0a..c30966c1fe 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -127,6 +127,7 @@ TriggerBox::all_trigger_props() all.add(Properties::patch_change); all.add(Properties::channel_map); all.add(Properties::used_channels); + all.add(Properties::region); return all; } @@ -313,7 +314,6 @@ Trigger::arm () void Trigger::disarm () { - _box.disarm (); _armed = false; ArmChanged(); /* EMIT SIGNAL */ TriggerArmChanged (this); @@ -1965,10 +1965,12 @@ AudioTrigger::captured (SlotArmInfo& ai, BufferSet&) delete &ai; // XXX delete is not RT-safe _box.queue_explict (index()); - TriggerBox::worker->request_build_source (this); _armed = false; ArmChanged(); /* EMIT SIGNAL */ + TriggerArmChanged (this); + + TriggerBox::worker->request_build_source (this, timecnt_t (data.length)); } int @@ -2438,6 +2440,7 @@ void MIDITrigger::captured (SlotArmInfo& ai, BufferSet& bufs) { if (ai.midi_buf->size() == 0) { + std::cerr << "nothing recorded\n"; _armed = false; ArmChanged(); /* EMIT SIGNAL */ delete &ai; @@ -2468,10 +2471,13 @@ MIDITrigger::captured (SlotArmInfo& ai, BufferSet& bufs) _box.queue_explict (index()); /* Meanwhile, build a new source and region from the data now in rt_midibuffer */ - TriggerBox::worker->request_build_source (this); + std::cerr << "request source ...\n"; _armed = false; ArmChanged(); /* EMIT SIGNAL */ + TriggerArmChanged (this); + + TriggerBox::worker->request_build_source (this, timecnt_t (data_length)); } void @@ -2946,6 +2952,8 @@ MIDITrigger::set_region_in_worker_thread_from_capture (std::shared_ptr r { assert (r); + std::cerr << "SRIWTFC " << r->name() << std::endl; + std::shared_ptr mr = std::dynamic_pointer_cast (r); if (!mr) { @@ -2966,7 +2974,8 @@ MIDITrigger::set_region_in_worker_thread_from_capture (std::shared_ptr r /* This is being used as a kind of shorthand for "everything" which is pretty stupid */ - send_property_change (ARDOUR::Properties::name); + std::cerr << "send region change\n"; + send_property_change (ARDOUR::Properties::region); return 0; } @@ -3597,10 +3606,16 @@ TriggerBox::disarm_all () void TriggerBox::finish_recording (BufferSet& bufs) { + std::cerr << "FR!\n"; SlotArmInfo* ai = _arm_info.load(); assert (ai); + + /* This transfers responsibility for the SlotArmInfo object to the + trigger + */ ai->slot.captured (*ai, bufs); _arm_info = nullptr; + _record_state = Disabled; } void From c986405fe0f9dfea7b11aad41addcb1f913f558e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 22 Oct 2024 14:48:12 -0600 Subject: [PATCH 021/113] fix two unintentionally committed API changes --- libs/ardour/triggerbox.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index c30966c1fe..03497d0557 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -1970,7 +1970,7 @@ AudioTrigger::captured (SlotArmInfo& ai, BufferSet&) ArmChanged(); /* EMIT SIGNAL */ TriggerArmChanged (this); - TriggerBox::worker->request_build_source (this, timecnt_t (data.length)); + TriggerBox::worker->request_build_source (this); } int @@ -2477,7 +2477,7 @@ MIDITrigger::captured (SlotArmInfo& ai, BufferSet& bufs) ArmChanged(); /* EMIT SIGNAL */ TriggerArmChanged (this); - TriggerBox::worker->request_build_source (this, timecnt_t (data_length)); + TriggerBox::worker->request_build_source (this); } void From 43961e2d86d84a362f56b3f6be2d4221f13a1b01 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 22 Oct 2024 14:49:11 -0600 Subject: [PATCH 022/113] remove debug output (and an inaccurate comment) --- libs/ardour/triggerbox.cc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 03497d0557..fb84925ac6 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -2440,7 +2440,6 @@ void MIDITrigger::captured (SlotArmInfo& ai, BufferSet& bufs) { if (ai.midi_buf->size() == 0) { - std::cerr << "nothing recorded\n"; _armed = false; ArmChanged(); /* EMIT SIGNAL */ delete &ai; @@ -2471,7 +2470,6 @@ MIDITrigger::captured (SlotArmInfo& ai, BufferSet& bufs) _box.queue_explict (index()); /* Meanwhile, build a new source and region from the data now in rt_midibuffer */ - std::cerr << "request source ...\n"; _armed = false; ArmChanged(); /* EMIT SIGNAL */ @@ -2952,8 +2950,6 @@ MIDITrigger::set_region_in_worker_thread_from_capture (std::shared_ptr r { assert (r); - std::cerr << "SRIWTFC " << r->name() << std::endl; - std::shared_ptr mr = std::dynamic_pointer_cast (r); if (!mr) { @@ -2971,10 +2967,6 @@ MIDITrigger::set_region_in_worker_thread_from_capture (std::shared_ptr r DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1 loaded midi region, span is %2\n", name(), data_length)); - /* This is being used as a kind of shorthand for "everything" which is - pretty stupid - */ - std::cerr << "send region change\n"; send_property_change (ARDOUR::Properties::region); return 0; @@ -3606,7 +3598,6 @@ TriggerBox::disarm_all () void TriggerBox::finish_recording (BufferSet& bufs) { - std::cerr << "FR!\n"; SlotArmInfo* ai = _arm_info.load(); assert (ai); From 2816c85324aa1276c297b76931c00c397a1e7a51 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 23 Oct 2024 01:10:11 +0200 Subject: [PATCH 023/113] Fix OSC observer heap buffer-overflow OSCCueObserver::send_init may populate a sparse map, rather than a contiguously indexed vector --- libs/surfaces/osc/osc_cue_observer.cc | 4 ++-- libs/surfaces/osc/osc_cue_observer.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/surfaces/osc/osc_cue_observer.cc b/libs/surfaces/osc/osc_cue_observer.cc index a4c86d2252..8300b2ff48 100644 --- a/libs/surfaces/osc/osc_cue_observer.cc +++ b/libs/surfaces/osc/osc_cue_observer.cc @@ -94,7 +94,7 @@ OSCCueObserver::refresh_strip (std::shared_ptr new_strip, Sor send_change_message (X_("/cue/mute"), 0, _strip->mute_control()); gain_timeout.push_back (0); - _last_gain.push_back (-1.0); + _last_gain[0] = -1; // unused _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_gain_message, this, 0, _strip->gain_control(), false), OSC::instance()); send_gain_message (0, _strip->gain_control(), true); @@ -162,7 +162,7 @@ OSCCueObserver::send_init() if (send->gain_control()) { gain_timeout.push_back (0); - _last_gain.push_back (-1.0); + _last_gain[i + 1] = -1.0; send->gain_control()->Changed.connect (send_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_gain_message, this, i + 1, send->gain_control(), false), OSC::instance()); send_gain_message (i + 1, send->gain_control(), true); } diff --git a/libs/surfaces/osc/osc_cue_observer.h b/libs/surfaces/osc/osc_cue_observer.h index ecde92f30d..97baa31da4 100644 --- a/libs/surfaces/osc/osc_cue_observer.h +++ b/libs/surfaces/osc/osc_cue_observer.h @@ -61,7 +61,7 @@ class OSCCueObserver float _last_signal; std::vector gain_timeout; bool tick_enable; - std::vector _last_gain; + std::map _last_gain; void name_changed (const PBD::PropertyChange& what_changed, uint32_t id); void send_change_message (std::string path, uint32_t id, std::shared_ptr controllable); From 86a4447805ba6ba09418f0f78b67a85f57c4a33e Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 23 Oct 2024 01:38:44 +0200 Subject: [PATCH 024/113] OSC: Never, ever bind a shared_ptr to a signal This fixes crashes when controllable are destroyed, or OSC surface is disabled (signals retain a reference). --- libs/surfaces/osc/osc_cue_observer.cc | 30 ++++++++++++++++++++------- libs/surfaces/osc/osc_cue_observer.h | 7 ++++--- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/libs/surfaces/osc/osc_cue_observer.cc b/libs/surfaces/osc/osc_cue_observer.cc index 8300b2ff48..8ca17d27a3 100644 --- a/libs/surfaces/osc/osc_cue_observer.cc +++ b/libs/surfaces/osc/osc_cue_observer.cc @@ -1,5 +1,6 @@ /* * Copyright (C) 2017-2018 Len Ovens + * Copyright (C) 2024 Robin Gareus * * 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 @@ -90,12 +91,12 @@ OSCCueObserver::refresh_strip (std::shared_ptr new_strip, Sor _strip->PropertyChanged.connect (strip_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::name_changed, this,_1, 0), OSC::instance()); name_changed (ARDOUR::Properties::name, 0); - _strip->mute_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_change_message, this, X_("/cue/mute"), 0, _strip->mute_control()), OSC::instance()); + _strip->mute_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_change_message, this, X_("/cue/mute"), 0, std::weak_ptr(_strip->mute_control())), OSC::instance()); send_change_message (X_("/cue/mute"), 0, _strip->mute_control()); gain_timeout.push_back (0); _last_gain[0] = -1; // unused - _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_gain_message, this, 0, _strip->gain_control(), false), OSC::instance()); + _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_gain_message, this, 0, std::weak_ptr(_strip->gain_control()), false), OSC::instance()); send_gain_message (0, _strip->gain_control(), true); send_init (); @@ -163,13 +164,14 @@ OSCCueObserver::send_init() if (send->gain_control()) { gain_timeout.push_back (0); _last_gain[i + 1] = -1.0; - send->gain_control()->Changed.connect (send_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_gain_message, this, i + 1, send->gain_control(), false), OSC::instance()); + send->gain_control()->Changed.connect (send_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_gain_message, this, i + 1, std::weak_ptr(send->gain_control()), false), OSC::instance()); send_gain_message (i + 1, send->gain_control(), true); } std::shared_ptr proc = std::dynamic_pointer_cast (send); - proc->ActiveChanged.connect (send_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_enabled_message, this, X_("/cue/send/enable"), i + 1, proc), OSC::instance()); - send_enabled_message (X_("/cue/send/enable"), i + 1, proc); + std::weak_ptr wproc (proc); + proc->ActiveChanged.connect (send_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_enabled_message, this, X_("/cue/send/enable"), i + 1, wproc), OSC::instance()); + send_enabled_message (X_("/cue/send/enable"), i + 1, wproc); } } @@ -218,8 +220,12 @@ OSCCueObserver::name_changed (const PBD::PropertyChange& what_changed, uint32_t } void -OSCCueObserver::send_change_message (string path, uint32_t id, std::shared_ptr controllable) +OSCCueObserver::send_change_message (string path, uint32_t id, std::weak_ptr weak_controllable) { + std::shared_ptr controllable = weak_controllable.lock (); + if (!controllable) { + return; + } if (id) { path = string_compose("%1/%2", path, id); } @@ -228,8 +234,12 @@ OSCCueObserver::send_change_message (string path, uint32_t id, std::shared_ptr controllable, bool force) +OSCCueObserver::send_gain_message (uint32_t id, std::weak_ptr weak_controllable, bool force) { + std::shared_ptr controllable = weak_controllable.lock (); + if (!controllable) { + return; + } if (_last_gain[id] != controllable->get_value()) { _last_gain[id] = controllable->get_value(); } else { @@ -247,8 +257,12 @@ OSCCueObserver::send_gain_message (uint32_t id, std::shared_ptr c } void -OSCCueObserver::send_enabled_message (std::string path, uint32_t id, std::shared_ptr proc) +OSCCueObserver::send_enabled_message (std::string path, uint32_t id, std::weak_ptr weak_proc) { + std::shared_ptr proc = weak_proc.lock (); + if (!proc) { + return; + } if (id) { _osc.float_message_with_id (path, id, (float) proc->enabled(), true, addr); } else { diff --git a/libs/surfaces/osc/osc_cue_observer.h b/libs/surfaces/osc/osc_cue_observer.h index 97baa31da4..b31bf56596 100644 --- a/libs/surfaces/osc/osc_cue_observer.h +++ b/libs/surfaces/osc/osc_cue_observer.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2017-2018 Len Ovens + * Copyright (C) 2024 Robin Gareus * * 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 @@ -64,9 +65,9 @@ class OSCCueObserver std::map _last_gain; void name_changed (const PBD::PropertyChange& what_changed, uint32_t id); - void send_change_message (std::string path, uint32_t id, std::shared_ptr controllable); - void send_gain_message (uint32_t id, std::shared_ptr controllable, bool force); - void send_enabled_message (std::string path, uint32_t id, std::shared_ptr proc); + void send_change_message (std::string path, uint32_t id, std::weak_ptr controllable); + void send_gain_message (uint32_t id, std::weak_ptr controllable, bool force); + void send_enabled_message (std::string path, uint32_t id, std::weak_ptr proc); void send_init (void); void send_end (uint32_t new_sends_size); void send_restart (void); From 84027120ccaeb232618b01e717b97bd9adcc4588 Mon Sep 17 00:00:00 2001 From: Matthew Smith Date: Wed, 23 Oct 2024 14:54:00 +0200 Subject: [PATCH 025/113] Fix OSC observer heap buffer-overflow --- libs/surfaces/osc/osc_cue_observer.cc | 6 ++---- libs/surfaces/osc/osc_cue_observer.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libs/surfaces/osc/osc_cue_observer.cc b/libs/surfaces/osc/osc_cue_observer.cc index 8ca17d27a3..0774f3c70f 100644 --- a/libs/surfaces/osc/osc_cue_observer.cc +++ b/libs/surfaces/osc/osc_cue_observer.cc @@ -94,7 +94,7 @@ OSCCueObserver::refresh_strip (std::shared_ptr new_strip, Sor _strip->mute_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_change_message, this, X_("/cue/mute"), 0, std::weak_ptr(_strip->mute_control())), OSC::instance()); send_change_message (X_("/cue/mute"), 0, _strip->mute_control()); - gain_timeout.push_back (0); + gain_timeout[0] = 0; _last_gain[0] = -1; // unused _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_gain_message, this, 0, std::weak_ptr(_strip->gain_control()), false), OSC::instance()); send_gain_message (0, _strip->gain_control(), true); @@ -162,7 +162,7 @@ OSCCueObserver::send_init() if (send->gain_control()) { - gain_timeout.push_back (0); + gain_timeout[i + 1] = 0; _last_gain[i + 1] = -1.0; send->gain_control()->Changed.connect (send_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_gain_message, this, i + 1, std::weak_ptr(send->gain_control()), false), OSC::instance()); send_gain_message (i + 1, send->gain_control(), true); @@ -246,10 +246,8 @@ OSCCueObserver::send_gain_message (uint32_t id, std::weak_ptr wea return; } if (id) { - _osc.text_message_with_id (X_("/cue/send/name"), id, string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())), true, addr); _osc.float_message_with_id (X_("/cue/send/fader"), id, controllable->internal_to_interface (controllable->get_value()), true, addr); } else { - _osc.text_message (X_("/cue/name"), string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())), addr); _osc.float_message (X_("/cue/fader"), controllable->internal_to_interface (controllable->get_value()), addr); } diff --git a/libs/surfaces/osc/osc_cue_observer.h b/libs/surfaces/osc/osc_cue_observer.h index b31bf56596..0243e76c3b 100644 --- a/libs/surfaces/osc/osc_cue_observer.h +++ b/libs/surfaces/osc/osc_cue_observer.h @@ -60,7 +60,7 @@ class OSCCueObserver ArdourSurface::OSC::OSCSurface* sur; float _last_meter; float _last_signal; - std::vector gain_timeout; + std::map gain_timeout; bool tick_enable; std::map _last_gain; From 89da2f2c87245cfe8e5eb7373120228543bc300f Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 16 Sep 2024 23:27:59 +0200 Subject: [PATCH 026/113] Define YDK/YTKMM Touch Event API --- libs/tk/ydk/gdkenumtypes.c | 3 + libs/tk/ydk/gdkevents.c | 29 ++++ libs/tk/ydk/gdkwindow.c | 30 +++- libs/tk/ydk/ydk/gdk/gdkevents.h | 23 +++ libs/tk/ydkmm/ydkmm/gdkmm/event.h | 3 + libs/tk/ydkmm/ydkmm/gdkmm/window.h | 3 + libs/tk/ytk/gtkmain.c | 3 + libs/tk/ytk/gtkwidget.c | 48 ++++++ libs/tk/ytk/ytk/gtk/gtkwidget.h | 6 + libs/tk/ytkmm/widget.cc | 153 +++++++++++++++++++ libs/tk/ytkmm/ytkmm/gtkmm/private/widget_p.h | 3 + libs/tk/ytkmm/ytkmm/gtkmm/widget.h | 3 + 12 files changed, 306 insertions(+), 1 deletion(-) diff --git a/libs/tk/ydk/gdkenumtypes.c b/libs/tk/ydk/gdkenumtypes.c index 3309edcde8..8156e97300 100644 --- a/libs/tk/ydk/gdkenumtypes.c +++ b/libs/tk/ydk/gdkenumtypes.c @@ -229,6 +229,9 @@ gdk_event_mask_get_type (void) { GDK_PROXIMITY_OUT_MASK, "GDK_PROXIMITY_OUT_MASK", "proximity-out-mask" }, { GDK_SUBSTRUCTURE_MASK, "GDK_SUBSTRUCTURE_MASK", "substructure-mask" }, { GDK_SCROLL_MASK, "GDK_SCROLL_MASK", "scroll-mask" }, + { GDK_TOUCH_BEGIN_MASK, "GDK_TOUCH_BEGIN_MASK", "touch-begin-mask" }, + { GDK_TOUCH_UPDATE_MASK, "GDK_TOUCH_UPDATE_MASK", "touch-update-mask" }, + { GDK_TOUCH_END_MASK, "GDK_TOUCH_END_MASK", "touch-end-mask" }, { GDK_ALL_EVENTS_MASK, "GDK_ALL_EVENTS_MASK", "all-events-mask" }, { 0, NULL, NULL } }; diff --git a/libs/tk/ydk/gdkevents.c b/libs/tk/ydk/gdkevents.c index 0f8bba2f0a..95a42c0ac0 100644 --- a/libs/tk/ydk/gdkevents.c +++ b/libs/tk/ydk/gdkevents.c @@ -387,6 +387,14 @@ gdk_event_new (GdkEventType type) new_event->button.x_root = 0.; new_event->button.y_root = 0.; break; + case GDK_TOUCH_BEGIN: + case GDK_TOUCH_UPDATE: + case GDK_TOUCH_END: + new_event->touch.x = 0.; + new_event->touch.y = 0.; + new_event->touch.x_root = 0.; + new_event->touch.y_root = 0.; + break; case GDK_SCROLL: new_event->scroll.x = 0.; new_event->scroll.y = 0.; @@ -596,6 +604,10 @@ gdk_event_get_time (const GdkEvent *event) case GDK_3BUTTON_PRESS: case GDK_BUTTON_RELEASE: return event->button.time; + case GDK_TOUCH_BEGIN: + case GDK_TOUCH_UPDATE: + case GDK_TOUCH_END: + return event->touch.time; case GDK_SCROLL: return event->scroll.time; case GDK_KEY_PRESS: @@ -674,6 +686,11 @@ gdk_event_get_state (const GdkEvent *event, case GDK_BUTTON_RELEASE: *state = event->button.state; return TRUE; + case GDK_TOUCH_BEGIN: + case GDK_TOUCH_UPDATE: + case GDK_TOUCH_END: + *state = event->touch.state; + return TRUE; case GDK_SCROLL: *state = event->scroll.state; return TRUE; @@ -770,6 +787,12 @@ gdk_event_get_coords (const GdkEvent *event, x = event->motion.x; y = event->motion.y; break; + case GDK_TOUCH_BEGIN: + case GDK_TOUCH_UPDATE: + case GDK_TOUCH_END: + x = event->touch.x; + y = event->touch.y; + break; default: fetched = FALSE; break; @@ -820,6 +843,12 @@ gdk_event_get_root_coords (const GdkEvent *event, x = event->button.x_root; y = event->button.y_root; break; + case GDK_TOUCH_BEGIN: + case GDK_TOUCH_UPDATE: + case GDK_TOUCH_END: + x = event->touch.x_root; + y = event->touch.y_root; + break; case GDK_ENTER_NOTIFY: case GDK_LEAVE_NOTIFY: x = event->crossing.x_root; diff --git a/libs/tk/ydk/gdkwindow.c b/libs/tk/ydk/gdkwindow.c index 774b5b2cb0..fab05d1cac 100644 --- a/libs/tk/ydk/gdkwindow.c +++ b/libs/tk/ydk/gdkwindow.c @@ -9887,6 +9887,9 @@ static const guint type_masks[] = { 0, /* GDK_OWNER_CHANGE = 34 */ 0, /* GDK_GRAB_BROKEN = 35 */ 0, /* GDK_DAMAGE = 36 */ + GDK_TOUCH_BEGIN_MASK, /* GDK_TOUCH_BEGIN = 37 */ + GDK_TOUCH_UPDATE_MASK, /* GDK_TOUCH_UPDATE = 38 */ + GDK_TOUCH_END_MASK, /* GDK_TOUCH_END = 39 */ }; G_STATIC_ASSERT (G_N_ELEMENTS (type_masks) == GDK_EVENT_LAST); @@ -9929,6 +9932,14 @@ is_motion_type (GdkEventType type) type == GDK_LEAVE_NOTIFY; } +static gboolean +is_touch_type (GdkEventType type) +{ + return type == GDK_TOUCH_BEGIN || + type == GDK_TOUCH_UPDATE || + type == GDK_TOUCH_END; +} + static GdkWindowObject * find_common_ancestor (GdkWindowObject *win1, GdkWindowObject *win2) @@ -10873,6 +10884,19 @@ proxy_button_event (GdkEvent *source_event, event->scroll.delta_y = source_event->scroll.delta_y; return TRUE; + case GDK_TOUCH_BEGIN: + case GDK_TOUCH_UPDATE: + case GDK_TOUCH_END: + convert_toplevel_coords_to_window (event_win, + toplevel_x, toplevel_y, + &event->touch.x, &event->touch.y); + event->touch.sequence = source_event->touch.sequence; + event->touch.deviceid = source_event->touch.deviceid; + event->touch.x_root = source_event->touch.x_root; + event->touch.y_root = source_event->touch.y_root; + event->touch.state = state; + return TRUE; + default: return FALSE; } @@ -11057,7 +11081,8 @@ _gdk_windowing_got_event (GdkDisplay *display, return; if (!(is_button_type (event->type) || - is_motion_type (event->type)) || + is_motion_type (event->type) || + is_touch_type (event->type)) || event_private->window_type == GDK_WINDOW_ROOT) return; @@ -11147,6 +11172,9 @@ _gdk_windowing_got_event (GdkDisplay *display, else if (is_button_type (event->type)) unlink_event = proxy_button_event (event, serial); + else if (is_touch_type (event->type)) + unlink_event = proxy_button_event (event, + serial); if (event->type == GDK_BUTTON_RELEASE && !event->any.send_event) diff --git a/libs/tk/ydk/ydk/gdk/gdkevents.h b/libs/tk/ydk/ydk/gdk/gdkevents.h index f6b4e04d3a..5dc8e6657d 100644 --- a/libs/tk/ydk/ydk/gdk/gdkevents.h +++ b/libs/tk/ydk/ydk/gdk/gdkevents.h @@ -50,6 +50,7 @@ typedef struct _GdkEventNoExpose GdkEventNoExpose; typedef struct _GdkEventVisibility GdkEventVisibility; typedef struct _GdkEventMotion GdkEventMotion; typedef struct _GdkEventButton GdkEventButton; +typedef struct _GdkEventTouch GdkEventTouch; typedef struct _GdkEventScroll GdkEventScroll; typedef struct _GdkEventKey GdkEventKey; typedef struct _GdkEventFocus GdkEventFocus; @@ -152,6 +153,9 @@ typedef enum GDK_OWNER_CHANGE = 34, GDK_GRAB_BROKEN = 35, GDK_DAMAGE = 36, + GDK_TOUCH_BEGIN = 37, + GDK_TOUCH_UPDATE = 38, + GDK_TOUCH_END = 39, GDK_EVENT_LAST /* helper variable for decls */ } GdkEventType; @@ -181,6 +185,9 @@ typedef enum GDK_PROXIMITY_OUT_MASK = 1 << 19, GDK_SUBSTRUCTURE_MASK = 1 << 20, GDK_SCROLL_MASK = 1 << 21, + GDK_TOUCH_BEGIN_MASK = 1 << 22, + GDK_TOUCH_UPDATE_MASK = 1 << 23, + GDK_TOUCH_END_MASK = 1 << 24, GDK_ALL_EVENTS_MASK = 0x3FFFFE } GdkEventMask; @@ -325,6 +332,21 @@ struct _GdkEventButton gdouble x_root, y_root; }; +struct _GdkEventTouch +{ + GdkEventType type; + GdkWindow *window; + gint8 send_event; + guint32 time; + gdouble x; + gdouble y; + guint state; + guint sequence; + guint flags; + guint deviceid; + gdouble x_root, y_root; +}; + struct _GdkEventScroll { GdkEventType type; @@ -500,6 +522,7 @@ union _GdkEvent GdkEventVisibility visibility; GdkEventMotion motion; GdkEventButton button; + GdkEventTouch touch; GdkEventScroll scroll; GdkEventKey key; GdkEventCrossing crossing; diff --git a/libs/tk/ydkmm/ydkmm/gdkmm/event.h b/libs/tk/ydkmm/ydkmm/gdkmm/event.h index c4d091da36..7c3710d102 100644 --- a/libs/tk/ydkmm/ydkmm/gdkmm/event.h +++ b/libs/tk/ydkmm/ydkmm/gdkmm/event.h @@ -92,6 +92,9 @@ enum EventType OWNER_CHANGE, GRAB_BROKEN, DAMAGE, + TOUCH_BEGIN, + TOUCH_UPDATE, + TOUCH_END, EVENT_LAST }; diff --git a/libs/tk/ydkmm/ydkmm/gdkmm/window.h b/libs/tk/ydkmm/ydkmm/gdkmm/window.h index d951bb5bef..f9d2e8a6d7 100644 --- a/libs/tk/ydkmm/ydkmm/gdkmm/window.h +++ b/libs/tk/ydkmm/ydkmm/gdkmm/window.h @@ -91,6 +91,9 @@ enum EventMask PROXIMITY_OUT_MASK = 1 << 19, SUBSTRUCTURE_MASK = 1 << 20, SCROLL_MASK = 1 << 21, + TOUCH_BEGIN_MASK = 1 << 22, + TOUCH_UPDATE_MASK = 1 << 23, + TOUCH_END_MASK = 1 << 24, ALL_EVENTS_MASK = 0x3FFFFE }; diff --git a/libs/tk/ytk/gtkmain.c b/libs/tk/ytk/gtkmain.c index df84f4efeb..4cb2516a2f 100644 --- a/libs/tk/ytk/gtkmain.c +++ b/libs/tk/ytk/gtkmain.c @@ -1599,6 +1599,7 @@ gtk_main_do_event (GdkEvent *event) case GDK_BUTTON_PRESS: case GDK_2BUTTON_PRESS: case GDK_3BUTTON_PRESS: + case GDK_TOUCH_BEGIN: gtk_propagate_event (grab_widget, event); break; @@ -1636,6 +1637,8 @@ gtk_main_do_event (GdkEvent *event) /* else fall through */ case GDK_MOTION_NOTIFY: case GDK_BUTTON_RELEASE: + case GDK_TOUCH_UPDATE: + case GDK_TOUCH_END: case GDK_PROXIMITY_IN: case GDK_PROXIMITY_OUT: gtk_propagate_event (grab_widget, event); diff --git a/libs/tk/ytk/gtkwidget.c b/libs/tk/ytk/gtkwidget.c index b8f8d78636..8b58c36d2e 100644 --- a/libs/tk/ytk/gtkwidget.c +++ b/libs/tk/ytk/gtkwidget.c @@ -197,6 +197,9 @@ enum { KEYNAV_FAILED, DRAG_FAILED, DAMAGE_EVENT, + TOUCH_BEGIN, + TOUCH_UPDATE, + TOUCH_END, LAST_SIGNAL }; @@ -537,6 +540,9 @@ gtk_widget_class_init (GtkWidgetClass *klass) klass->drag_drop = NULL; klass->drag_data_received = NULL; klass->screen_changed = NULL; + klass->touch_begin_event = NULL; + klass->touch_update_event = NULL; + klass->touch_end_event = NULL; klass->can_activate_accel = gtk_widget_real_can_activate_accel; klass->grab_broken_event = NULL; klass->query_tooltip = gtk_widget_real_query_tooltip; @@ -2377,6 +2383,39 @@ gtk_widget_class_init (GtkWidgetClass *klass) G_TYPE_NONE, 1, GDK_TYPE_SCREEN); + + /* YTK Touch */ + widget_signals[TOUCH_BEGIN] = + g_signal_new (I_("touch-start"), + G_TYPE_FROM_CLASS (gobject_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkWidgetClass, touch_begin_event), + _gtk_boolean_handled_accumulator, NULL, + _gtk_marshal_BOOLEAN__BOXED, + G_TYPE_BOOLEAN, 1, + GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); + + widget_signals[TOUCH_UPDATE] = + g_signal_new (I_("touch-update"), + G_TYPE_FROM_CLASS (gobject_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkWidgetClass, touch_update_event), + _gtk_boolean_handled_accumulator, NULL, + _gtk_marshal_BOOLEAN__BOXED, + G_TYPE_BOOLEAN, 1, + GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); + + widget_signals[TOUCH_END] = + g_signal_new (I_("touch-end"), + G_TYPE_FROM_CLASS (gobject_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkWidgetClass, touch_end_event), + _gtk_boolean_handled_accumulator, NULL, + _gtk_marshal_BOOLEAN__BOXED, + G_TYPE_BOOLEAN, 1, + GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); + + /** * GtkWidget::can-activate-accel: * @widget: the object which received the signal @@ -5001,6 +5040,15 @@ gtk_widget_event_internal (GtkWidget *widget, case GDK_DAMAGE: signal_num = DAMAGE_EVENT; break; + case GDK_TOUCH_BEGIN: + signal_num = TOUCH_BEGIN; + break; + case GDK_TOUCH_END: + signal_num = TOUCH_END; + break; + case GDK_TOUCH_UPDATE: + signal_num = TOUCH_UPDATE; + break; default: g_warning ("gtk_widget_event(): unhandled event type: %d", event->type); signal_num = -1; diff --git a/libs/tk/ytk/ytk/gtk/gtkwidget.h b/libs/tk/ytk/ytk/gtk/gtkwidget.h index d26cd4d077..fc9546b226 100644 --- a/libs/tk/ytk/ytk/gtk/gtkwidget.h +++ b/libs/tk/ytk/ytk/gtk/gtkwidget.h @@ -726,6 +726,12 @@ struct _GtkWidgetClass GdkEventAny *event); gboolean (* window_state_event) (GtkWidget *widget, GdkEventWindowState *event); + gboolean (* touch_begin_event) (GtkWidget *widget, + GdkEventTouch *event); + gboolean (* touch_update_event) (GtkWidget *widget, + GdkEventTouch *event); + gboolean (* touch_end_event) (GtkWidget *widget, + GdkEventTouch *event); /* selection */ void (* selection_get) (GtkWidget *widget, diff --git a/libs/tk/ytkmm/widget.cc b/libs/tk/ytkmm/widget.cc index 831041fc41..02850fded1 100644 --- a/libs/tk/ytkmm/widget.cc +++ b/libs/tk/ytkmm/widget.cc @@ -3395,6 +3395,9 @@ void Widget_Class::class_init_function(void* g_class, void* class_data) klass->drag_motion = &drag_motion_callback; klass->drag_drop = &drag_drop_callback; klass->drag_data_received = &drag_data_received_callback; + klass->touch_begin_event = &touch_begin_callback; + klass->touch_update_event = &touch_update_callback; + klass->touch_end_event = &touch_end_callback; #ifdef GTKMM_ATKMM_ENABLED #ifndef GTKMM_DISABLE_DEPRECATED @@ -4344,6 +4347,120 @@ gboolean Widget_Class::button_release_event_callback(GtkWidget* self, GdkEventBu typedef gboolean RType; return RType(); } +gboolean Widget_Class::touch_begin_callback(GtkWidget* self, GdkEventTouch* p0) +{ + Glib::ObjectBase *const obj_base = static_cast( + Glib::ObjectBase::_get_current_wrapper((GObject*)self)); + + // Non-gtkmmproc-generated custom classes implicitly call the default + // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc- + // generated classes can use this optimisation, which avoids the unnecessary + // parameter conversions if there is no possibility of the virtual function + // being overridden: + if(obj_base && obj_base->is_derived_()) + { + CppObjectType *const obj = dynamic_cast(obj_base); + if(obj) // This can be NULL during destruction. + { + try // Trap C++ exceptions which would normally be lost because this is a C callback. + { + // Call the virtual member method, which derived classes might override. + return static_cast(obj->on_touch_begin_event(p0)); + } + catch(...) + { + Glib::exception_handlers_invoke(); + } + } + } + + BaseClassType *const base = static_cast( + g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class). + ); + + // Call the original underlying C function: + if(base && base->touch_begin_event) + return (*base->touch_begin_event)(self, p0); + + typedef gboolean RType; + return RType(); +} +gboolean Widget_Class::touch_update_callback(GtkWidget* self, GdkEventTouch* p0) +{ + Glib::ObjectBase *const obj_base = static_cast( + Glib::ObjectBase::_get_current_wrapper((GObject*)self)); + + // Non-gtkmmproc-generated custom classes implicitly call the default + // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc- + // generated classes can use this optimisation, which avoids the unnecessary + // parameter conversions if there is no possibility of the virtual function + // being overridden: + if(obj_base && obj_base->is_derived_()) + { + CppObjectType *const obj = dynamic_cast(obj_base); + if(obj) // This can be NULL during destruction. + { + try // Trap C++ exceptions which would normally be lost because this is a C callback. + { + // Call the virtual member method, which derived classes might override. + return static_cast(obj->on_touch_update_event(p0)); + } + catch(...) + { + Glib::exception_handlers_invoke(); + } + } + } + + BaseClassType *const base = static_cast( + g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class). + ); + + // Call the original underlying C function: + if(base && base->touch_update_event) + return (*base->touch_update_event)(self, p0); + + typedef gboolean RType; + return RType(); +} +gboolean Widget_Class::touch_end_callback(GtkWidget* self, GdkEventTouch* p0) +{ + Glib::ObjectBase *const obj_base = static_cast( + Glib::ObjectBase::_get_current_wrapper((GObject*)self)); + + // Non-gtkmmproc-generated custom classes implicitly call the default + // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc- + // generated classes can use this optimisation, which avoids the unnecessary + // parameter conversions if there is no possibility of the virtual function + // being overridden: + if(obj_base && obj_base->is_derived_()) + { + CppObjectType *const obj = dynamic_cast(obj_base); + if(obj) // This can be NULL during destruction. + { + try // Trap C++ exceptions which would normally be lost because this is a C callback. + { + // Call the virtual member method, which derived classes might override. + return static_cast(obj->on_touch_end_event(p0)); + } + catch(...) + { + Glib::exception_handlers_invoke(); + } + } + } + + BaseClassType *const base = static_cast( + g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class). + ); + + // Call the original underlying C function: + if(base && base->touch_end_event) + return (*base->touch_end_event)(self, p0); + + typedef gboolean RType; + return RType(); +} gboolean Widget_Class::scroll_event_callback(GtkWidget* self, GdkEventScroll* p0) { Glib::ObjectBase *const obj_base = static_cast( @@ -7516,6 +7633,42 @@ bool Gtk::Widget::on_button_release_event(GdkEventButton* event) typedef bool RType; return RType(); } +bool Gtk::Widget::on_touch_begin_event(GdkEventTouch* event) +{ + BaseClassType *const base = static_cast( + g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class). + ); + + if(base && base->touch_begin_event) + return (*base->touch_begin_event)(gobj(),event); + + typedef bool RType; + return RType(); +} +bool Gtk::Widget::on_touch_update_event(GdkEventTouch* event) +{ + BaseClassType *const base = static_cast( + g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class). + ); + + if(base && base->touch_update_event) + return (*base->touch_update_event)(gobj(),event); + + typedef bool RType; + return RType(); +} +bool Gtk::Widget::on_touch_end_event(GdkEventTouch* event) +{ + BaseClassType *const base = static_cast( + g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class). + ); + + if(base && base->touch_end_event) + return (*base->touch_end_event)(gobj(),event); + + typedef bool RType; + return RType(); +} bool Gtk::Widget::on_scroll_event(GdkEventScroll* event) { BaseClassType *const base = static_cast( diff --git a/libs/tk/ytkmm/ytkmm/gtkmm/private/widget_p.h b/libs/tk/ytkmm/ytkmm/gtkmm/private/widget_p.h index eaba9a3f12..10a2e5dbb7 100644 --- a/libs/tk/ytkmm/ytkmm/gtkmm/private/widget_p.h +++ b/libs/tk/ytkmm/ytkmm/gtkmm/private/widget_p.h @@ -90,6 +90,9 @@ protected: static gboolean drag_motion_callback(GtkWidget* self, GdkDragContext* p0, gint p1, gint p2, guint p3); static gboolean drag_drop_callback(GtkWidget* self, GdkDragContext* p0, gint p1, gint p2, guint p3); static void drag_data_received_callback(GtkWidget* self, GdkDragContext* p0, gint p1, gint p2, GtkSelectionData* p3, guint p4, guint p5); + static gboolean touch_begin_callback(GtkWidget*, GdkEventTouch*); + static gboolean touch_update_callback(GtkWidget*, GdkEventTouch*); + static gboolean touch_end_callback(GtkWidget*, GdkEventTouch*); #ifdef GTKMM_ATKMM_ENABLED #ifndef GTKMM_DISABLE_DEPRECATED diff --git a/libs/tk/ytkmm/ytkmm/gtkmm/widget.h b/libs/tk/ytkmm/ytkmm/gtkmm/widget.h index 058d030cc9..d07dc13974 100644 --- a/libs/tk/ytkmm/ytkmm/gtkmm/widget.h +++ b/libs/tk/ytkmm/ytkmm/gtkmm/widget.h @@ -490,6 +490,9 @@ protected: virtual bool on_drag_drop(const Glib::RefPtr& context, int x, int y, guint time); /// This is a default handler for the signal signal_drag_data_received(). virtual void on_drag_data_received(const Glib::RefPtr& context, int x, int y, const SelectionData& selection_data, guint info, guint time); + virtual bool on_touch_begin_event(GdkEventTouch* event); + virtual bool on_touch_update_event(GdkEventTouch* event); + virtual bool on_touch_end_event(GdkEventTouch* event); #ifdef GTKMM_ATKMM_ENABLED /// This is a default handler for the signal signal_get_accessible(). virtual Glib::RefPtr on_get_accessible(); From 5cf392b17ad491237425b2c07c538c66bf81299b Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 18 Sep 2024 03:02:30 +0200 Subject: [PATCH 027/113] Implement YDK Touch API for Linux/X11 --- libs/tk/ydk/wscript | 3 +- libs/tk/ydk/x11/gdkdisplay-x11.c | 10 +++ libs/tk/ydk/x11/gdkevents-x11.c | 109 ++++++++++++++++++++++- libs/tk/ydk/x11/gdkwindow-x11.c | 22 +++++ libs/tk/ydk/ydk/gdk/x11/gdkdisplay-x11.h | 20 +++++ 5 files changed, 162 insertions(+), 2 deletions(-) diff --git a/libs/tk/ydk/wscript b/libs/tk/ydk/wscript index 45e04326b3..f01fcb0860 100644 --- a/libs/tk/ydk/wscript +++ b/libs/tk/ydk/wscript @@ -164,6 +164,7 @@ def configure(conf): conf.check_cc(header_name='X11/extensions/Xinerama.h', lib='Xinerama', uselib_store="XINERAMA", define_name='HAVE_XFREE_XINERAMA', execute = False, mandatory=False) + autowaf.check_pkg(conf, 'xi', uselib_store='XINPUT2', mandatory=False, atleast_version='1.7.10') def build(bld): if not bld.is_defined('YTK'): @@ -202,7 +203,7 @@ def build(bld): obj.ldflags = '-limm32 -lole32 -lgdi32 -lcomdlg32 -lwinspool -lcomctl32 -luuid' else: obj.source = libydk_sources + libydk_x11_sources - obj.uselib += ' GIO-UNIX X11 XEXT XINERAMA RANDR' + obj.uselib += ' GIO-UNIX X11 XEXT XINERAMA RANDR DL' obj.includes += ['ydk/x11/gdk', 'ydk/gdk/x11'] obj.export_includes += ['ydk/gdk'] obj.export_includes += ['ydk/x11'] diff --git a/libs/tk/ydk/x11/gdkdisplay-x11.c b/libs/tk/ydk/x11/gdkdisplay-x11.c index 0c63c55d16..ad7683187f 100644 --- a/libs/tk/ydk/x11/gdkdisplay-x11.c +++ b/libs/tk/ydk/x11/gdkdisplay-x11.c @@ -65,6 +65,9 @@ #include #endif +#ifdef HAVE_XINPUT2 +#include +#endif static void gdk_display_x11_dispose (GObject *object); static void gdk_display_x11_finalize (GObject *object); @@ -864,6 +867,13 @@ gdk_display_x11_finalize (GObject *object) g_hash_table_destroy (display_x11->atom_from_virtual); g_hash_table_destroy (display_x11->atom_to_virtual); + /* Multitouch */ +#ifdef HAVE_XINPUT2 + if (display_x11->xi.libxi) + dlclose (display_x11->xi.libxi); + g_hash_table_destroy (display_x11->touch_devices); +#endif + /* Leader Window */ XDestroyWindow (display_x11->xdisplay, display_x11->leader_window); diff --git a/libs/tk/ydk/x11/gdkevents-x11.c b/libs/tk/ydk/x11/gdkevents-x11.c index 186a8f5cb2..6b21642539 100644 --- a/libs/tk/ydk/x11/gdkevents-x11.c +++ b/libs/tk/ydk/x11/gdkevents-x11.c @@ -62,6 +62,11 @@ #include #endif +#ifdef HAVE_XINPUT2 +#include +#include +#endif + #include typedef struct _GdkIOClosure GdkIOClosure; @@ -237,6 +242,64 @@ _gdk_events_init (GdkDisplay *display) gdk_atom_intern_static_string ("WM_PROTOCOLS"), gdk_wm_protocols_filter, NULL); + +#ifdef HAVE_XINPUT2 + void* lxi = dlopen ("libXi.so", RTLD_NOW | RTLD_GLOBAL); + if (lxi) + { + display_x11->xi.XISelectEvents = dlsym (lxi, "XISelectEvents"); + display_x11->xi.XIQueryDevice = dlsym (lxi, "XIQueryDevice"); + display_x11->xi.XIFreeDeviceInfo = dlsym (lxi, "XIFreeDeviceInfo"); + if (display_x11->xi.XISelectEvents && display_x11->xi.XIQueryDevice && display_x11->xi.XIFreeDeviceInfo) + { + display_x11->xi.libxi = lxi; + } + else + { + dlclose (lxi); + } + } + + int firstevent, firsterror; + if (display_x11->xi.libxi && XQueryExtension (display_x11->xdisplay, "XInputExtension", &display_x11->xid_opcode, &firstevent, &firsterror)) + { + printf ("CHECK FOR TOUCHSCREENs\n"); + + int n_devices; + XIDeviceInfo* info; + + info = display_x11->xi.XIQueryDevice (display_x11->xdisplay, XIAllDevices, &n_devices); + + for (int i = 0; i < n_devices; ++i) { + XIDeviceInfo* dev = &info[i]; + if (!dev->enabled) { + continue; + } + if (!(dev->use == XISlavePointer || dev->use == XIFloatingSlave)) { + continue; + } + + gboolean direct_touch = FALSE; + XITouchClassInfo* classInfo; + + for (int j = 0; j < dev->num_classes; ++j) { + classInfo = (XITouchClassInfo*)(dev->classes[j]); + + if (classInfo->type == XITouchClass && ((XITouchClassInfo *)dev->classes[j])->mode == XIDirectTouch) { + direct_touch = TRUE; + } + } + if (direct_touch) { + printf ("XI: touch-device id=%d name='%s' ntouch: %d\n", dev->deviceid, dev->name, classInfo->num_touches); + if (!display_x11->touch_devices) { + display_x11->touch_devices = g_hash_table_new (g_direct_hash, NULL); + } + g_hash_table_insert (display_x11->touch_devices, GUINT_TO_POINTER (dev->deviceid), GUINT_TO_POINTER(1)); + } + } + display_x11->xi.XIFreeDeviceInfo (info); + } +#endif } void @@ -1233,7 +1296,7 @@ gdk_event_translate (GdkDisplay *display, event->button.state = (GdkModifierType) xevent->xbutton.state; event->button.button = xevent->xbutton.button; event->button.device = display->core_pointer; - + if (!set_screen_from_root (display, event, xevent->xbutton.root)) { return_val = FALSE; @@ -2124,6 +2187,9 @@ gdk_event_translate (GdkDisplay *display, break; default: + if (xevent->xcookie.type == GenericEvent) { + XGetEventData (display_x11->xdisplay, &xevent->xcookie); + } #ifdef HAVE_XKB if (xevent->type == display_x11->xkb_event_type) { @@ -2175,6 +2241,47 @@ gdk_event_translate (GdkDisplay *display, } else #endif +#ifdef HAVE_XINPUT2 + if (xevent->xcookie.type == GenericEvent && xevent->xcookie.extension == display_x11->xid_opcode + && display_x11->touch_devices && g_hash_table_lookup (display_x11->touch_devices, GUINT_TO_POINTER (((XIDeviceEvent *)xevent->xcookie.data)->deviceid))) + { + XIDeviceEvent *xev = (XIDeviceEvent *) xevent->xcookie.data; + printf ("TOUCH dev=%d src=%d | dt: %u flags: %x\n", xev->deviceid, xev->sourceid, xev->detail, xev->flags); + window = gdk_window_lookup_for_display (display, xev->event); + g_object_ref (window); + + event->touch.window = window; + event->touch.time = xev->time; + event->touch.x = xev->event_x; + event->touch.y = xev->event_y; + event->touch.x_root = xev->root_x; + event->touch.y_root = xev->root_y; + event->touch.state = 0 ; (GdkModifierType) xevent->xbutton.state; + event->touch.sequence = xev->detail; + event->touch.flags = xev->flags; + event->touch.deviceid = xev->deviceid; + + switch (xevent->xcookie.evtype) { + case XI_TouchBegin: + event->touch.type = GDK_TOUCH_BEGIN; + break; + case XI_TouchUpdate: + event->touch.type = GDK_TOUCH_UPDATE; + break; + case XI_TouchEnd: + event->touch.type = GDK_TOUCH_END; + break; + default: + return FALSE; + break; + } + + if (!set_screen_from_root (display, event, xev->root)) { + return_val = FALSE; + } + } + else +#endif #if defined(HAVE_XCOMPOSITE) && defined (HAVE_XDAMAGE) && defined (HAVE_XFIXES) if (display_x11->have_xdamage && window_private && window_private->composited && xevent->type == display_x11->xdamage_event_base + XDamageNotify && diff --git a/libs/tk/ydk/x11/gdkwindow-x11.c b/libs/tk/ydk/x11/gdkwindow-x11.c index 887a5ef5f4..7ba1dd5a6f 100644 --- a/libs/tk/ydk/x11/gdkwindow-x11.c +++ b/libs/tk/ydk/x11/gdkwindow-x11.c @@ -71,6 +71,10 @@ #include #endif +#ifdef HAVE_XINPUT2 +#include +#endif + const int _gdk_event_mask_table[21] = { ExposureMask, @@ -797,6 +801,24 @@ _gdk_window_impl_new (GdkWindow *window, g_object_ref (window); _gdk_xid_table_insert (screen_x11->display, &draw_impl->xid, window); +#ifdef HAVE_XINPUT2 + GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (gdk_drawable_get_display (window)); + if (display_x11->touch_devices) + { + XIEventMask evmask; + unsigned char mask[XIMaskLen(XI_LASTEVENT)] = { 0 }; + evmask.deviceid = XIAllDevices; + evmask.mask_len = sizeof(mask); + evmask.mask = mask; + + XISetMask(evmask.mask, XI_TouchBegin); + XISetMask(evmask.mask, XI_TouchUpdate); + XISetMask(evmask.mask, XI_TouchEnd); + + display_x11->xi.XISelectEvents (xdisplay, xid, &evmask, 1); + } +#endif + switch (GDK_WINDOW_TYPE (private)) { case GDK_WINDOW_DIALOG: diff --git a/libs/tk/ydk/ydk/gdk/x11/gdkdisplay-x11.h b/libs/tk/ydk/ydk/gdk/x11/gdkdisplay-x11.h index de85623662..0f6953f76b 100644 --- a/libs/tk/ydk/ydk/gdk/x11/gdkdisplay-x11.h +++ b/libs/tk/ydk/ydk/gdk/x11/gdkdisplay-x11.h @@ -36,6 +36,7 @@ G_BEGIN_DECLS typedef struct _GdkDisplayX11 GdkDisplayX11; +typedef struct _GdkXInput2Fn GdkXInput2Fn; typedef struct _GdkDisplayX11Class GdkDisplayX11Class; #define GDK_TYPE_DISPLAY_X11 (_gdk_display_x11_get_type()) @@ -52,6 +53,19 @@ typedef enum GDK_YES } GdkTristate; +#ifdef HAVE_XINPUT2 +#include + +struct _GdkXInput2Fn +{ + int (*XISelectEvents)(Display*, Window, XIEventMask*, int); + XIDeviceInfo* (*XIQueryDevice)(Display*, int, int*); + void (*XIFreeDeviceInfo)(XIDeviceInfo*); + void* libxi; +}; + +#endif + struct _GdkDisplayX11 { GdkDisplay parent_instance; @@ -155,6 +169,12 @@ struct _GdkDisplayX11 /* The offscreen window that has the pointer in it (if any) */ GdkWindow *active_offscreen_window; + +#ifdef HAVE_XINPUT2 + int xid_opcode; + GHashTable* touch_devices; + GdkXInput2Fn xi; +#endif }; struct _GdkDisplayX11Class From 79dae5f2b4a75211935527ef3ebcdcedf9c423be Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 25 Sep 2024 19:32:21 +0200 Subject: [PATCH 028/113] Implement multitouch grab --- libs/tk/ydk/gdkdisplay.c | 5 +++++ libs/tk/ydk/gdkwindow.c | 24 ++++++++++++++++++++++++ libs/tk/ydk/ydk/gdk/gdkdisplay.h | 2 ++ 3 files changed, 31 insertions(+) diff --git a/libs/tk/ydk/gdkdisplay.c b/libs/tk/ydk/gdkdisplay.c index f7b43cf874..b9b036cebe 100644 --- a/libs/tk/ydk/gdkdisplay.c +++ b/libs/tk/ydk/gdkdisplay.c @@ -153,6 +153,11 @@ gdk_display_dispose (GObject *object) display->queued_events = NULL; display->queued_tail = NULL; + if (display->touch_grabs) + { + g_hash_table_destroy (display->touch_grabs); + } + _gdk_displays = g_slist_remove (_gdk_displays, object); if (gdk_display_get_default() == display) diff --git a/libs/tk/ydk/gdkwindow.c b/libs/tk/ydk/gdkwindow.c index fab05d1cac..054d628814 100644 --- a/libs/tk/ydk/gdkwindow.c +++ b/libs/tk/ydk/gdkwindow.c @@ -10848,6 +10848,30 @@ proxy_button_event (GdkEvent *source_event, type, state, NULL, serial); + /* multitouch grab */ + if (type == GDK_TOUCH_BEGIN && !source_event->any.send_event) + { + GdkEventTouch* tev = (GdkEventTouch*) source_event; + if (!display->touch_grabs) { + display->touch_grabs = g_hash_table_new (g_direct_hash, NULL); + } + event_win = _gdk_window_find_descendant_at (toplevel_window, toplevel_x, toplevel_y, NULL, NULL); + g_hash_table_insert (display->touch_grabs, GUINT_TO_POINTER (tev->sequence), event_win); + } + else if (type == GDK_TOUCH_END && display->touch_grabs) + { + GdkEventTouch* tev = (GdkEventTouch*) source_event; + g_hash_table_remove (display->touch_grabs, GUINT_TO_POINTER (tev->sequence)); + } + else if (type == GDK_TOUCH_UPDATE && display->touch_grabs) + { + GdkEventTouch* tev = (GdkEventTouch*) source_event; + void* w = g_hash_table_lookup (display->touch_grabs, GUINT_TO_POINTER (tev->sequence)); + if (w) { + event_win = GDK_WINDOW (w); + } + } + if (event_win == NULL || display->ignore_core_events) return TRUE; diff --git a/libs/tk/ydk/ydk/gdk/gdkdisplay.h b/libs/tk/ydk/ydk/gdk/gdkdisplay.h index 7cc8665144..96bb0572c1 100644 --- a/libs/tk/ydk/ydk/gdk/gdkdisplay.h +++ b/libs/tk/ydk/ydk/gdk/gdkdisplay.h @@ -101,6 +101,8 @@ struct _GdkDisplay GdkKeyboardGrabInfo GSEAL (keyboard_grab); GdkPointerWindowInfo GSEAL (pointer_info); + GHashTable *GSEAL (touch_grabs); + /* Last reported event time from server */ guint32 GSEAL (last_event_time); }; From 24b916d125400b28d2eca2268e29ac001db80d41 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 26 Sep 2024 18:52:31 +0200 Subject: [PATCH 029/113] Touch Support for Ardour Button --- libs/widgets/ardour_button.cc | 38 ++++++++++++++++++++++++++++ libs/widgets/widgets/ardour_button.h | 2 ++ 2 files changed, 40 insertions(+) diff --git a/libs/widgets/ardour_button.cc b/libs/widgets/ardour_button.cc index a400b9df22..f31ed74827 100644 --- a/libs/widgets/ardour_button.cc +++ b/libs/widgets/ardour_button.cc @@ -103,6 +103,7 @@ ArdourButton::ArdourButton (Element e, bool toggle) UIConfigurationBase::instance().ColorsChanged.connect (sigc::mem_fun (*this, &ArdourButton::color_handler)); /* This is not provided by gtkmm */ signal_grab_broken_event().connect (sigc::mem_fun (*this, &ArdourButton::on_grab_broken_event)); + add_events (Gdk::TOUCH_BEGIN_MASK | Gdk::TOUCH_END_MASK); } ArdourButton::ArdourButton (const std::string& str, Element e, bool toggle) @@ -154,6 +155,7 @@ ArdourButton::ArdourButton (const std::string& str, Element e, bool toggle) UIConfigurationBase::instance().DPIReset.connect (sigc::mem_fun (*this, &ArdourButton::on_name_changed)); /* This is not provided by gtkmm */ signal_grab_broken_event().connect (sigc::mem_fun (*this, &ArdourButton::on_grab_broken_event)); + add_events (Gdk::TOUCH_BEGIN_MASK | Gdk::TOUCH_END_MASK); } ArdourButton::~ArdourButton() @@ -943,6 +945,42 @@ ArdourButton::set_led_left (bool yn) _led_left = yn; } +bool +ArdourButton::on_touch_begin_event (GdkEventTouch *ev) +{ + printf ("ArdourButton::on_touch_begin_event finger %d\n", ev->sequence); + focus_handler (this); + + CairoWidget::set_dirty (); + + if (!_act_on_release) { + if (_action) { + _action->activate (); + } else if (_auto_toggle) { + set_active (!get_active ()); + signal_clicked (); + } + } + return true; +} + +bool +ArdourButton::on_touch_end_event (GdkEventTouch *ev) +{ + printf ("ArdourButton::on_touch_end_event finger: %d\n", ev->sequence); + CairoWidget::set_dirty (); + + if (_act_on_release && _auto_toggle && !_action) { + set_active (!get_active ()); + } + signal_clicked (); + if (_act_on_release && _action) { + _action->activate (); + } + + return true; +} + bool ArdourButton::on_button_press_event (GdkEventButton *ev) { diff --git a/libs/widgets/widgets/ardour_button.h b/libs/widgets/widgets/ardour_button.h index ad998ebe6c..3681acaa9b 100644 --- a/libs/widgets/widgets/ardour_button.h +++ b/libs/widgets/widgets/ardour_button.h @@ -124,6 +124,8 @@ class LIBWIDGETS_API ArdourButton : public CairoWidget , public Gtkmm2ext::Activ bool on_button_press_event (GdkEventButton*); bool on_button_release_event (GdkEventButton*); + bool on_touch_begin_event (GdkEventTouch*); + bool on_touch_end_event (GdkEventTouch*); void set_image (const Glib::RefPtr&); From 000a1aaa462ba2f02b07204f37777fa0ad1e19dc Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 2 Oct 2024 00:17:07 +0200 Subject: [PATCH 030/113] Touch Support for Ardour Fader --- libs/widgets/ardour_fader.cc | 14 ++++++++++++++ libs/widgets/fader_widget.cc | 25 +++++++++++++++++++++++++ libs/widgets/widgets/ardour_fader.h | 1 + libs/widgets/widgets/fader_widget.h | 2 ++ 4 files changed, 42 insertions(+) diff --git a/libs/widgets/ardour_fader.cc b/libs/widgets/ardour_fader.cc index b086de64b6..e833640fcf 100644 --- a/libs/widgets/ardour_fader.cc +++ b/libs/widgets/ardour_fader.cc @@ -61,6 +61,8 @@ ArdourFader::ArdourFader (Gtk::Adjustment& adj, int orientation, int fader_lengt { update_unity_position (); + add_events (Gdk::TOUCH_UPDATE_MASK); + if (_orien == VERT) { CairoWidget::set_size_request(_girth, _span); } else { @@ -464,6 +466,18 @@ ArdourFader::on_motion_notify_event (GdkEventMotion* ev) return true; } +bool +ArdourFader::on_touch_update_event (GdkEventTouch* ev) +{ + GdkEventMotion mev; + mev.window = ev->window; + mev.time = ev->time; + mev.x = ev->x; + mev.y = ev->y; + mev.state = 0; + return ArdourFader::on_motion_notify_event (&mev); +} + /** @return pixel offset of the current value from the right or bottom of the fader */ int ArdourFader::display_span () diff --git a/libs/widgets/fader_widget.cc b/libs/widgets/fader_widget.cc index bcbe904234..a226bbda95 100644 --- a/libs/widgets/fader_widget.cc +++ b/libs/widgets/fader_widget.cc @@ -41,6 +41,8 @@ FaderWidget::FaderWidget (Gtk::Adjustment& adj, int orien) | Gdk::SCROLL_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK + | Gdk::TOUCH_BEGIN_MASK + | Gdk::TOUCH_END_MASK ); _adjustment.signal_value_changed().connect (mem_fun (*this, &FaderWidget::adjustment_changed)); @@ -100,6 +102,29 @@ FaderWidget::on_button_press_event (GdkEventButton* ev) return (_tweaks & NoButtonForward) ? true : false; } +bool +FaderWidget::on_touch_begin_event (GdkEventTouch *ev) +{ + StartGesture (0); + _grab_loc = (_orien == VERT) ? ev->y : ev->x; + _grab_start = (_orien == VERT) ? ev->y : ev->x; + _grab_window = ev->window; + _dragging = true; + return true; +} + +bool +FaderWidget::on_touch_end_event (GdkEventTouch *ev) +{ + if (!_dragging) { + return true; + } + _dragging = false; + StopGesture (0); + + return true; +} + bool FaderWidget::on_enter_notify_event (GdkEventCrossing*) { diff --git a/libs/widgets/widgets/ardour_fader.h b/libs/widgets/widgets/ardour_fader.h index cfcb15570f..bcbd59af9a 100644 --- a/libs/widgets/widgets/ardour_fader.h +++ b/libs/widgets/widgets/ardour_fader.h @@ -55,6 +55,7 @@ protected: void render (Cairo::RefPtr const&, cairo_rectangle_t*); bool on_motion_notify_event (GdkEventMotion*); + bool on_touch_update_event (GdkEventTouch*); void on_state_changed (Gtk::StateType); void on_style_changed (const Glib::RefPtr&); diff --git a/libs/widgets/widgets/fader_widget.h b/libs/widgets/widgets/fader_widget.h index baff3d9cbb..cd21dd0f83 100644 --- a/libs/widgets/widgets/fader_widget.h +++ b/libs/widgets/widgets/fader_widget.h @@ -62,6 +62,8 @@ public: protected: bool on_button_press_event (GdkEventButton*); bool on_button_release_event (GdkEventButton*); + bool on_touch_begin_event (GdkEventTouch*); + bool on_touch_end_event (GdkEventTouch*); bool on_enter_notify_event (GdkEventCrossing* ev); bool on_leave_notify_event (GdkEventCrossing* ev); bool on_scroll_event (GdkEventScroll* ev); From 8f32862e5839b07922f48a31210628c7f0d850fc Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 17 Sep 2024 22:05:44 +0200 Subject: [PATCH 031/113] Humble beginnings of implementing Touch API for YDK/Windows --- libs/tk/ydk/win32/gdkevents-win32.c | 143 ++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/libs/tk/ydk/win32/gdkevents-win32.c b/libs/tk/ydk/win32/gdkevents-win32.c index e78ed38f02..9903418511 100644 --- a/libs/tk/ydk/win32/gdkevents-win32.c +++ b/libs/tk/ydk/win32/gdkevents-win32.c @@ -88,6 +88,67 @@ #define QS_YDK_RELEVANT_INPUT 0x4ff // = QS_KEY | QS_MOUSEMOVE | QS_MOUSEBUTTON | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY | QS_SENDMESSAGE | QS_RAWINPUT +#ifndef WM_NCPOINTERUPDATE + +typedef DWORD POINTER_INPUT_TYPE; +typedef UINT32 POINTER_FLAGS; +typedef UINT32 TOUCH_FLAGS; +typedef UINT32 TOUCH_MASK; + +typedef enum _POINTER_BUTTON_CHANGE_TYPE +{ + POINTER_CHANGE_NONE, + POINTER_CHANGE_FIRSTBUTTON_DOWN, + POINTER_CHANGE_FIRSTBUTTON_UP, + POINTER_CHANGE_SECONDBUTTON_DOWN, + POINTER_CHANGE_SECONDBUTTON_UP, + POINTER_CHANGE_THIRDBUTTON_DOWN, + POINTER_CHANGE_THIRDBUTTON_UP, + POINTER_CHANGE_FOURTHBUTTON_DOWN, + POINTER_CHANGE_FOURTHBUTTON_UP, + POINTER_CHANGE_FIFTHBUTTON_DOWN, + POINTER_CHANGE_FIFTHBUTTON_UP +} POINTER_BUTTON_CHANGE_TYPE; + +typedef struct _POINTER_INFO { + POINTER_INPUT_TYPE pointerType; + UINT32 pointerId; + UINT32 frameId; + POINTER_FLAGS pointerFlags; + HANDLE sourceDevice; + HWND hwndTarget; + POINT ptPixelLocation; + POINT ptHimetricLocation; + POINT ptPixelLocationRaw; + POINT ptHimetricLocationRaw; + DWORD dwTime; + UINT32 historyCount; + INT32 InputData; + DWORD dwKeyStates; + UINT64 PerformanceCount; + POINTER_BUTTON_CHANGE_TYPE ButtonChangeType; +} POINTER_INFO; + +typedef struct _POINTER_TOUCH_INFO { + POINTER_INFO pointerInfo; + TOUCH_FLAGS touchFlags; + TOUCH_MASK touchMask; + RECT rcContact; + RECT rcContactRaw; + UINT32 orientation; + UINT32 pressure; +} POINTER_TOUCH_INFO; + +typedef BOOL (WINAPI *PFN_GetPointerType) (UINT32, POINTER_INPUT_TYPE*); +typedef BOOL (WINAPI *PFN_GetPointerTouchInfo) (UINT32, POINTER_TOUCH_INFO*); + +#define GET_POINTERID_WPARAM(wParam) (LOWORD(wParam)) + +#endif + +static PFN_GetPointerType getPointerType = 0; +static PFN_GetPointerTouchInfo getPointerTouchInfo = 0; + static gboolean gdk_event_translate (MSG *msg, gint *ret_valp); static void handle_wm_paint (MSG *msg, @@ -273,6 +334,11 @@ _gdk_win32_window_procedure (HWND hwnd, void _gdk_events_init (void) { + printf ("CHECK FOR Touch/Pointer API..\n"); + getPointerType = (PFN_GetPointerType) GetProcAddress (GetModuleHandle ("user32.dll"), "GetPointerType"); + getPointerTouchInfo = (PFN_GetPointerTouchInfo) GetProcAddress (GetModuleHandle ("user32.dll"), "GetPointerTouchInfo"); + printf ("Found GetPointerType = %p GetPointerTouchInfo = %p\n", getPointerType, getPointerTouchInfo); + GSource *source; #if 0 @@ -811,6 +877,10 @@ _gdk_win32_print_event (const GdkEvent *event) CASE (GDK_SETTING); CASE (GDK_OWNER_CHANGE); CASE (GDK_GRAB_BROKEN); + CASE (GDK_TOUCH_BEGIN); + CASE (GDK_TOUCH_UPDATE); + CASE (GDK_TOUCH_END); + CASE (GDK_TOUCH_CANCEL); #undef CASE default: g_assert_not_reached (); } @@ -935,6 +1005,7 @@ _gdk_win32_print_event (const GdkEvent *event) g_print ("%s: %s", _gdk_win32_window_state_to_string (event->window_state.changed_mask), _gdk_win32_window_state_to_string (event->window_state.new_window_state)); + break; case GDK_SETTING: g_print ("%s: %s", (event->setting.action == GDK_SETTING_ACTION_NEW ? "NEW" : @@ -942,11 +1013,23 @@ _gdk_win32_print_event (const GdkEvent *event) (event->setting.action == GDK_SETTING_ACTION_DELETED ? "DELETED" : "???"))), (event->setting.name ? event->setting.name : "NULL")); + break; case GDK_GRAB_BROKEN: g_print ("%s %s %p", (event->grab_broken.keyboard ? "KEYBOARD" : "POINTER"), (event->grab_broken.implicit ? "IMPLICIT" : "EXPLICIT"), (event->grab_broken.grab_window ? GDK_WINDOW_HWND (event->grab_broken.grab_window) : 0)); + break; + case GDK_TOUCH_BEGIN: + case GDK_TOUCH_UPDATE: + case GDK_TOUCH_END: + g_print ("Touch %s %d (%.4g,%.4g) (%.4g,%.4g) ", + (event->any.type == GDK_TOUCH_BEGIN) ? "Begin" : (event->any.type == GDK_TOUCH_END) ? "End" : "Update", + event->touch.sequence, + event->touch.x, event->touch.y, + event->touch.x_root, event->touch.y_root); + case GDK_TOUCH_CANCEL: + g_print ("Touch Cancel\n"); default: /* Nothing */ break; @@ -1915,6 +1998,51 @@ generate_button_event (GdkEventType type, _gdk_win32_append_event (event); } +static gboolean +handle_wm_pointer (GdkEventType type, GdkWindow* window, MSG* msg) +{ + POINTER_INPUT_TYPE pointer_type; + + if (!getPointerType || !getPointerTouchInfo) + { + return FALSE; + } + if (!getPointerType (GET_POINTERID_WPARAM (msg->wParam), &pointer_type)) + { + printf ("getPointerType failed to translate event\n"); + return FALSE; + } + if (pointer_type != 2 /* touch */) + { + printf ("Not A Touch event\n"); + return FALSE; + } + + POINTER_TOUCH_INFO touch_info; + if (!getPointerTouchInfo (GET_POINTERID_WPARAM (msg->wParam), &touch_info)) + { + printf ("getPointerTouchInfo failed to translate event\n"); + return FALSE; + } + + GdkEvent *event = gdk_event_new (type); + + event->touch.window = window; + event->touch.time = _gdk_win32_get_next_tick (msg->time); + event->touch.x = (gint16) GET_X_LPARAM (msg->lParam); + event->touch.y = (gint16) GET_Y_LPARAM (msg->lParam); + event->touch.x_root = msg->pt.x + _gdk_offset_x; + event->touch.y_root = msg->pt.y + _gdk_offset_y; + event->touch.state = 0; + event->touch.sequence = GET_POINTERID_WPARAM (msg->wParam); // XXX ? + event->touch.flags = 0; // XXX + event->touch.deviceid = 0; // XXX + + printf ("getPointerTouchInfo at: %.1fx%.1f root: %1.fx%1.f\n", event->touch.x, event->touch.y, event->touch.x_root, event->touch.y_root); + _gdk_win32_append_event (event); +} + + static void ensure_stacking_on_unminimize (MSG *msg) { @@ -2681,6 +2809,21 @@ gdk_event_translate (MSG *msg, return_val = TRUE; break; + case 0x0246 /* WM_POINTERDOWN */: + printf ("Event WM_POINTERDOWN\n"); + if (!handle_wm_pointer (GDK_TOUCH_BEGIN, window, msg)) { + // XXX -> generate_button_event ? + } + break; + case 0x0247 /* WM_POINTERUP */: + printf ("Event WM_POINTERUP\n"); + handle_wm_pointer (GDK_TOUCH_END, window, msg); + break; + case 0x0245 /* WM_POINTERUPDATE */: + printf ("Event WM_POINTERUPDATE\n"); + handle_wm_pointer (GDK_TOUCH_UPDATE, window, msg); + break; + case WM_NCMOUSEMOVE: GDK_NOTE (EVENTS, g_print (" (%d,%d)", From 42602e03292dd8b474e4c1bc78e2173f5efde739 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Sat, 26 Oct 2024 14:50:22 +0100 Subject: [PATCH 032/113] Add an alternative #include Having removed boost::function.hpp we need to replace it with gtkmm2ext/actions.h - otherwise, glibmm/refptr.h can't make sense of the type 'Gtk::ActionGroup' (go figure...) --- gtk2_ardour/window_manager.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/window_manager.h b/gtk2_ardour/window_manager.h index f3775320e9..d6385389cf 100644 --- a/gtk2_ardour/window_manager.h +++ b/gtk2_ardour/window_manager.h @@ -24,12 +24,14 @@ #include #include -#include #include +#include "gtkmm2ext/actions.h" #include "gtkmm2ext/bindings.h" #include "gtkmm2ext/window_proxy.h" +#include + #include "ardour/session_handle.h" class XMLNode; From b45e3ecc0cd4105c18bb49209047fbad5d0677c1 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 27 Oct 2024 17:14:22 +0100 Subject: [PATCH 033/113] Allow Lua Processors to declare parameter inline visibility --- libs/ardour/luaproc.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/ardour/luaproc.cc b/libs/ardour/luaproc.cc index 6241d4df8b..9bc69bb4de 100644 --- a/libs/ardour/luaproc.cc +++ b/libs/ardour/luaproc.cc @@ -380,6 +380,7 @@ LuaProc::load_script () _param_desc[pn].logarithmic = lr["logarithmic"].isBoolean () && (lr["logarithmic"]).cast (); _param_desc[pn].integer_step = lr["integer"].isBoolean () && (lr["integer"]).cast (); _param_desc[pn].sr_dependent = lr["ratemult"].isBoolean () && (lr["ratemult"]).cast (); + _param_desc[pn].inline_ctrl = lr["inline"].isBoolean () && (lr["inline"]).cast (); _param_desc[pn].enumeration = lr["enum"].isBoolean () && (lr["enum"]).cast (); if (lr["bypass"].isBoolean () && (lr["bypass"]).cast ()) { @@ -1094,6 +1095,7 @@ LuaProc::get_parameter_descriptor (uint32_t port, ParameterDescriptor& desc) con desc.integer_step = d.integer_step; desc.sr_dependent = d.sr_dependent; desc.enumeration = d.enumeration; + desc.inline_ctrl = d.inline_ctrl; desc.unit = d.unit; desc.label = d.label; desc.scale_points = d.scale_points; From 23d5dcd0807a586544637ac2dc26b4b840b95797 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 30 Oct 2024 19:12:21 +0100 Subject: [PATCH 034/113] Fix touch event propagation (custom grab) See also 79dae5f2b4a75211935527ef3ebcdcedf9c423be --- libs/tk/ydk/gdkwindow.c | 4 ++++ libs/tk/ytk/gtkmain.c | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/libs/tk/ydk/gdkwindow.c b/libs/tk/ydk/gdkwindow.c index 054d628814..8755b52905 100644 --- a/libs/tk/ydk/gdkwindow.c +++ b/libs/tk/ydk/gdkwindow.c @@ -10861,6 +10861,10 @@ proxy_button_event (GdkEvent *source_event, else if (type == GDK_TOUCH_END && display->touch_grabs) { GdkEventTouch* tev = (GdkEventTouch*) source_event; + void* w = g_hash_table_lookup (display->touch_grabs, GUINT_TO_POINTER (tev->sequence)); + if (w) { + event_win = GDK_WINDOW (w); + } g_hash_table_remove (display->touch_grabs, GUINT_TO_POINTER (tev->sequence)); } else if (type == GDK_TOUCH_UPDATE && display->touch_grabs) diff --git a/libs/tk/ytk/gtkmain.c b/libs/tk/ytk/gtkmain.c index 4cb2516a2f..c152ad3755 100644 --- a/libs/tk/ytk/gtkmain.c +++ b/libs/tk/ytk/gtkmain.c @@ -1427,6 +1427,11 @@ rewrite_event_for_grabs (GdkEvent *event) return NULL; break; + case GDK_TOUCH_BEGIN: + case GDK_TOUCH_END: + case GDK_TOUCH_UPDATE: + return NULL; + default: return NULL; } @@ -1599,7 +1604,6 @@ gtk_main_do_event (GdkEvent *event) case GDK_BUTTON_PRESS: case GDK_2BUTTON_PRESS: case GDK_3BUTTON_PRESS: - case GDK_TOUCH_BEGIN: gtk_propagate_event (grab_widget, event); break; @@ -1637,12 +1641,16 @@ gtk_main_do_event (GdkEvent *event) /* else fall through */ case GDK_MOTION_NOTIFY: case GDK_BUTTON_RELEASE: - case GDK_TOUCH_UPDATE: - case GDK_TOUCH_END: case GDK_PROXIMITY_IN: case GDK_PROXIMITY_OUT: gtk_propagate_event (grab_widget, event); break; + + case GDK_TOUCH_BEGIN: + case GDK_TOUCH_UPDATE: + case GDK_TOUCH_END: + gtk_propagate_event (event_widget, event); + break; case GDK_ENTER_NOTIFY: GTK_PRIVATE_SET_FLAG (event_widget, GTK_HAS_POINTER); From 952ec57a26203f3778cb91188ed52b2ca3373a4c Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 30 Oct 2024 19:19:30 +0100 Subject: [PATCH 035/113] Special case first touch-event: grab and emulate mouse button --- libs/tk/ydk/gdkwindow.c | 72 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 5 deletions(-) diff --git a/libs/tk/ydk/gdkwindow.c b/libs/tk/ydk/gdkwindow.c index 8755b52905..96cf56c08a 100644 --- a/libs/tk/ydk/gdkwindow.c +++ b/libs/tk/ydk/gdkwindow.c @@ -39,6 +39,8 @@ #undef DEBUG_WINDOW_PRINTING +#define FIRST_TOUCH_EMULATE_BUTTON_EVENT + #ifdef GDK_WINDOWING_X11 #include "gdkx.h" /* For workaround */ #endif @@ -9940,6 +9942,28 @@ is_touch_type (GdkEventType type) type == GDK_TOUCH_END; } +static gboolean +is_button_press (GdkEvent* event) +{ +#ifdef FIRST_TOUCH_EMULATE_BUTTON_EVENT + return event->any.type == GDK_BUTTON_PRESS || + (event->any.type == GDK_TOUCH_BEGIN && event->touch.flags & 0x20000); +#else + return event->any.type == GDK_BUTTON_PRESS; +#endif +} + +static gboolean +is_button_release (GdkEvent* event) +{ +#ifdef FIRST_TOUCH_EMULATE_BUTTON_EVENT + return event->any.type == GDK_BUTTON_RELEASE || + (event->any.type == GDK_TOUCH_END && event->touch.flags & 0x20000); +#else + return event->any.type == GDK_BUTTON_RELEASE; +#endif +} + static GdkWindowObject * find_common_ancestor (GdkWindowObject *win1, GdkWindowObject *win2) @@ -10807,7 +10831,7 @@ proxy_button_event (GdkEvent *source_event, toplevel_x, toplevel_y, &toplevel_x, &toplevel_y); - if (type == GDK_BUTTON_PRESS && + if (is_button_press (source_event) && !source_event->any.send_event && _gdk_display_has_pointer_grab (display, serial) == NULL) { @@ -10848,6 +10872,24 @@ proxy_button_event (GdkEvent *source_event, type, state, NULL, serial); +#ifdef FIRST_TOUCH_EMULATE_BUTTON_EVENT + if (is_touch_type (type) && source_event->touch.flags & 0x20000) + { + if (type == GDK_TOUCH_UPDATE) + { + /* first touch moves the mouse already (at least on Linux/X11). + * So there is no need to emulate GDK_MOTION_NOTIFY events. + */ + return TRUE; + } + + event_win = get_event_window (display, + pointer_window, + type == GDK_TOUCH_BEGIN ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE, state, + NULL, serial); + } + else +#endif /* multitouch grab */ if (type == GDK_TOUCH_BEGIN && !source_event->any.send_event) { @@ -10915,6 +10957,28 @@ proxy_button_event (GdkEvent *source_event, case GDK_TOUCH_BEGIN: case GDK_TOUCH_UPDATE: case GDK_TOUCH_END: +#ifdef FIRST_TOUCH_EMULATE_BUTTON_EVENT + if (source_event->touch.flags & 0x20000) { + if (type == GDK_TOUCH_UPDATE) { + g_assert (0); + return TRUE; + } + convert_toplevel_coords_to_window (event_win, + toplevel_x, toplevel_y, + &event->button.x, &event->button.y); + + event->button.type = type == GDK_TOUCH_BEGIN ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE; + event->button.time = source_event->touch.time; + event->button.x_root = source_event->touch.x_root; + event->button.y_root = source_event->touch.y_root; + event->button.axes = NULL; + event->button.state = 0; + event->button.button = 1; + event->button.device = display->core_pointer; + return TRUE; + } +#endif + convert_toplevel_coords_to_window (event_win, toplevel_x, toplevel_y, &event->touch.x, &event->touch.y); @@ -11076,8 +11140,7 @@ _gdk_windowing_got_event (GdkDisplay *display, _gdk_display_pointer_grab_update (display, serial); } - if (event->type == GDK_BUTTON_RELEASE && - !event->any.send_event) + if (is_button_release (event) && !event->any.send_event) { button_release_grab = _gdk_display_has_pointer_grab (display, serial); @@ -11204,8 +11267,7 @@ _gdk_windowing_got_event (GdkDisplay *display, unlink_event = proxy_button_event (event, serial); - if (event->type == GDK_BUTTON_RELEASE && - !event->any.send_event) + if (is_button_release (event) && !event->any.send_event) { button_release_grab = _gdk_display_has_pointer_grab (display, serial); From c88d3701366d1681b02f33264760b59b02f4d8b6 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 31 Oct 2024 02:02:09 +0100 Subject: [PATCH 036/113] Implement Windows multitouch support --- libs/tk/ydk/win32/gdkevents-win32.c | 111 ++++++++++++++++++++++++---- 1 file changed, 98 insertions(+), 13 deletions(-) diff --git a/libs/tk/ydk/win32/gdkevents-win32.c b/libs/tk/ydk/win32/gdkevents-win32.c index 9903418511..8dbbfecf99 100644 --- a/libs/tk/ydk/win32/gdkevents-win32.c +++ b/libs/tk/ydk/win32/gdkevents-win32.c @@ -168,6 +168,11 @@ static gboolean gdk_event_dispatch (GSource *source, static GList *client_filters; /* Filters for client messages */ +static GList *touch_mapper = NULL; + +static int last_touch_x[32]; +static int last_touch_y[32]; + static HCURSOR p_grab_cursor; static GSourceFuncs event_funcs = { @@ -231,6 +236,40 @@ track_mouse_event (DWORD dwFlags, GDK_NOTE (EVENTS, g_print(" (cancel TrackMouseEvent %p)", hwnd)); } +static int +touch_idx_lookup (DWORD id) +{ + GList* g = g_list_find (touch_mapper, GUINT_TO_POINTER(id)); + if (!g) { + return -1; + } + return g_list_position (touch_mapper, g); +} + +static int +touch_idx_map (DWORD id) +{ + GList* g = g_list_find (touch_mapper, GUINT_TO_POINTER(G_MAXUINT)); + if (!g) { + touch_mapper = g_list_append (touch_mapper, GUINT_TO_POINTER(id)); + } else { + g->data = GUINT_TO_POINTER(id); + } + return touch_idx_lookup (id); +} + +static int +touch_idx_unmap (DWORD id) +{ + GList* g = g_list_find (touch_mapper, GUINT_TO_POINTER(id)); + if (!g) { + return -1; + } + int rv = g_list_position (touch_mapper, g); + g->data = GUINT_TO_POINTER(G_MAXULONG); + return rv; +} + gulong _gdk_win32_get_next_tick (gulong suggested_tick) { @@ -2021,24 +2060,75 @@ handle_wm_pointer (GdkEventType type, GdkWindow* window, MSG* msg) POINTER_TOUCH_INFO touch_info; if (!getPointerTouchInfo (GET_POINTERID_WPARAM (msg->wParam), &touch_info)) { - printf ("getPointerTouchInfo failed to translate event\n"); + printf ("getPointerTouchInfo failed to translate event\n"); return FALSE; } + /* Touch positions are in screen coordinates, convert + * them to Window coordidates + */ + POINT point; + point.x = GET_X_LPARAM (msg->lParam); + point.y = GET_Y_LPARAM (msg->lParam); + + int touch_sequence = 0; + switch (type) + { + case GDK_TOUCH_BEGIN: + touch_sequence = touch_idx_map (GET_POINTERID_WPARAM (msg->wParam)); + break; + case GDK_TOUCH_END: + touch_sequence = touch_idx_unmap (GET_POINTERID_WPARAM (msg->wParam)); + break; + case GDK_TOUCH_UPDATE: + touch_sequence = touch_idx_lookup (GET_POINTERID_WPARAM (msg->wParam)); + break; + default: + return FALSE; + } + + // printf ("TOUCH %d SEQ %d %x | %d = %d | %d = %d\n", type, touch_sequence, GET_POINTERID_WPARAM (msg->wParam), (int)point.x, last_touch_x[touch_sequence], (int)point.y, last_touch_y[touch_sequence]); + + /* Dear Aliens, we're sorry to limit multitouch to 30 fingers */ + if (touch_sequence < 0 || touch_sequence > 31) + { + return FALSE; + } + + + /* Windows periodically sends WM_POINTERUPDATE updates. + * If a finger has not moved, do not create a GDK event. + */ + if (type == GDK_TOUCH_UPDATE + && (int)point.x == last_touch_x[touch_sequence] + && (int)point.y == last_touch_y[touch_sequence]) + { + return FALSE; + } + + last_touch_x[touch_sequence] = (int)point.x; + last_touch_y[touch_sequence] = (int)point.y; + + /* first single touch is already handled by Windows as mouse event */ + if (touch_sequence == 0) { + return TRUE; + } + + ScreenToClient (msg->hwnd, &point); GdkEvent *event = gdk_event_new (type); event->touch.window = window; event->touch.time = _gdk_win32_get_next_tick (msg->time); - event->touch.x = (gint16) GET_X_LPARAM (msg->lParam); - event->touch.y = (gint16) GET_Y_LPARAM (msg->lParam); + event->touch.x = (gint16) point.x; + event->touch.y = (gint16) point.y; event->touch.x_root = msg->pt.x + _gdk_offset_x; event->touch.y_root = msg->pt.y + _gdk_offset_y; event->touch.state = 0; - event->touch.sequence = GET_POINTERID_WPARAM (msg->wParam); // XXX ? - event->touch.flags = 0; // XXX - event->touch.deviceid = 0; // XXX + event->touch.sequence = GET_POINTERID_WPARAM (msg->wParam); // or touch_sequence + 1 + event->touch.flags = 0; // touch_sequence == 0 ? 0x20000 : 0; + event->touch.deviceid = 0; - printf ("getPointerTouchInfo at: %.1fx%.1f root: %1.fx%1.f\n", event->touch.x, event->touch.y, event->touch.x_root, event->touch.y_root); + printf ("getPointerTouchInfo type = %d at: %.1fx%.1f root: %1.fx%1.f seq=%d\n", type, event->touch.x, event->touch.y, event->touch.x_root, event->touch.y_root, touch_sequence); _gdk_win32_append_event (event); } @@ -2810,17 +2900,12 @@ gdk_event_translate (MSG *msg, break; case 0x0246 /* WM_POINTERDOWN */: - printf ("Event WM_POINTERDOWN\n"); - if (!handle_wm_pointer (GDK_TOUCH_BEGIN, window, msg)) { - // XXX -> generate_button_event ? - } + handle_wm_pointer (GDK_TOUCH_BEGIN, window, msg); break; case 0x0247 /* WM_POINTERUP */: - printf ("Event WM_POINTERUP\n"); handle_wm_pointer (GDK_TOUCH_END, window, msg); break; case 0x0245 /* WM_POINTERUPDATE */: - printf ("Event WM_POINTERUPDATE\n"); handle_wm_pointer (GDK_TOUCH_UPDATE, window, msg); break; From 9ed9567b4380226c51c8a5c665f91c8b037a68dc Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 24 Oct 2024 11:37:43 -0600 Subject: [PATCH 037/113] Evoral: add new is_xxxx() methods for various MIDI events, including is_realtime() --- libs/evoral/evoral/Event.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/evoral/evoral/Event.h b/libs/evoral/evoral/Event.h index 03b8b033d7..e410da41c4 100644 --- a/libs/evoral/evoral/Event.h +++ b/libs/evoral/evoral/Event.h @@ -155,12 +155,17 @@ public: bool is_channel_event() const { return (0x80 <= type()) && (type() <= 0xE0); } bool is_smf_meta_event() const { return _buf[0] == 0xFF; } bool is_sysex() const { return _buf[0] == 0xF0 || _buf[0] == 0xF7; } - bool is_spp() const { return _buf[0] == 0xF2 && size() == 1; } bool is_mtc_quarter() const { return _buf[0] == 0xF1 && size() == 1; } + bool is_spp() const { return _buf[0] == 0xF2 && size() == 1; } + bool is_song() const { return _buf[0] == 0xF3 && size() == 1; } + bool is_tune() const { return _buf[0] == 0xF6 && size() == 1; } + bool is_eox() const { return _buf[0] == 0xF7 && size() == 1; } + bool is_clock() const { return _buf[0] == 0xF8 && size() == 1; } + bool is_tick() const { return _buf[0] == 0xF9 && size() == 1; } bool is_mtc_full() const { return (size() == 10 && _buf[0] == 0xF0 && _buf[1] == 0x7F && _buf[3] == 0x01 && _buf[4] == 0x01); } - + bool is_realtime() const { return is_mtc_full() || ((_buf[0] >= 0xF1 && _buf[0] <= 0xfe) && size() == 1); } uint8_t note() const { return _buf[1]; } uint8_t velocity() const { return _buf[2]; } uint8_t poly_note() const { return _buf[1]; } From f8ddc827c74f43994b69582c5232fd47f82736d9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 24 Oct 2024 11:41:29 -0600 Subject: [PATCH 038/113] NO-OP: tweak comemnt that still referenced frames instead of samples --- libs/temporal/temporal/beats.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/temporal/temporal/beats.h b/libs/temporal/temporal/beats.h index 40541d974c..c72e0688ac 100644 --- a/libs/temporal/temporal/beats.h +++ b/libs/temporal/temporal/beats.h @@ -91,7 +91,7 @@ public: /** Create from ticks at a given rate. * - * Note this can also be used to create from frames by setting ppqn to the + * Note this can also be used to create from samples by setting ppqn to the * number of samples per beat. Note the resulting Beats will, like all * others, have the default PPQN, so this is a potentially lossy * conversion. From ebcc6b825047091cd1b7954da0222104f0e159c8 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 24 Oct 2024 11:43:30 -0600 Subject: [PATCH 039/113] add the concept of a length that is data-independent to MIDI files (libs) --- libs/ardour/ardour/audiofilesource.h | 2 +- libs/ardour/ardour/audiosource.h | 2 +- libs/ardour/ardour/disk_writer.h | 2 +- libs/ardour/ardour/midi_source.h | 4 +-- libs/ardour/ardour/session.h | 2 +- libs/ardour/ardour/smf_source.h | 5 +-- libs/ardour/ardour/source.h | 7 +++- libs/ardour/ardour/track.h | 2 +- libs/ardour/ardour/triggerbox.h | 13 ++++---- libs/ardour/audiofilesource.cc | 4 +-- libs/ardour/audiosource.cc | 2 +- libs/ardour/disk_writer.cc | 34 +++++++------------ libs/ardour/import.cc | 19 ++--------- libs/ardour/luaproc.cc | 2 -- libs/ardour/midi_model.cc | 22 ++++++++----- libs/ardour/midi_source.cc | 8 ++--- libs/ardour/session.cc | 12 ++++--- libs/ardour/session_state.cc | 6 ++-- libs/ardour/smf_source.cc | 19 ++++++----- libs/ardour/track.cc | 4 +-- libs/ardour/triggerbox.cc | 49 ++++++++++++++++------------ libs/evoral/SMF.cc | 27 +++++++++++---- libs/evoral/Sequence.cc | 43 +++++++++++++++++++++++- libs/evoral/evoral/SMF.h | 3 ++ libs/evoral/evoral/Sequence.h | 7 ++++ 25 files changed, 182 insertions(+), 118 deletions(-) diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h index fac0f4313c..7632b172ba 100644 --- a/libs/ardour/ardour/audiofilesource.h +++ b/libs/ardour/ardour/audiofilesource.h @@ -60,7 +60,7 @@ public: virtual int update_header (samplepos_t when, struct tm&, time_t) = 0; virtual int flush_header () = 0; - void mark_streaming_write_completed (const WriterLock& lock); + void mark_streaming_write_completed (const WriterLock& lock, Temporal::timecnt_t const & duration); int setup_peakfile (); void set_gain (float g, bool temporarily = false); diff --git a/libs/ardour/ardour/audiosource.h b/libs/ardour/ardour/audiosource.h index 9ea6c25f60..4160118601 100644 --- a/libs/ardour/ardour/audiosource.h +++ b/libs/ardour/ardour/audiosource.h @@ -57,7 +57,7 @@ class LIBARDOUR_API AudioSource : virtual public Source, public ARDOUR::AudioRea virtual float sample_rate () const = 0; - virtual void mark_streaming_write_completed (const WriterLock& lock); + virtual void mark_streaming_write_completed (const WriterLock& lock, Temporal::timecnt_t const & duration); virtual bool can_truncate_peaks() const { return true; } diff --git a/libs/ardour/ardour/disk_writer.h b/libs/ardour/ardour/disk_writer.h index 23f14e90db..9144275ebe 100644 --- a/libs/ardour/ardour/disk_writer.h +++ b/libs/ardour/ardour/disk_writer.h @@ -74,7 +74,7 @@ public: std::string steal_write_source_name (); int use_new_write_source (DataType, uint32_t n = 0); - void reset_write_sources (bool, bool force = false); + void reset_write_sources (); AlignStyle alignment_style () const { return _alignment_style; } void set_align_style (AlignStyle, bool force = false); diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h index b00a16574b..6f5725cc85 100644 --- a/libs/ardour/ardour/midi_source.h +++ b/libs/ardour/ardour/midi_source.h @@ -138,7 +138,7 @@ class LIBARDOUR_API MidiSource : virtual public Source virtual void mark_streaming_midi_write_started (const WriterLock& lock, NoteMode mode); virtual void mark_streaming_write_started (const WriterLock& lock); - virtual void mark_streaming_write_completed (const WriterLock& lock); + virtual void mark_streaming_write_completed (const WriterLock& lock, Temporal::timecnt_t const & duration); /** Mark write starting with the given time parameters. * @@ -160,7 +160,7 @@ class LIBARDOUR_API MidiSource : virtual public Source virtual void mark_midi_streaming_write_completed ( const WriterLock& lock, Evoral::Sequence::StuckNoteOption stuck_option, - Temporal::Beats when = Temporal::Beats()); + Temporal::timecnt_t const & when); virtual void session_saved(); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 42bd582e02..73822b8d95 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1978,7 +1978,7 @@ public: ARDOUR::CueMarkers pending_source_markers; // source markers created while recording private: - void reset_write_sources (bool mark_write_complete, bool force = false); + void reset_write_sources (); SourceMap sources; int load_sources (const XMLNode& node); diff --git a/libs/ardour/ardour/smf_source.h b/libs/ardour/ardour/smf_source.h index 07ecb2c53a..19cfcc1bef 100644 --- a/libs/ardour/ardour/smf_source.h +++ b/libs/ardour/ardour/smf_source.h @@ -58,10 +58,11 @@ public: void update_length (timepos_t const & dur); void mark_streaming_midi_write_started (const WriterLock& lock, NoteMode mode); - void mark_streaming_write_completed (const WriterLock& lock); + + void mark_streaming_write_completed (const WriterLock& lock, Temporal::timecnt_t const & duration); void mark_midi_streaming_write_completed (const WriterLock& lock, Evoral::Sequence::StuckNoteOption, - Temporal::Beats when = Temporal::Beats()); + Temporal::timecnt_t const & duration); XMLNode& get_state () const; int set_state (const XMLNode&, int version); diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h index 087dbb861c..1770e70ad9 100644 --- a/libs/ardour/ardour/source.h +++ b/libs/ardour/ardour/source.h @@ -83,7 +83,12 @@ public: void mark_for_remove(); virtual void mark_streaming_write_started (const WriterLock& lock) {} - virtual void mark_streaming_write_completed (const WriterLock& lock) = 0; + /* The duration argument is ignored for audio data, where length is + implicitly given by the sample data. It matters for MIDI data, where + the file may be intended to be N bars long, but has no events that + occur at that duration. + */ + virtual void mark_streaming_write_completed (const WriterLock& lock, Temporal::timecnt_t const & duration) = 0; virtual void session_saved() {} diff --git a/libs/ardour/ardour/track.h b/libs/ardour/ardour/track.h index 650b910cb7..46c0061ec6 100644 --- a/libs/ardour/ardour/track.h +++ b/libs/ardour/ardour/track.h @@ -145,7 +145,7 @@ public: void ensure_input_monitoring (bool); std::list > & last_capture_sources (); std::string steal_write_source_name (); - void reset_write_sources (bool, bool force = false); + void reset_write_sources (); float playback_buffer_load () const; float capture_buffer_load () const; int do_refill (); diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index ece9a8d18b..cf1d67ad08 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -715,7 +715,7 @@ class LIBARDOUR_API TriggerBoxThread void set_region (TriggerBox&, uint32_t slot, std::shared_ptr); void request_delete_trigger (Trigger* t); - void request_build_source (Trigger* t); + void request_build_source (Trigger* t, Temporal::timecnt_t const & duration); void summon(); void stop(); @@ -743,6 +743,7 @@ class LIBARDOUR_API TriggerBoxThread std::shared_ptr region; /* for DeleteTrigger and BuildSourceAndRegion */ Trigger* trigger; + Temporal::timecnt_t duration; void* operator new (size_t); void operator delete (void* ptr, size_t); @@ -757,9 +758,9 @@ class LIBARDOUR_API TriggerBoxThread CrossThreadChannel _xthread; void queue_request (Request*); void delete_trigger (Trigger*); - void build_source (Trigger*); - void build_midi_source (MIDITrigger*); - void build_audio_source (AudioTrigger*); + void build_source (Trigger*, Temporal::timecnt_t const & duration); + void build_midi_source (MIDITrigger*, Temporal::timecnt_t const &); + void build_audio_source (AudioTrigger*, Temporal::timecnt_t const &); }; struct CueRecord { @@ -783,7 +784,7 @@ struct SlotArmInfo { samplepos_t start_samples; Temporal::Beats end_beats; samplepos_t end_samples; - Temporal::timecnt_t captured; + samplecnt_t captured; RTMidiBufferBeats* midi_buf; AudioTrigger::AudioData audio_buf; RubberBand::RubberBandStretcher* stretcher; @@ -942,7 +943,7 @@ class LIBARDOUR_API TriggerBox : public Processor, public std::enable_shared_fro void dump (std::ostream &) const; - PBD::Signal Captured; + PBD::Signal Captured; private: struct Requests { diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index c3e83bfa13..e1c68d6852 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -249,13 +249,13 @@ AudioFileSource::set_state (const XMLNode& node, int version) } void -AudioFileSource::mark_streaming_write_completed (const WriterLock& lock) +AudioFileSource::mark_streaming_write_completed (const WriterLock& lock, Temporal::timecnt_t const & duration) { if (!writable()) { return; } - AudioSource::mark_streaming_write_completed (lock); + AudioSource::mark_streaming_write_completed (lock, duration); } int diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 970854610b..c67860064a 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -1150,7 +1150,7 @@ AudioSource::available_peaks (double zoom_factor) const } void -AudioSource::mark_streaming_write_completed (const WriterLock& lock) +AudioSource::mark_streaming_write_completed (const WriterLock& lock, Temporal::timecnt_t const &) { Glib::Threads::Mutex::Lock lm (_peaks_ready_lock); diff --git a/libs/ardour/disk_writer.cc b/libs/ardour/disk_writer.cc index c0e8607b32..79bcd8b2f4 100644 --- a/libs/ardour/disk_writer.cc +++ b/libs/ardour/disk_writer.cc @@ -123,7 +123,7 @@ DiskWriter::set_write_source_name (string const & str) { _write_source_name = str; - reset_write_sources (false); + reset_write_sources (); return true; } @@ -390,7 +390,7 @@ DiskWriter::set_state (const XMLNode& node, int version) node.get_property (X_("record-safe"), rec_safe); _record_safe.store (rec_safe); - reset_write_sources (false, true); + reset_write_sources (); return 0; } @@ -1072,7 +1072,7 @@ DiskWriter::do_flush (RunContext ctxt, bool force_flush) } void -DiskWriter::reset_write_sources (bool mark_write_complete, bool /*force*/) +DiskWriter::reset_write_sources () { std::shared_ptr c = channels.reader(); uint32_t n = 0; @@ -1087,12 +1087,6 @@ DiskWriter::reset_write_sources (bool mark_write_complete, bool /*force*/) if (chan->write_source) { - if (mark_write_complete) { - Source::WriterLock lock(chan->write_source->mutex()); - chan->write_source->mark_streaming_write_completed (lock); - chan->write_source->done_with_peakfile_writes (); - } - if (chan->write_source->removable()) { chan->write_source->mark_for_remove (); chan->write_source->drop_references (); @@ -1108,13 +1102,6 @@ DiskWriter::reset_write_sources (bool mark_write_complete, bool /*force*/) } } - if (_midi_write_source) { - if (mark_write_complete) { - Source::WriterLock lm(_midi_write_source->mutex()); - _midi_write_source->mark_streaming_write_completed (lm); - } - } - if (_playlists[DataType::MIDI]) { use_new_write_source (DataType::MIDI); } @@ -1186,7 +1173,6 @@ DiskWriter::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abo ChannelList::const_iterator chan; std::shared_ptr c = channels.reader(); uint32_t n = 0; - bool mark_write_completed = false; finish_capture (c); @@ -1315,7 +1301,11 @@ DiskWriter::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abo total_capture += timecnt_t ((*ci)->samples); } - _midi_write_source->mark_midi_streaming_write_completed (source_lock, Evoral::Sequence::ResolveStuckNotes, total_capture.beats()); + /* XXX we need to consider snapping the duration up to the next + * beat/bar here + */ + + _midi_write_source->mark_midi_streaming_write_completed (source_lock, Evoral::Sequence::ResolveStuckNotes, timecnt_t (total_capture)); } _last_capture_sources.insert (_last_capture_sources.end(), audio_srcs.begin(), audio_srcs.end()); @@ -1325,10 +1315,8 @@ DiskWriter::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abo _track.use_captured_sources (audio_srcs, capture_info); _track.use_captured_sources (midi_srcs, capture_info); - mark_write_completed = true; - out: - reset_write_sources (mark_write_completed); + reset_write_sources (); for (vector::iterator ci = capture_info.begin(); ci != capture_info.end(); ++ci) { delete *ci; @@ -1457,7 +1445,7 @@ DiskWriter::configure_io (ChanCount in, ChanCount out) } if (record_enabled() || changed) { - reset_write_sources (false, true); + reset_write_sources (); } return true; @@ -1472,7 +1460,7 @@ DiskWriter::use_playlist (DataType dt, std::shared_ptr playlist) return -1; } if (reset_ws) { - reset_write_sources (false, true); + reset_write_sources (); } return 0; } diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index 1a73351d0e..7232bc158a 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -134,7 +134,7 @@ open_importable_source (const string& path, samplecnt_t samplerate, ARDOUR::SrcQ } /* rewrap as a resampled source */ - return std::shared_ptr(new ResampledImportableSource(source, samplerate, quality)); + return std::shared_ptr(new ResampledImportableSource(source, samplerate, quality)); } catch (...) { } throw failed_constructor (); @@ -464,18 +464,7 @@ write_midi_data_to_new_files (Evoral::SMF* source, ImportStatus& status, /* we wrote something */ - /* try to guess at the meter, for 5/4 midi loop oddballs */ - int pulses_per_bar = 4; - Evoral::SMF::Tempo *tempo = source->nth_tempo (0); - if (tempo && (tempo->numerator>0) ) { - pulses_per_bar = tempo->numerator; - } - - /* extend the length of the region to the end of a bar */ - const Temporal::Beats length_beats = Temporal::Beats::ticks_at_rate(t, source->ppqn()); - smfs->update_length (timepos_t (length_beats.round_up_to_multiple(Temporal::Beats(pulses_per_bar,0)))); - - smfs->mark_streaming_write_completed (source_lock); + smfs->mark_streaming_write_completed (source_lock, timecnt_t (source->duration())); /* the streaming write that we've just finished * only wrote data to the SMF object, which is @@ -486,12 +475,10 @@ write_midi_data_to_new_files (Evoral::SMF* source, ImportStatus& status, smfs->load_model (source_lock, true); - /* Now that there is a model, we can set interpolation of parameters. */ - smfs->mark_streaming_write_completed (source_lock); - if (status.cancel) { break; } + } else { info << string_compose (_("Track %1 of %2 contained no usable MIDI data"), i, total_files) << endmsg; } diff --git a/libs/ardour/luaproc.cc b/libs/ardour/luaproc.cc index 9bc69bb4de..859d549e58 100644 --- a/libs/ardour/luaproc.cc +++ b/libs/ardour/luaproc.cc @@ -1165,7 +1165,6 @@ LuaProc::parse_scale_points (luabridge::LuaRef* lr) return std::shared_ptr (); } - int cnt = 0; std::shared_ptr rv = std::shared_ptr(new ScalePoints()); luabridge::LuaRef scalepoints ((*lr)["scalepoints"]); @@ -1174,7 +1173,6 @@ LuaProc::parse_scale_points (luabridge::LuaRef* lr) if (!i.value ().isNumber ()) { continue; } rv->insert(make_pair(i.key ().cast (), i.value ().cast ())); - ++cnt; } if (rv->size() > 0) { diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc index c35ab34291..fc016a67c6 100644 --- a/libs/ardour/midi_model.cc +++ b/libs/ardour/midi_model.cc @@ -1244,15 +1244,15 @@ MidiModel::write_to (std::shared_ptr source, { ReadLock lock (read_lock()); /* Sequence read-lock */ - source->drop_model(source_lock); + source->drop_model (source_lock); /* as of March 2022 or long before , the note mode argument does nothing */ source->mark_streaming_midi_write_started (source_lock, Sustained); for (Evoral::Sequence::const_iterator i = begin(TimeType(), true); i != end(); ++i) { - source->append_event_beats(source_lock, *i); + source->append_event_beats (source_lock, *i); } - source->mark_streaming_write_completed(source_lock); + source->mark_streaming_write_completed (source_lock, timecnt_t (duration())); /* no call to set_edited() because writing to "newsrc" doesn't remove * the need to write to "our own" source in ::sync_to_source() @@ -1284,7 +1284,7 @@ MidiModel::sync_to_source (const Source::WriterLock& source_lock) _midi_source.append_event_beats(source_lock, *i); } - _midi_source.mark_streaming_write_completed (source_lock); + _midi_source.mark_streaming_write_completed (source_lock, timecnt_t (duration())); set_edited (false); @@ -1300,10 +1300,10 @@ MidiModel::sync_to_source (const Source::WriterLock& source_lock) */ bool MidiModel::write_section_to (std::shared_ptr source, - const Source::WriterLock& source_lock, - TimeType begin_time, - TimeType end_time, - bool offset_events) + const Source::WriterLock& source_lock, + TimeType begin_time, + TimeType end_time, + bool offset_events) { ReadLock lock(read_lock()); MidiNoteTracker mst; @@ -1348,7 +1348,11 @@ MidiModel::write_section_to (std::shared_ptr source, } mst.resolve_notes (*source, source_lock, end_time); - source->mark_streaming_write_completed(source_lock); + /* the new source will have precisely the length given by begin_time + * and end_time. That might not be quite right in some cases. + */ + + source->mark_streaming_write_completed (source_lock, timecnt_t (end_time - begin_time)); set_edited(false); diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc index a899b1396b..f7be87cb75 100644 --- a/libs/ardour/midi_source.cc +++ b/libs/ardour/midi_source.cc @@ -376,10 +376,10 @@ MidiSource::mark_streaming_write_started (const WriterLock& lock) void MidiSource::mark_midi_streaming_write_completed (const WriterLock& lock, Evoral::Sequence::StuckNoteOption option, - Temporal::Beats end) + Temporal::timecnt_t const & duration) { if (_model) { - _model->end_write (option, end); + _model->end_write (option, duration.beats()); /* Make captured controls discrete to play back user input exactly. */ for (MidiModel::Controls::iterator i = _model->controls().begin(); i != _model->controls().end(); ++i) { @@ -395,9 +395,9 @@ MidiSource::mark_midi_streaming_write_completed (const WriterLock& } void -MidiSource::mark_streaming_write_completed (const WriterLock& lock) +MidiSource::mark_streaming_write_completed (const WriterLock& lock, Temporal::timecnt_t const & duration) { - mark_midi_streaming_write_completed (lock, Evoral::Sequence::DeleteStuckNotes); + mark_midi_streaming_write_completed (lock, Evoral::Sequence::DeleteStuckNotes, duration); } int diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index dd608d3faa..3537569706 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2411,7 +2411,7 @@ Session::set_sample_rate (samplecnt_t frames_per_second) sync_time_vars(); clear_clicks (); - reset_write_sources (false); + reset_write_sources (); DiskReader::alloc_loop_declick (nominal_sample_rate()); Location* loc = _locations->auto_loop_location (); @@ -6123,7 +6123,7 @@ Session::reset_native_file_format () if (tr) { /* don't save state as we do this, there's no point */ _state_of_the_state = StateOfTheState (_state_of_the_state | InCleanup); - tr->reset_write_sources (false); + tr->reset_write_sources (); _state_of_the_state = StateOfTheState (_state_of_the_state & ~InCleanup); } } @@ -6468,6 +6468,10 @@ Session::write_one_track (Track& track, samplepos_t start, samplepos_t end, time (&now); xnow = localtime (&now); + /* XXX we may want to round this up to the next beat or bar */ + + const timecnt_t duration (end - start); + for (vector >::iterator src=srcs.begin(); src != srcs.end(); ++src) { std::shared_ptr afs = std::dynamic_pointer_cast(*src); std::shared_ptr ms; @@ -6479,9 +6483,9 @@ Session::write_one_track (Track& track, samplepos_t start, samplepos_t end, plist.add (Properties::start, timepos_t (0)); } else if ((ms = std::dynamic_pointer_cast(*src))) { Source::WriterLock lock (ms->mutex()); - ms->mark_streaming_write_completed(lock); + ms->mark_streaming_write_completed (lock, duration); plist.add (Properties::start, timepos_t (Beats())); - } + } } /* construct a whole-file region to represent the bounced material */ diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 7edb0f6f19..f3b41a480d 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -2687,14 +2687,14 @@ Session::get_sources_as_xml () } void -Session::reset_write_sources (bool mark_write_complete, bool force) +Session::reset_write_sources () { std::shared_ptr rl = routes.reader(); for (auto const& i : *rl) { std::shared_ptr tr = std::dynamic_pointer_cast (i); if (tr) { _state_of_the_state = StateOfTheState (_state_of_the_state | InCleanup); - tr->reset_write_sources(mark_write_complete, force); + tr->reset_write_sources (); _state_of_the_state = StateOfTheState (_state_of_the_state & ~InCleanup); } } @@ -5442,7 +5442,7 @@ Session::save_as (SaveAs& saveas) /* ensure that all existing tracks reset their current capture source paths */ - reset_write_sources (true, true); + reset_write_sources (); /* creating new write sources marks the session as dirty. If the new session is empty, then diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index e5eeea6b88..98a24dc501 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -462,6 +462,7 @@ void SMFSource::update_length (timepos_t const & dur) { assert (!_length || (_length.time_domain() == dur.time_domain())); + Evoral::SMF::set_duration (dur.beats()); _length = dur; } @@ -470,7 +471,7 @@ void SMFSource::append_event_beats (const WriterLock& lock, const Evoral::Event& ev) { - if (!_writing || ev.size() == 0) { + if (!_writing || ev.size() == 0 || ev.is_realtime()) { return; } @@ -516,7 +517,7 @@ SMFSource::append_event_beats (const WriterLock& lock, const Temporal::Beats delta_time_beats = time - _last_ev_time_beats; const uint32_t delta_time_ticks = delta_time_beats.to_ticks(ppqn()); - Evoral::SMF::append_event_delta(delta_time_ticks, ev.size(), ev.buffer(), event_id); + Evoral::SMF::append_event_delta (delta_time_ticks, ev.size(), ev.buffer(), event_id); _last_ev_time_beats = time; _flags = Source::Flag (_flags & ~Empty); _flags = Source::Flag (_flags & ~Missing); @@ -528,7 +529,7 @@ SMFSource::append_event_samples (const WriterLock& lock, const Evoral::Event& ev, samplepos_t position) { - if (!_writing || ev.size() == 0) { + if (!_writing || ev.size() == 0 || ev.is_realtime()) { return; } @@ -622,15 +623,15 @@ SMFSource::mark_streaming_midi_write_started (const WriterLock& lock, NoteMode m } void -SMFSource::mark_streaming_write_completed (const WriterLock& lock) +SMFSource::mark_streaming_write_completed (const WriterLock& lm, Temporal::timecnt_t const & duration) { - mark_midi_streaming_write_completed (lock, Evoral::Sequence::DeleteStuckNotes); + mark_midi_streaming_write_completed (lm, Evoral::Sequence::DeleteStuckNotes, duration); } void -SMFSource::mark_midi_streaming_write_completed (const WriterLock& lm, Evoral::Sequence::StuckNoteOption stuck_notes_option, Temporal::Beats when) +SMFSource::mark_midi_streaming_write_completed (const WriterLock& lm, Evoral::Sequence::StuckNoteOption stuck_notes_option, Temporal::timecnt_t const & duration) { - MidiSource::mark_midi_streaming_write_completed (lm, stuck_notes_option, when); + MidiSource::mark_midi_streaming_write_completed (lm, stuck_notes_option, duration); if (!writable()) { warning << string_compose ("attempt to write to unwritable SMF file %1", _path) << endmsg; @@ -638,10 +639,11 @@ SMFSource::mark_midi_streaming_write_completed (const WriterLock& lm, Evoral::Se } if (_model) { - _model->set_edited(false); + _model->set_edited (false); } try { + Evoral::SMF::set_duration (duration.beats()); Evoral::SMF::end_write (_path); } catch (std::exception & e) { error << string_compose (_("Exception while writing %1, file may be corrupt/unusable"), _path) << endmsg; @@ -812,6 +814,7 @@ SMFSource::load_model_unlocked (bool force_reload) } _num_channels = _used_channels.size(); + _length = duration(); eventlist.sort(compare_eventlist); diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc index 3a26d38505..4fc20558f3 100644 --- a/libs/ardour/track.cc +++ b/libs/ardour/track.cc @@ -592,9 +592,9 @@ Track::steal_write_source_name() } void -Track::reset_write_sources (bool r, bool force) +Track::reset_write_sources () { - _disk_writer->reset_write_sources (r, force); + _disk_writer->reset_write_sources (); } float diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index fb84925ac6..93ecabb0b6 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -1966,6 +1966,8 @@ AudioTrigger::captured (SlotArmInfo& ai, BufferSet&) _box.queue_explict (index()); + TriggerBox::worker->request_build_source (this, timecnt_t (data.length)); + _armed = false; ArmChanged(); /* EMIT SIGNAL */ TriggerArmChanged (this); @@ -2452,8 +2454,11 @@ MIDITrigger::captured (SlotArmInfo& ai, BufferSet& bufs) old_rt_midibuffer = rt_midibuffer.exchange (ai.midi_buf); + Temporal::TempoMap::SharedPtr tmap (Temporal::TempoMap::use()); + timecnt_t dur = tmap->convert_duration (timecnt_t (ai.captured), timepos_t (ai.start_samples), Temporal::BeatTime); + loop_start = Temporal::Beats(); - loop_end = (*ai.midi_buf)[ai.midi_buf->size()-1].timestamp; + loop_end = dur.beats(); data_length = loop_end; _follow_length = Temporal::BBT_Offset (0, data_length.get_beats(), 0); set_length (timecnt_t (data_length)); @@ -2471,6 +2476,9 @@ MIDITrigger::captured (SlotArmInfo& ai, BufferSet& bufs) /* Meanwhile, build a new source and region from the data now in rt_midibuffer */ + // std::cerr << "capture done, ask for a source of length " << loop_end.str() << std::endl; + TriggerBox::worker->request_build_source (this, timecnt_t (loop_end)); + _armed = false; ArmChanged(); /* EMIT SIGNAL */ TriggerArmChanged (this); @@ -3437,6 +3445,7 @@ SlotArmInfo::SlotArmInfo (Trigger& s) : slot (s) , start_samples (0) , end_samples (0) + , captured (0) , midi_buf (nullptr) , stretcher (nullptr) { @@ -3571,11 +3580,9 @@ TriggerBox::arm_from_another_thread (Trigger& slot, samplepos_t now, uint32_t ch ai->start_samples = t_samples; ai->start_beats = t_beats; - if (_data_type == DataType::AUDIO) { - ai->captured = timecnt_t (timepos_t (0), timepos_t (0)); - } else { - ai->captured = timecnt_t::from_ticks (0, timepos_t (Beats())); - } + // std::cerr << "Will start at " << t_beats.str() << std::endl; + + ai->captured = 0; _arm_info = ai; } @@ -3638,7 +3645,8 @@ TriggerBox::maybe_capture (BufferSet& bufs, samplepos_t start_sample, samplepos_ t_bbt, t_beats, t_samples, tmap, ai->slot.quantization()); ai->end_samples = t_samples; ai->end_beats = t_beats; - return; + + //std::cerr << "will end at " << t_beats.str() << " samples " << ai->start_samples << " .. " << ai->end_samples << " = " << (ai->end_samples - ai->start_samples) << std::endl; } } @@ -3665,12 +3673,14 @@ TriggerBox::maybe_capture (BufferSet& bufs, samplepos_t start_sample, samplepos_ offset = ai->start_samples - start_sample; nframes -= offset; _record_state = Recording; + // std::cerr << "Hit start @ " << ai->start_samples << " within " << start_sample << " ... " << end_sample << " offset will be " << offset << " nf " << nframes << std::endl; } if ((ai->end_samples != 0) && (start_sample <= ai->end_samples && ai->end_samples < end_sample)) { /* we're going to stop */ nframes -= (end_sample - ai->end_samples); reached_end = true; + // std::cerr << "Hit end @ " << ai->end_samples << " within " << start_sample << " ... " << end_sample << " nf " << nframes << std::endl; } /* Audio */ @@ -3686,8 +3696,6 @@ TriggerBox::maybe_capture (BufferSet& bufs, samplepos_t start_sample, samplepos_ AudioBuffer& buf (bufs.get_audio (n)); ai->audio_buf.append (buf.data() + offset, nframes, n); } - - ai->captured += timecnt_t (start_sample, timepos_t (ai->start_samples)); } n_buffers = bufs.count().n_midi(); @@ -3734,11 +3742,11 @@ TriggerBox::maybe_capture (BufferSet& bufs, samplepos_t start_sample, samplepos_ } } } - - timecnt_t dur = tmap->convert_duration (timecnt_t (nframes), timepos_t (start_sample), Temporal::BeatTime); - ai->captured += dur; } + ai->captured += nframes; + //std::cerr << "Captured " << nframes << " total " << ai->captured << std::endl; + Captured (ai->captured); /* EMIT SIGNAL */ if (reached_end) { @@ -5562,7 +5570,7 @@ TriggerBoxThread::thread_work () delete_trigger (req->trigger); break; case BuildSourceAndRegion: - build_source (req->trigger); + build_source (req->trigger, req->duration); break; default: break; @@ -5632,10 +5640,11 @@ TriggerBoxThread::request_delete_trigger (Trigger* t) } void -TriggerBoxThread::request_build_source (Trigger* t) +TriggerBoxThread::request_build_source (Trigger* t, Temporal::timecnt_t const & len) { TriggerBoxThread::Request* req = new TriggerBoxThread::Request (BuildSourceAndRegion); req->trigger = t; + req->duration = len; queue_request (req); } @@ -5646,20 +5655,20 @@ TriggerBoxThread::delete_trigger (Trigger* t) } void -TriggerBoxThread::build_source (Trigger* t) +TriggerBoxThread::build_source (Trigger* t, Temporal::timecnt_t const & duration) { MIDITrigger* mt = dynamic_cast (t); AudioTrigger* at; if (mt) { - build_midi_source (mt); + build_midi_source (mt, duration); } else if ((at = dynamic_cast (t))) { - build_audio_source (at); + build_audio_source (at, duration); } } void -TriggerBoxThread::build_audio_source (AudioTrigger* t) +TriggerBoxThread::build_audio_source (AudioTrigger* t, Temporal::timecnt_t const & duration) { Track* trk = static_cast (t->box().owner()); SourceList sources; @@ -5710,7 +5719,7 @@ TriggerBoxThread::build_audio_source (AudioTrigger* t) } void -TriggerBoxThread::build_midi_source (MIDITrigger* t) +TriggerBoxThread::build_midi_source (MIDITrigger* t, Temporal::timecnt_t const & duration) { Track* trk = static_cast (t->box().owner()); std::shared_ptr ms = t->box().session().create_midi_source_for_session (trk->name()); @@ -5729,7 +5738,7 @@ TriggerBoxThread::build_midi_source (MIDITrigger* t) ms->append_event_beats (lock, ev); } - ms->mark_streaming_write_completed (lock); + ms->mark_streaming_write_completed (lock, duration); ms->load_model (lock); } diff --git a/libs/evoral/SMF.cc b/libs/evoral/SMF.cc index f8af97be0b..caadc2d918 100644 --- a/libs/evoral/SMF.cc +++ b/libs/evoral/SMF.cc @@ -49,7 +49,7 @@ using namespace std; namespace Evoral { SMF::SMF() - : _smf (0) + : _smf (nullptr) , _smf_track (0) , _empty (true) , _n_note_on_events (0) @@ -238,7 +238,7 @@ SMF::create(const std::string& path, int track, uint16_t ppqn) _smf = smf_new(); - if (_smf == NULL) { + if (_smf == nullptr) { return -1; } @@ -508,7 +508,7 @@ SMF::begin_write() } void -SMF::end_write(string const & path) +SMF::end_write (string const & path) { Glib::Threads::Mutex::Lock lm (_smf_lock); @@ -516,6 +516,9 @@ SMF::end_write(string const & path) return; } + + + FILE* f = g_fopen (path.c_str(), "w+b"); if (f == 0) { throw FileError (path); @@ -530,20 +533,30 @@ SMF::end_write(string const & path) } void -SMF::set_length (Temporal::Beats const & b) +SMF::set_duration (Temporal::Beats const & b) { if (!_smf) { return; } + size_t their_pulses = b.to_ticks (ppqn()); + for (uint16_t n = 0; n < _smf->number_of_tracks; ++n) { smf_track_t* trk = smf_get_track_by_number (_smf, n+1); - if (trk) { - smf_track_add_eot_pulses (trk, (int) floor (b.get_ticks() * ((double) ppqn() / Temporal::ticks_per_beat))); - } + (void) smf_track_add_eot_pulses (trk, their_pulses); } } +Temporal::Beats +SMF::duration () const +{ + if (!_smf) { + return Temporal::Beats(); + } + + return Temporal::Beats::ticks_at_rate (smf_get_length_pulses (_smf), ppqn()); +} + double SMF::round_to_file_precision (double val) const { diff --git a/libs/evoral/Sequence.cc b/libs/evoral/Sequence.cc index db9615b5f3..8a04122b8c 100644 --- a/libs/evoral/Sequence.cc +++ b/libs/evoral/Sequence.cc @@ -482,6 +482,7 @@ Sequence