Wikipedia:Reference desk/Archives/Computing/2021 January 10

= January 10 =

"Bitshift variations" song
How does this code actually work? (Source: https://txti.es/bitshiftvariationsincminor)

Ponzammo (talk) 08:30, 10 January 2021 (UTC)


 * If it works for you, you must be on a Linux system with an ALSA sound card driver. Not having one I cannot try this out. The C program produces an infinite stream of bytes, but I do not feel inclined to figure out the intentionally obfuscated code. Even if you figure it out, it will not make sense unless you understand the default encoding of aplay. The man page does not specify it. The .wav file format would be a plausible candidate for this default, but I see no way the C code could produce the requisite wave data. The .au file format would be another plausible candidate, but again, I see no way the C code could produce the requisite magic number. --Lambiam 11:01, 10 January 2021 (UTC)


 * If you send  data with no intelligible header, it defaults to PCM data. In the case of my machine, that default is unsigned 8 bit mono at 8000 Hz - I don't know how universal that default is, but the OP's code assumes something of that nature. For clarity, we can write a more legible program that synthesises a simple waveform, which can be piped to  :


 * -- Finlay McWalter··–·Talk 12:46, 10 January 2021 (UTC)


 * Reading the defaults for the individual options in the man page for aplay, unsigned 8 bit mono at 8000 Hz is indeed a standard default. -- Finlay McWalter··–·Talk 00:42, 11 January 2021 (UTC)


 * As a general remark, on the spectrum of obfuscated source-code, the program in the original post is "not very difficult to read." For example, I frequently read and build the entries from the IOCCC (one of the more famous obfuscated C code "competitions") - I find many of these to be entertaining and educational on a variety of fronts.
 * The sample source-code here is not very obfuscated - it's just poorly formatted, and relies on many default behaviors of the C programming language. Whether your C compiler will honor this specific dialect will depend on exactly which version of GCC (or other compiler) is present.
 * What we've got is a sum of filtered sawtooth functions - it's quite trivial to build a sawtooth wave out of a for-loop with incrementing index, depending on integer-wraparound to reset the signal value; and that data is passed to a variety of bitwise math that is essentially constructing some kind of harmonic "music"-like tones.
 * So to answer the question about how it works - here's a deep link directly into the middle of one of my favorite books: filtered white noise. It is a mathematical fact (derived formally in the entire lecture on noise analysis and deeply detailed in many free books available from the same author) - when you apply specially-constructed filtering to any input signal, especially one that begins with harmonic waveforms - you can easily produce an output signal that has characteristics mimicking a musical instrument.  By carefully crafting the filter, one can yield the specific properties that make music sound musical - things like timbre and harmonics - which have very simple mathematical forms expressible in various ways.
 * So to simplify the explanation: the source code in the example presented in this question produces a periodic signal (using a for-loop with integer wrap-around); and then it filters that periodic signal. It does so on four separate instances of a periodic signal - a linear combination of periodic waveforms - a poor-man's "sum of sinusoids" - ostensibly to add timbre.  It filters these through a very ugly noise-filter, namely the function g(i,x,t,o) - which uses a very ugly block of code to construct a strange LUT - so we're essentially building an FM Synthesizer.  And it does all of this using very poorly spaced sourcecode in the C language, relying on several default behaviors of the default C compiler, resulting in a sample program that is fairly difficult to understand and extremely difficult to compile on any computer that differs in even the slightest manner from the original author's expectations.
 * The point is, this is "complicated" code because it's very ugly and undocumented, but it's a standard method - sort of an "atom" from which the "molecules" of bigger signal-processing algorithms get built - so it's instantly recognizable to anyone who does this kind of signal processing on a regular basis.
 * The output - which is binary - is interpreted as an audio input by aplay, a test-tool provided by the Advanced Linux Sound Architecture system, an integrated part of many Linux systems that can directly interface to the sound output hardware.
 * Nimur (talk) 18:28, 11 January 2021 (UTC)
 * And a note to the wise: this sample-program is pretty harmless - but it's a great example of why users should be careful about copying text to their terminal. This text, when copied to the terminal, generates source-code, compiles that source-code, and then executes that source-code, and in fact pipes the program output to a hardware device-driver.  If a user does not understand why this is a risk "in general," the user probably has no business using a terminal in the first place - for any purpose whatsoever.  Copying commands to your terminal when you don't understand every single part of the command presents an extraordinarily hazardous computer-security risk.  Nimur (talk) 18:32, 11 January 2021 (UTC)


 * Consider me nerd-sniped. I was able to get the program to execute on macOS, by installing mplayer and gcc via Homebrew, and running the following: After spending way too much time tinkering with the obfuscated source code, I wrote a slightly more legible C program which produces the same output, and hopefully explains how it's being generated. Not sure anyone else will find that useful, but here it is.   Ciao! RoxySaunders (talk) 19:55, 11 January 2021 (UTC)
 * Thanks to RoxySaunders for providing source that builds and runs (in an unmodified form!) with modern, non-pathological tools!
 * As a note, one does not necessarily have to set sampling-rate at 8000 Hz. The song will sound musical - or at least chiptuney - at a variety of sampling frequencies.  This is a great way for the enthusiast to explore the interrelationship between arpeggio, vibrato, and tremolo, which are all really the same exact thing implemented with different bandwidth!  (... with some apologies to our music theory enthusiasts who may take offense - after all, without loss of generality, a sufficiently formal treatment can describe every audio signal as a sum of sinusoids - which is what makes computerized digital audio possible!)
 * For the user with less time, less ALSA, and more access to commercial software, here's sound in MATLAB. Nimur (talk) 22:15, 11 January 2021 (UTC)
 * Also, to fill in details for anyone not well-versed in Unix terminal: the C program feeds its output (the sound data) to standard output. This gets piped to aplay's stdin. As you can see from the man page, aplay reads stdin if not given a filename. aplay itself is a compact media player provided as part of ALSA. Programming exercise for those interested: extend the C program to play the audio itself by utilizing the ALSA libraries. --47.152.93.24 (talk) 03:43, 12 January 2021 (UTC)

Dead website
Say that you try to access a website that you have accessed many times over many years ... and, out of the blue, it's no longer available. Is there any way to find out what happened to it? (For example, the site "went out of business", etc., or whatever.) There is no error message or redirect or any such thing. The computer just sits there for several minutes ... with the hour-glass icon for "waiting" ... and, eventually, it says this: ''Problem loading page. The connection has timed out. The server at www.fyndit.com is taking too long to respond. The site could be temporarily unavailable or too busy. Try again in a few moments. If you are unable to load any pages, check your computer's network connection. If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.'' As indicated above, the website is www.fyndit.com ... it is (or was?) a website somewhat similar to eBay. Thanks. 32.209.55.38 (talk) 23:52, 10 January 2021 (UTC)


 * The site is (or was) the words "find it", with the intentional mis-spelling of "fynd". 32.209.55.38 (talk)  — Preceding undated comment added 23:57, 10 January 2021 (UTC)
 * There are sites that you can use to get a "third opinion" and rule out whether it is your local network or browser: Down For Everyone? A network timeout could mean many, many kinds of things have gone wrong in the network layer. The provider may have lost their DNS hosting. The DNS may point to a dead host instead of the real, live one. The host could be indeed switched off. I don't know if you're asking about "what happened to it" in an IT sense or a business sense. This is the computing reference desk. We could bring several tools to bear to fynd out what became of the server that was hosting this service. We can't really know if they are out of business, out of money, everyone quit, whatever the business reasons may be for such an outage, that is beyond our scope. Elizium23 (talk) 00:28, 11 January 2021 (UTC)
 * Fyndit.com shows an insecure website claiming they are "Currently down for maintenance". I hope that when they come up, they have TLS certificates. Elizium23 (talk) 00:30, 11 January 2021 (UTC)
 * It sort of looks to me like fyndit.com has been on life support for a while. Their maintenance page is copyright until 2016 and most sites updates those notices every year. Their Facebook page, Twitter and blog seem to have died in 2015 [//fynditblog.wordpress.com/] [//twitter.com/Fynd_It] [//www.facebook.com/WantIt.FyndIt]. Their iOS app seems to be dead [//apps.apple.com/us/app/fyndit-by-tutupata-inc/id720773056] no idea since when since Apple's apps store is fairly crap at providing info on the open web. Their pinterest, no idea since pinterest doesn't seem to believe in dates [//www.pinterest.nz/fyndit/_created/]. Looking at the archived version of their website, [//web.archive.org/web/20201031143127/http://www.fyndit.com/] most of the links and I mean simple ones like FAQ, contact us, hiring, privacy policy etc don't work. I think because of archiving issues with their complicated site as I can see signs of a privacy policy in search engine results and I'm surprised they would have kept it this long if the privacy page was dead. But if those links really were dead for years, that's another sign of how bad things were. Obviously someone needed renew the domain and perform other essential maintenance and was even still working on parts of it e.g. their G+ link was removed [//web.archive.org/web/20180215220242/http://www.fyndit.com/] but frankly I'm surprised you still found it useful last year. Maybe it'll be back, but I wouldn't count on it long term. Their community forum seems to have had a similar maintenance message for a long time [//web.archive.org/web/20200815192813/http://www.fyndit.com/vanilla/] [//web.archive.org/web/20180418064455/http://www.fyndit.com:80/vanilla/] [//web.archive.org/web/20160315184100/http://www.fyndit.com/vanilla/] Nil Einne (talk) 03:57, 11 January 2021 (UTC)


 * Both ping and dig tell me that www.fyndit.com resolves to IP 52.218.234.34, which is hosted by Amazon Technologies Inc.; whois produces "redacted for privacy" for almost everything, except that the registrant organization is Tutupata, Inc., based in California. The registry was last updated 2020-05-07, which is fairly recent. It looks like they did not pay the bill to Amazon. The latest capture by the Archive Team (which can use your donations) is from October 3, 2020, when FyndIt were still in the air. Here the FyndIt app is described as "FyndIt by Tutupata, Inc", but iTunes says it is not available in any store I tried (US, EU, India). There is an app named "fyndit.co" in Apple's app store, but it does not seem related. The signs point to the demise of FyndIt, Inc. and the website and app. I found no signs of life for Tutupata, Inc., either; in fact, FyndIt appears to have been a new incarnation of Tutupata rather than a spin-off. --Lambiam 14:58, 11 January 2021 (UTC)
 * , the Amazon IP indicates they were hosted on AWS, which can sometimes indicate that a company was being run on-the-cheap rather than self-hosting (although plenty of respectable companies host in the cloud too.) Elizium23 (talk) 18:32, 11 January 2021 (UTC)