# Imperfect Harmonics of String Instruments

A question appeared on Physics Stack Exchange asking why the harmonics of a piano string aren’t the exact integer multiples of the fundamental as Pythagoras and Fourier had taught.  The question asks about pianos, but this applies as well to guitars, violins, and all other string instruments.

http://physics.stackexchange.com/q/268568/353

There are several effects to consider.

• Stiffness of a non-zero thickness wire means higher harmonics are harder to make, due to having more bends, thus a teeny bit higher in frequency, more so the higher the harmonic.  There is a fourth-order differential equation to replace the usual wave equation, from which we obtain the frequency deviations for each harmonic.
• The ends of the wire are clamped.  Naively, these would be nodes (zero crossings) of a sine wave.  But the clamp prevents the wire from being at an angle.  In effect, the standing wave has less room to exist in that you’d think when measuring the distance between clamps.  This shifts everything up, including the fundamental. Higher harmonics with the same partial amplitude want greater angles at their nodes, thus are more affected.
• The string is pushing against air as it vibrates.  Resistance tends to slow things down. But does that mean harmonics would be higher or lower relative to their expected naive frequency based on the fundamental?
• The wire at rest is a straight line between two points. When vibrating, it’s longer. The higher harmonics may be thought of as fast short-scale activity riding on a curved slightly longer string.  This would lower the harmonic frequencies relative to the fundamental.  But this effect is smaller, and not yet mentioned in the answers (as of this writing.)

One fine day at a music store in Fort Collins, years ago, I saw a whimsical bass guitar, much smaller than normal, more like lute sized, and with strings of soft rubbery stuff, some kind of plastic or silicone probably.  It made an interesting bass sound.  Whereas a normal bass guitar string is under great tension, these strings were maybe under just a few pounds.  It made an interesting and different sound.  I suppose that instrument would exhibit interesting nonlinearities and off-integer harmonics in easy to measure ways.  But I had more important things to spend my money on.

# LIGO Announces 2nd Gravitation Wave Observation

This is great news for physicists!  As I started to drive home from work today, I heard this on NPR.   LIGO, the pair of mile-long L-shaped super-sensitive interferometers in Washington and Louisiana, picked up data last December looking a lot like a black hole collision.  Everyone by now has heard the announcement last February, of a signal picked up last September, indicating black holes of masses of about 29 and 36 solar masses.  Now there’s this collision, with masses about 8 and 14 solar masses.

Of course, it has been turned into audio.  The version I heard on the radio sounded very much like something watery or airy being suddenly sucked up, or  falling into a hole (of course.)   The audio at  https://www.ligo.caltech.edu/video/ligo20160211v2  uses the same data, but it doesn’t sound the same to me, but then, my car’s audio and my home computer’s audio aren’t the same.

The main news story from LIGO:  https://www.ligo.caltech.edu/news/ligo20160615

# Background Sounds & Ambient Environments

Sometimes it’s too quiet to concentrate on work.  Or too quiet to sleep.  Maybe there’s too much distracting noise from down the hall or from the neighbors.   How to create background noises more conducive to a desired state of mind, such as sleeping, studying or focused intellectual work?

I found a long clip on Youtube of random cafe noises, with occasional bean grinder whirrrs, muddled conversation, chairs scooching and outside traffic.  Robert aka “Duff The Psych”   made it with binaural microphones, which I suppose is something like what Kevin Braheny used to record vividly realistic you-are-there sound clips in his “Secret Rooms” album.   DtP creates “ASMR” recordings.  The clip is available to play at https://www.youtube.com/watch?v=BOdLmxy06H0  But note that visually, it’s just a latte sitting there.

Beware of some cafe or library background sound clips on Youtube – they are only one or two minutes long, looped many times to fill an hour.  You’ll get tired of those quickly.  Duff’s clip is not repeated, but a true hour long recording.

The cafe clip was nice, but even at one genuine hour of material, I don’t want to play it over and over and over day after day. It would get too familiar, though it may do its job just as well, played with the volume way down to be barely perceptible.  To cover distracting sounds, though, you’d want it cranked up more.   You’ll need more variety.  So where to get a wider variety of cafe sounds, and other useful backgrounds?

## Coffitivity

The website Coffitivity provides several types of cafe. You get three free online, and three more (as of this writing) for a few bucks.  I usually run this all day long with their volume slider at “5” even if I’m running other background sound sources.  The volume slider has only multiples of five. Zero is no sound.  You may wish there was finer control at the quiet end.  You could set the site’s volume slider to higher, say 10, and turn down the volume on your speaker, but then what if you need to watch an occasional Youtube video or lecture on Coursera?   Coffitivity provides apps for Android and iOS.

## Defonic

