vm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Code generated by go generate; DO NOT EDIT.

Index

Constants

View Source
const MAX_UNITS = 63
View Source
const MAX_VOICES = 32

Variables

This section is empty.

Functions

func ConstructPatterns

func ConstructPatterns(song *sointu.Song) ([][]byte, [][]byte, error)

func Synth

func Synth(patch sointu.Patch) (sointu.Synth, error)

Types

type AllFeatures

type AllFeatures struct {
}

AllFeatures is used by the library compilation / bridging to configure a virtual machine that supports every conceivable parameter, so it needs no members and just returns "true" to all queries about what it supports. Contrast this NecessaryFeatures that only returns true if the patch needs support for that feature

func (AllFeatures) InputNumber

func (_ AllFeatures) InputNumber(unitType string, paramName string) int

func (AllFeatures) Instructions

func (_ AllFeatures) Instructions() []string

func (AllFeatures) Opcode

func (_ AllFeatures) Opcode(unitType string) (int, bool)

func (AllFeatures) SupportsGlobalSend

func (_ AllFeatures) SupportsGlobalSend() bool

func (AllFeatures) SupportsModulation

func (_ AllFeatures) SupportsModulation(unit string, port string) bool

func (AllFeatures) SupportsParamValue

func (_ AllFeatures) SupportsParamValue(unit string, paramName string, value int) bool

func (AllFeatures) SupportsParamValueOtherThan

func (_ AllFeatures) SupportsParamValueOtherThan(unit string, paramName string, value int) bool

func (AllFeatures) SupportsPolyphony

func (_ AllFeatures) SupportsPolyphony() bool

func (AllFeatures) TransformCount

func (_ AllFeatures) TransformCount(unitType string) int

type BytePatch

type BytePatch struct {
	Commands         []byte
	Values           []byte
	DelayTimes       []uint16
	SampleOffsets    []SampleOffset
	PolyphonyBitmask uint32
	NumVoices        uint32
}

BytePatch is the compiler Sointu VM bytecode & data (delay times, sample offsets) ready to interpret or from which the ASM/WASM code can be generate.

PolyphonyBitmask is a rather peculiar bitmask used by Sointu VM to store the information about which voices use which instruments: bit MAXVOICES - n - 1 corresponds to voice n. If the bit 1, the next voice uses the same instrument. If the bit 0, the next voice uses different instrument. For example, if first instrument has 3 voices, second instrument has 2 voices, and third instrument four voices, the PolyphonyBitmask is:

(MSB) 110101110 (LSB)

func Encode

func Encode(patch sointu.Patch, featureSet FeatureSet) (*BytePatch, error)

type FeatureSet

type FeatureSet interface {
	Opcode(unitType string) (int, bool)
	TransformCount(unitType string) int
	Instructions() []string
	InputNumber(unitType string, paramName string) int
	SupportsParamValue(unitType string, paramName string, value int) bool
	SupportsParamValueOtherThan(unitType string, paramName string, value int) bool
	SupportsModulation(unitType string, paramName string) bool
	SupportsPolyphony() bool
	SupportsGlobalSend() bool
}

FeatureSet defines what opcodes / parameters are included in the compiled virtual machine It is used by the compiler to decide how to encode opcodes

type Instruction

type Instruction struct {
	Name           string
	TransformCount int
}

type Interpreter

type Interpreter struct {
	// contains filtered or unexported fields
}

Interpreter is a pure-Go bytecode interpreter for the Sointu VM bytecode. It can only simulate bytecode compiled for AllFeatures, as the opcodes hard coded in it for speed. If you are interested exactly how opcodes / units work, studying Interpreter.Render is a good place to start.

Internally, it uses software stack with practically no limitations in the number of signals, so be warned that if you compose patches for it, they might not work with the x87 implementation, as it has only 8-level stack.

func (*Interpreter) Release

func (s *Interpreter) Release(voiceIndex int)

func (*Interpreter) Render

func (s *Interpreter) Render(buffer []float32, syncBuf []float32, maxtime int) (samples int, syncs int, time int, renderError error)

func (*Interpreter) Trigger

func (s *Interpreter) Trigger(voiceIndex int, note byte)

func (*Interpreter) Update

func (s *Interpreter) Update(patch sointu.Patch) error

type NecessaryFeatures

type NecessaryFeatures struct {
	// contains filtered or unexported fields
}

NecessaryFeatures returns true only if the patch actually needs the support for the feature

func NecessaryFeaturesFor

func NecessaryFeaturesFor(patch sointu.Patch) NecessaryFeatures

func (NecessaryFeatures) InputNumber

func (n NecessaryFeatures) InputNumber(unitType string, paramName string) int

func (NecessaryFeatures) Instructions

func (n NecessaryFeatures) Instructions() []string

func (NecessaryFeatures) Opcode

func (n NecessaryFeatures) Opcode(unitType string) (int, bool)

func (NecessaryFeatures) SupportsGlobalSend

func (n NecessaryFeatures) SupportsGlobalSend() bool

func (NecessaryFeatures) SupportsModulation

func (n NecessaryFeatures) SupportsModulation(unit string, param string) bool

func (NecessaryFeatures) SupportsParamValue

func (n NecessaryFeatures) SupportsParamValue(unit string, paramName string, value int) bool

func (NecessaryFeatures) SupportsParamValueOtherThan

func (n NecessaryFeatures) SupportsParamValueOtherThan(unit string, paramName string, value int) bool

func (NecessaryFeatures) SupportsPolyphony

func (n NecessaryFeatures) SupportsPolyphony() bool

func (NecessaryFeatures) TransformCount

func (_ NecessaryFeatures) TransformCount(unitType string) int

type SampleOffset

type SampleOffset struct {
	Start      uint32
	LoopStart  uint16
	LoopLength uint16
}

type SynthService

type SynthService struct {
}

func (SynthService) Compile

func (s SynthService) Compile(patch sointu.Patch) (sointu.Synth, error)

Directories

Path Synopsis
+build ignore
+build ignore

Jump to

Keyboard shortcuts

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