-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (33 loc) · 807 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"github.com/gopxl/beep"
"github.com/gopxl/beep/speaker"
"github.com/hajimehoshi/ebiten/v2"
"gosynth/gui"
"gosynth/module"
"gosynth/output"
clock "gosynth/time"
"log"
"runtime"
"time"
)
func main() {
SampleRate := beep.SampleRate(44100)
clk := clock.NewClock(SampleRate.D(1))
rck := module.NewRack(clk, SampleRate)
str := output.NewStreamer(clk, rck)
go func() {
runtime.LockOSThread()
// Todo check if 50ms is enough (especially on Windows)
// higher value would mean more latency, might be an issue for live performance (MIDI keyboard)
err := speaker.Init(SampleRate, SampleRate.N(time.Millisecond*50))
if err != nil {
panic(err)
}
speaker.Play(str)
}()
app := gui.NewApp(rck)
if err := ebiten.RunGame(app); err != nil {
log.Fatal(err)
}
}