Giter VIP home page Giter VIP logo

coffeecollider's Introduction

coffeecollider's People

Contributors

mohayonao avatar robertbrewitz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coffeecollider's Issues

Implements BinaryOpUGen

  • +
  • -
  • *
  • /
  • /
  • %
  • ==
  • !=
  • <
  • >
  • <=
  • >=
  • min
  • max
  • &
  • |
  • ^
  • lcm
  • gcd
  • round
  • roundUp
  • trunc
  • atan2
  • hypot
  • hypotApx
  • pow
  • <<
  • >>
  • >>>
  • fill
  • ring1
  • ring2
  • ring3
  • ring4
  • difsqr
  • sumsqr
  • sqrsum
  • sqrdif
  • absdif
  • thresh
  • amclip
  • scaleneg
  • clip2
  • excess
  • fold2
  • wrap2
  • firstarg
  • randrange
  • exprandrange
  • numbinaryselectors

[ja] SynthDef template

template = SynthDef (out, osc)->
  (freq=440, amp=0.5)->
    Out.ar(out, osc.ar(freq) * amp)

こう書いた場合は

  • 外側の out, osc は build の引数で渡す (SynthDefの作成)
  • 内側の freq, amp は OutputProxy となる
def1 = template.build(0, SinOsc)
def2 = template.build(1, LFSaw) 

def1.play freq:880 # out 0 に SinOsc
def2.play freq:660 # out 1 に LFSaw

こう書けるので便利そう。

テンプレート引数は省略できて以下の2つは同じように解釈されたほうが良い。

def = SynthDef (freq, amp=0.5)->
  Out.ar(0, SinOsc.ar(freq) * amp)

def = SynthDef ->
  (freq, amp=0.5)->
    Out.ar(0, SinOsc.ar(freq) * amp)

Add UGens

  • SampleRate
  • SampleDur
  • RadiansPerSample
  • ControlRate
  • ControlDur
  • Free
  • FreeSelf
  • FreeSelfWhenDone
  • Pause
  • PauseSelf
  • PauseSelfWhenDone
  • Done
  • RecordBuf
  • BufWr

executable syncblock

a = syncblock ->
  100
console.log typeof a # => "function"
console.log a()      # => 100

error undefined in a task

Task.do ->
  s = def.play().on("end", ->
    s.stop() # s is undefined
  )
.play()

compiled

Task.do ->
  s = def.play().on("end", do (s)->
    ->
      s.stop() # s is undefined
  )
.play()

improved ?

Task.do ->
  s = do (s)->
    s = def.play().on("end", ->
      s.stop() # s is valid
  )
.play()

Can't play immediate

var cc = new CoffeeCollider();
cc.execute("(-> SinOsc.ar() ).play()").play();

Uncaught ReferenceError: SinOsc is not defined

error SynthDef

SynthDef ->
  Out.ar(0, Mix.fill(24, (i)->
    SinOsc.ar(440 * (i).midiratio())
  ) * 1/12)
.play()

compiled

((global)->
  (SynthDef(->
    cc.Out.ar(0, cc.Mix.fill(24, (i)->
      cc.SinOsc.ar((440.__mul__((i).midiratio())))
    ).__mul__((1.__div__(12)))))
  ).play(), [] # <- ERROR!!!!
).call(cc.__context__, this.self || global) 

[ja] How wait method should receive a complex condition?

タスクの中で wait をするときに例えば「a, b, c が終了するまたは1000msec経過する」のような複雑な条件を指定したい。その書き方について検討する。

@wait or(and(a, b, c), 1000)

これは分かりやすいけど、グローバル関数 or, and を消費する。

@wait @or(@and(a, b, c), 1000)

これだとグローバル関数は消費しないけどやかましい感じがする。

@wait (a * b * c) + 1000

演算子の拡張を使った書き方。分かりにくいし、演算子拡張メソッドの中が複雑になる。

@wait (a && b && c) || 1000

演算子の拡張を使った書き方その2。&&|| を新しく拡張する必要があり、他のコード部分に影響がでそう。wait関数に続く場合のみ拡張するなら可能か?

