Envelopes and samples
Run from the repository root to play on the default output device.
CGO_ENABLED=0 go run ./internal/test/synth/envelope-and-sample
To render the phrase without an audio device, pass an output path.
CGO_ENABLED=0 go run ./internal/test/synth/envelope-and-sample -out ./envelope-and-sample.wav
The demo plays the traditional melody "Frere Jacques" with a quiet sine
accompaniment. Listen for the opening one-shot samples, the notes that
release during attack in the third bar, and the sustained forward loop in
the fourth. The quick phrases use a bidirectional loop with tick-driven
stereo motion and slight vibrato. The final two bars use a sustain loop that exits at note-off.
Listen for the alternating drum parts every two bars. The synthesized
808-style kick has a longer low tail. The synthesized 909-style kick has a
sharper attack and a shorter tail. Both are one-shot PCM clips.
Coverage checklist
| Feature |
Public API |
Passage and check |
| Continuous and scheduled sine |
NewTone, Sine.NewVoice, TriggerAt |
Bar 1 holds a continuous bass. Later bars schedule the bass. The WAV test checks the melody over the accompaniment. |
| Phase 1 voice controls |
SetGainAt, SetPanAt, SetPitchAt, RetriggerAt, FadeAt, CutAt, ReleaseAt |
The scheduled bass changes gain, pan, and pitch, retriggers near zero, then fades and cuts. The lead releases at phrase boundaries. The synth tests check each control against exact PCM. |
| Pitched clips and percussion |
NewPCMInstrument, PitchHz, PitchSampleStep, TriggerAt |
The melody uses pitched samples and a source offset in the quick phrases. Both kick sounds use one-shot PCM. The WAV test checks all melody pitches and the attacks and tails of both kicks. |
| ADSR |
NewADSR |
The third bar releases during attack. The synth test checks that the release starts at the current level. |
| Tick envelopes |
PointEnvelope, TickVoice.ScheduleTick |
Tick changes drive stereo motion and vibrato on the quick phrases, and shape the 909-style kick level. The synth tests check pitch, pan, volume, and ordering. |
| Forward, bidirectional, and sustain loops |
SampleLoop, LoopForward, LoopPingPong, ReleaseAt |
Bar 4 sustains a forward loop, bars 5 and 6 reflect the cursor, and the final bars exit the sustain loop at note-off. The synth tests verify exact PCM across the wrap and release points. |