What would really be nice is to have a way to play a variety of subtle background noises.  A distant train.  Ocean waves.  Wind.  Maybe all three at the same time?  Defonic  shows you a bunch of icons. Click one, adjust the slider, and you’ve got a distant train, ocean, electric fan, cricket chirping at night, thunder, traffic, even “starship bridge”.    Try running their cafe along with Coffitivity in another browser tab.   Free, and I don’t see a “donate” button.  Defonic provides a mobile app.  Also, video backgrounds.

I saw another site similar to Defonic, forgot the name, with the same icons but missing the starship and some others. Maybe it was an older version?

## MyNoise

For some real ear candy, a wide variety of adjustable sounds can be played at MyNoise created by Dr. Ir. Stéphane Pigeon.    Free, but easier to use if you chip in five bucks.  There are oceany sounds, night sounds, droning sounds, all kinds of acoustic environments.  You will find a set of sliders like on a sound mixing board, or audio equalizer, to adjust the volume of various elements and frequency ranges in the soundscape.  Every noise generator has a few pre-designed mixes.  Pick for example “Twilight” and find mixes “Floating”, “Calming”, “Purity” and more.  Or pick the noise machine Warp Speed and choose Engine Control Room, Aboard the Enterprise, The Bridge or others, or set the sliders however you like. “Asleep in Quarters” is great for sleep, of course.  Or try Ice World with Clear Water, Magnetic Fields, Floating Particles and so on.

One great feature about MyNoise is the “animate” button, which causes the sliders to vary over time, changing the mix of elements contributing to the soundscape.  Night time crickets fade a bit a bit while the wind picks up, and later you may hear frogs dominate.  Keeps you from getting bored.

## Ambient-Mixer

If you feel like spending time in a old-time scholarly sound environment with a few distinguished colleages quietly (but not silently) studying, try the Hufflepuff Common Room.   There are several Harry Potter sound themes at  Ambient Mixer, along with Turkish coffee house, heavy industrial machines, meditative drums, science fiction places, everyday castle sounds, humming data center full of fans… there are *plenty* of sounds I haven’t started to explore.

“Distant world sounds help people mediate and improve the activities of the brain which involve the sensory processing and focus ability. The slow distant sounds have a relaxing effect on the nerves, giving people a beautiful feeling of happiness, freedom and optimism.”

Soundscapes are made up of several elements. Some run continuously, and some play at random times.    Like MyNoise, you have sliders to adjust the strength of the various elements.  No frequency EQ, but with Ambient Mixer you can pan left/right, set how often random elements such as quill scribbling or coffee pouring occur.    There is also a crossfade button, and mute if you don’t want that element at all.   A pause button stops everything temporarily in case you need quiet for a minute.   The only thing lacking is a master volume control – that would be nice to have.

The great thing about Ambient Mixer is that the various elements are separate – not all stuck on loops the same length.  The random play feature keeps the acoustical journey from getting stagnant.   With the volume low, playing one of the Harry Potter themes or a cafe, and the browser window buried under stuff I’m working on, I can completely forget it’s there, as well as forget where I am.

## Other

When I am painting or drawing or doing other artwork, or doing something requiring no word-thinking, I prefer a whole different sort of noise.  While mixing colors and dabbing at a canvas, I like talk radio – to keep the verbal part of my mind out of the way.   Depending on the time of day, I play broadcast radio, or look for archived recording on websites.   Favorites are Coast to Coast AM (George Noory’s show) with its wide variety of interesting guests, or if I feel like metaphysics, Nile MacFlouer’s Ageless Wisdom radio show or whatever crazy thing is airing on BBS Radio.

# Overheard at a rehearsal for 4’33”

Overheard at a rehearsal for 4’33”:

Oboist: …and over at measure 84, shall I take that full-measure rest right in line rhythmically with the previous and following measures, or do you suppose it would come off better with a bit of emphasis, maybe a bit of ritardo?

Conductor: Good question. I see… well, before that point, the score is building up energy, with soaring alternating arcs of silence, gradually going from not using the strings to the woodier instruments, but at the same time you have these absolutely soundless action punches in the support, the… er… the bass parts, and you’re kind of caught in the middle having to not play both as they come together there… and… yes, yes, I think you have a good idea. Quite perceptive! Ha ha, with all you talented musicians here, why they made me the conductor, I don’t know!

(laughter among whole group)

First Violinist: Because, Joe, you have a face made for having your back to the audience!

(more laughter)

Conductor: (tap, tap) Very funny, Maeve. Okay everyone, note what Linda suggests, we’ll go with a kind of ritardo in measure 84, just a little slow down, then resume the normal tempo. And… remember to watch me! Don’t miss that downbeat, because if we aren’t all together in doing nothing, right on the beat, the audience is going to get sore. Again.

