r/javascript • • May 27 '22

Web Audio Modem - What do you do when you cannot copy text between computers due to lack of internet connectivity? Build a modem using the Web Audio API, allowing data transfer via audio

https://martinmelhus.com/web-audio-modem
378 Upvotes

21 comments sorted by

33

u/[deleted] May 27 '22

this is amazing! I had tried to build something like this years ago to help a friend with a crazy idea. He was looking to control a device through the output from an audio jack - but I did not have the skills to make it happen, glad to see someone figure it out!

30

u/sickcodebruh420 May 27 '22

This is so cool! My LG washer/dryer combo has a feature like this. It sings a diagnostic code that their app will listen to and use to generate a report.

1

u/marx2k May 28 '22

I tried to get that working on android a few weeks ago and either they changed their app and the instructions no longer fit or I'm doing something wrong

19

u/[deleted] May 27 '22

As a person old enough to have once attached a modem speaker to a pay phone to transfer a few bytes of data to the home office, I can’t help but think we’ve come full circle.

As a web developer I think this is amazing though. Put an amplifier on the sending machine and one of those parabolic microphones birdwatchers use on the receiver. Then see how far you can broadcast “wirelessly” :-)

16

u/fl4v1 May 27 '22

Interesting that the transmission quality is poorer due to ambient noise or mic quality. I think you could leverage reencoding the bits with error correcting codes

3

u/Buckwheat469 May 28 '22 edited May 28 '22

In theory one could use the blank space between the bits as error correction. You have enough space for 2 or 3x the throughput. The method would be to listen for the bit at 392hz, then move up 86.1hz in frequency to see if it's also active in that location.

5

u/JohnnySuburbs May 27 '22

I always thought it’s be neat to do a social thing, allowing stuff to propagate solely through direct phone to phone contact

4

u/tomhermans May 27 '22

That's really cool. I'm gonna try to add this cuz I have a similar situation where this could work out the problem

2

u/PatchesMaps May 28 '22

I'm pretty sure there is already a chrome extension that does this

2

u/joombar May 28 '22

Why not use the screen and show a variety of qr codes that another device with a camera can pick up?

1

u/Ok_Firefighter4117 May 28 '22

Maybe because QR code can only hold a certain maximum of storage, while audio can be as long as you want.

5

u/luckyj May 28 '22

A sequence of QR codes can be as long as you want as well

1

u/joombar May 28 '22

There are versions of qr codes that can hold much more data than the common ones

1

u/Ok_Firefighter4117 May 29 '22

But wouldn't it still have a maximum capacity of data? While you can stream audio data theoretically for an infinite long time span.

1

u/joombar May 29 '22

Yes but you could stream images at 60fps on most monitors, probably with more information content than can fit in an audio stream

1

u/Ok_Firefighter4117 May 31 '22

But can you record and process all the data as quick as the fps?

1

u/joombar May 31 '22

I don’t know for sure how many fps it’ll be, but I’m confident it’ll be higher bandwidth than audio

1

u/osoese May 27 '22

good idea and very cool

1

u/konijntjesbroek May 30 '22

Use a crossover, USB stick, ad hoc wifi?

1

u/suspicious-account- May 30 '22

"This guy fucks"

1

u/Dygear Jun 15 '22

There is so many layers of cool stuff to learn in this. Bravo great work!