https://github.com/iljan/synth
https://github.com/iljan/synth
dsl-syntax functional noise-generator synthesizer
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/iljan/synth
- Owner: IljaN
- Created: 2020-06-26T19:36:28.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-25T23:53:12.000Z (about 2 years ago)
- Last Synced: 2025-03-25T03:04:23.457Z (about 1 year ago)
- Topics: dsl-syntax, functional, noise-generator, synthesizer
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# synth
Dirty functional synthesizer DSL.
```golang
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
```golang
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
```golang
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. */ })
```