# これはOK
@wait (a && b && c) || 1000

# これはNG
token = (a && b && c) || 1000
@wait token # true と評価されて無限に wait する

演算子の拡張を使った場合、n個のタスクを対象にするというのが書きにくい。配列を入力できるようにすると以下のように書けるけど分かりにくい?

@wait (1 && [a, b, c]) || 1000

&& のときは 1 に続ける。|| のときは 0 に続ける。

[ja] One Liner Notaion

140sc みたいな要領でツイッターに投稿できるサイズで coffee-collider コードを書きたい。

よく使いそうなものは 一文字クラス名、メソッドを用意する。

SinOsc.ar(440).play()
SinOsc.ar(440).p()

( Task.interval 100, ( -> synth.play() ) ).play()
(T.i 100, (->s.p())).p()
  • どのクラス、メソッドを対象とするか?
  • そもそも CoffeeScript はワンライナーに向いていない気がする

A4 is not "A4"

A4.midicps()   # 220 (wrong)
"A4".midicps() # 440 (correct)

[ja] Supporting Internet Explorer

音が崩れる。バッファサイズの調整が必要。

  • バッファサイズを確定させるタイミングの確認
  • Flash Fallback かどうかの判定追加
  • 適切なバッファサイズをさがす

Messaging

send a massage

// in client
cc.send("message", {value:100})
# in CoffeeCollider
Message.on 'message', (data)->
  console.log data # => {value:100}

receive a message

// in client
cc.on("message", function(data) {
  console.log(data); // #=> {value:100}
});
# in CoffeeCollider
Message.send 'message', {value:100}

