Compare commits
10 Commits
c8755ce8cc
...
master
Author | SHA1 | Date | |
---|---|---|---|
9f416e8e98 | |||
3540c83a36 | |||
55581825d0 | |||
0fb567a58e | |||
30dcf7206c | |||
430dd356d6 | |||
de1031a3f8 | |||
e828038729 | |||
1d0e1f84d3 | |||
9041122725 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
|||||||
# ES-5-Pipewire
|
# ES-5-Pipewire
|
||||||
es-5
|
es-5-pipewire
|
||||||
|
|
||||||
# ---> C
|
# ---> C
|
||||||
# Prerequisites
|
# Prerequisites
|
||||||
|
13
Makefile
13
Makefile
@ -1,11 +1,11 @@
|
|||||||
CXX = gcc
|
CXX = gcc
|
||||||
CXXFLAGS = -Wall
|
CXXFLAGS = -Wall
|
||||||
LDLIBS =
|
LDLIBS =
|
||||||
NAME = es-5
|
NAME = es-5-pipewire
|
||||||
LDLIBS += `pkg-config --cflags --libs libpipewire-0.3`
|
LDLIBS += `pkg-config --cflags --libs libpipewire-0.3`
|
||||||
|
|
||||||
es-5: es-5.c
|
es-5: es-5.c
|
||||||
$(CXX) $(CXXFLAGS) es-5.c -o $(NAME) $(LDLIBS)
|
$(CXX) $(CXXFLAGS) es-5.c -o $(NAME) $(LDLIBS) -lm
|
||||||
|
|
||||||
all: es-5
|
all: es-5
|
||||||
|
|
||||||
@ -13,4 +13,11 @@ clean:
|
|||||||
rm ./$(NAME)
|
rm ./$(NAME)
|
||||||
|
|
||||||
run: all
|
run: all
|
||||||
./es-5
|
./$(NAME)
|
||||||
|
|
||||||
|
debug: all
|
||||||
|
PIPEWIRE_DEBUG=5 ./$(NAME)
|
||||||
|
|
||||||
|
install: all
|
||||||
|
sudo mkdir -p /opt/$(NAME)
|
||||||
|
sudo cp ./$(NAME) /opt/$(NAME)/
|
||||||
|
27
README.md
27
README.md
@ -1,2 +1,29 @@
|
|||||||
# ES-5-Pipewire
|
# ES-5-Pipewire
|
||||||
|
|
||||||
|
A Pipewire client for the Expert Sleepers ES-5 eurorack module. Based upon [ES-5 Linx](https://github.com/CarlColglazier/ES-5Linx). This module takes eight gate inputs and converts them to a single output.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
### Requirements
|
||||||
|
- GCC
|
||||||
|
- Pipewire Development
|
||||||
|
|
||||||
|
#### Fedora & RHEL
|
||||||
|
```sh
|
||||||
|
sudo dnf install gcc pipewire-devel
|
||||||
|
```
|
||||||
|
#### Debian & Ubuntu
|
||||||
|
```sh
|
||||||
|
sudo apt install gcc pipewire-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build
|
||||||
|
```sh
|
||||||
|
make
|
||||||
|
```
|
||||||
|
## Install
|
||||||
|
```sh
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
This will build the binary and copy it over to the `/opt/es-5-pipewire` directory.
|
||||||
|
131
es-5.c
131
es-5.c
@ -1,6 +1,135 @@
|
|||||||
|
#include <math.h>
|
||||||
|
#include <spa/param/latency-utils.h>
|
||||||
#include <pipewire/pipewire.h>
|
#include <pipewire/pipewire.h>
|
||||||
|
|
||||||
|
#define ES_5_RANGE 128
|
||||||
|
#define GATE_LOW_EDGE 0.1
|
||||||
|
|
||||||
|
struct data;
|
||||||
|
|
||||||
|
struct port {
|
||||||
|
struct data *data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct data {
|
||||||
|
struct pw_main_loop *loop;
|
||||||
|
struct pw_filter *filter;
|
||||||
|
struct port *in_ports[8];
|
||||||
|
struct port *out_port;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void on_process(void *userdata, struct spa_io_position *position) {
|
||||||
|
struct data *data = userdata;
|
||||||
|
float *in, *out;
|
||||||
|
uint32_t i, n_samples = position->clock.duration;
|
||||||
|
float signal = 0.5f;
|
||||||
|
|
||||||
|
// Read Inputs 1-7
|
||||||
|
out = pw_filter_get_dsp_buffer(data->out_port, n_samples);
|
||||||
|
if (out == NULL) return;
|
||||||
|
for (int input = 0; input < 7; input++) {
|
||||||
|
in = pw_filter_get_dsp_buffer(data->in_ports[input], n_samples);
|
||||||
|
if(in != NULL && *in > GATE_LOW_EDGE) {
|
||||||
|
signal += powf(2, input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read Input 8
|
||||||
|
in = pw_filter_get_dsp_buffer(data->in_ports[7], n_samples);
|
||||||
|
if(in != NULL && *in > GATE_LOW_EDGE) {
|
||||||
|
signal = -ES_5_RANGE+signal;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert signal to expect output scale
|
||||||
|
signal = signal / ES_5_RANGE;
|
||||||
|
|
||||||
|
// Send to output
|
||||||
|
for (i = 0; i < n_samples; i++) {
|
||||||
|
*out++ = signal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void do_quit(void *userdata, int signal_number) {
|
||||||
|
struct data *data = userdata;
|
||||||
|
pw_main_loop_quit(data->loop);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct pw_filter_events filter_events = {
|
||||||
|
PW_VERSION_FILTER_EVENTS,
|
||||||
|
.process = on_process,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct port* add_port(char* name, struct data data) {
|
||||||
|
return pw_filter_add_port(data.filter,
|
||||||
|
PW_DIRECTION_INPUT,
|
||||||
|
PW_FILTER_PORT_FLAG_MAP_BUFFERS,
|
||||||
|
sizeof(struct port),
|
||||||
|
pw_properties_new(
|
||||||
|
PW_KEY_FORMAT_DSP, "32 bit float mono audio",
|
||||||
|
PW_KEY_PORT_NAME, name,
|
||||||
|
NULL),
|
||||||
|
NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
struct data data = { 0, };
|
||||||
|
const struct spa_pod *params[1];
|
||||||
|
uint8_t buffer[1024];
|
||||||
|
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
||||||
|
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
|
|
||||||
|
data.loop = pw_main_loop_new(NULL);
|
||||||
|
|
||||||
|
pw_loop_add_signal(pw_main_loop_get_loop(data.loop), SIGINT, do_quit, &data);
|
||||||
|
pw_loop_add_signal(pw_main_loop_get_loop(data.loop), SIGTERM, do_quit, &data);
|
||||||
|
|
||||||
|
data.filter = pw_filter_new_simple(
|
||||||
|
pw_main_loop_get_loop(data.loop),
|
||||||
|
"ES-5",
|
||||||
|
pw_properties_new(
|
||||||
|
PW_KEY_MEDIA_TYPE, "Audio",
|
||||||
|
PW_KEY_MEDIA_CATEGORY, "Filter",
|
||||||
|
PW_KEY_MEDIA_ROLE, "DSP",
|
||||||
|
NULL),
|
||||||
|
&filter_events,
|
||||||
|
&data);
|
||||||
|
|
||||||
|
data.in_ports[0] = add_port("input_1", data);
|
||||||
|
data.in_ports[1] = add_port("input_2", data);
|
||||||
|
data.in_ports[2] = add_port("input_3", data);
|
||||||
|
data.in_ports[3] = add_port("input_4", data);
|
||||||
|
data.in_ports[4] = add_port("input_5", data);
|
||||||
|
data.in_ports[5] = add_port("input_6", data);
|
||||||
|
data.in_ports[6] = add_port("input_7", data);
|
||||||
|
data.in_ports[7] = add_port("input_8", data);
|
||||||
|
|
||||||
|
data.out_port = pw_filter_add_port(data.filter,
|
||||||
|
PW_DIRECTION_OUTPUT,
|
||||||
|
PW_FILTER_PORT_FLAG_MAP_BUFFERS,
|
||||||
|
sizeof(struct port),
|
||||||
|
pw_properties_new(
|
||||||
|
PW_KEY_FORMAT_DSP, "32 bit float mono audio",
|
||||||
|
PW_KEY_PORT_NAME, "output",
|
||||||
|
NULL),
|
||||||
|
NULL, 0);
|
||||||
|
|
||||||
|
params[0] = spa_process_latency_build(&b,
|
||||||
|
SPA_PARAM_ProcessLatency,
|
||||||
|
&SPA_PROCESS_LATENCY_INFO_INIT(
|
||||||
|
.ns = 10 * SPA_NSEC_PER_MSEC
|
||||||
|
));
|
||||||
|
|
||||||
|
if (pw_filter_connect(data.filter,
|
||||||
|
PW_FILTER_FLAG_RT_PROCESS,
|
||||||
|
params, 1) < 0) {
|
||||||
|
fprintf(stderr, "can't connect\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pw_main_loop_run(data.loop);
|
||||||
|
|
||||||
|
pw_filter_destroy(data.filter);
|
||||||
|
pw_main_loop_destroy(data.loop);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user