wavx

package module
v0.0.0-...-b50b806 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2021 License: MIT Imports: 13 Imported by: 0

README

wavx

A tiny toy synthesizer written in Go

Documentation

Index

Constants

View Source
const (
	AmplitudeInputSignal     = "signal"
	AmplitudeInputModulation = "modulation"
)
View Source
const (
	DistortionInputSignal             = "signal"
	DistortionInputTresholdModulation = "threshold-modulation"
)
View Source
const (
	FilterInputSignal              = "signal"
	FilterInputCutoffModulation    = "cutoff-modulation"
	FilterInputResonanceModulation = "resonance-modulation"
)
View Source
const (
	AdderInput = "signal"
)
View Source
const SampelRate44100 = 44100
View Source
const (
	StdOscillatorInputFreqMod = "frequency-modulation"
)

Variables

This section is empty.

Functions

func AbsInt

func AbsInt(n int) int

func ApplyCommand

func ApplyCommand(cmd Command, data interface{}) error

func MaxAbsInts

func MaxAbsInts(ns []int) int

func RoundInt

func RoundInt(f float64) int

Types

type Activator

type Activator struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Activator) Activate

func (a *Activator) Activate()

func (*Activator) Deactivate

func (a *Activator) Deactivate()

func (*Activator) IsActive

func (a *Activator) IsActive() bool

type Adder

type Adder struct {
	Activator
	// contains filtered or unexported fields
}

func NewAdder

func NewAdder() *Adder

func (*Adder) ConnectInput

func (a *Adder) ConnectInput(input string, op Outputter)

func (*Adder) Execute

func (a *Adder) Execute(cmd Command)

func (*Adder) Inputs

func (a *Adder) Inputs() []string

func (*Adder) Output

func (a *Adder) Output(secs float64) float64

type AllPassFilter

type AllPassFilter struct {
	Gain         float64
	DelayMsec    float64
	SamplingRate float64
	// contains filtered or unexported fields
}

func NewAllPassFilter

func NewAllPassFilter(gain, delayMsec, samplingRate float64) *AllPassFilter

func (*AllPassFilter) Next

func (f *AllPassFilter) Next(x float64) float64

type Amplituder

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

func NewAmplituder

func NewAmplituder(baseAmpl float64) *Amplituder

func (*Amplituder) ConnectInput

func (a *Amplituder) ConnectInput(input string, op Outputter)

func (*Amplituder) Inputs

func (a *Amplituder) Inputs() []string

func (*Amplituder) Output

func (a *Amplituder) Output(secs float64) float64

type ChangeFloat

type ChangeFloat struct {
	Mode  ChangeMode
	Value float64
}

func ParseChangeFloat

func ParseChangeFloat(s string) (ChangeFloat, error)

func (ChangeFloat) Applied

func (cf ChangeFloat) Applied(v float64) float64

type ChangeInt

type ChangeInt struct {
	Mode  ChangeMode
	Value int64
}

func ParseChangeInt

func ParseChangeInt(s string) (ChangeInt, error)

func (ChangeInt) Applied

func (ci ChangeInt) Applied(v int64) int64

type ChangeMode

type ChangeMode int
const (
	ChangeAbs ChangeMode = iota
	ChangeInc
	ChangeDec
)

type Chorus

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

func NewChorus

func NewChorus(sampleRate float64, delayMSec float64) *Chorus

func (*Chorus) ConnectInput

func (d *Chorus) ConnectInput(op Outputter)

func (*Chorus) ConnectInputLFO

func (d *Chorus) ConnectInputLFO(op Outputter)

func (*Chorus) Output

func (d *Chorus) Output(secs float64) float64

type CombFilter

type CombFilter struct {
	Gain         float64
	DelayMsec    float64
	SamplingRate float64
	// contains filtered or unexported fields
}

func NewCombFilter

func NewCombFilter(gain, delayMsec, samplingRate float64) *CombFilter

func (*CombFilter) Change

func (f *CombFilter) Change(delayMsec, samplingRate float64)

