Documentation / Programming / SBG
SBG package
Versioned API documentation and examples, mirrored from pkg.go.dev. Open the canonical package page
package sbg
Package sbg converts supported SBaGen .sbg sequences into validated SynapSeq sequences.
Overview
New receives the caller's core.AppContext and returns a Converter. Its LoadFile method converts a local SBaGen file, while LoadContent converts SBaGen text already held in memory. Both methods return a core.LoadedContext, so callers can inspect the generated sequence, retrieve its SPSQ representation through RawContent, or render it with the regular core API.
Example Usage
converter, err := sbg.New(synapseq.NewAppContext())
if err != nil {
log.Fatal(err)
}
loaded, err := converter.LoadFile("session.sbg")
if err != nil {
log.Fatal(err)
}
if err := loaded.WAV("session.wav"); err != nil {
log.Fatal(err)
}
Conversion Notes
Converted content starts with a warning about possible conversion errors. Full-line SBaGen comments are copied below this warning in their original order, preserving their # or ## prefixes.
Supported SBaGen voices are mapped to the corresponding SPSQ tracks. Binaural sign orientation is preserved: + maps to left-right (higher frequency on the left), and - maps to right-left (higher frequency on the right). The beat magnitude remains non-negative, including signed zero. Spin voices are approximated with pink noise and a pan effect. An SBaGen -m source becomes an SPSQ music source named after its file base, and each mix voice becomes a music track. Music paths must remain within the current directory and cannot contain parent traversal; their extension is removed so SynapSeq can resolve an MP3 or WAV source. The SBaGen -r option becomes the SPSQ sample rate; it defaults to 44100 when absent. SBaGen fade markers are accepted but converted to steady transitions.
Timeline hours may use one or two digits; minutes and seconds use two digits. A sequence with a single timeline entry is treated as open-ended and converted to 30 minutes by repeating its final state at the end of that period.
Types
type Converter struct {
// contains filtered or unexported fields
}
Converter converts SBaGen content through the provided SynapSeq application context.
func New(ctx *synapseq.AppContext) (*Converter, error)
New creates an SBaGen converter using ctx.
func (c *Converter) LoadContent(content string) (*synapseq.LoadedContext, error)
LoadContent converts in-memory SBaGen content into a validated SynapSeq sequence.
Example
converter, err := sbg.New(synapseq.NewAppContext())
if err != nil {
panic(err)
}
loaded, err := converter.LoadContent(exampleContent)
if err != nil {
panic(err)
}
fmt.Println(loaded.Duration())
Output:
1m0s
func (c *Converter) LoadFile(path string) (*synapseq.LoadedContext, error)
LoadFile converts the SBaGen sequence at path into a validated SynapSeq sequence.
Example
dir, err := os.MkdirTemp("", "synapseq-sbg-example")
if err != nil {
panic(err)
}
defer os.RemoveAll(dir)
path := filepath.Join(dir, "session.sbg")
if err := os.WriteFile(path, []byte(exampleContent), 0o600); err != nil {
panic(err)
}
converter, err := sbg.New(synapseq.NewAppContext())
if err != nil {
panic(err)
}
loaded, err := converter.LoadFile(path)
if err != nil {
panic(err)
}
fmt.Println(loaded.Duration())
Output:
1m0s