Skip to content

Instantly share code, notes, and snippets.

"use strict";
const output = new Float32Array(8192).map((_, i) => Math.sin(i));
process.stdout.write(Buffer.from(output.buffer));
awk '{ system("sleep 0.1"); print $0 }'
"use strict";
const through = require("through");
module.exports = through(function(data) {
Array.from(data).forEach((ch) => { this.queue(ch); });
});
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
play -t s16 -r 44100 -c 2 -q -
let param = new AudioParam2(1);
let gain = audioContext.createGain();
let t0 = audioContext.currentTime;
param.bind(gain.gain);
param.setValueAtTime(0, t0);
param.linearRampToValueAtTime(1, t0 + 1);
param.getValueAtTime(t0 + 0.5);
@mohayonao
mohayonao / WorkerTimer.js
Last active October 12, 2016 14:18
WorkerTimer for Browser
window.WorkerTimer = (function() {
var TIMER_WORKER_SOURCE = [
"var timerIds = {}, _ = {};",
"_.setInterval = function(args) {",
" timerIds[args.timerId] = setInterval(function() { postMessage(args.timerId); }, args.delay);",
"};",
"_.clearInterval = function(args) {",
" clearInterval(timerIds[args.timerId]);",
"};",
"_.setTimeout = function(args) {",
@mohayonao
mohayonao / index.html
Created February 18, 2016 11:37
SeekBufferSourceNode
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>SeekBufferSourceNode</title>
<style>
.btn { width:100px;height:25px;background:lightgray;border:solid 1px lightgray;border-radius:5px;outline:none }
</style>
</head>
<body>
const api = require("./api");
const dsp = require("./dsp");
const driver = require("./driver");
const triolet = require("triolet.bundle");
triolet.compose({ api, dsp, driver });
//================================================
const triolet = require("tiolet.browser/client");
// (
// {
// var trig = Dust.kr(10);
// SinOsc.ar(
// TRand.kr(300, 3000, trig)
// ) * 0.1
// }.play;
// )
let TrandExample = ($) => {