Пример #1
0
// Converts a treble note offset to a midi offset
func noteTMidi(note float64, quaverCount float64) s.Sound {
	// NOTE: Only [-8, 8] allowed for 'note'.
	bFloat, sharp := math.Modf(note)
	base := int(bFloat)
	if sharp < 0 {
		sharp += 1.0
		base--
	}

	// 0 = B = offset 8
	midi := trebleMidi[base+8] + trebleKeys[base+8]
	if sharp > 0.1 {
		midi++
	}
	midiToSound := s.NewTimedSound(util.MidiToSound(midi), quaverCount*q)
	return s.NewADSREnvelope(midiToSound, 15, 50, 0.5, 20)
}
Пример #2
0
func SampleAdsrEnvelope() s.Sound {
	// Includes: TimedSound and SineWave
	return s.NewADSREnvelope(
		s.NewTimedSound(s.NewSineWave(880.0), 875),
		50, 200, 0.5, 100)
}