Skip to content

Instantly share code, notes, and snippets.

function example01(audioContext, pulse) {
var destination = audioContext.destination;
var t0 = audioContext.currentTime;
pulse(destination, t0, { frequency: 440, volume: 0.3, duty: 0.8 });
}
.speaker {
width: 32px;
height: 32px;
stroke-width: 3px;
stroke-linecap: round;
stroke-linejoin: round;
border-radius: 4px;
background: #ecf0f1;
}
import React, { Component, PropTypes } from "react";
import Volatile from "./Volatile";
@Volatile({ timeout: 2500 })
class UI extends Component {
static propTypes = {
data: PropTypes.number.isRequired,
};
shouldComponentUpdate(nextProps) {
function importScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement("script");
script.async = 1;
script.type = "text/javascript";
script.src = src;
script.onerror = reject;
script.onload = () => {
document.body.removeChild(script);
@mohayonao
mohayonao / BiquadFilterCoefficients.js
Last active September 12, 2016 08:54
BiquadFilter
"use strict";
const LOWPASS = "lowpass";
const HIGHPASS = "highpass";
const BANDPASS = "bandpass";
const LOWSHELF = "lowshelf";
const HIGHSHELF = "highshelf";
const PEAKING = "peaking";
const NOTCH = "notch";
const ALLPASS = "allpass";
// velocity-for-color
// https://github.com/brunchboy/afterglow/blob/master/src/afterglow/controllers/ableton_push.clj#L24
module.exports = (h, s, v) => {
if (v < 3) {
return 0;
}
const brightnessShift = (60 < v) ? 0 : (37 < v) ? 1 : (15 < v) ? 2 : 3;
if (s < 20) {
function selectAudioChannel(type) {
var splitter = audioCtx.createChannelSplitter(2);
audioSource.disconnect(); // ?
switch (type) {
case 'L':
audioSource.connect(splitter);
splitter.connect(audioCtx.destination, 0);
break;
case 'R':
audioSource.connect(splitter);
const synthdef = require("synthdef");
const def1 = synthdef(($) => {
let s;
s = $("SinOsc").ar(220, 0, 0.5);
s = $("Out").ar(0, s);
return s;
});
const def2 = synthdef(($) => {
module.exports = new Uint32Array([
0x46464952, 0x0000002c, 0x45564157, 0x20746d66,
0x00000010, 0x00020001, 0x0000ac44, 0x0002b110,
0x00100004, 0x61746164, 0x00000008, 0x8000c000, 0x3fff7fff
]).buffer;
let audioContext = new AudioContext();
let sched = new WebAudioScheduler({
context: audioContext
});
function metronome(e) {
sched.insert(e.playbackTime + 0.000, ticktack, { frequency: 880, duration: 1.00 });
sched.insert(e.playbackTime + 0.500, ticktack, { frequency: 440, duration: 0.05 });
sched.insert(e.playbackTime + 1.000, ticktack, { frequency: 440, duration: 0.05 });
sched.insert(e.playbackTime + 1.500, ticktack, { frequency: 440, duration: 0.05 });