Trombonist: Yeah, sounds great. Hey, I’ve got a smudge on my sheet music here, or.. a little tear in the page, in measure 115. I can’t tell what was written there. Is that a hushed D that I don’t play, or a D flat?

Tuba: D flat. I got the exact same part as you, but down an octave. But damn! I just realized something! I got my B flat tuba here, but I’m supposed to be playing my E flat, which is out in my van in the parking lot. Damn! DAMN!

Conductor: Chill, Harvey. Ah, that could be a problem. Could you transpose the key mentally as you go along?

Tuba: Hey, I’m a tuba player! How smart do you think I am?

(scattered laughter)

Conductor: Well, Harvey, don’t mind the instrument. This would be a serious problem with other pieces, but for this one, just finger the notes as if you had your E flat. Because…I’ll tell you a little secret… the audience isn’t going to notice!

Tuba: Okay, cool, I’ll do that. No problem.

Conductor: (tap, tap) Okay! Let’s play through the whole thing again, with all the changes discussed. And remember that quirky one-beat measure at the top of page four. I expect to hear exactly one beat of nothing there, between the restful quietude before and bold stillness following. (make big downstroke with baton, then holds still)

(faint sounds of an air conditioner, muffled outdoor traffic…)

(four and a half minutes later…)

Conductor (looking surprised, in a good way): Hey, nice! That was all right! You did great! Yes, fantastic! We’ll do fine at the concert. I suppose that’ll be all for today. Yes, let’s pack up. No more 4’33” for now. We don’t want to peak too soon. Unless anyone has any comments or suggestions?

Cowbell Specialist: Uh, yeah… so, maybe this piece could use more cowbell?

# Is “Black” a Color? A Comment on 4’33”

Is music, which is normally made of sound waves, still music when the amplitudes of those waves are zero?

An odd thing my dad said, way back when I was a kid, about colors: black isn’t a color. All the other colors of paint, crayons, cloth, bird feathers were colors, but since black doesn’t reflect light (in a ideal limit), it isn’t a color. Only light has color.

Since then I’ve put plenty of thought into many things, and have concluded that Dad was nuts. Is zero degrees Farenheit not a temperature? Is the origin of a coordinate system not in the space measured by those coordinates? Does an account with a business cease to exist when, for a day, there is neither debt nor credit in it? Does Atheism count among the religions? Is silence a sound?

Yes, because you can’t reason about things without the minima and maxima, the null set and the superset of all subsets, a resting ground of all variables, an absence of all moveable pieces.

Discussion of Atheism should fit right in with any discussion of religion, not because there’s a definite culture or school of thought Atheism with the general qualities of a Religion, but because we don’t want a hole in the space of thoughts and possibilities in which we roam in our discussions.

Crayola does indeed put a “black” crayon in their boxes bought by millions of parents for their kids.

So silence, when intended as music, must count as music, just so that it’s in the continuum of music which is short, music which is soft, music which has many long pauses and rests, songs about four and a half minutes long written in triple pianissimo all the way through.

This was originally a comment to a youtube video, https://youtu.be/WTCVnKROlos, of a TED talk about John Cage’s famous work 4’33” where the musicians perform silence for four and a half minutes.

# A Review of Build Systems, 2015

To study waves, one must calculate. To calculate requires creating software. If it’s not simple, a build system and souce control system help keep things straight.

Every few years I look over the landscape of build systems to see what’s new, what’s different, and if I might like to choose a different favorite for my own general use and to recommend for projects at work.

Peeking ahead, The Conclusion: CMake is the winner in most cases, with QMake a close second if there’s only one target.

Sometime around ten years ago I chose Peter Miller’s Cook for personal projects because it seemed elegant, useful, and solved some problems of using plain Makefiles.   For a large project containing several executables, several libraries, user documentation and technical documentation, it is common to have a Makefile, or whatever files a build system uses, for each of those components, and a master file to invoke them.  This is done all the time with Makefiles. But there are problems with that – conveying values of variables, having to repeat dependencies, lists of linker options, and so forth, and worst of all, having to re-determine file obsolescence over and over as each Makefile determines the work needed for its target.   Cook solved some of those problems, as did several other newer build systems.   What is desired, ultimately, is to spend little time on build system activities compared to actually compiling and linking.  In particular, a null build (when all target files are up to date) should run “quick” which for most us, should be just a few seconds if not in an apparent instant.

The key paper on this, “Recursive Make Considered Harmful” by Peter Miller, is required reading for all computer scientists, software engineers, and science-math-art types like me who pretend to be such.  It can be found in numerous places on the WWW.

Another important characteristic of a good build system is platform independence.  Make and Cook both fail at this, due to using shell commands for carrying out build steps.   It is impossible to write a command to compile on Linux or BSD, and have it also work on Mac, and also on Windows, and also on all the popular embedded systems.   This is not just a matter of hiding “gcc” or “clang” or “CL” behind a macro \$(CC) along with their more common options.    Abstraction to the point of telling the build system to “compile” a .cpp file to get an object file (and we don’t have to say if it’s “.o” or “.obj”) allows platform-independent builds.

