op1

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Attack = iota
	Decay
	Sustain
	Release
	Playmode
	Portamendo
)

ADSR parameters

Variables

View Source
var (
	AllowedADSR = [][]int{
		Range(64, 16320, 512),
		Range(64, 16320, 512),
		Range(0, 32767, 512),
		Range(64, 16320, 512),
		[]int{2048, 5120, 11264, 14336},
		[]int{64, 192, 6140},
	}

	AllowedOctave = []int{-2, 1, 0, 1, 2} // Octave ranges from -2 to +2

	AllowedEngine = []Setting{
		Setting{
			Name: "cluster",
			Parameters: [][]int{
				Range(3072, 17408, 128),
				Range(0, 32767, 128),
				Range(512, 24064, 128),
				Range(3, 1638, 128),
			},
		},
		Setting{
			Name: "digital",
			Parameters: [][]int{
				Range(0, 32767, 128),
				Range(2048, 26624, 128),
				Range(-32768, 32767, 128),
				Range(0, 32767, 128),
			},
		},
		Setting{
			Name: "dna",
			Parameters: [][]int{
				Range(-29491, 32767, 128),
				Range(4608, 12800, 128),
				Range(0, 32767, 128),
				Range(0, 32767, 128),
			},
		},
		Setting{
			Name: "drwave",
			Parameters: [][]int{
				Range(0, 32767, 128),
				Range(0, 32767, 128),
				Range(0, 32767, 128),
				Range(0, 32767, 128),
				Range(32000, 32000, 128),
			},
		},
	}

	AllowedEffects = []Setting{
		Setting{
			Name: "nitro",
			Parameters: [][]int{
				Range(64, 16448, 128),
				Range(-32768, 32768, 512),
				Range(0, 20643, 128),
				Range(64, 16448, 128),
			},
		},
		Setting{
			Name: "cwo",
			Parameters: [][]int{
				Range(0, 32767, 128),
				Range(0, 32767, 128),
				Range(0, 32767, 128),
				Range(0, 32767, 128),
			},
		},
		Setting{
			Name: "delay",
			Parameters: [][]int{
				Range(1024, 11264, 128),
				Range(3276, 32767, 128),
				Range(0, 16384, 128),
				Range(0, 32767, 128),
			},
		},
		Setting{
			Name: "grid",
			Parameters: [][]int{
				Range(1344, 16704, 128),
				Range(1344, 16704, 128),
				Range(0, 32767, 128),
				Range(0, 32767, 128),
				Range(8000, 8000, 128),
				Range(8000, 8000, 128),
				Range(8000, 8000, 128),
				Range(8000, 8000, 128),
			},
		},
	}

	AllowedLFO = []Setting{
		Setting{
			Name: "element",
			Parameters: [][]int{
				[]int{7168, 5056, 5280, 2000, 2144},
				Range(-32767, 32767, 512),
				[]int{1024, 2000, 2448, 5056, 7168},
				[]int{1024, 2000, 5056, 5824, 10526, 15360},
			},
		},
		Setting{
			Name: "tremelo",
			Parameters: [][]int{
				Range(16400, 32440, 512),
				Range(-32767, 32767, 512),
				Range(-32767, 32767, 512),
			},
		},
	}
)

specified allowed values for parameters

View Source
var MAXENDPOINT = int64(2147483646)

2147483646 = max value found in the sample end points

View Source
var SAMPLECONVERSION = int64(4058)

2147483646/(44100*12) ~ 4058

View Source
var SAMPLERATE = int64(44100)

Functions

func Has added in v1.0.0

func Has(list []int, val int) bool

func Hashid added in v1.0.0

func Hashid(ints []int) string

func Range added in v1.0.0

func Range(start, end, inc int) (r []int)

Range generates a list of numbers from specified range, inclusive

Types

type DrumPatch

type DrumPatch struct {
	DrumVersion int     `json:"drum_version"`
	DynaEnv     []int64 `json:"dyna_env"`
	End         []int64 `json:"end"`
	FxActive    bool    `json:"fx_active"`
	FxParams    []int64 `json:"fx_params"`
	FxType      string  `json:"fx_type"`
	LfoActive   bool    `json:"lfo_active"`
	LfoParams   []int64 `json:"lfo_params"`
	LfoType     string  `json:"lfo_type"`
	Name        string  `json:"name"`
	Octave      int64   `json:"octave"`
	Pitch       []int64 `json:"pitch"`
	Playmode    []int64 `json:"playmode"`
	Reverse     []int64 `json:"reverse"`
	Start       []int64 `json:"start"`
	Type        string  `json:"type"`
	Volume      []int64 `json:"volume"`
}

DrumPatch is a list of custom fields sometimes set by OP-1

func NewDrumPatch added in v1.0.0

func NewDrumPatch() DrumPatch

NewDrumPatch returns a new DrumPatch with correct defaults

func (*DrumPatch) Save added in v1.0.0

func (drumpatch *DrumPatch) Save(audioClip string, fnameOut string) (err error)

Save creates a drum patch from op1 meta data and a song clip

type Setting added in v1.0.0

type Setting struct {
	Name       string
	Parameters [][]int
}

type SynthPatch added in v1.0.0

type SynthPatch struct {
	Adsr         [8]int  `json:"adsr"`
	FxActive     bool    `json:"fx_active"`
	FxParams     [8]int  `json:"fx_params"`
	FxType       string  `json:"fx_type"`
	Knobs        [8]int  `json:"knobs"`
	LfoActive    bool    `json:"lfo_active"`
	LfoParams    [8]int  `json:"lfo_params"`
	LfoType      string  `json:"lfo_type"`
	Name         string  `json:"name"`
	Octave       int     `json:"octave"`
	SynthVersion int     `json:"synth_version"`
	Type         string  `json:"type"`
	BaseFreq     float64 `json:"base_freq,omitempty"`
}

func NewSynthPatch added in v1.0.0

func NewSynthPatch() (sd SynthPatch)

func NewSynthSamplePatch added in v1.0.0

func NewSynthSamplePatch(freq ...float64) (sd SynthPatch)

func RandomSynthPatch added in v1.0.0

func RandomSynthPatch(seed ...int64) (sd SynthPatch)

func ReadSynthPatch added in v1.0.0

func ReadSynthPatch(fname string) (sp SynthPatch, err error)

func (SynthPatch) Check added in v1.0.0

func (s SynthPatch) Check() (err error)

Check will return an error if any of the values are out of range

func (SynthPatch) Encode added in v1.0.0

func (s SynthPatch) Encode() (encoded string)

func (SynthPatch) SaveSample added in v1.0.0

func (s SynthPatch) SaveSample(fname string, fnameout string, trimSilence bool) (err error)

Build a synth patch from a file

func (SynthPatch) SaveSynth added in v1.0.0

func (s SynthPatch) SaveSynth(fnameOut string, fnamein ...string) (err error)

Jump to

Keyboard shortcuts

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