The theremin is an electronic musical instrument that you play without touching it. Your right hand near a vertical antenna controls pitch, your left hand near a loop antenna controls volume, and the instrument turns your body’s tiny electrical influence into a singing, gliding tone. Leon Theremin, a Russian physicist, invented it in 1920, and more than a century later it still pulls in composers, film scorers and interactive artists.
What the theremin actually is
The theremin is a box with two antennas. A straight rod usually rises from the right side and a horizontal loop sticks out from the left. You stand in front of it, and the space around those antennas becomes the instrument.
Move your right hand toward the rod and the pitch climbs. Pull it away and the pitch falls. Lower your left hand toward the loop and the sound fades, until it goes silent just above the metal. Lift it and the note swells back.
There are no keys, frets or strings. Nothing marks where a note lives. A player finds each pitch by ear and muscle memory, holding the hand still in midair to the nearest few millimetres. That is why a well-played theremin sounds like a human voice or a cello, and a badly played one sounds like a haunted house.
It was also one of the first electronic instruments to get real attention. It came well before synthesizers and before the electric guitar became common, and it was the first one many audiences in the 1920s ever heard. Its original names reflect that era: “etherphone” and “thereminvox” (in Russian, termenvox), after the inventor’s name in its French form.
How a theremin works
The theremin’s sound comes from a neat bit of radio engineering. Once you understand three ideas (capacitance, heterodyning and resonance), the whole instrument makes sense.
Your body is part of the circuit
A capacitor is two conductors separated by a gap. It stores charge, and how much depends on the size of the conductors and how close they are.
In a theremin, the pitch antenna is one conductor. Your hand is the other. You’re connected to electrical ground through the floor and, more reliably, through the instrument’s own ground, so your body acts like a large conductive plate. As your hand moves closer to the rod, the capacitance between them goes up. Move away and it drops.
The change is tiny. You’re talking about fractions of a picofarad up to a few picofarads, which is far too small to matter in most circuits. The theremin is designed so that this tiny change matters a lot.
The heterodyne trick: two oscillators and one audible difference
Inside a classic theremin there are two radio-frequency oscillators. These are circuits that swing back and forth at a steady rate, far above human hearing. In an LC oscillator, the frequency depends on the inductance (L) and capacitance (C) in the circuit:
f = 1 / (2π√(LC))
One oscillator runs at a fixed frequency. The other, the variable oscillator, has the pitch antenna wired into its tuning circuit. When your hand adds capacitance, the variable oscillator’s frequency drops slightly.
Neither oscillator is audible on its own. The magic happens in the mixer. When you combine two frequencies in a nonlinear circuit, you get new ones: their sum and their difference. This is the heterodyne principle, which radio receivers have used since the early 20th century. A filter throws away the very high sum frequency. The difference stays, and if the oscillators are close in frequency, that difference lands in the range you can hear.
Here is an illustrative example with round numbers:
| Hand position | Fixed oscillator | Variable oscillator | Difference you hear |
|---|---|---|---|
| Far from rod | 260,000 Hz | 260,000 Hz | 0 Hz (silence or a low rumble) |
| Middle distance | 260,000 Hz | 260,220 Hz | 220 Hz (A3) |
| Closer | 260,000 Hz | 260,440 Hz | 440 Hz (A4) |
| Very close | 260,000 Hz | 260,880 Hz | 880 Hz (A5) |
(In this example the variable oscillator is set so it rises as your hand nears. Designers can arrange it either way; what matters is the gap.)
Look at that 440 Hz row. The variable oscillator moved by about 0.17 percent. Because frequency depends on the square root of capacitance, that’s roughly a 0.34 percent change in C. A shift of a fraction of a percent at radio frequency becomes a full musical octave at audio frequency. That magnification is the whole reason a hand in the air can play melodies.
It also explains why the theremin is so touchy. Shift your weight, lean forward or let someone walk past, and the pitch moves. You’re playing the electrical field of the room, and your whole body is in it.
The volume antenna works by resonance
The loop on the left uses a different trick. It’s connected to a third oscillator, and that oscillator feeds a tuned circuit, a filter that responds strongly at one frequency and weakly at others.
When your left hand is up high, the volume oscillator sits near the filter’s sweet spot and produces a strong signal. As your hand drops toward the loop, the added capacitance pulls the oscillator off that sweet spot. The filter’s output shrinks. The circuit rectifies that output into a control voltage, which drives a voltage-controlled amplifier on the audio signal. Less control voltage, less volume.
So the theremin player gets two continuous controls in midair: pitch on the right, loudness on the left. With practice you can use the left hand to articulate notes, cutting the sound between pitches so the instrument doesn’t just slide everywhere.
Why the pitch field isn’t even
Capacitance doesn’t change linearly with distance. Near the rod, a tiny movement makes a big pitch jump. Far away, you have to move a long way for a small change. On a raw circuit, the high notes would be squashed into a few centimetres next to the antenna.
Good theremin designs work hard to linearize the pitch field so that musical intervals are spread more evenly through the air. Designers use extra inductance in series with the antenna, careful oscillator design and tuning controls to shape the response. Clara Rockmore, the instrument’s greatest virtuoso, pushed Leon Theremin to improve exactly this, along with the range and responsiveness, so she could play fast classical passages.
Even on the best instruments, the spacing isn’t perfectly even. Players learn the field’s shape the way violinists learn how notes get closer together as you move up the fingerboard.
What makes the tone
A pure difference frequency would be close to a sine wave, which sounds thin. Real theremins sound richer because the mixing stage isn’t perfectly clean, and designers add waveshaping and filtering to bring in harmonics. Modern instruments such as Moog’s Etherwave include controls for waveform and brightness, so you can move from a flute-like tone to something nasal and buzzy.
The rest of the character comes from the player. Vibrato, slides, swells and the slight wobble of a human hand are what make the theremin sound alive.
Analog, digital and assisted theremins
The classic design is fully analog. It warms up, drifts with temperature and needs retuning after a few minutes on. Plenty of players love it anyway.
Newer instruments take other routes:
- Digital oscillators. Some theremins measure antenna capacitance and generate the tone digitally, which makes them more stable and allows different sounds.
- Pitch correction. Moog’s Theremini, released in 2014, can snap your hand’s position toward notes of a chosen scale. You can turn the assistance down as you improve.
- Open hardware. The Open.Theremin project is an open-source design built around an Arduino-compatible board, popular with makers and students.
The physics is the same in all of them. Your hand changes a capacitance, and electronics turn that change into pitch and volume.
From a Petrograd lab to New York concert halls

