mirror of
https://github.com/vsariola/sointu.git
synced 2025-11-12 04:46:13 -05:00
feat(tracker): don't save instrument name in instrument files
The filename is used as the instrument name when it is loaded.
This commit is contained in:
parent
55f9c36bd5
commit
7459437822
47
tracker/generate/clean_presets.go
Normal file
47
tracker/generate/clean_presets.go
Normal file
@ -0,0 +1,47 @@
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/vsariola/sointu"
|
||||
"github.com/vsariola/sointu/tracker"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func main() {
|
||||
filepath.WalkDir("presets", func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if d.IsDir() {
|
||||
return nil
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
var instr sointu.Instrument
|
||||
if yaml.Unmarshal(data, &instr) != nil {
|
||||
fmt.Fprintf(os.Stderr, "could not unmarshal the preset file %v: %v\n", path, err)
|
||||
return nil
|
||||
}
|
||||
tracker.RemoveUnusedUnitParameters(&instr) // remove invalid parameters
|
||||
instr.Name = "" // we don't need the names in the preset files as they are derived from the file path
|
||||
outData, err := yaml.Marshal(instr)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "could not marshal the preset file %v: %v\n", path, err)
|
||||
return nil
|
||||
}
|
||||
if err := os.WriteFile(path, outData, 0644); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "could not write the preset file %v: %v\n", path, err)
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user