4 ms·
> I only expected this to work on Ubuntu And yet here's the command: cat /dev/urandom | hexdump -v -e '/1 "%u\n"' | awk '{ split("0,2,4,5,7,9,11,12",a,","
by zeveb 11y ago
> I only expected this to work on Ubuntu
And yet here's the command:
cat /dev/urandom | hexdump -v -e '/1 "%u\n"' | awk '{ split("0,2,4,5,7,9,11,12",a,","); for (i = 0; i < 1; i+= 0.0001) printf("%08X\n", 100*sin(1382*exp((a[$1 % 8]/12)*log(2))*i)) }' | xxd -r -p | aplay -c 2 -f S32_LE -r 16000
There's nothing Ubuntu-specific there: it works fine on other Linuxes.
It's gotten more than a little annoying, this widespread equivalence between Ubuntu and Linux. Ubuntu is a Linux distro, albeit hardly the best, most idiomatic or most traditional. It's just a single distro, out of many.
- JoeAltmaier 11y agoBut lets admit that distros of Linux have become idiomatic. Its reasonable to give a caveat when describing any Linux procedure. This is not an Ubuntu issue at all. In fact, what's the point of different distros if they aren't idiomatic?
- cyphar 11y agoIt's incorrect to assume that a shell script that uses tools like xxd and awk is distro-specific. Almost every distribution ships the GNU coreutils and other GNU base tools. It's going to work on basically every distribution. What makes distributions unique is their package manager, release and security philosophy, amount of cruft, etc.
- JoeAltmaier 11y agoEven the same distro line but different versions may have significant issues. This is why every build on top of Linux (e.g. Android) calls out a particular kernel version. Even a particular version for the build machine. Because things like command line tools differ over time. Versionology is a whole universe of hurt on Linux.
- cyphar 11y agoThat's the cost of supporting code that is constantly being updated, you need to start freezing versions and backporting fixes. Also, I'm not sure what command line tools you're referring to as "differing over time". Kernel version freezing is mainly fear of new code (or out-of-tree vendor patchsets that depend very strongly on the kernel ABI which changes every few months -- but that's not user visible). Sure, if your system never changes anything you don't need to worry about software versions. But there are many other problems with that.
- robertelder 11y agoPart of this exercise was to leverage highly portable and backward compatible utilities as much as possible, so I expect stuff like cat and awk to work mostly the same everywhere. 'aplay' is the one I was not sure about. If I recall correctly, it was even necessary to explicitly 'sudo apt-get install' on older versions of Ubuntu.
- zeveb 11y agoaplay is part of ALSA, which is old enough that I wouldn't expect any differences between it on Ubuntu & on other Linuxes. FWIW, I really dig the demo: it's cool.