Hacker News new | past | comments | ask | show | jobs | submit login
The 1-Bit Instrument (ucpress.edu)
69 points by todsacerdoti on May 12, 2020 | hide | past | favorite | 38 comments



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. They are often very-high quality, and very efficient!

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


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.


They're basically identical circuits except in a power supply the input is DC (or for an inverter, a sinewave) while in a Class D amp the input is an arbitrary analog signal.


> 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.

Well, they also put a low-pass filter after.


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


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


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."


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.


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.


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


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.


Sigma-Delta is just an adder which is equivalent to a comparator thus it might be cheaper actually:

   module pdm(clk, level, O);
   parameter N = 16;
   input     wire         clk;
   input     wire [N-1:0] level;
   output    wire          O;
   reg [N+1:0] sigma = 0;
   assign O = ~sigma[N+1];
   always @(posedge clk) sigma <= sigma + {O,O,level};
   endmodule
I’ll grant you that PWM is a bit more intuitive. I bet there is a more thorough comparison between them but I haven’t seen it.


Does PWM generate weird phase artifacts when switching between low and high amplitudes? Much like Doppler distortion in earbuds?


* PDM, not PWM


Likewise, musical roads essentially turn your vehicle into a 1-bit amplifier. https://en.wikipedia.org/wiki/Musical_road


Exactly. The one in Tijeras is impressive.


See also the Super Audio CD format: https://en.wikipedia.org/wiki/Super_Audio_CD


Indeed, the ultimate limit of quality is governed by quantum fluctuations... and incredibly, we're already "there".

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5520655/


Pretty fascinating how much is involved in making a perfect 1kHz wave. The paper mentions metrology. What are these used to measure?


Yeah, I think the author needs to take an introductory Signals & Systems class. They could learn not only about delta-sigma DACs but also the relationship between Fourier decomposition and LTI signals, plus the basics of psychoacoustics. They say, "Appreciation of how the 1-bit waveform acts conceptually (and psychoacoustically) is necessary for understanding and implementing timbral and sonic interest in 1-bit music," but they themselves lack anything more than the rudiments of that appreciation.

There are some fun techniques in the article, though! I was surprised to see my friend Norm Hardy mentioned — I had never realized he was a pioneer of computer music :)


They are very good indeed. But of course, a true audiophile wouldn't use them ;)

By the way, while the principle behind class D amplifiers was already long known, it's the gallium nitride MOSFET technology used for switching that makes them really of sufficient quality.


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


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.


DAISY.COM


Yeah! I have to wonder how that flanging that kicks in at ~12sec is achieved. (Same signal slightly delayed? Another voice?) (Found the program ... no longer fluent in sight-reading 8080 hex though!)



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/


If you want to listen first and already have spotify:

https://open.spotify.com/album/6Ie1GtBI9ZCfmcT1OsK8a0?si=Aov...

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


Holy shit that is amazing! I'm getting one immediately, what a beautiful concept


My prized possession. Beautiful work. Implemented in a clear CD case.


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


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

https://www.youtube.com/watch?v=lZRcGWa0Rrw


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


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.


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=pDfsAemVaDA


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

Remake: https://www.youtube.com/watch?v=shj1_T68SBo


So basically an SACD.


Without oversampling and with a lot of clever hacks.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: