From 5179ace697f702d7103c9aa6e26478363e0f6a4d Mon Sep 17 00:00:00 2001 From: rcerc <88944439+rcerc@users.noreply.github.com> Date: Thu, 19 Jun 2025 16:39:47 -0400 Subject: Rudimentary streaming of raw MIDI over multicast UDP --- midimcast.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 midimcast.c (limited to 'midimcast.c') diff --git a/midimcast.c b/midimcast.c new file mode 100644 index 0000000..6ad047f --- /dev/null +++ b/midimcast.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include + +#include "midimcast.h" + +void env_read_common(const char **const mcast_group, uint16_t *const mcast_port) +{ + midimcast_debug = getenv("DEBUG") != NULL; + + *mcast_group = getenv("MCAST_GROUP"); + if (!*mcast_group) + *mcast_group = "224.212.21.175"; + debug("Using multicast group %s", *mcast_group); + + const char *const mcast_port_str = getenv("MCAST_PORT"); + if (mcast_port_str) { + const long mcast_port_untrunc = strtol(mcast_port_str, NULL, 0); + if (mcast_port_untrunc < 0 || mcast_port_untrunc > UINT16_MAX) + err("Port %ld does not exist", mcast_port_untrunc); + *mcast_port = mcast_port_untrunc; + } else { + *mcast_port = 8000; + } + debug("Using multicast port %" PRIu16, *mcast_port); +} + +uint64_t now() { + struct timespec ts; + err_std(clock_gettime, CLOCK_REALTIME, &ts); + return ts.tv_sec * 1000 + ts.tv_nsec / 1000000; +} -- cgit v1.2.3