Generate Spectrograms in Shell
If you're an avid user of various BitTorrent trackers that specialise in the distribution of lossless music files, you may find this short article interesting.
One robust way of ensuring the uniqueness of FLAC files is to perform spectral analysis of said files that shall unveil many useful things, be it an abnormal frequency cut-off, a so-called "shelf" at 16 kHz, dodgy artefacts and so on. It may also be useful to produce two types of spectrograms of lossless files, that is, full-length and zoomed-in spectrograms, and perhaps even automate the process of uploading full-length spectrograms to an image hosting service of your choice. Since many BitTorrent trackers support BBCode, it wouldn't hurt to create a neatly formatted text file containing all the necessary information on each processed FLAC file. That's what genspec is capable of doing.
the details
genspec
relies on sox
for producing spectral analysis of FLAC files
and curl
for uploading full-length spectrograms to either
catbox or ptpimg; the latter requires you to have an
account, whereas the former shall work without setting up anything.
Should you choose the latter, you'll need to obtain your API key by
signing in to your account, viewing the source code of the main page,
searching for api_key keyword, copying its value and
then pasting it into the ptpapi variable at the
beginning of the script, genspec.
portability
The script has been tested multiple times using dash and
shall run on all GNU/Linux distributions and *BSD operating systems
regardless of the non-interactive shell you're using. genspec
uses the -i option of sed
, which is
considered non-portable, although it's supported by both Free- and
OpenBSD; GNU/Linux distros obviously support this option as well.