Compare commits
2 Commits
13e5f50154
...
001931a1fa
Author | SHA1 | Date |
---|---|---|
Bailey Stevens | 001931a1fa | |
Bailey Stevens | c487112a58 |
57
flake.lock
57
flake.lock
|
@ -33,6 +33,24 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_3": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1694529238,
|
||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"napalm": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
|
@ -70,11 +88,33 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"phyzzy": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_3",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1696417150,
|
||||
"narHash": "sha256-9b9JcfaA9T7kDt0f31unUqYgTe5S7JMrcZMkHQdKZUE=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "2097785400b5eadf9110167eba55290de98691c5",
|
||||
"revCount": 22,
|
||||
"type": "git",
|
||||
"url": "https://fem.mint.lgbt/mmelodies/phyzzy.git"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://fem.mint.lgbt/mmelodies/phyzzy.git"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"napalm": "napalm",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": "nixpkgs",
|
||||
"phyzzy": "phyzzy"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
|
@ -91,6 +131,21 @@
|
|||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
phyzzy.url = "git+https://fem.mint.lgbt/mmelodies/phyzzy.git";
|
||||
phyzzy.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
napalm.url = "github:nix-community/napalm";
|
||||
napalm.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
@ -35,6 +39,7 @@
|
|||
mmelodies = {
|
||||
frontend = final.callPackage ./default.nix {};
|
||||
backend = final.callPackage ./backend {};
|
||||
synth = final.callPackage (import inputs.phyzzy) {};
|
||||
};
|
||||
});
|
||||
};
|
||||
|
|
|
@ -28,6 +28,19 @@
|
|||
};
|
||||
};
|
||||
|
||||
systemd.services.phyzzy = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
User = "appuser";
|
||||
Group = "audio";
|
||||
ExecStart = "${pkgs.mmelodies.synth}/bin/phyzzy -nogui";
|
||||
|
||||
Restart = "always";
|
||||
CPUSchedulingPolicy = "fifo";
|
||||
CPUSchedulingPriority = "20";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d /run/mmelodies 0755 nginx nginx 12h -"
|
||||
];
|
||||
|
|
|
@ -2,20 +2,47 @@ import * as THREE from 'three';
|
|||
// @ts-ignore
|
||||
import { UpdateRequest, Update } from "/proto/mmelodies.proto";
|
||||
|
||||
const url = new URL("/api", location.href);
|
||||
const send = document.querySelector("#send");
|
||||
// Subscribe to the audioprocess event
|
||||
let socket: WebSocket | null = null;
|
||||
function connect_ws() {
|
||||
const url = new URL("/api", location.href);
|
||||
|
||||
url.protocol = "ws";
|
||||
if (location.protocol.startsWith("https")) {
|
||||
url.protocol = "wss";
|
||||
url.protocol = "ws";
|
||||
if (location.protocol.startsWith("https")) {
|
||||
url.protocol = "wss";
|
||||
}
|
||||
|
||||
const ws = new WebSocket(url);
|
||||
ws.binaryType = "arraybuffer";
|
||||
|
||||
ws.addEventListener("open", () => {
|
||||
const message = UpdateRequest.create({ paramRefresh: true});
|
||||
const request = UpdateRequest.encode(message).finish();
|
||||
if (socket) {
|
||||
socket.send(request);
|
||||
}
|
||||
});
|
||||
|
||||
ws.addEventListener("error", (event) => {
|
||||
console.log(event);
|
||||
});
|
||||
|
||||
ws.addEventListener("close", () => {
|
||||
socket = null;
|
||||
setTimeout(() => {
|
||||
socket = connect_ws();
|
||||
}, 2500);
|
||||
});
|
||||
|
||||
// Listen for messages
|
||||
ws.addEventListener("message", (event) => {
|
||||
const message = Update.decode(new Uint8Array(event.data));
|
||||
console.log(message);
|
||||
});
|
||||
|
||||
return ws;
|
||||
}
|
||||
const socket = new WebSocket(url);
|
||||
socket.binaryType = 'arraybuffer'
|
||||
|
||||
socket.addEventListener("message", (event) => {
|
||||
const message = Update.decode(new Uint8Array(event.data));
|
||||
console.log(message);
|
||||
});
|
||||
socket = connect_ws();
|
||||
|
||||
// Select all range input elements
|
||||
const sliders = document.querySelectorAll(
|
||||
|
@ -27,10 +54,12 @@ sliders.forEach((slider, i) => {
|
|||
slider.addEventListener("input", function () {
|
||||
console.log(`Slider ${this.id} position: ${this.value}`);
|
||||
|
||||
const message = UpdateRequest.create({ paramChanges: [{ id: i, value: this.value }] });
|
||||
const buffer = UpdateRequest.encode(message).finish();
|
||||
if (socket) {
|
||||
const message = UpdateRequest.create({ paramChanges: [{ id: i, value: this.value }] });
|
||||
const buffer = UpdateRequest.encode(message).finish();
|
||||
|
||||
socket.send(buffer);
|
||||
socket.send(buffer);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -256,4 +285,4 @@ if (window.AbsoluteOrientationSensor) {
|
|||
} else {
|
||||
// Log a message to the console if AbsoluteOrientationSensor is not supported
|
||||
console.log('AbsoluteOrientationSensor is not supported in this browser.');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue