Skip to content

Instantly share code, notes, and snippets.

View audionerd's full-sized avatar

Eric Skogen audionerd

View GitHub Profile
@audionerd
audionerd / import_map.json
Last active March 10, 2023 07:24
using @xstate/react v2.0.1 in a deno fresh app
{
"react": "https://esm.sh/@preact/compat",
"use-isomorphic-layout-effect": "https://esm.sh/*use-isomorphic-layout-effect?alias=react:preact/compat&deps=react",
"use-sync-external-store/": "https://esm.sh/*use-sync-external-store/",
"use-subscription": "https://esm.sh/*use-subscription?alias=react:preact/compat&deps=react",
"xstate": "https://esm.sh/*xstate@4.37.0?alias=react:preact/compat&deps=react",
"@xstate/react": "https://esm.sh/*@xstate/react@2.0.1?alias=react:preact/compat&deps=react"
}
@audionerd
audionerd / m5stack-rca-module.ino
Last active January 6, 2023 02:48
Playing Audio from the M5Stack RCA Module 13.2
// M5Stack Core Basic + RCA Module 13.2 (PCM5102)
// based on https://github.com/m5stack/M5Stack/blob/b3e801f/examples/Unit/RCA/RCA.ino
#include <M5Unified.h>
void setup() {
auto cfg = M5.config();
cfg.external_spk = true;
cfg.internal_spk = false;
@audionerd
audionerd / atom-script-babel-upgrade.md
Created February 5, 2019 18:38
Using rgbkrk/atom-script and the latest version of Babel

Using the latest version of Babel with rgbkrk/atom-script

Update Babel CLI

cd ~/.atom/packages/script
npm uninstall --save-optional babel-cli
npm install --save-optional @babel/cli@latest
npm install --save-dev @babel/preset-env@latest
npm install --save-dev @babel/core@latest
@audionerd
audionerd / supersaw-shooter.scd
Last active March 22, 2024 06:29
SuperSaw (Roland JP-8000 and JP-8080) in SuperCollider
// via https://web.archive.org/web/20191104212834/https://www.nada.kth.se/utbildning/grukth/exjobb/rapportlistor/2010/rapporter10/szabo_adam_10131.pdf
(
{ | freq = 523.3572, mix=0.75, detune = 0.75 |
var detuneCurve = { |x|
(10028.7312891634*x.pow(11)) -
(50818.8652045924*x.pow(10)) +
(111363.4808729368*x.pow(9)) -
(138150.6761080548*x.pow(8)) +
(106649.6679158292*x.pow(7)) -
@audionerd
audionerd / xstate-react-hooks.js
Created October 31, 2018 20:01
using xstate with react hooks
import React, { useState, useEffect, useMemo } from 'react'
import { Machine } from 'xstate'
import { interpret } from 'xstate/lib/interpreter'
const toggleMachine = Machine({
id: 'toggle',
initial: 'inactive',
states: {
inactive: {
on: { TOGGLE: 'active' }
Idle
Artwork
Draw
Draw Idle
Draw Drawing
Marquee
Marquee Idle
Marquee Drawing Freeform
Marquee Drawing Line
Marquee Moving Artwork
Workspace
text focus -> Text Entry Mode
toolbar marquee tool -> Marquee Selection Mode
Drawing Mode
pointerdown -> Drawing
pointerup -> Drawing Idle
option key & pointerdown -> Erasing
Drawing Idle*
Drawing
-- via https://stackoverflow.com/questions/5723154/truncate-a-string-in-the-middle-with-javascript
-- https://stackoverflow.com/questions/831552/ellipsis-in-the-middle-of-a-text-mac-style/36470401#36470401
function truncateMiddle (str, maxLength, separator)
maxLength = maxLength or 30
separator = separator or "…"
if (maxLength < 1) then return str end
if (string.len(str) <= maxLength) then return str end
if (maxLength == 1) then return string.sub(str, 0, 1) .. separator end
@audionerd
audionerd / spout.lua
Created May 31, 2018 04:09
spout for norns
-- spout.
--
-- key2 = sample A
-- key3 = sample B
-- enc2 = tempo
-- enc3 = rate selection
--
engine.name = 'Ack'
@audionerd
audionerd / index.js
Last active May 27, 2018 04:36
Callbags and Canceling with CAF
require('regenerator-runtime/runtime')
import { forEach, map, pipe, fromEvent, scan } from 'callbag-basics'
import CAF from 'caf'
let source = pipe(
fromEvent(document, 'keydown'),
map(event => function * (signal) {
console.log('%cbegin', 'color:red')
yield CAF.delay(signal, 1000)