| ̅ ̅ ̅| ͟ ͟ ͟ | ̅ ̅| ͟ ͟ | ̅ ̅| ͟ ͟ | ̅| ͟ ͟| ̅| ͟ | ̅ ̅ ̅| ͟ ͟ ͟
March 26, 2020 4:15 PM   Subscribe

The most primitive possible type of electronic audio output from a computer is a 1-bit output line, which is either high or low, and which, when toggled, can be made to emit square waves or pulse trains of a fixed volume. These days, the most familiar examples of this are the audio devices of 1980s computers such as the IBM PC, the Apple II and the Sinclair Spectrum, though the first recorded example of 1-bit computer music was a rendition of “For He's A Jolly Good Fellow”, programmed in 1949 on the BINAC by Betty Holberton. Most examples of music played on a 1-bit device sound rudimentary, consisting of monophonic arrangements of square-wave beeps, though there are techniques which may be used to achieve polyphonic and multitimbral sounds. Blake Troise, a composer who works with limited computer hardware, has written a paper enumerating some of these techniques, along with the physical and psychoacoustic principles behind them. Troise has also used these techniques to produce a short album, in a jazz-fusion/City Pop idiom; this was originally released on a custom-programmed AVR microcontroller with a 1-bit speaker output, which has sold out, though the Bandcamp release includes the source code for the compositions, running on Troise's μMML compiler/tracker.

Previously in 1-bit music: Shiru.
posted by acb (30 comments total) 48 users marked this as a favorite
Can I just say that I appreciate the illustration of the Gibbs Phenomenon in the post title?
posted by kaibutsu at 4:29 PM on March 26 [8 favorites]

Wow. That is pretty amazing and has brought back a flood of memories.

In.... 1980? 81? ... I had the bright idea that I could amplify a microphone output so it peaked at +5V and connect that to one of the digital inputs of my Microtan 65, sample that as fast as possible (not very fast - a couple of KHz maybe) for as long as possible (about half a second probably) and thereby create a one-bit sample (no ADC here!), and then connect a speaker to a digital output and play that sample back. By this means I produced an appallingly bad but just about recognisable rendition of the word "hello". In a time when the most sophisticated sound produced by any computer I had access to was a monotone bleep, this caused pandemonium! I mean, people really confused this with the whole idea of a computer being "alive", the only other example of a "speaking" computer they knew being basically that, in Star Trek or whatever.

Later I wrote software for that same Microtan that rendered a stave (staff) on the screen and let you interactively place notes on it, and play back the result. All in the stunning 64x64 screen resolution available! This was still a basic squarewave bleep output though, just frequency modulated to get the effect. The idea that I could have produced anything remotely like the music in this post is frankly mind-boggling - almost as much as as the speaking computer was to my peers in 1981! I suppose that really I couldn't have done - the techniques here are probably way beyond the capabilities of the Microtan - but nonetheless I would never have imagined that 1-bit sound could be anything like this.

In summary: fantastic post! Thank you.
posted by merlynkline at 5:21 PM on March 26 [11 favorites]

I think people worked out how to play tunes on a Teletype machine, back in the day, too
posted by thelonius at 5:51 PM on March 26

