Skip to content

IljaN/synth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

synth

Dirty functional synthesizer DSL.

s := inst.New(48000, 16, 500000)
out := s.Master(
    // Mix two osc`s and pass the result trough a filter-chain
    inst.Chain(
        s.Mix(inst.OscOut(s.NewOsc(generator.Sine, 230)), inst.OscOut(s.NewOsc(generator.WhiteNoise, 330))),
        filter.NewLPF(0.00110).Filter,
        filter.NewDelayFilter(0.06, 0.03343, 0.05).Filter,
    ),
)

if err := encoding.WriteWAV("sound.wav", out, 16); err != nil {
    log.Fatal(err)
}

Custom generator functions

s := inst.New(48000, 16, 500000)
out := s.Master(
    inst.OscOut(generator.NewOsc(func(x float64) float64 {
        return 1.0 / math.SqrtPhi * x
    }, 140, 16)),
)

if err := encoding.WriteWAV("sound.wav", out, 16); err != nil {
    log.Fatal(err)
}

// Visualize with ffplay
ffplay("sound.wav", 48000)

Lazy higher-order transformation

inst.Chain(
    filter.NewDelayFilter(0.0533, 0.002, 0.002).Filter,
    filter.NewFlangerFilter(0.053,0.03,0.2).Filter,
    func(buf *audio.FloatBuffer) { /* Custom transform. */ })

Releases

No releases published

Packages

No packages published