sfzconvert

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package sfzconvert converts an SFZ instrument file into an FZ series full dump (.fzf). Each SFZ region becomes one FZ voice, with its key range, velocity range, and root key mapped into the bank sector.

WAV files referenced by the SFZ are read and resampled internally, with no intermediate .fzv files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(ctx context.Context, sfzPath, outputPath string, targetRate uint32, fitToDisk bool) error

Convert reads the SFZ file at sfzPath, converts all regions to FZ voices, and writes a full dump to outputPath. targetRate must be 36000, 18000, or 9000. If fitToDisk is true the rate is automatically stepped down from targetRate to ensure the output fits on a single floppy disk; an error is returned if even 9000 Hz is too large. The context is checked between WAV loads so a long convert can be cancelled. A stereo sample is refused: the command carries no channel answer, so the alternative is a voice of double length at half the pitch.

func ConvertDir

func ConvertDir(ctx context.Context, dirPath, outputPath string, targetRate uint32, fitToDisk bool) error

ConvertDir reads all WAV files from dirPath (sorted alphabetically), assigns each one to a sequential MIDI key starting at C2 (MIDI 36), and writes a full dump to outputPath. This is the zero-SFZ workflow for simple drum kits. The context is checked between WAV loads so a long convert can be cancelled. A stereo WAV is refused: the command carries no channel answer, and a mangled voice is worse than a refusal naming the file.

func ConvertMultiDisk

func ConvertMultiDisk(ctx context.Context, sfzPath, outputPrefix string, targetRate uint32) error

ConvertMultiDisk converts an SFZ file to a 2-disk full dump, writing outputPrefix-1.img and outputPrefix-2.img. Disk 1 contains the complete bank and voice headers plus the first portion of audio. Disk 2 contains pure audio continuation (no bank or voice headers), matching the format the hardware writes when saving a multi-disk instrument. The context is checked between WAV loads. Stereo samples are refused, as they are in Convert.

func ConvertMultiDiskFS added in v0.5.0

func ConvertMultiDiskFS(ctx context.Context, fsys fs.FS, sfzPath string, targetRate uint32, channel voiceimport.Channel) (voicebuild.MultiDiskResult, error)

ConvertMultiDiskFS converts the SFZ file at sfzPath inside fsys into a two disk full dump. It is the in-memory twin of ConvertMultiDisk: the caller writes the returned disks. channel carries the same answer ConvertFS takes.

Types

type Result added in v0.5.0

type Result struct {
	FZF  []byte
	Rate uint32
}

Result carries an in-memory conversion: the assembled full dump and the sample rate actually used, which fit to disk may have stepped down from the requested rate.

func ConvertDirFS added in v0.5.0

func ConvertDirFS(ctx context.Context, fsys fs.FS, targetRate uint32, fitToDisk bool, channel voiceimport.Channel) (*Result, error)

ConvertDirFS converts every WAV in fsys at any depth (sorted by path, sequential keys from C2) and returns the assembled full dump. It is the in-memory twin of ConvertDir. Depth is the one place the two differ.

ConvertDir takes a directory path, so the WAVs below it may belong to a neighbouring library. Its refusal tells the caller to move them up. fsys is exactly the tree the browser user dropped, already counted by the dialog. Converting the top level alone would drop the rest in silence.

channel answers for the whole folder, as it does in ConvertFS.

func ConvertFS added in v0.5.0

func ConvertFS(ctx context.Context, fsys fs.FS, sfzPath string, targetRate uint32, fitToDisk bool, channel voiceimport.Channel) (*Result, error)

ConvertFS converts the SFZ file at sfzPath inside fsys and returns the assembled full dump. It is the in-memory twin of Convert: same pipeline, same fit to disk behaviour, no filesystem writes. Sample references resolve inside fsys.

channel answers for the whole instrument: it says which side of a stereo sample the FZ keeps. voiceimport.ChannelMonoOnly refuses stereo input rather than guessing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL