Skip to content

Commit

Permalink
fixes and py script update.
Browse files Browse the repository at this point in the history
formuls is now able to compile into a standalone with pyinstaller (and some jiggery pokery file moving).

Signed-off-by: jrdooley <[email protected]>
  • Loading branch information
jrdooley committed Dec 16, 2022
1 parent 9e32647 commit 56392b9
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 75 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified build/.DS_Store
Binary file not shown.
Binary file modified src/.DS_Store
Binary file not shown.
15 changes: 6 additions & 9 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@ else
endif
endif

LIBPD_DIR = ../libs/libpd
LIBPD_DIR = ./libs/libpd
LIBPD = $(LIBPD_DIR)/libs/libpd.$(SOLIB_EXT)

abl_link~.class.sources = externals/abl_link~.cpp externals/abl_link_instance.cpp

SRC_FILES = formulsengine/PdObject.cpp formulsengine/main.cpp formulsengine/RtAudio.cpp
EXT_FILES = external/abl_link~.cpp external/abl_link_instance.cpp
TARGET = ../../build/formulsengine
TARGET = ../build/formulsengine

CXXFLAGS += -I$(LIBPD_DIR)/pure-data/src -I$(LIBPD_DIR)/libpd_wrapper \
-I$(LIBPD_DIR)/libpd_wrapper/util -I$(LIBPD_DIR)/cpp \
Expand All @@ -50,19 +47,19 @@ CXXFLAGS += -I$(LIBPD_DIR)/pure-data/src -I$(LIBPD_DIR)/libpd_wrapper \
$(TARGET): ${SRC_FILES:.cpp=.o} $(LIBPD)
g++ -o $(TARGET) $^ $(LIBPD) $(AUDIO_API)
ifeq ($(PLATFORM), mac)
mkdir -p ../../build/libs && cp $(LIBPD) ../../build/libs
mkdir -p ../../build/pd && cp -r ./pd ../../build/
mkdir -p ../build/ && cp $(LIBPD) ../build/
mkdir -p ../build/pd && cp -r ./pd ../build/
endif

$(LIBPD):
cd $(LIBPD_DIR) && make UTIL=true EXTRA=true

