Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
filterd
fctrl
*.o
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib"]
path = lib
url = git@github.com:tuneraudio/tunerlib.git
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
OUT = filterd
SRC = ${wildcard *.c}
OBJ = ${SRC:.c=.o}

CFLAGS:=-std=gnu99 \
-Wall -Wextra -pedantic \
-Ilib/include \
${CFLAGS}

LDFLAGS:=-ljack -lm -lpthread \
-Llib -ltuner \
${LDFLAGS}

${OUT}: lib ${OBJ}
${CC} -o $@ ${OBJ} ${LDFLAGS}

client lib:
${MAKE} -C $@

clean:
${RM} ${OUT} ${OBJ}

.PHONY: clean lib client install uninstall
1 change: 0 additions & 1 deletion README

This file was deleted.

43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# README

This code creates a simple jack client that takes a specified biquad
filter and processes audio passed to the client via the jack audio
server.

## Overview

To properly use this client you must run two separate processes. The
first is the jack client (`fctrl`) which processes real time audio and
acts as a Unix socket server, and the second is a Unix socket client
(`filterd`) which transmits requests to change the state of the real
time filter.

## Building

```
git submodule update --init
make
make client
```

## Usage

To run the filter:

```
./filterd.sh
```

Then to run the client:

```
./client/fctrl
```

```
command>type={'lpf','bpf','hpf','peq','hsh','lsh'}

fc=double
g=double
bw=double
```
15 changes: 15 additions & 0 deletions client/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
OUT = fctrl
SRC = ${wildcard *.c}
OBJ = ${SRC:.c=.o}

CFLAGS:=-std=gnu99 \
-Wall -Wextra -pedantic \
${CFLAGS}

${OUT}: ${OBJ}
${CC} -o $@ ${OBJ} ${LDFLAGS}

clean:
${RM} ${OUT} ${OBJ}

.PHONY: clean install uninstall
70 changes: 70 additions & 0 deletions client/fctrl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>

#include "../filterd.h"

static inline ssize_t
prompt(char *buf, size_t size)
{
printf("command> ");
fgets(buf, size, stdin);
return buf ? (ssize_t)strlen(buf) : -1;
}

int
main(void)
{
struct sockaddr_un remote;
cmd_t command;
int fd;

if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
perror("socket");
exit(EXIT_FAILURE);
}

/* assign the socket path */
remote.sun_family = AF_UNIX;
strcpy(remote.sun_path, socket_path);

if (connect(fd, (struct sockaddr *)&remote, sizeof(remote)) == -1) {
perror("connect");
exit(EXIT_FAILURE);
}

ssize_t ret;
while ((ret = prompt(command, BUFF_SIZE))) {
/* remove \n character */
command[--ret] = '\0';

/* send message */
if (send(fd, command, ret, 0) == -1) {
perror("send");
exit(EXIT_FAILURE);
}

ret = recv(fd, command, BUFF_SIZE, 0);

if (ret == 0)
break;
else if (ret == -1) {
perror("recv");
exit(EXIT_FAILURE);
}

command[ret] = '\0';
printf("status> %s\n", command);
}

printf("Server closed connection\n");
close(fd);
return 0;
}

// vim: et:sts=4:sw=4:cino=(0
37 changes: 0 additions & 37 deletions filter_client/Makefile

This file was deleted.

31 changes: 0 additions & 31 deletions filter_client/README.md

This file was deleted.

131 changes: 0 additions & 131 deletions filter_client/biquad_df1.c

This file was deleted.

Loading