Along with this, is the fact that most Windows developers like to use MS Visual Studio.  Most linux/unix developer are happy with a command line, though a variety of IDEs could be in use.  Java and Android developers tend to use Eclipse.  Abstraction of specific commands into named concepts allows the build system to produces artifacts that aren’t command-based, such as IDE project files, and files for less abstract build systems such as Makefiles.

This sort of build system, highly abstract and which produces files for simpler build systems,  could be called a Second-Order Build System.  These seem to be the winning technique throughout industry.  CMake excels at this.

## CATEGORIES of BUILD SYSTEMS

* Simple direct build systems

:  Make, Cook, Rake. Often limited to few platforms, specific toolchains.  Easy to learn, use, test. Horrible once you want to scale up or spread to other tools, platforms.

Main benefit is these are easy to learn, having a simple basic working principle.

Easy to set up for tiny projects, as long as you don’t want portability.

Fine for in-house one-off projects.

* Powerful Self-Contained Build Systems

, providing abstraction and portability, which do all the work themselves such as finding platform-dependent libraries, fiddling with paths, invoking compilers.  Scons is an example.

* Second-Order Build System

, also abstract and portable, but don’t do the work themselves.  Instead these systems degate the blue-collar work to simpler build systems, which is nearly always Make. A second-order build system creates Makefiles or IDE project files.  Beware the dangers of Recursive Make. Widely used examples: QMake, CMake.

* Specialized Build Systems

– just for a certain language, maybe only on a specific platform.  Unlike the Simple Direct Build Systems, these don’t even pretend to be portable or abstract.  Fine for academic exploration, specialized embedded systems, cutting edge new hardware.   Use one of these if necessary, but otherwise avoid. Not discussed further in this article.

* No Build System

.  Some languages such as the “scripting” ones, like Python, Perl do not need compiling.  A byte-code compiled file may be created by the interpreter, but is handled entirely by the interpreter. It is hardly a build system. In other cases, no build system is fine for students writing “hello world”, researchers trying out experimental compilers, and offbeat platforms lacking a normal set of tools.

## REQUIREMENTS and DESIRED CHARACTERISTICS of a GOOD BUILD SYSTEM

### Popularity

* Well established, well-used. We can rely on it for mission-critical work, company jewels.  Must have escaped its crib of origination, gotten into the hands of many users with no connection with the inventors.   Exception: for those who love intellectual adventures, debugging, and have ample spare time for writing and submitting patches, then never mind. This exception is not applicable to me or anyone I know.
* Good documentation, good online support, widespread know-how.  We do not want to be often scrutinizing the build tools’ source to figure out how to use it.
* One way to see if a tool has popularity, support, and community is to run a half-hearted superficial Google search. (Or a duck-duck-go search.)  When not trying hard, success stories, blogs, tutorials and more should come up anyway.   This is evidence that the tool has escaped its crib.

### Logic and Efficiency

* Can build just one component of a large system.   If the source control allows it, a developer should be able to pull just one major component with its dependencies, compile it, debug it, and submit changes.  Some build systems insist on running only from the top level.
* Quick null build (all files already up to date)
* Multiple out-of-tree builds (diff CPU, demo/real, debug/release, ..)
* Faster is better than Slower.  (Duh!)
* Not cumbersome for tiny projects.

### Targets and Development Environments

* Can build on and target Windows, Linux, with future targets that may include OSX, iOS, Android, various embedded systems.
* When building on Windows, can create files for Visual Studio.
* On Mac, files for XCode.
* There is no IDE of choice on Linux, but perhaps support for Eclipse would be nice – if only as an indication that the tool can support a wide variety of development environments.

### Toolset flexibility

* Choice of compiler: gcc vs clang.  Could we use clang for  Windows projects? Sure, anything is possible these days, but how easy will it be to support stunts like that in the build system?
* No hand-writ dependencies  (like xxx.c : xxx.h  common.h seen in Makefiles) (but can be done if necessary)
* Easy to incorporate external library, component, etc w/o much fuss.
* While C, C++ will be our main languages, should not be confined to working with those.

### Installation and Ramping Up

* Using the build tool does not require installing forty other things, esp not obscure languages, libraries which in turn drag in tons of stuff
* Easy for an experienced developer, not expert on the build system, to figure out how to use it for a typical medium-sized project.

## WORTHY CANDIDATES

With comments, evaluations, links. Highly biased, based on my limited knowledge and search time.

### GNU Make

Simple direct build system based on famous old unix ‘make’.
Very unix/linux oriented. Uses shell commands.
Original make on unix created 1970s, grew popular long ago, now universal.
http://www.gnu.org/software/make/  – current

