Compare commits

...

8 Commits

4 changed files with 82 additions and 23 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
# ES-5-Pipewire
es-5
es-5-pipewire
# ---> C
# Prerequisites

View File

@ -1,11 +1,11 @@
CXX = gcc
CXXFLAGS = -Wall
LDLIBS =
NAME = es-5
NAME = es-5-pipewire
LDLIBS += `pkg-config --cflags --libs libpipewire-0.3`
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
@ -13,4 +13,11 @@ clean:
rm ./$(NAME)
run: all
./es-5
./$(NAME)
debug: all
PIPEWIRE_DEBUG=5 ./$(NAME)
install: all
sudo mkdir -p /opt/$(NAME)
sudo cp ./$(NAME) /opt/$(NAME)/

View File

@ -1,2 +1,29 @@
# 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.

61
es-5.c
View File

@ -1,7 +1,10 @@
#include <math.h>
#include <spa/param/latency-utils.h>
#include <pipewire/pipewire.h>
#define ES_5_RANGE 128
#define GATE_LOW_EDGE 0.1
struct data;
struct port {
@ -11,18 +14,40 @@ struct port {
struct data {
struct pw_main_loop *loop;
struct pw_filter *filter;
struct port *in_port_one;
struct port *in_port_two;
struct port *in_port_three;
struct port *in_port_four;
struct port *in_port_five;
struct port *in_port_six;
struct port *in_port_seven;
struct port *in_port_eight;
struct port *in_ports[8];
struct port *out_port;
};
static void on_process(void *userdata, struct spa_io_position *position) {}
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;
@ -70,14 +95,14 @@ int main(int argc, char *argv[]) {
&filter_events,
&data);
data.in_port_one = add_port("input_1", data);
data.in_port_two = add_port("input_2", data);
data.in_port_three = add_port("input_3", data);
data.in_port_four = add_port("input_4", data);
data.in_port_five = add_port("input_5", data);
data.in_port_six = add_port("input_6", data);
data.in_port_seven = add_port("input_7", data);
data.in_port_eight = add_port("input_8", 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,