Skip to content

Instantly share code, notes, and snippets.

@interstar
interstar / mb_accelerometer.py
Last active July 12, 2021 03:42
Grab MicroBit Accelerometer to Serial
# See https://www.youtube.com/watch?v=DcgRHOqSFm8
from microbit import *
uart.init(baudrate=115200)
while True:
display.clear()
x,y,z=accelerometer.get_values()
display.set_pixel(2,2,4)
@interstar
interstar / serial2midi.pde
Last active July 12, 2021 03:41
Processing sketch to turn Microbit Accelerometer data (received from the serial cable) into MIDI
// See https://www.youtube.com/watch?v=DcgRHOqSFm8
import processing.serial.*;
import themidibus.*;
Serial serialPort;
MidiBus midiBus;
void setup() {
size(700,500);
@interstar
interstar / protoplug_arpeggiator.lua
Last active December 13, 2022 10:01
A simple arpeggiator that turns one note into an arpeggio in Lua Protoplug
--[[
name: One Key Arp
description: Takes in a single Midi Note, generates a "chord"
(ie. collection of notes) but then play the chord as an arpeggio
author: synaesmedia
See : https://www.youtube.com/watch?v=MHo1FXyRvrA for tutorial
--]]
require "include/protoplug"
@interstar
interstar / rectext.py
Last active August 27, 2021 14:31
recursively include text files
import sys, re
# Run like this :
# python3 rectext.py toplevel.txt
#
# include statement looks like this
# @include fname.txt
def slurp(fName) :
@interstar
interstar / jchords.rb
Last active December 13, 2022 09:52
Modern Japanese Chord Progression
## Japanese chord progression
## Based on https://www.youtube.com/watch?v=yKV58VVGV9k
## See https://www.youtube.com/watch?v=ADr8hrjpKbo
define :oneChord do | tonic, mode, deg |
majorKeyTriads = [:M,:m,:m,:M,:M,:m,:dim]
minorKeyTriads = [:m,:dim,:M,:m,:m,:M,:M]
majorKey7s = [:M7,:m7,:m7,:M7,:dom7,:m7,:halfdiminished]
minorKey7s = [:m7,:halfdiminished,:M7,:m7,:m7,:M7,:dom7]
@interstar
interstar / squarewavesynth.lua
Created September 24, 2021 18:48
A noisy square-wave drone synth
--[[
name: square demo
description: > generate a squarewave with pulse width control
author: synaesmedia
See https://www.youtube.com/watch?v=8kXs8XIyq1U
--]]
require "include/protoplug"
@interstar
interstar / squarewavesynth2.lua
Created September 30, 2021 14:49
Square Wave Synth in Lua Protoplug (part 2)
--[[
name: square demo
description: > Square wave synth with pulse width control & ADSR envelopes
author: synaesmedia
see : https://www.youtube.com/watch?v=eBLbpXHaYIE
Protoplug : https://github.com/pac-dev/protoplug
--]]
require "include/protoplug"
@interstar
interstar / scope.py
Last active October 11, 2021 15:27
Python scope test
print("""
# Scope demo in Python
# the x bound in the scope of f is visible within y
# but is not the same as the x bound at the global scope
x = 4
y = 3
def f(x) :
def g(y) :
@interstar
interstar / drill1.rb
Last active October 22, 2021 03:20
UK Drill in Sonic Pi
# UK Drill Beat in Sonic Pi
# Tutorial : https://www.youtube.com/watch?v=ELA339I4NwY
# Note : this Sonic Pi Sketch relies on you having certain drill type drum samples
# Put them in the directory referenced in the variable called sampleKit
# you'll need samples called hat.wav, hat2.wav, kick.wav, snare.wav and noise.wav
define :flatfifth do |c|
@interstar
interstar / squarewavesynth5.lua
Created January 13, 2022 11:52
Noisy Square Wave Synth #5 : Now with low-pass filter
--[[
name: square demo 5
description: > generate a squarewave with pulse width control and filter
author: synaesmedia
--]]
require "include/protoplug"
local makeFilter = require "include/dsp/cookbook filters"