Documentation
¶
Overview ¶
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.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
Converter converts SBaGen content through the provided SynapSeq application context.
func New ¶
func New(ctx *synapseq.AppContext) (*Converter, error)
New creates an SBaGen converter using ctx.
func (*Converter) LoadContent ¶
func (c *Converter) LoadContent(content string) (*synapseq.LoadedContext, error)
LoadContent converts in-memory SBaGen content into a validated SynapSeq sequence.
Example ¶
package main
import (
"fmt"
synapseq "github.com/synapseq-foundation/synapseq/v4/core"
"github.com/synapseq-foundation/synapseq/v4/sbg"
)
const exampleContent = "alpha: 300+10/20\noff: -\nNOW alpha\n+00:01:00 off\n"
func main() {
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 (*Converter) LoadFile ¶
func (c *Converter) LoadFile(path string) (*synapseq.LoadedContext, error)
LoadFile converts the SBaGen sequence at path into a validated SynapSeq sequence.
Example ¶
package main
import (
"fmt"
"os"
"path/filepath"
synapseq "github.com/synapseq-foundation/synapseq/v4/core"
"github.com/synapseq-foundation/synapseq/v4/sbg"
)
const exampleContent = "alpha: 300+10/20\noff: -\nNOW alpha\n+00:01:00 off\n"
func main() {
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