• Play audio from a serial port

    From AKAcastor@21:1/162 to All on Sun May 5 14:53:36 2024
    A fun post I saw today on Mastodon, by Rue Mohr (who is a great person to follow for interesting retro computer and embedded electronics projects).


    Chris/akacastor

    The post on Mastodon: (includes a quick demo vid of audio playback) https://infosec.exchange/@RueNahcMohr/112389733393979313

    Play audio from a serial port!!!
    I came up with an encoder that can turn audio into a 115200 baud serial stream that when played back thru an RC filter, recovers the audio. :] #lookmumnocomputr

    You can make this easy player here!
    https://github.com/ruenahcmohr/115kaudio


    --- Maximus 3.01
    * Origin: Another Millennium - Canada - another.tel (21:1/162)
  • From Bob Worm@21:1/205 to AKAcastor on Tue May 7 16:34:00 2024
    Re: Play audio from a serial port
    By: AKAcastor to All on Sun May 05 2024 14:53:36

    Hi, AKAcastor.

    Play audio from a serial port!!!

    That's some top flight bodgery - I love it. I will have to try setting that up for myself. 100 bonus points for a tenuous Look Mum No Computer connection, as well.

    I wonder what the low pass works out as? Surely if the start bit is 0 and the stop bit is 1 you're going to end up with a constant 11.5kHz whine?

    Heha, look at me worrying about audio quality... this thing's going to sound like balls and that's completely OK.

    BobW
    --- SBBSecho 3.20-Linux
    * Origin: >>> Magnum BBS <<< - bbs.magnum.uk.net (21:1/205)
  • From AKAcastor@21:1/162 to Bob Worm on Wed May 8 15:42:24 2024
    Play audio from a serial port!!!

    That's some top flight bodgery - I love it. I will have
    to try setting that up for myself. 100 bonus points for
    a tenuous Look Mum No Computer connection, as well.

    It really is a fun hack, isn't it?

    I wonder what the low pass works out as? Surely if the
    start bit is 0 and the stop bit is 1 you're going to
    end up with a constant 11.5kHz whine?

    The low pass filter would probably be filtering out the start bit if it is the only 0 bit? A single bit at 115.2 kbps would be filtered out at 57.6 kHz (it's a pulse lasting 8.68 microseconds, that would be half the cycle), I think - though I really don't have much knowledge of analog electronics.

    Heha, look at me worrying about audio quality... this
    thing's going to sound like balls and that's completely OK.

    I'm actually surprised to have not seen this kind of trick in use before. Seems like it could have fit in during the 80s when any (cheap) audio more than a beep was highly desirable.


    Chris/akacastor


    --- Maximus 3.01
    * Origin: Another Millennium - Canada - another.tel (21:1/162)
  • From Bob Worm@21:1/205 to AKAcastor on Thu May 9 07:45:15 2024
    Re: Play audio from a serial port
    By: AKAcastor to Bob Worm on Wed May 08 2024 15:42:24

    Hi, AKAcastor.

    The low pass filter would probably be filtering out the start bit if it is the only 0 bit? A single bit at 115.2 kbps would be filtered out at 57.6 kHz (it's a pulse lasting 8.68 microseconds, that would be half the cycle), I think - though I really don't have much knowledge of analog electronics.

    That's a good question. I suppose the instantaneous pulse would be 57.6 kHz but an alternative way to look at it would be as a 11.5 kHz signal with a really wonky 9:1 duty cycle... I further suppose since it's a "square" wave the instantaneous frequency could be considered to be infinity (obviously not really).

    I will ask my good friend Martin - he loves this kind of thing.

    I'm actually surprised to have not seen this kind of trick in use before. Seems like it could have fit in during the 80s when any (cheap) audio more than a beep was highly desirable.

    There were a good number of consumer and homebrew projects for doing this with the parallel port. In theory a nice clean 8 bit output, I made one with my school friend back in the day and it sounded *awful*. I suspect our quality control was not good enough as other people reported good results.

    Oh for the days when you could just walk into Maplin and buy qty. 1 components... In fact we just turned up with a list of "0.1uF electrolytic" etc and handed it to the poor guy behind the counter to rummage through the catalogue and find the 20 or so part codes we needed for us and then fetch them from the back!

    BobW
    --- SBBSecho 3.20-Linux
    * Origin: >>> Magnum BBS <<< - bbs.magnum.uk.net (21:1/205)
  • From AKAcastor@21:1/162 to Bob Worm on Thu May 9 11:06:48 2024
    That's a good question. I suppose the instantaneous
    pulse would be 57.6 kHz but an alternative way to look
    at it would be as a 11.5 kHz signal with a really wonky
    9:1 duty cycle... I further suppose since it's a
    "square" wave the instantaneous frequency could be
    considered to be infinity (obviously not really).

    Being a square wave definitely makes the frequency measurement less intuitive! (and far beyond my analog comprehension) After I sent the last message, I thought about how hilariously over-simplified my intuitions on analog frequencies are. Usually everything is digitized by the time it makes it onto my plate.

    There were a good number of consumer and homebrew
    projects for doing this with the parallel port. In
    theory a nice clean 8 bit output, I made one with my
    school friend back in the day and it sounded *awful*. I
    suspect our quality control was not good enough as
    other people reported good results.

    It could also be especially hard to compare reported results if some peoples standard for good results were different. :) But with results being awful that does suggest the quality control may have been suspect. ;)

    Oh for the days when you could just walk into Maplin
    and buy qty. 1 components... In fact we just turned up
    with a list of "0.1uF electrolytic" etc and handed it
    to the poor guy behind the counter to rummage through
    the catalogue and find the 20 or so part codes we
    needed for us and then fetch them from the back!

    I still like to order very small quantities from Digikey, I assume if any of the orders aren't being filled by robots then the people working there are probably judging me for wasting their time packaging 83 cents worth of resistors. (and I still end up with spare parts left over!)


    Chris/akacastor

    --- Maximus 3.01
    * Origin: Another Millennium - Canada - another.tel (21:1/162)
  • From Spectre@21:3/101 to AKAcastor on Fri May 10 04:18:00 2024
    I'm actually surprised to have not seen this kind of trick in use before. Seems like it could have fit in during the 80s when any (cheap) audio more than a beep was highly desirable.

    Most seemed to use a parallel port instead, or even just 8 bits straight off the BUS off whatever they're in, in a D2A setup. MOD era D2A in ModPlay on
    the PC. SAM on the Apple II, "Hellooh, my name is Saaam."

    Spec


    *** THE READER V4.50 [freeware]
    --- SuperBBS v1.17-3 (Eval)
    * Origin: A camel is a horse designed by a committee. (21:3/101)
  • From Spectre@21:3/101 to Spectre on Fri May 10 04:24:00 2024
    I'm actually surprised to have not seen this kind of trick in use

    The bit I forgot, is that these tend to be fairly CPU heavy, and you have to
    be able to hit the Parallel/Serial port pretty fast. Making it difficult for the systems of the age to do anything else save drive these sound devices.


    *** THE READER V4.50 [freeware]
    --- SuperBBS v1.17-3 (Eval)
    * Origin: A camel is a horse designed by a committee. (21:3/101)
  • From Nightfox@21:1/137 to Spectre on Thu May 9 12:50:47 2024
    Re: Play audio from a serial port
    By: Spectre to Spectre on Fri May 10 2024 04:24 am

    The bit I forgot, is that these tend to be fairly CPU heavy, and you have to be able to hit the Parallel/Serial port pretty fast. Making it difficult for the systems of the age to do anything else save drive these sound devices.

    In the early 90s, I saw a sound driver for Windows 3.1 that used the PC speaker, so that WAV audio files & such could be enabled that way. Although it worked, and was kinda cool for what it was, it slowed down the PC significantly while playing audio that way. I imagine it was a similar issue.

    Nightfox
    --- SBBSecho 3.20-Linux
    * Origin: Digital Distortion: digdist.synchro.net (21:1/137)
  • From AKAcastor@21:1/162 to Nightfox on Thu May 9 16:52:40 2024
    In the early 90s, I saw a sound driver for Windows 3.1
    that used the PC speaker, so that WAV audio files & such
    could be enabled that way. Although it worked, and was
    kinda cool for what it was, it slowed down the PC
    significantly while playing audio that way. I imagine
    it was a similar issue.

    Just recently I was reminded of that same sound driver (I have vague memories of being wowed by it as a kid without a sound card) in the DOSBox-X discord chat. For anyone curious to try it, a link to the PC speaker audio driver for Win 3.1:

    https://winworldpc.com/product/pc-speaker-driver-wi/pc-speaker-driver-windows-31


    Chris/akacastor

    --- Maximus 3.01
    * Origin: Another Millennium - Canada - another.tel (21:1/162)
  • From Bob Worm@21:1/205 to AKAcastor on Fri May 10 14:01:16 2024
    Re: Play audio from a serial port
    By: AKAcastor to Bob Worm on Thu May 09 2024 11:06:48

    Hi, AKAcastor.

    I have returned from my work travels and put the incredibly complicated 2 component circuit together - great success!

    So, essentially if I fire all zeros at it then (pre-filter) my oscilloscope measures 11.5kHz. I suspect it's just counting transitions, though, so it's probably being a bit literal. The low pass does a good job on that, like 370mV p2p left out of the 3.5V leaving the UART.

    I didn't have a 0.02uF capacitor so I used a 0.022, according to an online calculator that means the low pass comes out to 2.7 kHz instead of 2.95 kHz. It have a pair of .01uF here so I could try that, but it worked well enough that I didn't bother. I'm sure someone far more into the maths and engineering than me could do some sums and figure out if the analogue circuit is attenuating that as if it's 11.5kHz or 57.6kHz... I dunno :)

    And so... the output was quite "hot" as described on the blog, about 3V p2p with audio. I hadn't thought about it before but obviously it also has a bias of about 1.5V. I didn't fancy feeding that into anything so I stuck a potentiometer after the output and a capacitor in series to block the DC.

    Result: Surprisingly decent audio, actually. Nothing you'd want to listen to for leisure but, yeah - broadly similar to what's shown in the video on the blog. Possibly it would sound better if it were played through speakers and re-recorded to smooth out some of the rough edges (as in the video).

    Fun oddity: with my oscilloscope sat post-filter I noticed that it would trigger and display a waveform when sending audio but not when I just sat there mashing the keyboard in the terminal. Space would sometimes trigger it and the arrow keys always did... It turns out because it idles high, you need either a lot of data (arrow keys send 3 characters back to back) or a very "zero-dense" character, such as space (which only has one bit set), to drain enough out of the filter capacitor for the 'scope to notice the voltage drop :)

    I'm going to put together a cheeky YouTube video showing all of this but I need to source some different audio, as I think that LMNC track is available to buy and I don't have permission to use it...

    BobW
    --- SBBSecho 3.20-Linux
    * Origin: >>> Magnum BBS <<< - bbs.magnum.uk.net (21:1/205)
  • From Bob Worm@21:1/205 to AKAcastor on Wed May 15 22:08:14 2024
    Re: Play audio from a serial port
    By: Bob Worm to AKAcastor on Fri May 10 2024 14:01:16

    Hi, all.

    I'm going to put together a cheeky YouTube video showing all of this but I need to source some different audio, as I think that LMNC track is available to buy and I don't have permission to use it...

    Finally got the YouTube video up - if anyone's interested it is here:

    https://youtu.be/Q9vlxCXxzrg

    If not... don't watch it :)

    BobW
    --- SBBSecho 3.20-Linux
    * Origin: >>> Magnum BBS <<< - bbs.magnum.uk.net (21:1/205)
  • From AKAcastor@21:1/162 to Bob Worm on Sun May 19 12:36:38 2024
    Re: Play audio from a serial port
    Finally got the YouTube video up - if anyone's interested it is here:

    https://youtu.be/Q9vlxCXxzrg

    Bob - wonderful video! Great presentation and excellent demonstration of what's coming out of the serial port and how it sounds. Super well done.

    Your observation about single keypresses with a low number of '0' bits being filtered out is interesting too - as you said, it makes sense when you think about it - such a clear demonstration can be really enlightening to see in action.

    Thank you for sharing your video, it's a great watch and you do a great job of showing us the technical details.

    The audio quality is shockingly good! I know I would have been overjoyed to have audio of this quality before I got a Soundblaster in the 90s.


    Chris/akacastor

    --- Maximus 3.01
    * Origin: Another Millennium - Canada - another.tel (21:1/162)