Exemplo n.º 1
0
func main() {
	fs := audio.NewSin()
	fs.Input("pitch", audio.Value(-0.4))
	fm := audio.NewMul()
	fm.Input("a", audio.Value(0.2))
	fm.Input("b", fs)

	s := audio.NewSquare()
	s.Input("pitch", audio.Value(-0.1))
	f := audio.NewFilter()
	f.Input("in", s)
	f.Input("freq", fm)

	debug.View(debug.Render(debug.Process(f, 10)))
}
Exemplo n.º 2
0
func (o *Object) init() {
	var p interface{}
	switch o.Kind {
	case "clip":
		p = audio.NewClip()
	case "delay":
		p = audio.NewDelay()
	case "engine":
		p = audio.NewEngine()
	case "env":
		p = audio.NewEnv()
	case "mul":
		p = audio.NewMul()
	case "noise":
		p = audio.NewNoise()
	case "quant":
		p = audio.NewQuant()
	case "rand":
		p = audio.NewRand()
	case "sin":
		p = audio.NewSin()
	case "skip":
		p = audio.NewSkip()
	case "sequencer":
		p = audio.NewStep()
	case "square":
		p = audio.NewSquare()
	case "sum":
		p = audio.NewSum()
	case "value":
		p = audio.Value(o.Value)
	case "gate":
		p = midi.NewGate()
	case "note":
		p = midi.NewNote()
	default:
		panic("bad kind: " + o.Kind)
	}
	var dup *audio.Dup
	if proc, ok := p.(audio.Processor); ok {
		dup = audio.NewDup(proc)
	}
	o.proc = p
	o.dup = dup
	o.output = make(map[dest]*audio.Output)
}
Exemplo n.º 3
0
func NewObject(name, kind string, value float64) *Object {
	var p interface{}
	switch kind {
	case "clip":
		p = audio.NewClip()
	case "engine":
		p = audio.NewEngine()
	case "env":
		p = audio.NewEnv()
	case "mul":
		p = audio.NewMul()
	case "rand":
		p = audio.NewRand()
	case "sin":
		p = audio.NewSin()
	case "square":
		p = audio.NewSquare()
	case "sum":
		p = audio.NewSum()
	case "value":
		p = audio.Value(value)
	case "note":
		p = audio.NewMidiNote()
	case "gate":
		p = audio.NewMidiGate()
	default:
		panic("bad kind: " + kind)
	}
	var dup *audio.Dup
	if proc, ok := p.(audio.Processor); ok {
		dup = audio.NewDup(proc)
	}
	return &Object{
		Name:  name,
		Kind:  kind,
		Value: value,
		Input: make(map[string]string),

		proc:   p,
		dup:    dup,
		output: make(map[dest]*audio.Output),
	}
}