clean:
rm -f formulsengine/*.o
rm -f src/*.o

clobber: clean
rm -f $(TARGET)
ifeq ($(PLATFORM), mac)
rm -rf ./libs
endif
cd $(LIBPD_DIR) && make clobber
cd $(LIBPD_DIR) && make clobber
3 changes: 2 additions & 1 deletion src/faust/ffx.lib
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ with{
//------------REPEATER------//
// Glitchy tempo-synchronised repeater effect.
// Two delayensembles act like "voices", ensuring audio is always present in a delay line and captured immediately after the capture button has been released
repeater = _,_ <: delayensemble(0),delayensemble(1) :> _,_
repeater = _,_ <: delayensemble(0),delayensemble(1) :> _,_ <: sp.stereoize(_ *(1-(mono))), (sp.stereoize(_ *(mono)) : + <: si.bus(2)) :> _,_
with {
tempo = hslider("bpm",120,1,240,1) : 60/(_) : ba.sec2samp(_); // global tempo
divl = hslider("beatdivisionl",1,1,5,1) : int; //sample/capture duration in beats
divr = hslider("beatdivisionr",1,1,5,1) : int; //sample/capture duration in beats
capl = button("capturel"); // capture some sound!
capr = button("capturer"); // capture some sound!
mono = checkbox("repeatermono") : si.smoo; //sums channels together or creates true stereo glitching
level = hslider("repeaterlevel",1,0,1,0.01) : pow(2.7) : si.smoo; // effect level

capcountl = +(1)~(ba.sAndH(capl : ba.impulsify)) : %(2) : int;
Expand Down
32 changes: 23 additions & 9 deletions src/formuls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
#!/usr/bin/env python3

import sounddevice as sd
import os
import sys
from tkinter import *
import pathlib

def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")

return os.path.join(base_path, relative_path)

# Create main window
mainWindow =Tk()
Expand Down Expand Up @@ -35,30 +46,33 @@
def RUN():
deviceGet = clicked.get()
audioOutput = deviceGet[0]
command1 = "./gui/node ./gui/open-stage-control/ -s 127.0.0.1:9000 -o 9001 -l ./gui/_main.json --client-options framerate=25 hdpi=0 &" # run o-s-c interface
command2 = "./formulsengine 1 " + audioOutput + " 16 &" # audio process
command3 = "./formulsengine 0 " + audioOutput + " 1 &" # control process
# command0 = "cd " + resource_path("")
command1 = resource_path("gui/node") + " " + resource_path("gui/open-stage-control/") + " -s 127.0.0.1:9000 -o 9001 -l " + resource_path("gui/_main.json") + " --client-options framerate=25 hdpi=0 &" # run o-s-c interface
command2 = "cd " + resource_path("") + "; " + resource_path("pd/formulsengine") + " 1 " + audioOutput + " 16 &" # audio process
command3 = "cd " + resource_path("") + "; " + resource_path("pd/formulsengine") + " 0 " + audioOutput + " 1 &" # control process
# os.system(command0)
os.system(command1)
os.system(command2)
os.system(command3)
os.system("pwd")

# function to stop formulsengines and node/open stage control
def STOP():
os.system("killall formulsengine")
os.system("killall node")

# function to kill all subprocesses and quit
# function to kill all subprocesses and exit the program
def QUIT():
os.system("killall formulsengine")
os.system("killall node")
quit()
sys.exit()

# load images for run, stop and quit buttons
runicon = PhotoImage(file = r"icons/run.png")
runicon = PhotoImage(file = resource_path("icons/run.png"))
runicon = runicon.subsample(2,2)
stopicon = PhotoImage(file = r"icons/stop.png")
stopicon = PhotoImage(file = resource_path("icons/stop.png"))
stopicon = stopicon.subsample(2,2)
quiticon = PhotoImage(file = r"icons/quit.png")
quiticon = PhotoImage(file = resource_path("icons/quit.png"))
quiticon = quiticon.subsample(3,3)

# create run, stop and quit buttons
Expand Down
Binary file added src/formulsengine/PdObject.o
Binary file not shown.
Binary file added src/formulsengine/RtAudio.o
Binary file not shown.
8 changes: 0 additions & 8 deletions src/formulsengine/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
#include "PdBase.hpp"
#include "RtAudio.h"
#include "PdObject.h"
#include "external/abl_link~.hpp"
#include "external/z_libpd.h"

// extern "C" {
// void abl_link_tilde_setup();
// }

RtAudio audio;
pd::PdBase lpd;
Expand All @@ -45,8 +39,6 @@ void init(int thepatch, int deviceSelect, int channelsOut){ // JD: "int deviveS
exit(1);
}

abl_link_tilde_setup();

// receive messages from pd
lpd.setReceiver(&pdObject);
lpd.subscribe("cursor");
Expand Down
Binary file added src/formulsengine/main.o
Binary file not shown.
68 changes: 57 additions & 11 deletions src/gui/_main.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@
"off": 0,
"mode": "toggle",
"doubleTap": false,
"value": "",
"default": "",
"value": 1,
"default": 1,
"linkId": "",
"address": "/@{this.id}",
"preArgs": "",
Expand Down Expand Up @@ -434,7 +434,7 @@
"sensitivity": 1,
"steps": 240,
"origin": "auto",
"value": "",
"value": 110,
"default": 110,
"linkId": "",
"address": "auto",
Expand Down Expand Up @@ -889,7 +889,7 @@
"padding": 1,
"html": "",
"css": "font-size: 150%",
"value": "",
"value": 3,
"default": 3,
"linkId": "",
"address": "auto",
Expand Down Expand Up @@ -1865,8 +1865,8 @@
"sensitivity": 1,
"steps": "",
"origin": "auto",
"value": "",
"default": "",
"value": 1,
"default": 1,
"linkId": "",
"address": "auto",
"preArgs": "",
Expand Down Expand Up @@ -2539,7 +2539,7 @@
"visible": true,
"interaction": true,
"comments": "",
"width": "30%",
"width": "25%",
"height": "25%",
"expand": true,
"colorText": "auto",
Expand Down Expand Up @@ -2580,12 +2580,58 @@
{
"type": "button",
"top": "25%",
"left": "33.3%",
"left": "25%",
"id": "repeatermono",
"visible": true,
"interaction": true,
"comments": "",
"width": "25%",
"height": "25%",
"expand": true,
"colorText": "auto",
"colorWidget": "auto",
"colorStroke": "auto",
"colorFill": "auto",
"alphaStroke": 1,
"alphaFillOff": "auto",
"alphaFillOn": "auto",
"lineWidth": 5,
"padding": 0,
"html": "",
"css": "",
"colorTextOn": "auto",
"label": "MONO",
"vertical": false,
"wrap": false,
"on": 1,
"off": 0,
"mode": "toggle",
"doubleTap": false,
"value": "",
"default": "",
"linkId": "",
"address": "/@{this.id}",
"preArgs": "",
"typeTags": "",
"decimals": 2,
"target": "",
"ignoreDefaults": false,
"bypass": false,
"onValue": "",
"onCreate": "",
"lock": false,
"borderRadius": "auto",
"decoupled": false
},
{
"type": "button",
"top": "25%",
"left": "50%",
"id": "repeaterlinked",
"visible": true,
"interaction": true,
"comments": "",
"width": "33.3%",
"width": "25%",
"height": "25%",
"expand": true,
"colorText": "auto",
Expand Down Expand Up @@ -2626,12 +2672,12 @@
{
"type": "button",
"top": "25%",
"left": "70%",
"left": "75%",
"id": "repeaterhold",
"visible": true,
"interaction": true,
"comments": "",
"width": "30%",
"width": "25%",
"height": "25%",
"expand": true,
"colorText": "auto",
Expand Down
Binary file modified src/libs/.DS_Store
Binary file not shown.
78 changes: 41 additions & 37 deletions src/pd/_main-control.pd
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,14 @@ rollingfreezerdrylevelchaos rollingfreezerfeedback;
#X connect 52 7 10 0;
#X connect 53 0 54 0;
#X restore 23 92 pd ROLLINGFREEZER________;
#N canvas 439 163 567 636 REPEATER______________ 0;
#N canvas 439 163 614 725 REPEATER______________ 0;
#X obj 34 21 inlet;
#X obj 476 595 outlet;
#X msg 34 587 parallel \$1;
#X obj 82 555 s \$0-master-bus-fx;
#X obj 34 608 s \$0-master-bus-fx;
#X msg 130 455 capture \$1;
#X msg 217 432 beatdivision \$1;
#X obj 476 685 outlet;
#X msg 34 637 parallel \$1;
#X obj 82 605 s \$0-master-bus-fx;
#X obj 34 658 s \$0-master-bus-fx;
#X msg 130 505 capture \$1;
#X msg 217 482 beatdivision \$1;
#N canvas 360 421 686 457 REPEATER____ 0;
#X obj 58 39 inlet;
#X obj 58 170 sel 0 1;
Expand Down Expand Up @@ -492,14 +492,14 @@ rollingfreezerdrylevelchaos rollingfreezerfeedback;
#X connect 28 0 30 0;
#X connect 29 0 20 0;
#X connect 30 0 20 0;
#X restore 130 407 pd REPEATER____;
#X obj 130 476 s \$0-master-bus-fx;
#X obj 217 453 s \$0-master-bus-fx;
#X obj 82 513 f.seq.automater \$0 \$0-repeaterlevel 1;
#X obj 179 358 == 0;
#X obj 179 379 s \$0-repeater-hold;
#X obj 191 535 s \$0-repeater-level-gui;
#X obj 227 346 s \$0-master-bus-fx;
#X restore 130 457 pd REPEATER____;
#X obj 130 526 s \$0-master-bus-fx;
#X obj 217 503 s \$0-master-bus-fx;
#X obj 82 563 f.seq.automater \$0 \$0-repeaterlevel 1;
#X obj 179 408 == 0;
#X obj 179 429 s \$0-repeater-hold;
#X obj 191 585 s \$0-repeater-level-gui;
#X obj 227 396 s \$0-master-bus-fx;
#N canvas 822 512 527 375 REPEATER_RANDOM__ 0;
#N canvas 63 231 699 723 RANDOM_BEAT_DIV___ 0;
#X obj 67 49 r link;
Expand Down Expand Up @@ -769,13 +769,13 @@ rollingfreezerdrylevelchaos rollingfreezerfeedback;
#X connect 20 2 14 1;
#X connect 20 2 13 1;
#X connect 21 0 16 1;
#X restore 227 324 pd REPEATER_RANDOM__;
#X obj 276 294 s \$0-master-bus-fx;
#X obj 276 188 unpack s f;
#X obj 276 210 list fromsymbol;
#X obj 276 230 f.util.asci2char;
#X obj 276 251 pack f f;
#X msg 276 273 repeaterinput \$1 \$2;
#X restore 227 374 pd REPEATER_RANDOM__;
#X obj 276 344 s \$0-master-bus-fx;
#X obj 276 238 unpack s f;
#X obj 276 260 list fromsymbol;
#X obj 276 280 f.util.asci2char;
#X obj 276 301 pack f f;
#X msg 276 323 repeaterinput \$1 \$2;
#N canvas 1309 247 345 275 beatdivprocessing 0;
#X obj 50 25 inlet;
#X obj 50 62 fudiformat;
Expand All @@ -790,13 +790,15 @@ rollingfreezerdrylevelchaos rollingfreezerfeedback;
#X connect 4 0 5 0;
#X connect 5 0 3 0;
#X connect 5 1 3 1;
#X restore 324 166 pd beatdivprocessing;
#X msg 82 534 repeaterlevel \$1;
#X obj 34 79 route repeaterparallel repeaterlevel repeaterbeatdivision
#X restore 324 216 pd beatdivprocessing;
#X msg 82 584 repeaterlevel \$1;
#X obj 330 185 s \$0-repeater-linked;
#X obj 34 59 route repeaterparallel repeaterlevel repeaterbeatdivision
repeaterhold repeaterrandom repeaterinput repeaterbeatdivisionsactive
repeaterlinked;
#X obj 330 135 s \$0-repeater-linked;
#X connect 0 0 24 0;
repeaterlinked repeatermono;
#X obj 342 136 s \$0-master-bus-fx;
#X msg 341 114 repeatermono \$1;
#X connect 0 0 25 0;
#X connect 2 0 4 0;
#X connect 5 0 8 0;
#X connect 6 0 9 0;
Expand All @@ -813,15 +815,17 @@ repeaterlinked;
#X connect 20 0 21 0;
#X connect 21 0 16 0;
#X connect 23 0 3 0;
#X connect 24 0 2 0;
#X connect 24 1 10 0;
#X connect 24 2 7 0;
#X connect 24 3 11 0;
#X connect 24 4 15 0;
#X connect 24 5 17 0;
#X connect 24 6 22 0;
#X connect 24 7 25 0;
#X connect 24 8 1 0;
#X connect 25 0 2 0;
#X connect 25 1 10 0;
#X connect 25 2 7 0;
#X connect 25 3 11 0;
#X connect 25 4 15 0;
#X connect 25 5 17 0;
#X connect 25 6 22 0;
#X connect 25 7 24 0;
#X connect 25 8 27 0;
#X connect 25 9 1 0;
#X connect 27 0 26 0;
#X restore 23 114 pd REPEATER______________;
#N canvas 880 60 640 677 REVERB_FILTER_LIMITER_ 0;
#X obj 23 19 inlet;
Expand Down

0 comments on commit 56392b9

Please sign in to comment.