mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-18 21:14:31 -04:00
feat: save recovery data to disk and/or DAW project
This commit is contained in:
parent
97a1b2f766
commit
462faf5f4e
@ -3,6 +3,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/vsariola/sointu/cmd"
|
||||
"github.com/vsariola/sointu/tracker"
|
||||
"github.com/vsariola/sointu/tracker/gioui"
|
||||
@ -49,10 +54,13 @@ func init() {
|
||||
vst2.PluginAllocator = func(h vst2.Host) (vst2.Plugin, vst2.Dispatcher) {
|
||||
modelMessages := make(chan interface{}, 1024)
|
||||
playerMessages := make(chan tracker.PlayerMessage, 1024)
|
||||
model, err := tracker.LoadRecovery(modelMessages, playerMessages)
|
||||
if err != nil {
|
||||
model = tracker.NewModel(modelMessages, playerMessages)
|
||||
recoveryFile := ""
|
||||
if configDir, err := os.UserConfigDir(); err == nil {
|
||||
randBytes := make([]byte, 16)
|
||||
rand.Read(randBytes)
|
||||
recoveryFile = filepath.Join(configDir, "Sointu", "sointu-vsti-recovery-"+hex.EncodeToString(randBytes))
|
||||
}
|
||||
model := tracker.NewModel(modelMessages, playerMessages, recoveryFile)
|
||||
player := tracker.NewPlayer(cmd.DefaultService, playerMessages, modelMessages)
|
||||
tracker := gioui.NewTracker(model, cmd.DefaultService)
|
||||
tracker.SetInstrEnlarged(true) // start the vsti with the instrument editor enlarged
|
||||
@ -102,6 +110,12 @@ func init() {
|
||||
tracker.Quit(true)
|
||||
tracker.WaitQuitted()
|
||||
},
|
||||
GetChunkFunc: func(isPreset bool) []byte {
|
||||
return tracker.SafeMarshalRecovery()
|
||||
},
|
||||
SetChunkFunc: func(data []byte, isPreset bool) {
|
||||
tracker.SafeUnmarshalRecovery(data)
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user