func NewBeatsKey(idx int) Key { osc := snd.NewOscil(sawsine, notes[idx], snd.NewOscil(triangle, 4, nil)) dmp := snd.NewDamp(bpm.Dur(), osc) d := snd.BPM(float64(bpm) * 1.25).Dur() dmp1 := snd.NewDamp(d, osc) drv := snd.NewDrive(d, osc) mix := snd.NewMixer(dmp, dmp1, drv) frz := snd.NewFreeze(bpm.Dur()*4, mix) adsr := snd.NewADSR(250*ms, 500*ms, 300*ms, 400*ms, 0.85, 1.0, frz) key := &BeatsKey{snd.NewInstrument(adsr), adsr} key.Off() return key }
sqsine = snd.SquareSynthesis(49) sine = snd.Sine() triangle = snd.Triangle() notes = snd.EqualTempermant(12, 440, 48) keys [12]Key reverb snd.Sound metronome snd.Sound loop *snd.Loop lowpass *snd.LowPass keymix *snd.Mixer keygain *snd.Gain master *snd.Mixer mastergain *snd.Gain bpm = snd.BPM(80) loopdur = snd.Dtof(bpm.Dur(), snd.DefaultSampleRate) * 8 //nframes sndbank = []KeyFunc{NewPianoKey, NewWobbleKey, NewBeatsKey} sndbankpos = 0 ms = time.Millisecond ) func makekeys() { keymix.Empty() for i := range keys { keys[i] = sndbank[sndbankpos](51 + i) // notes[51] is Major C keys[i].Freeze() keymix.Append(keys[i]) }