A physicist chasing a different problem
Lev Sergeyevich Termen, known in the West as Leon Theremin, was born in St Petersburg in 1896. He trained in physics and music, and by 1920 he was working in Abram Ioffe’s lab at the Physico-Technical Institute in Petrograd.
His task wasn’t musical. He was building equipment to measure the dielectric properties of gases, using oscillating circuits whose frequency changed with what sat between their plates. The usual story is that he noticed the device’s whine changed as his hand moved nearby. A musician by training, he started playing tunes on it.
He also saw the security potential. The same principle could detect a person approaching an object, and he developed proximity alarms alongside the instrument.
Lenin, a European tour and America
In 1922 Theremin demonstrated his invention to Vladimir Lenin in the Kremlin, and Lenin reportedly tried playing it himself. The Soviet government saw the instrument as a showcase for electrification and modern science, and it sent Theremin on a tour of Europe, where he played to packed halls.
He arrived in the United States at the end of 1927 and stayed for about a decade. He received a US patent for the instrument in 1928, gave demonstrations to high society and to scientists, and staged concerts in New York, including ensemble performances with multiple theremins at Carnegie Hall.
The RCA theremin
RCA licensed the design and began manufacturing theremins in 1929, aiming at home musicians. Only around 500 were made. The timing was terrible: the stock market crash came the same year, and the instrument was far harder to play than the marketing implied. Most buyers couldn’t get a tune out of it.
Surviving RCA theremins are now prized by collectors and players. Clara Rockmore’s own instrument was a heavily customized one built for her by Theremin himself.
Clara Rockmore and the concert theremin
Clara Rockmore (born Clara Reisenberg in Vilnius in 1911) was a violin prodigy whose career was cut short by problems with her bow arm. She met Theremin in New York and turned his invention into a serious concert instrument.
She developed aerial fingering, a system of hand and finger positions that let her jump between precise pitches without sliding through everything in between. She played Bach, Tchaikovsky, Rachmaninoff and Saint-Saëns with phrasing that sounded like a singer or a string player. Her 1977 album The Art of the Theremin, produced by Robert Moog, is still the recording most players point to when they want to show what the instrument can do.
Another early champion was Lucie Bigelow Rosen, who commissioned new works for the theremin. Bohuslav Martinů wrote his Fantasia for theremin, oboe, piano and string quartet for her in 1944. Rockmore premiered Anis Fuleihan’s Concerto for Theremin with Leopold Stokowski in 1945.
Composers experimented with Theremin’s other inventions too. Edgard Varèse wrote Ecuatorial (1934) for an ensemble including two fingerboard theremins, though the parts were later reassigned to ondes Martenot. Percy Grainger wrote Free Music for multiple theremins in the 1930s, chasing gliding, unpitched-sounding lines that conventional instruments couldn’t play.
The other inventions
Theremin didn’t stop at one instrument. With composer Henry Cowell he built the Rhythmicon (1931), an early rhythm machine that could play complex polyrhythms. He also built the Terpsitone, a platform version of the theremin where a dancer’s whole body moved through the field to control pitch. Picture a dancer performing music through movement in the early 1930s, decades before motion tracking. In a sense, it was one of the first interactive media artworks.
Disappearance and the Great Seal bug
In 1938 Theremin returned to the Soviet Union. Why he went is still debated. Once there he was arrested, sent to the gulag and then put to work in a closed research bureau, the kind of prison lab where scientists worked for the state.
One of his creations from this period became famous in espionage history. “The Thing” was a passive listening device hidden inside a carved wooden replica of the Great Seal of the United States, presented to the US ambassador in Moscow in 1945. It had no battery. A radio beam aimed at it from outside powered it and carried the room’s sound back out. Americans discovered it in 1952. The idea of using external radio energy to read a small resonating cavity is a distant relative of the RFID tags in your keycards today.
Theremin was eventually rehabilitated. He visited the West again late in his life and was the subject of Steven M. Martin’s 1993 documentary Theremin: An Electronic Odyssey. He died in Moscow that year, aged 97.
How the theremin became the sound of the uncanny
The theremin’s swooping, voice-like tone made it a gift for film composers looking for psychological strangeness.
Miklós Rózsa used it in two 1945 films: Alfred Hitchcock’s Spellbound, for the protagonist’s disturbed mental states, and Billy Wilder’s The Lost Weekend, to evoke an alcoholic’s craving. Rózsa won the Academy Award for Best Original Score for Spellbound. The theremin parts on both were played by Samuel Hoffman, a podiatrist by profession who became Hollywood’s go-to thereminist.
Then came science fiction. Bernard Herrmann’s score for The Day the Earth Stood Still (1951) used two theremins alongside electric strings and other unusual instruments. After that, the theremin meant flying saucers. A run of 1950s B-movies leaned on it so hard that the association never faded.
Hoffman also crossed into pop and rock. He played on Music Out of the Moon (1947), an exotic easy-listening album that became a hit, and on Captain Beefheart and His Magic Band’s “Electricity” in 1967.
Later scores used the instrument with a knowing wink or real emotional weight:
- Howard Shore’s music for Tim Burton’s Ed Wood (1994), a nod to the 1950s sci-fi films the movie is about, with theremin played by Lydia Kavina.
- Danny Elfman’s score for Mars Attacks! (1996), another affectionate throwback.
- Justin Hurwitz’s score for First Man (2018), which treated the theremin as a lonely, intimate voice rather than an alien one.
On British television, Jim Parker’s theme for Midsomer Murders features theremin, played by Celia Sheen, and it’s one of the few places a mainstream audience hears the instrument every week.
Three famous “theremins” that aren’t