### GNU Autotools = Autoconf, Automake

Tools to generate Makefiles, adapting them to specific machines according to 32/64 bit, availability of libraries, optimization levels.
Widely used for GNU and other open source projects.
Messy system that grew over time into rat’s nest of detail.
Difficult to learn.  Very unix/linux oriented, shell commands.
Only build system for which the word ‘arcane’ is used.
http://www.gnu.org/software/automake/   – current
https://autotools.io/index.html  (2013)

### CMake

Second-Order Build System, covering all significant platforms, architectures.
From ITK, maker of VTK 3D data visualization software.

Though it creates recursive makefiles on linux, the problems with that are anulled
because cmake stays in charge during dependency checks, writes clever makefiles.

Used by many large projects, open source and proprietary.
I am familiar with CMake for NRAO’s CASA radio astronomy software. It worked well.
CMake is used by ROOT, the major software tool used for high energy physics at CERN.
Used by:  OpenCV, Point Cloud Library,  zlib, Armadillo, OGRE 3d engine

Can build an individual target, but by name at top level,
not by cd’ing down and building there.
Created ~2000, grew within science and 3D graphics community,
then mid-2000s started catching on more widely.
http://www.cmake.org/   – current
http://aosabook.org/en/cmake.html

### QMake

Second-Order Build System.
Primarily for Qt-based C++ projects, requiring special preprocessing.
Can be used for non-Qt projects, but this is rarely done.
Easy to learn, get going on small projects.
Simple clean language. Add source file with elegant lines like
```HEADERS += foo.h SOURCES += foo.cpp```
Deal with common conditional situations with code like
```!exists( main.cpp ) { error( "No main.cpp file found" ) } win32 { SOURCES += win32demoscreen.cpp }```
Easy to deal with platform variations, since Qt already aims to be cross-platform.
But its biggest flaw: makes only one target per *.pro file.  It is possible
to have many .pro files, and have QMake create as many Makefiles, with a master
Makefile to rule over them, but it is not clear to me if this is a good idea. Also,
one may define multiple “configurations” in one .pro, each providing one target, but
you must manually run qmake once for each config.
http://doc.qt.io/qt-5/qmake-overview.html
https://blog.qt.io/blog/2009/10/12/to-make-or-not-to-make-qmake-and-beyond/

### Boost.Build

Created for Boost libraries.
Handles all platforms of interest, variety of toolchains. Since the Boost libraries
strive hard for universal portability, it makes sense their build tools would follow.
http://www.boost.org/build/index.html

### Scons

Python-based direct build system.
Was used by NRAO for CASA, until they switched to CMake.
(Parts are still scons, or have scons and cmake as redundant build systems.)
Good at handling many files spread over complex directory tree, with
the resulting file much smaller than equivalent Makefiles, perhaps 1/4 to 1/10th size.
Weak at IDE support – does not create .proj etc but instead, you must teach
your IDE (VS, XCode or whichever) to run scons as an external command or script.
see https://bitbucket.org/scons/scons/wiki/IDEIntegration
Even so, just isn’t nice with Windows development.
Anyone who tries feels it’s a strain, and is happy to move to something else such as cmake.
Can build out of source tree, but there’s a bit of a trick to it (2010)
http://stackoverflow.com/a/1763804/10468
“ridiculously long incremental build times just checking if anything had changed.” (2009, not finding anything recent to counter this claim.)
Uses Py 2.7, nothing earlier.
Created around 2000.   Projects and praise from users: http://www.scons.org/refer.php
As of 2014-2015, slowly moving toward Python3. Current version of scons is 2.3.5
http://www.scons.org/
https://bitbucket.org/scons/scons/wiki/SconsVsOtherBuildTools

### WAF

Runs fast, so they say.
Re-design of scons to improve its worst features
“it is essentially a library of components that are suitable for use in a build system”
(ugh, if that’s like how Drupal isn’t a CMS but components to build your own CMS, I’m outta here!)
Waf is used in a number of non-trivial projects, none of which I have any personal familiarity.

### Apache Ant

and related tools Maven et al
Used in large, or any size, Java projects.
Heavily uses XML.  I do not fancy hand-editing XML.
http://ant.apache.org/

### Ninja  – NEW (to me)

Created to deal with Chromium’s thirty thousand source files. Minimalist, fast,
and intended to be the lower-level output of some higher-level, more abstract build generator.
Higher-level generators include gyp, CMake.
Might be worth looking into, trying on a small toy project, but for
now, there’s not enough anecdotal evidence, big users to form any opinions.
Created in 2011. Last revision 2015.
http://neugierig.org/software/chromium/notes/2011/02/ninja.html
http://martine.github.io/ninja/manual.html

