Skip to content

Instantly share code, notes, and snippets.

View softpunch's full-sized avatar

Ryan softpunch

View GitHub Profile
@softpunch
softpunch / tryMusicBotBot
Last active September 20, 2017 20:46
source for @tryMusicBotBot
// http://cheapbotsdonequick.com/source/trymusicbotbot
// http://twitter.com/trymusicbotbot
{
"origin": [
"Have you ever tried #activity# while listening to #artist#?"
],
@softpunch
softpunch / musingBot
Last active September 20, 2017 04:38
source for @musingbot
// http://cheapbotsdonequick.com/source/musingbot
// http://twitter.com/musingbot
{
"origin": ["#intro# the most #niceWord# #art# is #mod1# #description#", "#intro# my #bodyPart# is #tastyFood#", "is it wrong to want #art# to be more #description#?", "#intro# #existence# is just one big #foodStuff# after all"],
"intro": [
"maybe",
@softpunch
softpunch / justIntonation
Last active July 30, 2017 06:20
Just Intonation WebMIDI conversion [WIP]
// MIDI note conversion
// util adapted from
// https://github.com/sole/MIDIUtils/blob/master/src/MIDIUtils.js
var noteMap = {};
var noteNumberMap = [];
var notes = [ "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" ];
@softpunch
softpunch / webMidiPitchLFO.js
Last active December 4, 2019 08:10
Send WebMIDI Pitchbend LFO
// use webMIDI to send a pitch-bend message
// that oscillates like an LFO
// HTML code:
//
// <label for="outputSelector">select midi output</label><br>
// <select id="outputSelector" onchange="updatePort()">
// <option value="null" selected>[none]</option>
// </select>
// <input type="button" value="play" onclick="playIt()" />
@softpunch
softpunch / signalWork.js
Last active July 10, 2017 23:55
Make Signals Work (Modulation, Range, Translation, Application, Interpolation)
// make a signal do what you want it to do
//
// LFO manipulation
// (assume the signal ranges from -1 to 1)
// make the value range 0-1 (no negative numbers, aka unsigned)
var destination = (signal + 1) / 2;
// adjust another number/value using the LFO signal
@softpunch
softpunch / rampValSnips.js
Last active July 7, 2017 01:58
Ramps/Oscillators
// snippets from @mohayonao's pure js implementation of web audio api
// https://github.com/mohayonao/web-audio-engine/
// https://github.com/mohayonao/web-audio-engine/blob/master/build/web-audio-engine.js
// basic constructors
// audio scheduled source node
},{"../impl":126,"../utils":135}],31:[function(require,module,exports){
@softpunch
softpunch / euclidArray.js
Created July 3, 2017 21:12
Euclidean Rhythm Generator (ideal for p5.js)
// @mkontogiannis's euclidean rhythm calculator
// https://github.com/mkontogiannis/euclidean-rhythms
//
// specifically grok'd from this version:
// https://unpkg.com/euclidean-rhythms@2.0.1/dist/bundle.umd.js
//
// see also:
// http://cgm.cs.mcgill.ca/~godfried/publications/banff.pdf
// http://www.atonalmicroshores.com/2014/03/bjorklund-py/
//
@softpunch
softpunch / webMidiListen.js
Created July 3, 2017 00:17
WebMidi Parse Basic Input
//
// choose an input, listen to it; (Chrome only; no iOS)
//
//
// HTML component:
//<label for="inputSelector">select midi input</label><br>
//<select id="inputSelector" onchange="updateInputPort()">
// <option value="null" selected>[none]</option>
//</select>
@softpunch
softpunch / webMidiStart.js
Last active July 3, 2017 00:11
WebMIDI basic initialization (output only)
//
// Chrome only; no iOS
//
// Initialize WebMidi; create dropdown selector for output port
//
// HTML component:
// <label for="outputSelector">select midi output</label><br>
@softpunch
softpunch / webAudioStart.js
Created July 2, 2017 22:49
Web Audio Base (basic initialization)
// basic minimum initialization
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var audioContext = new AudioContext();
// set latency hint
if ("latencyHint" in audioContext) {
audioContext.latencyHint = "playback";
};