Back in the day (1980-81, probably) we were happily peeking and poking at our Apple ][ to make it produce various tones and then simple monophonic melodies.

But then some game or whatever came out that played polyphonic music on the Apple speaker. Just two voices, as I recall.

"I can figure out how to do that, too, then," thought I, and busily went to work with my little 6502 assembly-language compiler.

Reader, I couldn't. So huge props to whoever can figure how how to play even two polyphonic lines at once on those one-bit systems, let alone all the fancy stuff Troise is doing.
posted by flug at 7:36 PM on March 26 [3 favorites]

Speaking of of merlynkline's early experiment with 1-bit voice sampling, I seem to remember something like that being used in Castle Wolfenstein. I seem to recall many "CKTHWKEaKcKhKtKSHuSHnSHgTHTHKKKCHCH" type things being hissed and buzzed at us throughout the game.

If I recall it took my friends and me a good while to figure out that there were supposed to be actual words in these messages and they weren't just little bleepy-scratchy one-bit sound effects.

FWIW you can download that Castle Wolfenstein sound library here (would run on an Apple 2 emulator, looks like) or do it the 2020 way and just watch/hear a playthrough of Castle Wolfenstein on Youtube, which includes "Halt!" "Achtung!" and all the other one-bit highlights.
posted by flug at 7:50 PM on March 26 [2 favorites]

The Commodore PET in the 1970s could do monophonic sound if you hooked an amplifier and speaker to two specific bottom pins of a circuit board on the backplane of the computer and poked the right data out of it. I don't see any mention of this anywhere in a quick search, but it's true.

Thelonius, maybe you're thinking of making music by printing voluminous pages from line printers back in the day? That was a thing, but I don't recall a similar stunt with teletype. They just sort of clunk with one sound at one speed.
posted by lothar at 7:52 PM on March 26 [2 favorites]

flug, I did that too. I even disassembled Music Construction Set to see if I could figure out its polyphonic magic, to no avail. The trick turns out to be ultrasonic duty cycling -- clicking the speaker so quickly that it can't keep up with the transient wave, and it smooths the signal into an arbitrary waveform. This all has to be timed by the CPU, so you have to have cycle-exact machine code routines, and store all the music in a compact form to fit into RAM, etc.
posted by RobotVoodooPower at 8:12 PM on March 26 [2 favorites]

As a long-time fan of the tech and mad skills behind chiptuneage (all hail Martin Galway), I've never seen anything so focussed on working with 1-bit oscillators and a CPU without using a lot of additional hardware.

So it's a welcome insight (not to mention that bibliography! Good to see Alan Turing mentioned as one of the first to coax tunage out of a CPU.) It was back in that era that hackers noticed that CPUs made electronic hash that could be heard on an AM radio - so of course they learned to turn that into music!
posted by Twang at 9:05 PM on March 26 [1 favorite]

When I was about 10 years old (1980-ish) I would load up Lemonade Stand on my Apple ][. (Video: Lemonade Stand for the Apple II)

Just because it would play music. While I could find the data and pokes that played the tunes, I couldn't find the pokes that did the magic bit of loading that machine code routine. So I'd just start the game and then quit so I could then use my programs to play whatever tunes I wanted. It took a couple more years before I discovered an Apple ][ 6502 assembly language book which just happened to have a magic music playing routine as one of the examples. A couple of years later and it was Amiga 4 channel 8bit stereo so I moved on.

Thanks for the post, it's cool to find out how much could be done.
posted by zengargoyle at 1:08 AM on March 27

As a long-time fan of the tech and mad skills behind chiptuneage (all hail Martin Galway), I've never seen anything so focussed on working with 1-bit oscillators and a CPU without using a lot of additional hardware.

It's the chip music equivalent of writing games/demos that run on a stock Atari 2600; creativity within severe constraints.
posted by acb at 3:26 AM on March 27 [1 favorite]

To a first approximation, you can substitute sampling frequency for bit depth. DSD for instance uses a 1-bit sample but also runs at a sampling rate of 2.8MHz. Once you reach a certain level of processing power that you can directly manipulate a 1 bit signal using PWM to do a reasonable facsimile of sampled audio. That's how RealSound did it back in the '80s. You could get the equivalent of 6-bit PCM out of an XT.
posted by Your Childhood Pet Rock at 7:00 AM on March 27 [2 favorites]

It's rather lovely to see academic citations from the publications I read in my youth, such as: Follin, T. "Star Tip 2." Your Sinclair 20 (1987): 55. (Rather bad audio of which lives here: Star Tip 2 - World of Spectrum)

And the hardware to produce Troise's music is very small: a $2 8-pin chip, a battery, and something to output it to. You've got 8 KB of program storage and 512 bytes of working memory.
posted by scruss at 7:26 AM on March 27

I remember trying 1 bit digital sampling on the old Apple][+ that my family had. Playing audio at extreme high volume through the cassette port produced a very distorted but almost recognizable sounds. I never did figure out how to make it sound better.
posted by AndrewStephens at 7:46 AM on March 27

Someone assembled a supermix of PC games using PWM. Although I don't see Another World in there.
posted by RobotVoodooPower at 7:49 AM on March 27

This is fantastic.
posted by cortex at 7:56 AM on March 27 [1 favorite]

> flug, I did that too. I even disassembled Music Construction Set to see if I could figure out its polyphonic magic, to no avail. The trick turns out to be ultrasonic duty cycling

Yes, even at the time I figured out it was likely something of that sort. But then I also realized that getting something of that sort working was going to be a real major project, not just maybe 2X as hard as getting a single melody to play--which was quite easy.

So that is when I saw the light and gave up.
posted by flug at 8:09 AM on March 27 [1 favorite]

Thought looking at something like this (more detailed discussion of how Michael Mahon's Apple 2 software synth you linked above works) it was maybe not as quite complicated as I had made it out to be.

Still, it is well into the major project category, for sure.
posted by flug at 8:17 AM on March 27

IIRC, dimmable LEDs work the same way; the LED never receives a lower voltage, just a PWM square wave with a lower duty cycle.
posted by acb at 8:21 AM on March 27 [1 favorite]

Yup, LEDs dim using PWM. That “breathing” LED while your Macbook is sleeping? Just PWM ramping up and down.

Incandescent dimmers kinda work using the same concept, except they are chopping up the AC waveform to make a lower effective RMS voltage.
posted by scruss at 8:35 AM on March 27 [1 favorite]

As an electronic music geek, chiptune appreciator and general sort of nerd, I love this post more than anything I have seen in a while.

Also a fine album for me to listen to while I wait for my used Zorlon Cannon to arrive. :)
posted by Foosnark at 8:38 AM on March 27

Incandescent dimmers kinda work using the same concept, except they are chopping up the AC waveform to make a lower effective RMS voltage.

I always thought they were potentiometers reducing the voltage by Ohm's Law.
posted by acb at 8:53 AM on March 27

I always thought they were potentiometers reducing the voltage by Ohm's Law.

That would work in theory but would waste a lot of energy and your dimmer would get very very hot. Interestingly you can buy just such a device to put between an amplifier and speaker so that you can overdrive the amp but not be unbearably loud. They are large and expensive.
posted by sjswitzer at 9:05 AM on March 27 [1 favorite]

Here's the start of a section on making sounds on the Apple II.

Paul Lutus wrote a program for the Apple II called Electric Duet which could play 2 voice music on a Apple II using the techniques in the thread above. It's on the Internet Archive here. I booted it up in an Apple II emulator running on my Mac and it's...worse than I remembered? Allegedly the emulator I'm using is very good, but in years of musical training, the intonation is glaringly off. Still it's like a dancing bear: not that it dances well, but that it dances at all which is amazing.
Paul Lutus wrote it up here which includes sound files from Electric Duet.
posted by plinth at 10:00 AM on March 27 [1 favorite]

That's a nice article on one-bit theory and techniques. I like how Troise positions one-bit music practice as akin to choosing an acoustic instrument as your primary tool, arguing that 1-bit composers have created a '1-bit instrumental idiolect to rival any acoustic instrument'. If you really commit to a technique like this it's remarkable how far you can go. . .

I do find it a bit misleading to focus on the term '1-bit', as that term is also used to refer to the common industry practice of pulse-density modulation, commonly referred to as a one-bit dac. In that practice, digital audio is oversampled up to 512x faster than traditional digital audio but with only one-bit of resolution. Sony's super-audio format oversamples 64x, for a sampling rate of 2.8224 MHz vs. CD audio 44.1kHz. It seems like practically all digital audio convertors use some form of this practice nowadays.

A more accurate name for Troise's practice is PWM (pulse-width modulation) audio, because the practice utilizes changes in the width of a pulse (as opposed to the density of pulses) at a more traditional sampling rate in the kHz. Interest in this technique seems mostly to be driven by how easy it is to implement in low-cost microcontrollers using easy to access platforms like Arduino - but as described above, people have been using this approach for a long time. It is also how class-D digital amplifiers work.

But I guess this is one of the times where the accuracy of a name is less important than its ability to convey a rough idea to a large group of people. In our society a reference to digital storage (bits) is more generally understood than a reference to electrical engineering (PWM).

Anyone interested in this should also check out Tristan Perich's work (previously, previously) who has done a lot of cool work with PWM audio (and also describes it as 1-bit audio. . . )
posted by ianhattwick at 10:32 AM on March 27 [3 favorites]

 the intonation is glaringly off

When you're dividing a fixed clock frequency with 8-bit integer resolution to form notes, equal tempered it ain't gonna be
posted by scruss at 1:13 PM on March 27 [1 favorite]

i mean if they really fixed the clock it should work better

sorry i'm leaving ow ow sorry
posted by cortex at 2:08 PM on March 27

I fixed this clock so now it's right twice a day!
posted by straight at 5:29 PM on March 27 [1 favorite]

So I just dug out my tube of ATtiny85s, my AVR programmer, a breadboard and some other bits and built one of these. It sounds amazing¹! The circuit is so very simple:
                       |o   A   |             
          VCC--(10kΩ)--+ 1  T  8+--VCC        
                       |    t   |             
                      -+ 2  i  7+-            
                       |    n   |             
                      -+ 3  y  6+-      (     
                       |    8   |      ((     
                  GND--+ 4  5  5+--(SPKR(--GND
                       |________|      ((     

          Pin 1: RST - held high through pull-up to prevent reset
          Pin 4: GND
          Pin 5: PB0 - through speaker/buzzer to GND
          Pin 8: VCC - can be a CR2032 Lithium coin cell

          Not shown: 100 nF decoupling capacitor between VCC and GND
          Short Pin 1 to GND to restart song
Fly Me to the Moon in the repo is a lovely bubbly, silly version complete with rocket launch effects. This is delightful fun!

(NB: for those who want to repeat this, the music compiler builds but fails to run on a 64-bit system. It runs lovely on a Raspberry Pi, though. Also, unless you have the steps for an AVR toolchain memorized, the process has a foul learning curve, made worse by clickbait copypasta tutorials that the search engines love but the content is badly wrong. Took me most of today just to get my first beeps out of this …)

¹: for suitably qualified values of amazing, of course. It's a bloody oversampled beeper after all.
posted by scruss at 1:49 PM on March 28

a composer I knew had a tale of a grad student who took 8 pins from a printer port, put each one in an audio mixer channel, then staggered the amps so each was twice the raw level of the one before it

he then wrote a self modifying forth program (an automata model I think?) to put data onto the port
posted by idiopath at 4:16 AM on March 31

Blake Troise gave me permission to put up recordings of two of his arrangements that are in the github repo but not on the album: (so technically a self-link, but only 'cos I'm hosting them)
posted by scruss at 6:58 AM on April 3 [2 favorites]

« Older The Internet Archive's National Emergency Library   |   Michael Sorkin, 1948-2020 Newer »

This thread has been archived and is closed to new comments