### tup (NEW!)

Fast, “correct” (not clear exactly what that commenter had in mind saying this)
Not enough usage yet out there to establish solid opinions
Did not pass my “half-hearted superficial Google search”  test.
http://stackoverflow.com/a/24953691/10468 compared to cmake, autotools
http://gittup.org/tup/
http://gittup.org/tup/make_vs_tup.html

## IGNORED

### A-A-P

Alternative build system.
Read about it around ten years ago. Does not just build, but also delivers the result, being more intelligent about installing than “make install”.
Never heard of anyone actually using this, even to try it out when looking at other build systems.
http://www.a-a-p.org/

### Rake

Ruby is an elegant language.  Rake uses Rakefiles, like Makefiles but
written in ruby, with powerful data structures, blocks (lambdas) and so forth.
I’ve found setting up a Rakefile to do anything tedious, taking more
know-how than I care to spend, especially after using CMake, QMake and others

### Cook

Just hasn’t caught on, despite widespread fame of its creator’s paper.
Still has the problem of Make, with build operations given as shell commands.

## WHO SWITCHES AND WHY?

* NRAO CASA switched from scons to cmake.  with custom scripts, cmake was easier to administer and do everyday tasks such as add new source files.  Null builds were slow, and there were some problems with dependency analysis between the dozens of target libraries and executables.
* (2005) An open source game engine went from cmake to scons. Very strong Python culture. Today, they appear to be developing on only Visual Studio, supporting Windows only.
* Open Office (not sure if before or after the split to Libre Office) had been using
perl scripts, then decided to use CMake.  The switch was a long slow process,
* Many stories can be found on “success stories” pages and “projects using ___” pages, and Q&A forums of all sorts. Most common reasons are: dealing with too many files, needing oddball tools supported, and reducing build time.

## FAVORITES

QMake – for the elegant langauge, power, portable, right level of abstraction
CMake – almost as elegant, but a bit more powerful than QMake due to ease of
handling multiple targets.

For my personal projects, if there’s a GUI it’ll be Qt, so I’ll use QMake.

For projects involving a team, multiple target components, with or without GUI,
you can’t go wrong choosing CMake.

I might try boost.build out of curiosity, but not for anything multi-platform, since
it can’t make VS .proj files, or the equivalent for XCode. Otherwise, on a slow weekend I might toy with Rake, since I like the elegance of Ruby, or WAF since I don’t know enough about it.

## HOW DO BUILD SYSTEMS DECAY?

1. Great new system is invented.
2. Doesn’t deal with general patterns like *.c –> *.o so wildcards are added
3. Want Release and Debug, or Demo, Standard and Pro versions…
4. Want out-of-tree builds, or access to source via different than default paths
5. Need to handle versions of OS, libraries, toolsets; can’t just hide behind some macro
6. More complex project has several target executables, needs more sophisticated logic
to execute the same build logic but with some variations.

7. Tool becomes badly-designed full-blown language interpreter!

## MY BIASES and PREJUDICES

Don’t make any major company-wide decisions bases on what I say!
* I have used CMake, QMake, Scons, hand written Makefiles, and have tried without any great depth Rake, Cook, IMake, waf, and some others.
* Like all Linux users, I have done the “configure; make; make install” dance a thousand times. I have not tried to set up autotools for a project, and gotten anywhere. My last attempt to work through a tutorial and go beyond it was in 2002, when I was at Colorado State.
* Most of my software work has been on small-scale projects or well-defined small parts of larger projects. Occasionally I work on a larger project, in which case the build system has always been scons or cmake.
* Most of my work has been for in-house use by scientists, engineers, specialists.  Some has been open source and some has been proprietary.  Almost entirely the subject matter is graphics, imaging, computer vision, scientific computing, signal processing, laboratory data acquisition and such. I don’t touch business software, web apps, or consumer shrink-wrap even if I have a ten foot pole handy.

Comparisons of builds systems, rationales for switching
* https://wiki.openoffice.org/wiki/Build_System_Analysis  (cmake, perl)
* http://stackoverflow.com/a/18291580/10468
* https://wiki.openoffice.org/wiki/Build_System_Analysis#Analysis_of_the_current_build_system compares cmake, gnu make in depth

### QUOTE from designer of QMAKE

CMake, for example, relies on the Makefile generator, and creates Makefiles which in turn calls back into CMake to do the build. This solution is not only fork-heavy, but also limiting, since you can only parallelize as well as the backend generator allows you to. So, unless the output Makefile is one single huge Makefile, you’ll run into limitations.

Scons will build directly, but is too slow at parsing dependencies, so each build you do takes forever to start. Waf is better in this respect, but both lack a proper set of backends for project generations (Vcproj, XCode, Makefiles etc).  They are also based on Python, which adds a dependency of a 3rd party library, which we want to avoid due to both the multitude of platforms Qt supports, and because of all the utility libraries.

