Skip to content

Instantly share code, notes, and snippets.

@mohayonao
mohayonao / formant.coffee
Created March 20, 2013 13:06
Formant Khoomii
formants =
a:[700, 1200, 2900]
i:[300, 2700, 2700]
u:[390, 1200, 2500]
e:[450, 1750, 2750]
o:[460, 880, 2800]
freq = 174.61412048339844
freq = T("+", freq, T("sin", {freq:3, mul:0.8}).kr()).kr()
@mohayonao
mohayonao / Gruntfile.coffee
Created March 26, 2013 00:29
gruntで更新のあったファイルだけ処理する
module.exports = (grunt)->
'use strict'
GRUNT_CHANGED_PATH = '.grunt-changed-file'
if grunt.file.exists GRUNT_CHANGED_PATH
changed = grunt.file.read GRUNT_CHANGED_PATH
grunt.file.delete GRUNT_CHANGED_PATH
changed_only = (file)-> file is changed
else
changed_only = -> true
@mohayonao
mohayonao / worker.coffee
Last active December 16, 2015 06:39 — forked from hitode909/worker.coffee
流れるようなインターフェイス, 引数つき
class Worker
constructor: (@context=@)->
@jobs = []
register: (job) ->
@jobs.push job
work: ->
job = do @jobs.shift
args = [=> @work.apply @, arguments].concat [].slice.call arguments
@mohayonao
mohayonao / imageloader.coffee
Created April 17, 2013 00:36
画像を一回だけ読み込むやつ
class ImageLoader
map = {}
constructor: (@src)->
if not map[@src]
@dfd = new $.Deferred
map[@src] = @
return map[@src]
load: ->
img = new Image
@mohayonao
mohayonao / animate.coffee
Created April 17, 2013 00:47
アニメーション処理の便利なやつ
animate = (opts)->
func = arguments[arguments.length-1]
ifps = 1000 / (opts.fps ? 60)
prev = 0
_animate = (now)->
dt = now - prev
if dt > ifps
result = func now, dt
prev = now
if result != false
@mohayonao
mohayonao / sortedbraille.txt
Created April 18, 2013 03:49
sorted braille
⠀⠁⠂⠃⠄⠅⠆⠇⡀⡁⡂⡃⡄⡅⡆⡇⠈⠉⠊⠋⠌⠍⠎⠏⡈⡉⡊⡋⡌⡍⡎⡏⠐⠑⠒⠓⠔⠕⠖⠗⡐⡑⡒⡓⡔⡕⡖⡗⠘⠙⠚⠛⠜⠝⠞⠟⡘⡙⡚⡛⡜⡝⡞⡟⠠⠡⠢⠣⠤⠥⠦⠧⡠⡡⡢⡣⡤⡥⡦⡧⠨⠩⠪⠫⠬⠭⠮⠯⡨⡩⡪⡫⡬⡭⡮⡯⠰⠱⠲⠳⠴⠵⠶⠷⡰⡱⡲⡳⡴⡵⡶⡷⠸⠹⠺⠻⠼⠽⠾⠿⡸⡹⡺⡻⡼⡽⡾⡿⢀⢁⢂⢃⢄⢅⢆⢇⣀⣁⣂⣃⣄⣅⣆⣇⢈⢉⢊⢋⢌⢍⢎⢏⣈⣉⣊⣋⣌⣍⣎⣏⢐⢑⢒⢓⢔⢕⢖⢗⣐⣑⣒⣓⣔⣕⣖⣗⢘⢙⢚⢛⢜⢝⢞⢟⣘⣙⣚⣛⣜⣝⣞⣟⢠⢡⢢⢣⢤⢥⢦⢧⣠⣡⣢⣣⣤⣥⣦⣧⢨⢩⢪⢫⢬⢭⢮⢯⣨⣩⣪⣫⣬⣭⣮⣯⢰⢱⢲⢳⢴⢵⢶⢷⣰⣱⣲⣳⣴⣵⣶⣷⢸⢹⢺⢻⢼⢽⢾⢿⣸⣹⣺⣻⣼⣽⣾⣿
@mohayonao
mohayonao / Ch1Code.coffee
Created April 23, 2013 01:53
SuperColliderをCoffeeScriptで書くとしたらこんな感じかな
"Hello world"
Server.default = s = Server.internal.boot()
#############
play((->SinOsc.ar(LFNoise0.kr(12, mul: 600, add: 100), 0.3)))
#############
###
play({RLPF.ar(Dust.ar([12, 15]), LFNoise1.ar(1/[3, 4], 1500, 1600), 0.02)})
###
T(_.zip( pan=[-1,+1], dust=[12,15], freq=[1/3, 1/4] ).map ([ pan, dust, freq ])->
T.Pan2.ar(T.RLPF.ar(T.Dust.ar(dust), LFNoise1.ar(freq, 1500, 1600), 0.02), pan)
).play()
@mohayonao
mohayonao / task.coffee
Last active December 16, 2015 19:30
ちょっとずつ実行する
class Task
constructor: (opts={})->
@_task = [].slice.call arguments, 1
@_init = opts.init ? ->{}
@_doMax = opts.do ? 1
@_timer = 0
start: ->
@_doCount = 0
@_taskIndex = 0
dp_match = (p1, p2)->
table = for j in [0...p2.length] by 1
null for i in [0...p1.length] by 1
i = j = 0
score = table[0][0] = 1
cands = []
while i < p1.length - 1 or j < p2.length - 1
[_i, _j] = [i+1, j+1]