func (*CombFilter) Next

func (f *CombFilter) Next(x float64) float64

type Command

type Command map[string]string

func (Command) String

func (c Command) String() string

type Distortion

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

func NewDistortion

func NewDistortion(baseThreshold float64) *Distortion

func (*Distortion) ConnectInput

func (d *Distortion) ConnectInput(input string, op Outputter)

func (*Distortion) Inputs

func (d *Distortion) Inputs() []string

func (*Distortion) Output

func (d *Distortion) Output(secs float64) float64

type Envelope

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

func NewEnvelope

func NewEnvelope(ps EnvelopeParams) *Envelope

func (*Envelope) IsActive

func (e *Envelope) IsActive() bool

func (*Envelope) IsStarted

func (e *Envelope) IsStarted() bool

func (*Envelope) Release

func (e *Envelope) Release(secs float64)

func (*Envelope) Start

func (e *Envelope) Start(secs float64)

func (*Envelope) Value

func (e *Envelope) Value(secs float64) float64

type EnvelopeParams

type EnvelopeParams struct {
	Attack  float64
	Decay   float64
	Sustain float64
	Release float64
}

EnvelopeParams holds all envelope params; attack, decay and release are in seconds

type EnveloppedOscillator

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

type Filter

type Filter struct {
	Params FilterParams

	Activator
	// contains filtered or unexported fields
}

func NewFilter

func NewFilter(mode FilterMode, baseCutoff float64, baseResonance float64) *Filter

func (*Filter) ChangeCutoff

func (f *Filter) ChangeCutoff(cutoff float64)

func (*Filter) ChangeMode

func (f *Filter) ChangeMode(mode FilterMode)

func (*Filter) ChangeParameters

func (f *Filter) ChangeParameters(params FilterParams)

func (*Filter) ChangeResonance

func (f *Filter) ChangeResonance(res float64)

func (*Filter) ConnectInput

func (f *Filter) ConnectInput(input string, op Outputter)

func (*Filter) Execute

func (a *Filter) Execute(cmd Command)

func (*Filter) Inputs

func (f *Filter) Inputs() []string

func (*Filter) Output

func (f *Filter) Output(secs float64) float64

func (*Filter) Parameters

func (f *Filter) Parameters() FilterParams

type FilterMode

type FilterMode string
const (
	FilterModeLowPass  FilterMode = "lowpass"
	FilterModeHighPass FilterMode = "highpass"
	FilterModeBandPass FilterMode = "bandpass"
)

type FilterParams

type FilterParams struct {
	Mode      FilterMode
	Cutoff    float64
	Resonance float64
}

type FixedSustainEnvelope

type FixedSustainEnvelope struct {
	*Envelope
	// contains filtered or unexported fields
}

func NewFixedSustainEnvelope

func NewFixedSustainEnvelope(ps EnvelopeParams, sustainDuration float64) *FixedSustainEnvelope

func (*FixedSustainEnvelope) Value

func (e *FixedSustainEnvelope) Value(secs float64) float64

type InputOutputter

type InputOutputter interface {
	Outputter
	Activate()
	Deactivate()
	Execute(cmd Command)
	Inputs() []string
	ConnectInput(input string, op Outputter)
}

type LFO

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

func NewLFO

func NewLFO(typ StdOscillatorType, offset, amplitude, freq float64) *LFO

func (*LFO) Output

func (lfo *LFO) Output(secs float64) float64

type LinearBuffer

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

func NewLinearBuffer

func NewLinearBuffer(maxSize int) *LinearBuffer

func (*LinearBuffer) ChangeMaxSize

func (b *LinearBuffer) ChangeMaxSize(n int)

func (*LinearBuffer) FirstValue

func (b *LinearBuffer) FirstValue() float64

func (*LinearBuffer) IsEmpty

func (b *LinearBuffer) IsEmpty() bool

func (*LinearBuffer) Push

func (b *LinearBuffer) Push(v float64)

type OscillatorPool

