Skip to content

Instantly share code, notes, and snippets.

View johngriffin's full-sized avatar

John Griffin johngriffin

View GitHub Profile
var Botkit = require('botkit')
var token = process.env.SLACK_TOKEN
var controller = Botkit.slackbot({
// reconnect to Slack RTM when connection goes bad
retry: Infinity,
debug: false
})
{
"name": "toy-slack-bot",
"version": "1.0.0",
"description": "A sample Node.js Slackbot",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"beepboop-botkit": "^1.4.0",
Proposition
-----------
Vinyl is making a comeback, sales have grown every year in the UK for the last 9 years.
50% YoY growth in 2015 UK. Turntables were the most popular audio item sold on
Amazon during the run up to Christmas 2015.
People now discover music through digital services, the common way to bookmark this
music is with playlists. We make it easy to go from playlist to physical vinyl.
Shipping can form a large percentage of the total price for vinyl (typically 10-50%)
so we help to find sellers who can combine shipping for multiple items.
// Return a random sequence with a given length of notes
void generateSequence(int notes[], int num_notes, int range) {
// Make sure pin 0 is unconnected
randomSeed(analogRead(0));
for (int i=0;i<num_notes;i++) {
notes[i] = random((1-range), (range-1));
}
}
int quantizePot(int pin, int range) {
float sensorValue = analogRead(pin);
// assume pot value is 0 - 1024
// quantize to value between 1 and range
float value = ((sensorValue / 1024) * (range-1)) + 1;
return (int)lround(value);
}
#include <SoftwareSerial.h>
SoftwareSerial midi(5, 6); // RX, TX
#define MIDINOTEON 144 //144 = 10010000 in binary, note on command
void setup() {
midi.begin(31250); // Set MIDI baud rate: 31250
}
@johngriffin
johngriffin / slonimsky-midi-pseudocode
Created January 9, 2016 09:10
MIDI playing Middle C for 1 second - pseudocode
NoteOn(velocity=127, note=60)
wait (1)
NoteOn(velocity=0, note=60)