Implements UGen

  • SoundIn
  • AudioIn
  • BLowPass
  • BHiPass
  • BAllPass
  • BBandPass
  • BBandStop
  • BPeakEQ
  • BLowShelf
  • BHiShelf
  • BLowPass4
  • BHiPass4
  • BinaryOpUGen
  • UnaryOpUGen
  • MulAdd
  • Sum3
  • Sum4
  • PlayBuf
  • TGrains
  • BufRd
  • BufWr
  • RecordBuf
  • ScopeOut
  • ScopeOut2
  • Tap
  • LocalBuf
  • MaxLocalBufs
  • SetBuf
  • ClearBuf
  • QuadN
  • QuadL
  • QuadC
  • CuspN
  • CuspL
  • GbmanN
  • GbmanL
  • HenonL
  • HenonL
  • HenonC
  • LatoocarfianN
  • LatoocarfianL
  • LatoocarfianC
  • LinCongN
  • LinCongL
  • LinCongC
  • StandardN
  • StandardL
  • FBSineN
  • FBSineL
  • FBSineC
  • LorenzL
  • CheckBadValues
  • Amplitude
  • Compander
  • CompanderD
  • Normalizer
  • Limiter
  • PingPong
  • Delay1
  • Delay2
  • DelayN
  • DelayL
  • DelayC
  • CombN
  • CombL
  • CombC
  • AllpassN
  • AllpassL
  • AllpassC
  • BufDelayN
  • BufDelayL
  • BufDelayC
  • BufCombN
  • BufCombL
  • BufCombC
  • BufAllpassN
  • BufAllpassL
  • BufAllpassC
  • DelTapWr
  • DelTapRd
  • Demand
  • Duty
  • TDuty
  • DemandEnvGen
  • DUGen
  • Dseries
  • Dgeom
  • Dbufrd
  • Dbufwr
  • ListDUGen
  • Dseq
  • Dser
  • Dshuf
  • Drand
  • Dxrand
  • Dwrand
  • Dswitch1
  • Dswitch
  • Dwhite
  • Dbrown
  • Dibrown
  • Dstutter
  • Donce
  • Dreset
  • Dpoll
  • Dunique
  • DiskOut
  • DiskIn
  • VDiskIn
  • Done
  • FreeSelf
  • PauseSelf
  • FreeSelfWhenDone
  • PauseSelfWhenDone
  • Pause
  • Free
  • EnvGen
  • Linen
  • FFT
  • IFFT
  • FSinOsc
  • Klang
  • Klank
  • DynKlank
  • DynKlang
  • Blip
  • Saw
  • Pulse
  • Resonz
  • OnePole
  • OneZero
  • TwoPole
  • TwoZero
  • APF
  • Integrator
  • Decay
  • Decay2
  • Lag
  • Lag2
  • Lag3
  • Ramp
  • LagUD
  • Lag2UD
  • Lag3UD
  • VarLag
  • LeakDC
  • RLPF
  • RHPF
  • LPF
  • HPF
  • BPF
  • BRF
  • MidEQ
  • LPZ1
  • HPZ1
  • Slope
  • Changed
  • LPZ2
  • HPZ2
  • BPZ2
  • BRZ2
  • Median
  • Slew
  • FOS
  • SOS
  • Ringz
  • Formlet
  • DetectSilenct
  • Freeverb
  • Freeverb2
  • GVerb
  • Gendy1
  • Gendy2
  • Gendy3
  • GrainSin
  • GrainFM
  • GrainBuf
  • GrainIn
  • Warp1
  • Hilbert
  • HilbertFIR
  • FreqShift
  • IEnvGen
  • Control
  • AudioControl
  • TrigControl
  • LagControl
  • In
  • LocalIn
  • LagIn
  • InFeedback
  • InTrig
  • Out
  • ReplaceOut
  • OffsetOut
  • LocalOut
  • XOut
  • SharedOut
  • SharedIn
  • SampleRate
  • SampleDur
  • RadiansPerSample
  • ControlRate
  • ControlDur
  • SubsampleOffset
  • NumOutputBuses
  • NumInputBuses
  • NumAudioBuses
  • NumControlBuses
  • NumBuffers
  • NumRunningSynths
  • BufSampleRate
  • BufRateScale
  • BufFrames
  • BufSamples
  • BufDur
  • BufChannels
  • InterplEnv
  • InterplXYC
  • InterplPairs
  • InterplChord
  • Line
  • XLine
  • LinLin
  • LinExp
  • ExpLin
  • ExpExp
  • AmpComp
  • AmpCompA
  • K2A
  • A2K
  • T2K
  • T2A
  • DC
  • Silent
  • MouseX
  • MouseY
  • MouseButton
  • KeyState
  • BeatTrack
  • Loudness
  • Onsets
  • KeyTrack
  • MFCC
  • BeatTrack2
  • Mix
  • MoogFF
  • RandSeed
  • RandID
  • Rand
  • IRand
  • TRand
  • TIRand
  • LinRand
  • NRand
  • ExpRand
  • TExpRand
  • CoinGate
  • TWindex
  • WhiteNoise
  • BrownNoise
  • PinkNoise
  • ClipNoise
  • GrayNoise
  • Crackle
  • Logistic
  • LFNoise0
  • LFNoise1
  • LFNoise2
  • LFClipNoise
  • LFDNoise0
  • LFDNoise1
  • LFDNoise3
  • LFDClipNoise
  • Hasher
  • MantissaMask
  • Dust
  • Dust2
  • Osc
  • SinOsc
  • SinOscFB
  • OscN
  • VOsc
  • VOsc3
  • COsc
  • Formant
  • LFSaw
  • LFPar
  • LFCub
  • LFTri
  • LFGauss
  • LFPulse
  • VarSaw
  • Impulse
  • SyncSaw
  • Index
  • WrapIndex
  • IndexInBetween
  • DetectIndex
  • Shaper
  • IndexL
  • DegreeToKey
  • Select
  • SelectX
  • LinSelectX
  • SelectXFocus
  • Vibrato
  • TChoose
  • TWChoose
  • PSinGrain
  • Pan2
  • LinPan2
  • Pan4
  • Balance2
  • Rotate2
  • PanB
  • PanB2
  • BiPanB2
  • DecodeB2
  • PanAz
  • XFade2
  • LinXFade2
  • PartConv
  • Spring
  • Ball
  • TBall
  • PitchShift
  • Pluck
  • Poll
  • Splay
  • SplayAz
  • SplayZ
  • Trig1
  • Trig
  • SendTrig
  • SendReply
  • TDelay
  • Latch
  • Gate
  • PulseCount
  • Peak
  • RunningMin
  • RunningMax
  • Stepper
  • PulseDivider
  • SetResetFF
  • ToggleFF
  • ZeroCrossing
  • Timer
  • Sweep
  • Phasor
  • PeakFollower
  • Pitch
  • InRange
  • InRect
  • Fold
  • Clip
  • Wrap
  • Schmidt
  • MostChange
  • LeastChange
  • LastValue
  • SendPeakRMS
  • AccelerometerX
  • AccelerometerY
  • AccelerometerZ

