Ejemplo n.º 1
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 "saw":
		p = audio.NewBandLimitedSaw()
	case "sin":
		p = audio.NewSin()
	case "skip":
		p = audio.NewSkip()
	case "sequencer":
		p = audio.NewStep()
	case "square":
		p = audio.NewBandLimitedSquare()
	case "sum":
		p = audio.NewSum()
	case "triangle":
		p = audio.NewBandLimitedTriangle()
	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)
}
Ejemplo n.º 2
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),
	}
}