Skip to content

Instantly share code, notes, and snippets.

@mohayonao
mohayonao / morse-code.json
Created July 14, 2014 06:18
morse-code.json
{
"0": "-----",
"1": ".----",
"2": "..---",
"3": "...--",
"4": "....-",
"5": ".....",
"6": "-....",
"7": "--...",
"8": "---..",
@mohayonao
mohayonao / MarioMML.py
Created January 22, 2011 00:14
Python+PyAudio+MMLでマリオのBGM再生 http://www.youtube.com/watch?v=rQtyiy-OOtA
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
import math
import array
import random
import itertools
import collections
@mohayonao
mohayonao / find_homography
Created March 25, 2011 22:09
4つの点からホモグラフィ行列(平面射影変換行列)を求める
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy
def find_homography(src, dst):
# X = (x*h0 +y*h1 + h2) / (x*h6 + y*h7 + 1)
# Y = (x*h3 +y*h4 + h5) / (x*h6 + y*h7 + 1)
#
//////////////////////////////////////////////////////////////////////////
(
// analog bubbles
{
f = LFSaw.kr(0.4, 0, 24, LFSaw.kr([8,7.23], 0, 3, 80)).midicps; // glissando function
CombN.ar(SinOsc.ar(f, 0, 0.04), 0.2, 0.2, 4) // echoing sine wave
}.play)
//////////////////////////////////////////////////////////////////////////
@mohayonao
mohayonao / 00.md
Last active July 23, 2018 13:49
CoffeeCollider勉強会用の資料 http://goo.gl/Z2JmZ2

IDE

http://mohayonao.github.io/CoffeeCollider/

  • "Run" でコードを実行
  • "Stop" で停止
  • "Link" でコードをリンク化 (保存)
  • "Compile" コンパイル後のコード(JavaScript)を表示

IDEの機能

  • サンプルコード読み込み
(function() {
"use strict";
global.AudioContext = global.AudioContext || global.webkitAudioContext;
global.OfflineAudioContext = global.OfflineAudioContext || global.webkitOfflineAudioContext;
if (typeof global.AudioContext !== "undefined") {
if (typeof global.AudioContext.prototype.createGain !== "function") {
global.AudioContext.prototype.createGain = global.AudioContext.prototype.createGainNode;
}
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 });
@mohayonao
mohayonao / LoadBinaryForIE9.js
Created February 12, 2013 12:23
IE9でXMLHttpRequestを使ってバイナリファイルを読み込むやつ
var path = "";
var callback = function(array) {
console.log(array.length);
};
var xhr = new XMLHttpRequest();
xhr.open("GET", path);
xhr.responseType = "arraybuffer"; // IE9はこれが効かない.
xhr.onreadystatechange = function() {

sdef

音の設計書

  • (sdef: json)
  • (builder: function)
  • (name: string, builder: function)
  • (builder: function, ctls: string[])
  • (name: string, builder: function, ctrls: string[])

inst

import neume, { scapi } from "neume";
const neu = neume();
const { mul, SinOsc } = scapi;
const hello = neu.def("hello", () => {
const freq = ctl("freq");
SinOsc(freq)::mul(0.2);
});