A few days ago, I reported that I had finally re-balanced by ‘plays’: my top ten composers were no longer so dominant in my history of composition plays as they had once been.
I mentioned then that I had, by way of response, been able to remove my ‘top ten’ from the excludes.txt which prevented AMP from playing anything by those composers. I had hoped that, in response, AMP would start playing at least something of my top ten! Sadly, the maths is against them still: if there are 500 composers in a collection, then the odds of any of the top ten being picked for a random play is 1 in 50, or about 2%. I wouldn’t want to bet on a horse with those odds!
Of course, that was the whole point: Bach and Britten must take their chance, equal with Marcel Tournier or Siegmund von Hausegger. By being treated equally, they won’t re-dominate my play history as they once did.
Except!… sometimes I really do want to listen to some Bach or Britten or Vaughan Williams! That is, occasionally, it would be nice to say to AMP ‘stop picking entirely randomly; play Salieri’. There’s still a random choice of what music by Salieri would be picked, but at least I could force the choice of composer. While I’m at it, why not allow the choice of genre to be over-ridden, too? If I’m sick of hearing opera for a while, I’d maybe like to say ‘play orchestral’ or ‘play choral’. Anything but ‘play opera’!
Basically: why not permit AMP to unbalance my plays once more, by allowing me to occasionally ‘influence’ or override ‘true random’?!
Four New Run-Time Switches
So now it’s time to introduce four new run-time switches I’ve added to AMP (which is now bumped to version 1.09 in consequence) to allow this ‘temporary unbalancing’ to happen: ––composer=xxxx, ––genre=xxxx, ––performer=xxxx and –comment=xxxx are all now permitted.
The four switches all take single-word arguments and will do wild-card searches to find a match. For example ––composer=william will match Ralph Vaughan Williams and John Williams (and William Matthias… in fact, anyone who has the word ‘william’ somewhere in their name). If you want to get really precise, wrap the precise wording in double quotes. So ––composer=”ralph vaughan williams” will now only match RVW’s compositions.
You can only use one switch at a time. If you try using two or more, then an order of precedence applies: comment is overridden by performer; which in turn is overidden by genre, and genre is overridden by composer. So if you tried saying, for example, ––composer=beethoven ––performer=karajan, you’ll get some Beethoven played, but it won’t necessarily be conducted by Karajan (though given how often Karajan recorded Beethoven, the chances are good that it will be anyway!)
Hopefully, you’ve noticed from the examples I’ve shown so far that all the switches are case-insensitive. ––composer=britten will match Britten, BRITTEN or even BrItTeN. The same goes for the other three switches.
If you specify none of the new switches, AMP works exactly as it has done hitherto: pick a composer at random, and then pick one of his or her compositions at random after that. None of that earlier functionality is affected at all by the new switches.
Finally, in case it wasn’t obvious, a ‘run-time switch’ means a parameter you put on the command line so that you influence how AMP runs. So the basic command to run AMP is just:
…but now you can say:
And so on.
I just want now to list some of the specific features of the new switches and the rules that govern their use:
1.0 Single Arguments
The switches take single arguments only. You cannot, for example, say ––genre=opera,concerto. You might hope that to mean ‘pick me something that’s either an opera or a concerto’, but AMP will regard that as an instruction to find something that has literally been catalogued as ‘opera,concerto’. Hopefully, you don’t have anything in your music catalogue that is tagged like that! Therefore, you’ll just get an error message to say ‘nothing matches’.
You similarly cannot say ––composer=britten,mozart and hope to hear works by either Benjamin Britten or Wolfgang Mozart: the search will find no-one literally called “Britten,Mozart” and will thus fail to play anything at all.
2.0 One at a time
As already mentioned, you can’t use more than one switch at a time. If you try, the order of precedence sets in. Composer wins over the others. Genre wins over Performer. And Performer wins over Comment. Comment beats nothing at all!
3.0 Avoid Spaces … and Double-Quote if you insist on using them
The switch arguments should not contain spaces, but if they do, wrap them in double quotes. Thus ––composer=Ralph Vaughan Williams is wrong and won’t work, but ––composer=”Ralph Vaughan Williams” is fine.
4.0 Wildcard Matching is Automatic
Again as mentioned previously, switch arguments will always be matched with wildcards. So ––composer=britten will match ‘Benjamin Britten’, without the need to specify the first name at all. Obviously, that could cause issues: if you search for composer=bach, there’s no telling which of the family might get matched: you could well end up with the music of CPE, JS, JC or any of the host of others! But, at best, the automatic wildcard matching means that you needn’t try to spell out Jean-Joseph Cassanéa de Mondonville in full and without making any typing mistakes! A simpler search for ––composer=mondonville will work fine to get his music playing.
5.0 But wildcard matching only works ‘outside’
Wildcard matching only works around the ‘outside edges’ of what you supply. I mean that if you supply ‘smith’, that will match ‘john smith’ or ‘robert smithson’ or ‘Hugh Tyrwitt Smith Mondonville’. But if you supplied ‘johann bach’, the search engine cannot match anything in between the two component words, so ‘johann bach’ would be matched; so would ‘georg johann bach’… but not ‘johann sebastian bach’: it can’t search within the words you supply. Similarly, ––composer=”Ralph Williams” won’t find Ralph Vaughan Williams, because that would require the matching of something inside the supplied value, not either side of it.
6.0 Excludes and Time Bar Observation Rules
The fundamental rule is: A search for a specific genre or performer or comment will always obey artist excludes and time bars. But a search for a specific composer will ignore any excludes or time bars.
That is, if you’ve configured an exclude.txt to stop anything by (say) Mozart ever being played… then a search for ––genre=opera will definitely NOT match a Mozart opera. And if you played something by Britten at 9AM, such a search will definitely NOT match a Britten opera until at least 3PM (assuming you’re using the default 6 hour time bar).
Similarly, if you said ––performer=Karajan then nothing by Mozart that Karajan conducted will be selected (because the excludes.txt is still respected); and if you happened to play a Beethoven piano sonata at 9AM, then nothing of Beethoven’s conducted by Karajan will be selected for play until at least 3PM (again, assuming the default 6-hour time bar is in use)
Selections by composer, however, will never respect the excludes or the time bar. That is, assuming your excludes.txt still mentions Mozart, but you now say ––composer=Mozart then music by Mozart will be played. If you’ve deliberately specified to play a named composer with an override switch, it’s considered pointless to take into account previous attempts to prevent that composer being selected for random play!
I should finally note that the new switches can be appended in any order and in any position within the AMP command line invocation. This specifically means that if you have an alias set up to mean a bunch of runtime options, you can add any of the new ––composer, ––genre or ––performer switches to the end of the alias and have them take effect.
For example: I currently have this line set up in my .bashrc:
alias ampr='amp --musicdir=/sourcedata/music/classical --usedb --dbname=main --selections=3'
When I type the command “ampr” in a terminal session, therefore, this means ‘use a database called main, make three random selections, and my music directory is found in such-and-such a location’. Invoked like that, AMP will randomly select three composers and play one work by each before quitting. That’s ‘traditional AMP’ at work.
Now, however, I can do this:
This means, “use a database called main, make three random selections, my music directory is found in such-and-such a location, and make sure all of the three selections are of works by a composer called Britten”. All the options already aliased to the “ampr” command, in other words, are retained, and the new switch is tacked onto the end of it all, temporarily, for the duration of this AMP run, but without the fundamental options hard-assigned to the alias needing to be modified or specified. I can therefore occasionally and temporarily demand to hear the work of a particular composer or conductor without that requiring me to edit my .bashrc every time!
Note in particular, though, that the ––selections switch applies globally. By which I mean, if I’ve asked AMP to make 3 random selections, then throwing ––composer=britten into the mix will mean that all three selections will be of music by Britten. It won’t apply the ––composer switch to just the first selection and then revert to ‘any random composer’ after that first selection has played, for example.
Obviously, the new options can make running AMP -and understanding what it’s doing when it runs- more tricky than previously: having more choices can be like that! If it all seems a bit complicated and fiddly, just remember that you don’t ever have to use these new switches if you don’t need or want their functionality. AMP will keep running as it always has done if you don’t. Specifically, you can still run AMP in ‘local mode’, whereby you cd to a folder full of music files and invoke AMP there, directly: AMP will still play precisely what it’s told to do, if you run it that way, with no randomisation of any sort involved!
How to Upgrade
To obtain the new version of AMP, click here. Download that file somewhere (I shall assume your $HOME/Downloads folder for what follows). Upgrading then consists simply of issuing these commands (or equivalents):
chmod +x $HOME/Downloads/amp.sh sudo mv $HOME/Downloads/amp.sh /usr/bin
The move of the download to your /usr/bin should be sufficient to simply over-write the earlier version of the script. If you’re prompted to over-write, simply agree to do so.
Have fun with unbalanced randomness!