[ja] Task.mml

MMLでスケジューリングできたら便利だと思う。

Task.mml mml, (data)->
  # do something
.play()
  • dataに何が入ってくるのか?
  • 使える記法は?

error adverb

error

[1,2,3] +S+ [1,2,3,4,5,6,7,8,9,10]

compiled

[1, 2, 3](S.__plus__().__add__([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))

ok

[1,2,3]+S+[1,2,3,4,5,6,7,8,9,10]

compiled

[1, 2, 3].__add__([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], cc.SHORT)

[ja] Time Value Syntax

Max/MSPのような時間値シンタックスを導入したい。

http://www.cycling74.com/docs/max5/vignettes/core/maxtime_syntax.html

Line.kr(0, 1, dur:"1.0.0") # 1小節かけて 0 から 1 に変化する

実装案

  1. コンパイル時に文字列がシンタックスに合致していればその場で数値に変換する
    • 実行時のパフォーマンス good
    • 時間単位が異なる (UGen系は秒、タスクwait はミリ秒を使っている)
    • 周波数を期待する箇所で書けない
    • マスターBPMに対応できない
  2. 受け取る関数内で変換する
    • 実行時のパフォーマンスの問題 bad
    • 時間単位を柔軟に決められる
    • 周波数を期待する箇所で書ける (実行時に変換すればよい)
    • マスターBPMに対応できる
    • 実装量が増える
  3. コンパイル時に合致していれば関数呼び出しに変換する
    • 実行時のパフォーマンスの問題 bad
    • 時間単位が異なる (UGen系は秒、タスクwait はミリ秒を使っている)
    • 周波数を期待する箇所で書けない
    • マスターBPMに対応できる

対応策

  • 時間単位の変換は手動で行う
@wait "1.0.0" * 1000 # 1小節待つ
  • 周波数変換用シンタックスを作る
SinOsc.kr("~1.0.0") # 1小節を周波数に変換する ( ~ はサイン波のイメージ)
  • マスターBPMへの対応は関数で処理しないと不可能

記法 (案)

  • 周波数
    • 100hz → 0.01
  • ミリ秒
  • 50ms → 0.05
    • 10sec → 10
    • 1min → 60
  • 時:分:秒.ミリ秒
    • 00:03:25.230 → 205.230
  • サンプル数
    • 1000samples → (1000 / samleRate)
    • 1000samples/44100hz → (1000 / 44100)

以下はマスターBPMとの連携が必要となり、省略した場合は定数として扱えない

  • ノート長
    • L4
    • bpm140 L4 → 0.42857142857142855
  • 小節/拍/ticks
    • 2.3.240
    • bpm140 2.3.240 → 4.928571428571428
  • ticks
    • 1 tick は四分音符の 1/480 とする
    • 480ticks
    • bpm140 480ticks → 0.42857142857142855

Implements UGen.prototype

  • madd
  • range
  • exprange
  • curverange
  • unipolar
  • bipolar
  • clip
  • fold
  • wrap
  • blend
  • lag
  • lag2
  • lag3
  • lagud
  • lag2ud
  • lag3ud
  • varlag
  • slew
  • prune
  • linlin
  • linexp
  • explin
  • expexp
  • lincurve
  • curvelin
  • bilin

[ja] Chord Object

コードの表現について。こんな感じで書く?

Chord("M7", 1).toDegrees() #=> [ 4, 7, 11, 12 ]
Chord("M7", 1).toFreqs(440) #=> [ freq... ]
Chord("M7", 1).toRatios() #=> [ ratio... ]
  • 配列に変換できると良い (ノート番号 / 周波数 / ratio)
  • アルペジオストリームみたいなのとか?
  • チューニングを指定できる

cc namespace

source

Synth.def ->
  Out.ar(0, SinOsc.ar(440))
.play()

replaced (prefix cc)

cc.Synth.def ->
  cc.Out.ar(0, cc.SinOsc.ar(440))
.play()

Implements UnaryOpUGen

  • neg
  • not
  • isNil
  • notNil
  • bitNot
  • abs
  • asFloat
  • asInt
  • ceil
  • floor
  • frac
  • sign
  • squared
  • cubed
  • sqrt
  • exp
  • reciprocal
  • midicps
  • cpsmidi
  • midiratio
  • ratiomidi
  • dbamp
  • ampdb
  • octcps
  • cpsoct
  • log
  • log2
  • log10
  • sin
  • cos
  • tan
  • asin
  • acos
  • atan
  • sinh
  • cosh
  • tanh
  • rand
  • rand2
  • linrand
  • bilinrand
  • sum3rand
  • distort
  • softclip
  • coin
  • digitvalue
  • silence
  • thru
  • rectWindow
  • hanWindow
  • welWindow
  • triWindow
  • ramp
  • scurve
  • numunaryselectors
  • num
  • tilde
  • pi

[ja] Task Template

template = Task (a, b)->
  (i)->
    s = def.play()
    s.set freq:a * i
    @wait b
    s.set freq:a * i * 2
    @wait b

task1 = Task.do(10, template(440, 0.50)).play()
task2 = Task.do(10, template(660, 0.45)).play()

[ja] Should restructure for supporting WebSocket in the future

WebSocketに対応させることで、それぞれのクライアントで書いたコードに基づいてサーバーが信号処理を行い、その結果を共に聞くといったソーシャル音響プログラミングが可能になる。現在のWorker内で eval して信号処理を行う方法をそのまま WebSocketServer に対応させた場合、サーバー内で eval することになり良くない。そこでOSCのようなメッセージのやりとりでサーバーを制御する構成に作り変えたい。ただし、一般的な用途であるローカルでの運用が複雑になったりUIとの連携の遅延が大きくなってはならない。ソケットサーバーでの運用はUIとの連携は考えない。

error Mix

SynthDef ->
  Out.ar(0, Mix.fill(24, (i)->
    SinOsc.ar([440, 441] * (i).midiratio()) * 1/12
  ))
.play()

caught
Uncaught TypeError: Cannot read property 'inputs' of undefined

[ja] Tempo Related Time Value Syntax

from #2

BPMを省略した場合はマスターテンポに連携させたい

Task.do ->
  Master.setBPM 120
  s.play freq:440, dur:"L8"
  t = Task.do ->
    Master.setBPM 140
    s.play freq:660, dur:"L4"
    @wait 100
    Master.setBPM 180
    s.play freq:660, dur:"L4"
    @wait 100
  .play()
  # @wait t
  s.play freq:440, dur:"L8" # ここのBPMは?
  @wait 1000
.play()

[ja] How send/receive a message between a client and a server?

Like this?

// in the client
var cc = new CoffeeCollider();
$button.on("click", function() {
  cc.send("button-click", 1000);
});
cc.recv("response-from-server", function(data) {
  console.log(data); //=> [100,200]
});
# in the server
Message.recv "button-click", (data)->
  console.log data #=> 1000
Message.send "response-from-server", [100, 200]
  • どういう用途で使うか?
    • busのデータを送信する
    • UIの操作を反映させる
    • 他は?

[ja] Custom Build

必要なモジュールだけ組み込んでビルドできると良い。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.