type OscillatorPool struct {
	sync.RWMutex
	Activator
	// contains filtered or unexported fields
}

func NewOscillatorPool

func NewOscillatorPool() *OscillatorPool

func (*OscillatorPool) ConnectInput

func (a *OscillatorPool) ConnectInput(input string, op Outputter)

func (*OscillatorPool) Execute

func (p *OscillatorPool) Execute(cmd Command)

func (*OscillatorPool) Inputs

func (p *OscillatorPool) Inputs() []string

func (*OscillatorPool) Output

func (a *OscillatorPool) Output(secs float64) float64

type Outputter

type Outputter interface {
	Output(secs float64) float64
}

type Reverb

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

func NewReverb

func NewReverb(sampleRate float64) *Reverb

func (*Reverb) ConnectInput

func (d *Reverb) ConnectInput(op Outputter)

func (*Reverb) Output

func (d *Reverb) Output(secs float64) float64

type StdOscillator

type StdOscillator struct {
	Params       StdOscillatorParams
	FreqModInput Outputter

	Muted bool
	// contains filtered or unexported fields
}

func NewStdOscillator

func NewStdOscillator(typ StdOscillatorType, baseFreq float64, baseAmpl float64, overtones int) *StdOscillator

func (*StdOscillator) Activate

func (o *StdOscillator) Activate()

func (*StdOscillator) ChangeAmpl

func (o *StdOscillator) ChangeAmpl(ampl float64)

func (*StdOscillator) ChangeFreq

func (o *StdOscillator) ChangeFreq(freq float64)

func (*StdOscillator) ChangeOvertones

func (o *StdOscillator) ChangeOvertones(n int)

func (*StdOscillator) ChangeParameters

func (o *StdOscillator) ChangeParameters(params StdOscillatorParams)

func (*StdOscillator) ChangeType

func (o *StdOscillator) ChangeType(typ StdOscillatorType)

func (*StdOscillator) ConnectInput

func (o *StdOscillator) ConnectInput(input string, op Outputter)

func (*StdOscillator) Deactivate

func (o *StdOscillator) Deactivate()

func (*StdOscillator) Execute

func (o *StdOscillator) Execute(cmd Command)

func (*StdOscillator) Inputs

func (o *StdOscillator) Inputs() []string

func (*StdOscillator) IsMuted

func (o *StdOscillator) IsMuted() bool

func (*StdOscillator) Mute

func (o *StdOscillator) Mute()

func (*StdOscillator) Output

func (o *StdOscillator) Output(secs float64) float64

func (*StdOscillator) Parameters

func (o *StdOscillator) Parameters() StdOscillatorParams

func (*StdOscillator) Unmute

func (o *StdOscillator) Unmute()

type StdOscillatorParams

type StdOscillatorParams struct {
	Type      StdOscillatorType
	Freq      float64
	Ampl      float64
	Overtones int
}

type StdOscillatorType

type StdOscillatorType string
const (
	StdOscillatorSine     StdOscillatorType = "sine"
	StdOscillatorSquare   StdOscillatorType = "square"
	StdOscillatorSaw      StdOscillatorType = "saw"
	StdOscillatorTriangle StdOscillatorType = "triangle"
)

type Synthesizer

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

func NewSynthesizer

func NewSynthesizer(sampleRate int, outputter Outputter) *Synthesizer

func (*Synthesizer) Close

func (s *Synthesizer) Close() error

func (*Synthesizer) Next

func (s *Synthesizer) Next() float32

func (*Synthesizer) Open

func (s *Synthesizer) Open() error

func (*Synthesizer) Start

func (s *Synthesizer) Start() error

func (*Synthesizer) Stop

func (s *Synthesizer) Stop() error

type WavOutputter

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

func NewWavOutputter

func NewWavOutputter(filePath string) (*WavOutputter, error)

func (*WavOutputter) Output

func (o *WavOutputter) Output(secs float64) float64

sample-rate = 44100

Directories

Path Synopsis
cmd
wav

Jump to

Keyboard shortcuts

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