
The 1-Bit Instrument - todsacerdoti
https://online.ucpress.edu/jsmg/article/1/1/44/2337/The-1-Bit-InstrumentThe-Fundamentals-of-1-Bit
======
etaioinshrdlu
You can make any sound with 1 bit if you can switch it fast enough. In fact it
is called a Class D amplifier [https://en.wikipedia.org/wiki/Class-
D_amplifier](https://en.wikipedia.org/wiki/Class-D_amplifier). They are often
very-high quality, and very efficient!

This is also how high quality electronic motor drives and servos generally
work.

~~~
cardiffspaceman
Sony used to hype its 1-bit CD players. They did invest in sending a bitstream
to the amplifier at a high enough bit rate to keep the resulting
"quantization" noise from being audible in the first place.

Switched power supplies have always seemed to be, to me, kin to class D
amplifiers, though the block diagrams don't highlight the similarities.

~~~
etaioinshrdlu
Yeah, it's basically PWM, which is used in basically everything.

~~~
FullyFunctional
Well, it Sigma-Delta modulation which isn't PWM.

~~~
FullyFunctional
I should have added: "But Sigma-Delta is as easy (in fact, probably easier) to
implement that I really don't understand why people ever use PWM anywhere.
It's so inferior IMO."

~~~
etaioinshrdlu
Well PWM is probably easier to analyze mathematically. The harmonics produced
are more predictable. Knowing min off-time and on-time so easily is helpful
when designing circuits. It's also super easy to implement PWM in digital
logic or software, it basically needs only timer and a comparator.

~~~
dreamcompiler
Sigma-Delta is very easy to implement as well; it just requires a different
way of thinking. In S-D you always try to preserve and compensate for the
errors you make in quantization, while in PWM you throw the errors away. In
physics you'd label S-D an error-conserving system vs PWM an error-dissipative
system.

~~~
FullyFunctional
Well put. Another example is Floyd–Steinberg dithering which is also error-
conserving.

My (effectively one-line) implementation above was derived from first-
principle:

Given a desired target level 0 <= T <= 1, control the output O in {1,0}, such
that O on on average is T. Do this by integrating the error T - O over time
and switching O such that the sum of (T - O) is finite.

    
    
       S = O = 0
       loop:
         S = S + (T - O)
         O = (S >= 0)
    

In fixed point arithmetic this becomes even simpler (assume N-bit arith) S =
Sf * 2^N = Sf << N. As |S| <= 1, N+2 bits is sufficient

    
    
       S = O = 0
       loop:
         D = T + (~O + 1) << N === T + (O << N) + (O << (N+1))
         S = S + D
         O = 1 & ~(S >> (N+1))
    

and that's the Verilog below

~~~
dreamcompiler
Completely agree. I've always considered Floyd-Steinberg dithering to be a 2D
version of Sigma-Delta. It's all about diffusing and minimizing error
quantities, to trade higher sampling _rate_ for lower sample _resolution_
while conserving total information content.

Another example is Bresenham's algorithm for drawing straight lines on raster
displays. The quantity being approximated there is the slope of the line,
which is approximated with minimal diffused error _as the line is being drawn_
with only integer adds and subtracts. No divisions and no floating point
needed.

These are some of the most subtly beautiful algorithms in computing.

------
tasty_freeze
There was a music program for the Sol-20 microcomputer, which was an 8080
running a tad slower than 2MHz. 4 voice polyphony.

The program came with a tiny card plugged into the S-100 bus consisting of
nothing more than an RC filter. The Sol didn't use interrupts. The program
worked by toggling EI/DI (enable and disable interrupt) to cause one of the
pins on the s-100 bus to toggle.

The intonation of especially suffers because those notes are more affected by
the fixed 8080 clock cycle.

Here is a clip of it. This clip is from an emulator of the Sol-20, and it uses
a higher order filter than the first order RC used by the original hardware.
The real hardware is harsher sounding than this. The ten seconds of the 25
second clip is unimpressive, but the 2nd half shows how much can be done with
such limited hardware.

[http://sol20.org/media/d-minor.mp3](http://sol20.org/media/d-minor.mp3)

~~~
ksaj
It reminds me of the PC-Speaker program which ran on 8086 computers (at
4.77Mhz or 12Mhz if you had a turbo switch). PC-Speaker was really quite
distorted by comparison, but you could create reasonably understandable voice.
Anything too complicated just sounded like a hissy mess.

~~~
mycall
DAISY.COM

------
jedimastert
Related in name, but still super cool, is the 1-Bit Symphony by Tristan
Perich. He programmed a symphony on an ATTiny that outputs directly from one
of the output pins (through a volume pot) to the headphone jack.

[http://www.1bitsymphony.com/](http://www.1bitsymphony.com/)

~~~
eganist
If you want to listen first and already have spotify:

[https://open.spotify.com/album/6Ie1GtBI9ZCfmcT1OsK8a0?si=Aov...](https://open.spotify.com/album/6Ie1GtBI9ZCfmcT1OsK8a0?si=Aov1MkSvTV6rkd4ZyeWAjQ)

If you're into chiptunes, this hits the spot.

------
joezydeco
Seems like the author owned a ZX Spectrum and little else.

There were other 1-bit machines out there, like the Apple ][. Paul Lutus'
_Electric Duet_ managed to get two-voices out of the speaker and he describes
the process here:

[https://arachnoid.com/electric_duet/index.html](https://arachnoid.com/electric_duet/index.html)

------
seph-reed
This was the top hit for 1bit music that I could find: neat!

[https://www.youtube.com/watch?v=lZRcGWa0Rrw](https://www.youtube.com/watch?v=lZRcGWa0Rrw)

------
snalty
This video explains how they used 1-bit sound to generate Pikachu's sounds in
Pokemon Yellow on the Game Boy.

[https://www.youtube.com/watch?v=fooSxCuWvZ4](https://www.youtube.com/watch?v=fooSxCuWvZ4)

~~~
willis936
Neat work, but their method of improving the audio quality is not very good.
They could get much better results by looking at the magnitude spectrum of the
source audio, lowpass filtering with a cutoff chosen to keep 95% (if possible)
of the energy (likely 1-2 kHz) then downsampling to nyquist. 4 kSamp/s @ 4
bits per sample would sound much better than his method, and it wouldn’t take
extra fancy software tricks. The driver/speaker on a gameboy isn’t going to
have a very controlled lowpass filter, and it’s behavior is also unknown.
Delta-sigma is heavily reliant on the output lowpass filter.

------
zimpenfish
Let us not forget Tim Follin's masterpieces: Agent X and Agent X II. Hearing
this come out of a Spectrum in the mid-80s was _astonishing_. I recorded them
onto tape for Walkman listening.

[https://www.youtube.com/watch?v=JOZ8rbmlWrk](https://www.youtube.com/watch?v=JOZ8rbmlWrk)

[https://www.youtube.com/watch?v=pDfsAemVaDA](https://www.youtube.com/watch?v=pDfsAemVaDA)

~~~
Flow
Here's another tune along with a remake of it for the C64.

Tim Follins original ZX Spectrum tune:
[https://www.youtube.com/watch?v=Iz46pCROkjM](https://www.youtube.com/watch?v=Iz46pCROkjM)

Remake:
[https://www.youtube.com/watch?v=shj1_T68SBo](https://www.youtube.com/watch?v=shj1_T68SBo)

------
layoutIfNeeded
So basically an SACD.

~~~
willis936
Without oversampling and with a lot of clever hacks.