### On the Hairy Growth of new Tools into Monsters

Quote from SomeCallMeTim on ycombinator, 2013

When people (myself included) start taking advantage of the fact that Make is Turing-complete and writing arbitrary “programs” in their Makefiles, it typically starts simple; you want to do something like build ALL the files in a folder, so you use a wildcard. Then you want to add dependency checking, so you use the wildcard to convert between .o to .d, keeping the same folder structure.  And I don’t want the .o and .d files to be generated where the .c files live, so I need to add this code here that converts the paths.

OOPS, this project uses a slightly different folder structure, and so I need to add a case where it looks in DIFFERENT relative paths.

Oh dear; I just realized that I need this code to work ALMOST the same in a different project that needs to be built with the same Makefile; that means I need to include it twice, using different options each time.

And it turns out that it DOESN’T work the way I expect, so now I have to use \$(eval), meaning some of my Make variables are referenced with \$(VAR), and some with \$\$(VAR), depending on whether I want them to grab the CURRENT version of the variable or the calculated version.
But now, now I have all of my code to create my project in one convenient place, and creating a new project Makefile is quite trivial! It’s all very clean and nice.

But the next person to try to change the folder structure, or to otherwise try to get this now-crazy-complicated house of cards to do something that I didn’t anticipate has to become just as adept at the subtleties of \$(eval …) and Makefile functions (define …); error messages when you get things wrong tend to make early C and C++ compiler errors look straightforward and useful by comparison.

For a far more complicated example, take a look at the Android NDK Makefile build system. 5430 lines of .mk files that make your life very easy…right up until you want to do something they didn’t anticipate, or until they ship a version with a bug (which they’ve done a several times now) that screws up your build.
>>>

# Adventures in Neon Discharge Bulbs

—— 001 ———-
neon001.sub
neon001flash.cir

When I was young, my dad took me to a magazine store. There were all kinds of magazines – gardening, hunting, world politics, race cars, doll collecting, you name it. Being the kind of kid who was often looking through the ventilation slots in the back of the TV to watch glowing tube filaments, I was quick to pick up an electronics magazine. This one happened to be the January 1969 issue of Elementary Electronics.

Cover of the magazine I grabbed

The first build-it-yourself project I opened to had several NE2 neon bulbs, some resistors and capacitors, a couple transistors and a battery. Looked simple without being too simple. The author, Herb Friedman (W2ZLF), described how the lights would blink in interesting ways, making great example of what some authors would have called an “idiot display”, pure blinkenlight fun, for little cost or effort. With bleepy chirpy sounds too.

“And soon the listener finds that exactly at the moment he thinks he has discovered the rhythm of the sound pattern, the light pattern makes a slight change and the sounds follow with a similar change in sequence. At one moment you may hear a clock inside
the box (accompanied by a glide tone), while the next moment your clock shifts into a sweep that mystifies.”

Great! I will build one.

While I already understood how one NE2 with one resistor and one capacitor worked to make a blinker, I couldn’t comprehend the messier network of this magazine project. Just what will it do?

Schematic that caught my interest when I was a kid

I wondered what would happen if the capacitors were connected in other ways. Why six bulbs? What if we added a seventh – what would be good ways to add extra capacitors? I had only two maybe three NE2 bulbs taken out of old radios and whatever. I aimed to get a few more and build this gadget.

A PDF of the whole Jan/Feb ’69 issue is available at www.americanradiohistory.com

I never did build that thing – other projects became more important. Now that we live in an age of advanced computing and sophisticated FOSS software which anyone can have, who needs to build anything? We can simulate it on a computer.

A blinking light illustrates one of the simplest feature of a wave or any type of oscillation: repetition in time. The number of blinks per second, or per minute, is the frequency. The time between blinks is the period. Use whatever time unit is convenient.

frequency: how many blinks per second, or per minute.
period: how long it waits between blinks.

This circuit is the simplest oscillator one can build. Only three parts! (Besides the power source.)

Simple NE2 relaxation oscillator

How it works: Initially, there’s no charge on the capacitor. Charge from the power source flows through the resistor, accumulating in the capacitor. As the capacitor’s voltage rises, it eventually reaches the “breakdown voltage” (or “strike voltage”) of the neon bulb, typically around 80V to 90V but could be higher. This much voltage makes a strong enough electric field between the electrodes that electrons are peeled off their atoms, making a plasma. As electrons recombine with positive Ne+ ions, light is given off. Once started, the plasma does not require as much voltage to be maintained. Typically about 35V to 45V or so will be found across the bulb in typical use.

