8 ms·
Using the Web Audio API to Make a Modem
- amigoingtodie 9y agoLots of weird anecdotes. Why is the computer unable to be connected to the internet? Why are you pasting so much code from stack overflow to visual studio? Cool implementation - should try ultrasonic...
- empath75 9y agoIt seems like it was just a story. Like tethering his cell phone would have been a more realistic option also.
- tyingq 9y agoGuessing some contractual clause that the device not be connected to any other network.
- jdavis703 9y agoIf you work in a SCIF or similar office environment you have to place your phone, and other personal electronic devices in a locker before entering the main office.
- empath75 9y agoSetting up a modem to get around an air gap seems like it would violate that.
- sgt 9y agoMaybe he's working onboard a navy ship?
- danellis 9y agoI used to work for Sophos, the British anti-virus company. We had three networks in the office: green, purple and red. Green was the corporate network that everyone had access to, mostly used to read email in Lotus Notes. Purple was an ad hoc network used by developers for various testing machines. Red was connected to the Internet. A few privileged people had a PC on their desk connected to the red network, but most developers did not. There were a couple of red-network PCs around the office that we could use of we needed to look something up. If we actually needed to download a file (say, an open source project, or some tutorial or documentation), we'd download it there and run a command that emailed it to us. The email would arrive in Notes with the attachment stripped off for virus checking. Some time later, we'd get another email saying that the attachment had been scanned and was available in another Notes database. It wasn't the best learning environment.
- adrianN 9y agoAt least you learned what kind of jobs to avoid.
- dTal 9y agoThat seems harsh. It was an anti-virus company. Imagine the mayhem if they didn't have that kind of isolation. Nor is that the most isolated that working environments get, not by a long measure; there exist employers who will destroy your phone if you accidentally bring it to work.
- adrianN 9y agoGiven the track record of security vulnerabilities in anti-virus products, they clearly put the emphasis on the wrong things.
- amigoingtodie 9y agoI think he meant Lotus Notes.
- pavlov 9y agoA discussion about the Web Audio API from a couple of weeks ago with the title "I don't know who the Web Audio API is designed for": https://news.ycombinator.com/item?id=15240762 https://news.ycombinator.com/item?id=15240762 I'm still not convinced that this API is actually useful for any application that needs to play sound or music, but it definitely seems to have the "interesting synthesizer experiments" segment covered.
- fasteddy 9y agohttps://inverted3.gitlab.io/drum-machine/ https://inverted3.gitlab.io/drum-machine/ is a working multi channel drum machine using Web Audio.
- floatboth 9y agoThere are a few trackers too: https://github.com/steffest/BassoonTracker https://github.com/steffest/BassoonTracker https://github.com/mbitsnbites/soundbox https://github.com/mbitsnbites/soundbox https://github.com/pgregory/wetracker https://github.com/pgregory/wetracker Also, I wrote a WebExtension that lets you apply pan and gain to audio in YouTube videos (and other videos that are not cross-domain) using Web Audio https://addons.mozilla.org/en-US/firefox/addon/soundfixer/ https://addons.mozilla.org/en-US/firefox/addon/soundfixer/
- pavlov 9y agoYes, the API lets you build 1979-style synths out of a toybox of generators and filters. However it lacks support for the most common task in real-world digital audio: computing samples into a buffer and queueing it for playback. (There is ScriptProcessorNode but it’s deprecated and performance is not up to audio rendering standards.)
- BillyWM 9y ago>There is ScriptProcessorNode but it’s deprecated and performance is not up to audio rendering standards. On the web, "deprecated" doesn't mean you can't use it. It can take a long time for "officially deprecated by the standards" to become "I can't use it anymore" (obsoleted). The replacement is the "AudioWorklet" interface and the purpose is to fix those exact synchronization issues. I wouldn't expect ScriptProcessorNode to disappear from the browser until the replacement is actually rolled out. The Web Audio API started as the Audio Data API in Firefox, which was nothing but a buffer to blast samples into, then the Web Audio API was a refinement/competing standard above that extremely simplistic API (I adapted a Javascript-based .mod player to use AudioData instead of sticking an <audio> tag in the page circa 2011). You've been able to generate and play back samples in browser (without Flash) for ~6-7 years now, they're simply making official changes to the underlying API in the hopes of improving it. "Deprecated" is just bureaucracy.
- mikeflynn 9y agoThat's a cool project. For others to experiment with, there is also quiet-js that is similar: https://github.com/quiet/quiet-js https://github.com/quiet/quiet-js
- brian-armstrong 9y agoAh hey, I made this. I was going to post it but it looks like I don't have to :) Here's the live demo of it https://quiet.github.io/quiet-js https://quiet.github.io/quiet-js
- ape4 9y agoFun project. But what about an ethernet cable, bluetooth, NFC, wifi,...
- krallja 9y ago...USB drive, USB keyboard HID driven by the laptop, QR code to webcam, CD-ROM, floppy...
- JetSpiegel 9y agoIP over Avian Carriers
- ravenstine 9y agoFor those who didn't know... https://en.wikipedia.org/wiki/IP_over_Avian_Carriers https://en.wikipedia.org/wiki/IP_over_Avian_Carriers
- sgt 9y agoThat's cool. I managed to whistle: 00 @@`@@@@@@```@@@@@`@` ` `
- beached_whale 9y agoAll I can think of with this is another way to bridge air gaps but accessible to more people.
- tyingq 9y agoVery cool. Funny that a Norwegian would settle for an implementation limited to 7 bit ascii though.
- tyingq 9y agoEr, because many Nordic characters wouldn't pass, if that wasn't clear.
- adrianN 9y agoSo did the author manage to successfully load a website using this modem? How did they teach their operating system to use the modem?
- nayuki 9y agoCool demo! From the title, I mistakenly thought it might be to make a dial-up compliant modem in JavaScript. But nope, it's a custom toy protocol instead. The encoder (sound playback) works in Chrome and Firefox, but the decoder (microphone recording) works in Chrome but not Firefox. Also, the encoder/decoder can't handle non-ASCII text; maybe it is only grabbing the low 8 bits of each UTF-16 code unit.
- westurner 9y agoWhile we're talking about Air Gaps, it's probably worth mentioning GSMem (an {x86,} internal bus as a GSM cellular transceiver (modem)); from Wikipedia: https://en.wikipedia.org/wiki/Air_gap_malware https://en.wikipedia.org/wiki/Air_gap_malware
- ravenstine 9y agoHaving worked on a similar project, my experience is that signal-to-noise is a very challenging problem when you have an air gap. Inevitably, it opens up room for minute errors caused by accoustics. The only "reliable" workarounds I devised were to increase broadcast duration and rebroadcasting the same data with simple checksums. This was what I came up with: https://github.com/Ravenstine/airsocket https://github.com/Ravenstine/airsocket Note it's extreme crappiness is due to a combination of my inexperience and also my desire to build as many parts from scratch as possible. The Web Audio API is only used to play audio, but the oscillator and decoding functions were written by me. It barely works. It's probably better to go full Web Audio all the way since I'm sure there's hardware acceleration(particularly with AnalyserNode). The author's method of encoding bytes is also far superior to what I came up with. I wish such an article was published when I was trying to devise my own audio modem. He does an excellent job going over every step and explaining what's going on. Documentation and tutorials around Web Audio used to be too convoluted, with basic examples too few and far between.
- anilakar 9y agoCongratulations. You just found out the essence of signal processing in telecommunications.
- brian-armstrong 9y agoI have a WebAudio modem that works reasonably well, and I went a different direction with it. Mine uses a C DSP/SDR library with good error correction, run through emscripten to generate the samples. You can try it here https://quiet.github.io/quiet-js https://quiet.github.io/quiet-js
- ravenstine 9y agoActually, I think it was your project that gave me the idea to attempt near-ultrasonic transmission. I could only get to ~15000hz before it would just not work and I never figured out why that was. Maybe there's a flaw in how I used the Goertzel algorithm. (reason I went with Goertzel is because I built it for a previous project and wanted to see how far I could take it) Is that example page new? That's brilliant. Your ultrasonic transmission seems to work pretty consistently.
- pgeorgi 9y agocoreboot has something similar to provide an early boot console in a device without "simple" output devices, using the PC speaker[0][1]. I doubt many people use it, but it's one of the things that can save the day. Although in case of "this corporate computer is air gapped", I wonder what corp policies that little project violated. [0] Sender (highly hardware specific): https://review.coreboot.org/cgit/coreboot.git/tree/src/drivers/pc80/pc/spkmodem.c https://review.coreboot.org/cgit/coreboot.git/tree/src/drive... [1] Receiver: https://review.coreboot.org/cgit/coreboot.git/tree/util/spkmodem_recv/spkmodem-recv.c https://review.coreboot.org/cgit/coreboot.git/tree/util/spkm...
- tuxxy 9y agoWoah, I had no idea this existed. This is pretty neat!
- foreigner 9y agoA friend and I once entered a competition to see who could transmit a text message first between two computers using DAQ boards. The judges walked around the room giving every team two wires. By the time they got to us they had run out, so we had to use paperclips. Our implementation did single-bit handshaking. Most of the other teams were trying to use a clock-based solution. Or throughout was super slow, but because our solution was stupid-simple we got it working first and won!
- a_t48 9y agoCould you elaborate? Did you use something like Morse Code?
- mkagenius 9y agoGoogle Tone[1] is a similar work. 1. https://chrome.google.com/webstore/detail/google-tone/nnckehldicaciogcbchegobnafnjkcne?hl=en https://chrome.google.com/webstore/detail/google-tone/nnckeh...
- deleted 9y ago[deleted]
- jonknee 9y agoInteresting security implications for air gapped systems, gotta yank the 3.5mm too!
- krallja 9y agoAnd the bus... https://news.ycombinator.com/item?id=15473481 https://news.ycombinator.com/item?id=15473481 Good luck patching THAT hole.
- scottpiper 9y agoFire this person immediately. Is it cool work? Sure. Is the person technically proficient and could find work elsewhere easily? Yes. Did they purposefully violate the policies put in place on them? Yes! I hope their client finds this article.
- maaaats 9y agoYou do understand this is just a cool hack and proof of concept?
- zAy0LfpBZLC8mAC 9y agoYeah, and fire everyone else, too, because they didn't forget everything they knew before touching the computer, so they transmitted information from the internet to the computer by typing it in, thus connecting it to the internet, you can't have that!
- stordoff 9y ago> Did they purposefully violate the policies put in place on them? Yes! Unproven. The _motivation_ is that they have a dev. machine w/o Internet access, leading to them implementing this. There's nothing to suggest they went beyond seeing if it was feasible or that they actually used it on the dev. machine (the photo of it "in action" shows the decoder being loaded from martme.github.io, strongly suggesting that machine already has functional Internet access).
- martinmelhus 9y agoI created this, so please let me explain myself. After stumbling over a really cool Web Audio API synthesizer I wanted to play around with the API myself. I used my work situation for inspiration, but I just wanted a fun pet project and didn't really bother to deep dive into the theory of modems. Hence the naive implementation and lack of error correction. So, do I actually use this at work? Truth be told, I've only ever used it to show of to my collegues. USB-drives are way more practical in every situation where I might want to use this. But the modem is able to provide the tool I set out to make: to copy ascii text between two computers! Glad to see that you guys liked it!
- ivionday 9y agoWhat was the cool synthesizer you found?
- qualitytime 9y agoMay not be this one but was on HN some time ago: https://inverted3.gitlab.io/drum-machine/ https://inverted3.gitlab.io/drum-machine/
- martinmelhus 9y agoThis one! https://webaudiodemos.appspot.com/midi-synth/ https://webaudiodemos.appspot.com/midi-synth/
- deleted 9y ago[deleted]
- xupybd 9y agoSo why can't your development machine be internet connected?
- bewo001 9y agoCombine it with WebRTC and implement T.30. Find a WebRTC/SIP/PSTN gateway. Send a Fax from the browser!! You might laugh, but we do have an API for sending DTMF tones in WebRTC..
- staunch 9y agoMaybe an "acoustic coupler" of some kind would help? They look so cool, I've always wanted an excuse to use one for something. https://en.wikipedia.org/wiki/Acoustic_coupler https://en.wikipedia.org/wiki/Acoustic_coupler
- beezle 9y agoAh yes..my fond memories of 300 baud and being able to read my program listing as it printed on the teletype or when lucky, video terminal. Thankfully I missed 110 baud.
- mschuster91 9y agoCan you please add an export function to the encoder? It's a nice way to create electronic music!
- perpetualcrayon 9y agoWould the signal from the headphones need to be boosted to make the connection more reliable? It might be useful / fun to implement a 2-wire-protocol or other IoT protocol. I'm thinking you should be able to implement up to 2-wire given the R and L channels of the headphones.
- deleted 9y ago[deleted]
- JorgeGT 9y agoAlso worth checking: minimodem http://www.whence.com/minimodem/ http://www.whence.com/minimodem/ (and an audio cable if your laptop has a line-in minijack!)
- deleted 9y ago[deleted]