Ask people to name a theremin song and you’ll often hear examples that use something else. Clearing these up helps you hear what a real theremin sounds like.
The Beach Boys, “Good Vibrations” (1966). That wavering high line is an Electro-Theremin, sometimes called a Tannerin, built by trombonist Paul Tanner. It produces a theremin-like sine tone, but Tanner played it by sliding a handle along a marked track. There’s no antenna and no playing in the air. The confusion is understandable, and the song did a lot to revive interest in the real thing.
The original Star Trek theme. The eerie wordless melody is a human soprano, Loulie Jean Norman, not a theremin.
The Doctor Who theme. Delia Derbyshire of the BBC Radiophonic Workshop realized Ron Grainer’s theme in 1963 using tape manipulation, oscillators and painstaking editing. No theremin was involved.
Jimmy Page of Led Zeppelin, on the other hand, really did use a theremin-type instrument on stage, waving his hand over it during live versions of “Whole Lotta Love”. You can see it in the concert film The Song Remains the Same.
Robert Moog and the revival
Robert Moog’s story starts with the theremin. He built his first theremin in 1949, at age 14, from a magazine article, then designed his own, published plans for hobbyists and, after founding R.A. Moog Co. at 19, sold kits and finished instruments through his small company. That business, and the electronics skills he developed doing it, led directly to the modular synthesizers that made the Moog name famous in the 1960s.
He never left the theremin behind. He produced Clara Rockmore’s 1977 album and appeared in the 1993 documentary. His company’s Etherwave theremin, in production since the 1990s and sold both assembled and as a kit, became the standard instrument for a generation of new players.
Moog Music marked the instrument’s centenary with the Claravox Centennial in 2020, a professional theremin named in Rockmore’s honour. It combines a classic analog sound path with modern features such as presets and MIDI and CV outputs, so the instrument can control synthesizers and software.
The Moog connection also explains why so many electronic musicians see the theremin as an origin point. The idea that you could shape sound continuously with a gesture instead of a key runs through Moog’s synths and well beyond them.
What playing a theremin is really like
You need patience. The first time you switch one on, you’ll get a sound almost immediately, and you’ll have almost no control over it. That gap between “it makes noise” and “it plays music” is what separates the theremin from nearly every other instrument.
Stance matters more than you’d think
Because your whole body is part of the circuit, you have to stand still. Pick a spot, keep your feet planted and your torso steady, and let only your arms move. Many players mark their position on the floor with tape. Lean forward an inch and your whole pitch map shifts.
The instrument also needs to sit at the right height, usually so the pitch antenna’s middle section is around chest or shoulder level. Most theremins mount on a microphone stand or a dedicated stand rather than a table, which lets you face them squarely.
Finding notes in the air
Beginners usually start by sliding up and down with the whole arm, which is where the cliché “woo-ooo” comes from. The next step is learning to jump. Rockmore’s aerial fingering uses small, precise movements of the fingers and wrist to reach nearby notes while the arm stays mostly put. Carolina Eyck, a German thereminist and composer, developed her own method of eight hand positions to map the instrument’s range, and published it as The Art of Playing the Theremin.
Vibrato is essential. A small, regular wobble of the pitch hand smooths over tiny tuning errors and gives the tone life, much as it does for singers and violinists.
The left hand shapes phrases
New players often forget the volume hand. But the left hand is what turns sliding into separate notes. Drop it to cut the sound, move the right hand to the next pitch, lift the left hand to start again. Fast articulation comes from coordinating the two.
Quick steps: your first session on a theremin
- Switch on and let an analog theremin warm up for ten minutes.
- Mount it on a stand at chest height and plant your feet.
- Tune it so pitch drops to near-zero with your hand at your side.
- Play a slow scale against a tuner or a sustained keyboard note.
- Use the volume hand to separate each note of the scale.
- Record yourself and listen back for pitch drift.
Studio tip
Practise with a drone, a sustained note from a keyboard or an app. Hearing the beating between your pitch and the drone tells you instantly if you’re sharp or flat, and it trains your ear far faster than glancing at a tuner.
Choosing a theremin today
You have more options now than at any point in the instrument’s history. Prices change and models come and go, so treat this as a map of the types rather than a shopping list.
| Type | Examples | Best for | Trade-offs |
|---|---|---|---|
| Professional analog | Moog Claravox Centennial | Concert work, recording, serious study | Highest cost, needs warm-up and tuning |
| Mid-range analog | Moog Etherwave (assembled or kit) | Learners who want a “real” theremin feel | Less linear field than top models |
| Digital with assistance | Moog Theremini | Beginners, producers, pitch-corrected parts | Some players find the feel less direct |
| Open-source kits | Open.Theremin | Makers, students, hackers | You build and calibrate it yourself |
| Novelty and miniature | Matryomin (a theremin inside a matryoshka doll, popular in Japan), toy units | Fun, ensembles, gifts | Limited range and control |
Pay attention to three things: the linearity of the pitch field, how stable the tuning stays over a session, and whether the instrument has proper audio outputs. A theremin with a poor field is genuinely harder to learn, which defeats the point of starting cheap.
Heads up
Theremins react to their environment. Nearby metal, other people moving, and even changes in room temperature shift the tuning, so set up away from walls and retune before every take.
Learning resources are easy to find. Online video lessons, method books by players such as Carolina Eyck, and active player communities make the instrument far more approachable than it was for those RCA owners in 1930.
Why artists still love it
Composers love the theremin’s voice. Artists working with technology love something deeper: it’s the first widely known instrument where the interface is your body in space.
It’s the ancestor of gesture interfaces
When you wave at a motion sensor, pinch in the air for a VR headset or tap a capacitive touchscreen, you’re using descendants of Theremin’s idea. Your phone’s screen detects your finger through changes in capacitance, the same physics behind the pitch antenna.
Media artists have explored this lineage for decades. Michel Waisvisz’s The Hands (first version 1984), developed at STEIM in Amsterdam, turned hand and finger movements into control of electronic sound. Max Mathews’s Radio Baton tracked batons in space to conduct computer music. Later, cheap sensors such as Microsoft’s Kinect and the Leap Motion controller put full-body and hand tracking into artists’ studios. Each of these asks the same question Theremin asked in 1920: what happens when the space around a performer becomes the instrument?
It makes the invisible audible
There’s a poetic side too. The theremin turns an invisible electromagnetic field into something you can hear. Audiences watching a thereminist see a person shaping sound out of nothing. Installations borrow this effect all the time, using proximity or body capacitance so visitors discover that their presence changes the work.
Pair a theremin with visuals and the effect doubles. Artists drive generative graphics or “projection mapping” from the theremin’s pitch and volume so that one gesture moves both sound and image. Modern instruments with CV and MIDI outputs make this straightforward.
It resists perfection
Finally, the theremin is hard. It wobbles, drifts and exposes every unsteady breath. In a world of quantized beats and pitch correction, plenty of artists find that refreshing. The instrument rewards listening, and it never sounds exactly the same twice.
Build or code your own theremin
You don’t need to buy an instrument to explore the idea. Creative coders and makers can prototype theremin-like pieces cheaply.
Hardware routes. An Arduino with a capacitive sensing library can read a wire or foil plate as an antenna and send values to your computer. The Open.Theremin board gives you a proper heterodyne design to build and modify. A simple optical alternative uses a distance sensor in place of an antenna; it isn’t a true theremin, but it captures the playing feel.
TouchDesigner. The free non-commercial licence is enough to experiment. The Leap Motion CHOP or Kinect CHOP brings hand positions in as channels. Map one hand’s distance to an Audio Oscillator CHOP’s frequency and the other to a Math CHOP scaling the output level, and you have a gesture theremin that can also drive visuals in the same network.
p5.js in the browser. p5.js is free and runs anywhere. A mouse makes a decent stand-in for a hand, and a webcam with a hand-tracking model can go further. If you’re new to the library, our guide to “p5 js” covers the basics. The sketch at the end of this article uses your mouse as a hand and also draws the heterodyne process, so you can see why two inaudible waves make one audible note.
Processing and openFrameworks. Both are free and good for installation work where you need a standalone app on a dedicated machine, with Processing’s Sound library or openFrameworks’ audio output generating the tone.
A few design ideas to borrow from the real instrument:
- Use an exponential pitch mapping, so equal hand movements give equal musical intervals.
- Smooth the incoming values. Real theremins glide, and jittery sensor data sounds harsh.
- Give the player a separate volume control. Without articulation, every gesture becomes one long slide.
- Add optional scale quantization, like the Theremini, for installations where visitors have ten seconds rather than ten years.
FAQ
Is the theremin hard to learn?
Yes. Getting a sound takes seconds, but playing in tune takes months of regular practice, because there’s nothing physical to guide your hand. Ear training, a fixed stance and practice against a drone shorten the process considerably.
Do you touch a theremin when you play it?
No. You play entirely in the air. Touching the pitch antenna produces a jump or noise, and bringing your hand all the way down to the volume loop simply silences the instrument.
Who invented the theremin and when?
Leon Theremin (Lev Termen), a Russian physicist, invented it in 1920 in Petrograd while working on equipment for measuring gases. He received a US patent in 1928.
Is the theremin in “Good Vibrations”?
No. The Beach Boys used an Electro-Theremin built by Paul Tanner, which you play by moving a slider along a track. It sounds similar but works differently.
What is the best theremin for beginners?
A Moog Etherwave is the common choice if you want a traditional analog theremin with a decent pitch field. If you’d rather get musical results quickly, the Moog Theremini’s pitch correction helps, and you can reduce it as your control improves.
Why does a theremin sound so spooky?
Its tone is close to a pure wave with smooth glides and vibrato, which our ears associate with a human voice. Hearing a voice-like sound with no body behind it feels uncanny, and decades of 1950s sci-fi soundtracks cemented the link.
Try it live
This sketch turns your mouse into a hand. Move right toward the pitch rod for higher notes and down toward the loop to fade out. Click once to switch the sound on, and click again to mute it. The sound uses your browser’s built-in Web Audio, not p5.sound. The three waves at the top show the heterodyne idea, slowed down so you can see it: two fast “radio” waves combine, and the slow swell in the mixed wave is the note you hear.
// Mouse theremin: move toward the rod for higher pitch,
// move down toward the loop to fade out. Click to switch sound on or off.
let audio = null; // browser audio, created on first click
let osc, amp;
let soundOn = false;
let t = 0;
const ROD_X = 700; // where the pitch antenna stands
const LOOP_Y = 520; // height of the volume loop
const NOTES = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'];
function setup() {
createCanvas(800, 600);
textFont('monospace');
}
function draw() {
background(14, 16, 26);
// 1. How far the "hand" (mouse) is from each antenna
let dPitch = constrain(ROD_X - mouseX, 10, 620);
let dVol = constrain(LOOP_Y - mouseY, 0, 360);
// 2. Closer to the rod means higher pitch, over three octaves.
// Exponential mapping so equal hand moves give equal musical steps.
let semitones = map(dPitch, 10, 620, 36, 0);
let freq = 110 * pow(2, semitones / 12);
// 3. Closer to the loop means quieter. Right at the loop is silence.
let vol = map(dVol, 0, 360, 0, 1);
// 4. Send values to the oscillator, smoothed so it glides like a real theremin
if (audio && soundOn) {
osc.frequency.setTargetAtTime(freq, audio.currentTime, 0.02);
amp.gain.setTargetAtTime(vol * 0.25, audio.currentTime, 0.05);
}
drawAntennas();
drawHeterodyne(freq, vol);
drawReadout(freq, vol);
// the hand
noStroke();
fill(255, 200, 120, 200);
circle(mouseX, mouseY, 26);
t += 1;
}
function drawAntennas() {
stroke(200);
strokeWeight(6);
line(ROD_X, 80, ROD_X, 560); // pitch rod
noFill();
strokeWeight(5);
ellipse(160, LOOP_Y + 20, 220, 40); // volume loop
noStroke();
fill(150);
textSize(12);
text('pitch rod', ROD_X - 30, 70);
text('volume loop', 120, LOOP_Y + 70);
}
function drawHeterodyne(freq, vol) {
// Real theremins use radio waves far above hearing.
// Here they are slowed down so you can watch them mix.
let fixedCycles = 60;
let octavesUp = log(freq / 110) / log(2);
let beat = map(octavesUp, 0, 3, 1, 10); // higher note, more swells
let varCycles = fixedCycles + beat;
let rows = [
{ y: 120, label: 'fixed oscillator', c: color(90, 160, 255) },
{ y: 200, label: 'variable oscillator (your hand)', c: color(120, 230, 170) },
{ y: 310, label: 'mixed: each slow swell is one cycle of the note', c: color(255, 170, 90) }
];
for (let r = 0; r < 3; r++) {
noFill();
strokeWeight(1.5);
stroke(rows[r].c);
beginShape();
for (let x = 0; x <= 600; x += 2) {
let p = x / 600;
let a = sin(TWO_PI * fixedCycles * p + t * 0.05);
let b = sin(TWO_PI * varCycles * p + t * 0.06);
let y;
if (r === 0) y = a * 25;
else if (r === 1) y = b * 25;
else y = (a + b) * 18 * vol; // the volume hand scales the output
vertex(40 + x, rows[r].y + y);
}
endShape();
noStroke();
fill(rows[r].c);
textSize(12);
text(rows[r].label, 40, rows[r].y - (r === 2 ? 45 : 32));
}
}
function drawReadout(freq, vol) {
// Turn the frequency into the nearest note name
let midi = round(69 + 12 * log(freq / 440) / log(2));
let name = NOTES[midi % 12] + (floor(midi / 12) - 1);
noStroke();
fill(230);
textSize(16);
text(nf(freq, 0, 1) + ' Hz (' + name + ')', 40, 420);
text('volume ' + nf(vol * 100, 0, 0) + '%', 40, 445);
fill(150);
textSize(12);
text(soundOn ? 'click to mute' : 'click to start sound', 40, 470);
}
function mousePressed() {
// Browsers only allow sound after a click, so we build it here
if (!audio) {
audio = new (window.AudioContext || window.webkitAudioContext)();
osc = audio.createOscillator();
osc.type = 'triangle';
amp = audio.createGain();
amp.gain.value = 0;
osc.connect(amp);
amp.connect(audio.destination);
osc.start();
}
soundOn = !soundOn;
if (soundOn) audio.resume();
else amp.gain.setTargetAtTime(0, audio.currentTime, 0.05);
}
Variations to try:
- Add vibrato. Wobble
freqwithsin(t * 0.3) * 3before sending it to the oscillator, and hear how much more human it sounds. - Quantize to a scale. Round
semitonesto the nearest note of a pentatonic scale for an assisted mode like the Theremini. - Let the air drift. Real analog theremins wander as they warm up. Add a slow drift to the pitch with
noise(), which our “perlin noise tutorial” explains in depth. - Swap the mouse for a body. Replace
mouseXandmouseYwith hand positions from a webcam tracker, and you’re a step closer to Theremin’s Terpsitone.