Skip to content

Instantly share code, notes, and snippets.

@giuliomoro
giuliomoro / inotify.cpp
Created February 8, 2024 21:18
inotify watcher
#include <errno.h>
#include <poll.h>
#include <unistd.h>
#include <string.h>
std::vector<InotifyPath> watchPaths(const std::vector<std::string>& paths, unsigned int timeoutMs, int flags)
{
// largely taken from main inotify
std::vector<InotifyPath> files;
std::vector<int> wd;
@giuliomoro
giuliomoro / _main.pd
Last active November 9, 2023 13:04
Reading BeagleBone/PocketBeagle's ADCs from Pd on Bela. Based on core/default_libpd_render.cpp from github.com/BelaPlatform/Bela @ 66a872b9368a6ae4b54a2ace3a2b2568725c078c
#N canvas 313 359 450 300 12;
#X obj 114 145 print;
#X obj 118 113 r bela_lowResAnalogIn;
#X connect 1 0 0 0;
#include <Bela.h>
#include "RNBO.h"
#include <string>
#include <MiscUtilities.h>
#include <algorithm>
//#define BELA_RNBO_USE_TRILL // uncomment to use Trill
#ifdef BELA_RNBO_USE_TRILL
#include <libraries/Trill/Trill.h>
#endif // BELA_RNBO_USE_TRILL
@giuliomoro
giuliomoro / uEnv.txt
Created November 23, 2022 23:57
Stuff for CTAG on 5.10
#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0
uname_r=5.10.145+
#uuid=
#dtb=
###U-Boot Overlays###
###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays
###Master Enable
enable_uboot_overlays=1
@giuliomoro
giuliomoro / Makefile
Created October 7, 2022 09:03
hvcc basic build on macos 10.14.6
C_SRCS:=$(wildcard c/*.c)
CXX_SRCS:=$(wildcard c/*.cpp hvwrap.cpp)
C_OBJS:=$(C_SRCS:%.c=%.o)
CXX_OBJS:=$(CXX_SRCS:%.cpp=%.o)
CPPFLAGS:=-Ic -include aligned_alloc.h
CXXFLAGS:=-std=c++14
CFLAGS:=-std=c11
CXX:=clang++
CC:=clang
@giuliomoro
giuliomoro / _main.pd
Last active October 12, 2023 19:28
An example _main.pd to use on Bela . Make sure the branch of Bela you are using has support for BELA_LIBPD_SERIAL in Bela/core/default_libpd_render.cpp
#N canvas 368 72 801 510 12;
#X obj 104 216 s bela_setSerial;
#X obj 342 251 r bela_serial;
#X obj 104 21 loadbang;
#X obj 128 362 unpack f f f f f f;
#X obj 128 405 pack f f f f f f;
#X obj 127 444 print floats;
#X obj 346 372 unpack s s s s s s;
#X obj 346 408 pack s s s s s s;
#X obj 345 447 print symbols;
// based on default_libpd_render.cpp at 319c9f9fd6c8af38a8336161c252d86315a2380a. Estimates CPU usage for the patch by processing
// several seconds of audio in setup() and printing the estimated CPU time. Then it exits.
// check for modifications "CPU_METER"
/*
* Default render file for Bela projects running Pd patches
* using libpd.
*/
#include <Bela.h>
@giuliomoro
giuliomoro / Evo.h
Last active May 6, 2021 17:09
Bela: libpd + EVO time-of-flight sensor, implemented in C++
#include <I2c.h>
class Evo : public I2c
{
public:
int readI2C() override {
i2c_char_t c = 0;
if(write(i2C_file, &c, sizeof(c)) != sizeof(c))
{
// error, abort
@giuliomoro
giuliomoro / _main.pd
Created March 29, 2021 12:37
Bela: libpd + HC-SR04 ultrasonic distance sensor, implemented in C++
#N canvas 0 22 450 300 12;
#X obj 37 37 r distance;
#X obj 76 90 print;
#X connect 0 0 1 0;
@giuliomoro
giuliomoro / _main.pd
Created March 14, 2021 19:14
HC-SR04 for Pd on Bela, sample-accurate
#N canvas 87 19 1280 778 12;
#X obj 160 234 samphold~;
#X floatatom 160 311 7 0 0 0 - - -;
#X obj 160 279 snapshot~;
#X obj 49 138 loadbang;
#X obj 51 181 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
1;
#X obj 806 40 loadbang;
#X obj 808 83 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
1;