A Volta instrument is a patch — a little wiring diagram. The smallest one needs just two things: a source (what makes the tone) and a gain (how loud).
source = sine (freq pitch) is a sine-wave oscillator. pitch is whatever note is playing; freq pitch turns that note into a frequency in Hz.
gain = vel * 0.5 sets the level to half of the note's velocity (how hard it's struck).
loop = play beep !"c3 e3 g3 e3" plays the patch through a four-note pattern. Press ▶ Play and watch the scope — then start typing. Every edit recompiles and plays instantly.
Note names are letter + octave: c3, eb3, f#4. A ~ is a rest — a silent step that keeps its place in time.
The starting point#
The lesson opens with this song in the editor. Every edit recompiles and plays.
-- Hello, sound: the smallest possible instrument.
beep = patch {
source = sine (freq pitch),
gain = vel * 0.5
}
loop = play beep !"c3 e3 g3 e3"
What to watch#
The scope draws a smooth, round wave — a pure sine, the simplest possible tone. The spectrum has one peak and nothing above it: a single frequency, no harmonics stacked on top.
Goals#
The workbench checks these as you work; the solution is there when you want it.
- Press ▶ Play and hear it
- Write your own melody — at least four different notes
- Stretch: give the phrase eight or more steps
Make it yours#
Make the melody yours — find three notes that sound good together and end the phrase on the note it started on.
Further reading#
Language reference in the reference.