This glowing plasma conducts electricity, discharging the capacitor until its voltage drops to the extinction voltage of the neon bulb, {{V_e}}. At this point, the plasma dissipates, losing conductivity and glow, in only a millisecond becoming insulator. Then the cycle repeats, the resistor charging the capacitor as before.

So, what’s the simplest way to model an NE2 neon discharge lamp in SPICE?
I’m on Linux, using ngspice. Models can be found out there in the www, but I think it’d be more fun and educational to create something from scratch, starting simple and building it up.

The most important feature of the neon lamp is that is acts as a switch, normally off (infinite resistance) but can be on, with some nonzero resistance. The switch is turned on by a certain threshold voltage, then turns off at some lower extinction voltage. Basic hysteresis. Luckily, it happens that (afik) all flavors of SPICE have a standard switch component, “S”, which does everything we want. Although, instead of using S’s built-in Ron resistance parameter, we’ll use an explicit resistor in series, so we can diddle around with it later. NE2s aren’t exactly linear when on, but we’ll deal with that another day. For now, SPICE’s S will do fine for a basic first attempt at simulating an NE2 bulb.

BTW, if I didn’t mention already, I’m using ngspice-26 on a 64-bit quadcore Arch Linux machine.

First, the simplest rough NE2 model possible, in a file named neon001.sub

```Neon NE2 super-simple version 001
* Lamp turns on at 80V, off at 40V, with on resistance given as model parameter

.model ne2sw  SW (Ron=41ohm VT=60V  VH=20V)

.SUBCKT Neon001  1  2
R1  1  11  45ohm
S  11 2   1 2   ne2sw
.ENDS
```

Then a circuit to use it, a simple RC flasher:

```Testing NE2 models as simple one-bulb flasher
.include neon001.sub

Vpwr   Vplus  0   120V
R1     Vplus  2   220K
C1      2   20      2.2uF
RCmeas 20    0      1ohm     ; to measure current through C1
X1      2   21   Neon001
RNmeas 21    0   1ohm        ; to measure current in neon bulb
.end
```

Run a transient simulation in ngspice

```tran  3msec 5sec  uic
plot v(2)
```

Voltage on capactor from SPICE simulation

Odd, that one lower peak dropping down lower than the others. This is normal when the time step of a simulation is around the same size, or larger, than the time it takes for some fast process to occur. In this case, the discharging of the capacitor through the plasma-filled NE2 happens in less than a millisecond. The integrator using t_delta=3ms flies right over that, computing a system state after the event based on varying conditions at varying amounts of time before the event. With a 3ms step, it can’t accurately compute how much charge the capacitor loses.

Try a slightly different time step:

```tran 3.1msec 3 uic
```

Capacitor voltage, slightly different time step.

The pattern of lower peak variation is different. This is purely a simulator effect, nothing to do with real life. Since we are interested in simulating flasher circuits with multiple lights, it would be good to solve this problem. There’s about a 10V difference between the lowest of the low peaks and the highest of them. That amount of simulation error make useless any simulation of more complex circuits.

Two ways to solve this:
1. smaller time steps. This is easy. We get way more data, but our CPUs have not trouble dealing with that. 0.1ms might be good.
2. Modify the NE2 model to involve more capacitance, inductance, physical time delay effects of the plasma, so that the discharge process takes longer. Still, we need smaller time steps since 3ms was way too big.

```tran 0.07msec 1.2 uic
plot v(2)
```

With smaller time step

Tightly zoomed into a time span of a couple microseconds, we see how fast the discharge occurs. There are time steps within the discharge downslope. Probably not enough for accuracy, but we are glad that the curve bottoms out at 40V

Zoom-in of time axis showing discharge event

You may have noticed in the SPICE file that I had put a one-ohm resistor in series with the capacitor. We can plot the current flowing through the capacitor with it.

```plot v(20)
```

Current flow in capacitor

Current flow in capacitor, magnified to show it’s positive, not zero, most of the time

The secone plot is zoomed in tight to a small voltage range, to show that the current is never zero, but positive as the capacitor charges for almost the entire cycle, and then briefly in 1/1000th the time discharges with a large current.

In switching and oscillating circuits like this, performing in a steady cycle, it’s normally a good rule of thumb (and physics) that the average current in each capacitor is zero.

An engineer building a neon discharge flasher like this would be wise to choose a type of capacitor which can handle the sudden reverse current flow, and have small ESR and lead inductance.

Another one-ohm resistor is in series with the neon bulb. By plotting v(21) and zooming in tight, we find zero current during most of the cycle, with

Current flow in the NE2

NE2 current, magnified. It really is zero most of the time.

The average is not zero.  The NE2 is either off, like a piece of insulator, or it’s on, positive current flow for a brief time.

The important thing we have found with our crude NE2 model is that it works, but we must choose small time steps to avoid false variations of oscillation cycles.

I will write later about the basic NE2 multivibrator.