AMP – Frequently Asked Questions

1.0 What is the difference between Fast and Full scanning when populating a database?

Both scan modes populate a table called “Libraryartists” (one row per discovered composer) and “Albums” (one row per discovered album, but they achieve this outcome in two different ways.

The fast scan finds folders containing FLAC files within a ‘directory tree’ and then reads the metadata from the first FLAC file found in each folder only. The full scan similarly finds all folders containing FLACs, but reads every FLAC files’ metadata, populating an intermediate table called “tracks” as it does so.

The difference is that the fast scan is obviously much quicker. Imagine a folder containing 45 FLAC files, comprising all the tracks associated with a 5 Act opera. The fast scan only reads one file before declaring it has found ‘Giuseppe Verdi’ to be the composer and ‘Otello’ to be the opera. The full scan reads all 45 files, creating 45 rows in the tracks table, each saying ‘Giuseppe Verdi, Otello’.

At the end of its work, the full scan creates the libraryartists and albums tables as distinct (i.e., unique) selections out of the tracks table.

Both types of scan therefore ending up creating the same pair of tables that AMP then goes on to use, except that the fast scan does it much more quickly.

2.0 When I do a fast scan, I’m told I have 400 albums belonging to 114 unique composers. When I do a full scan, I get different numbers. Why?

To start with, read the reply to question 1. Once you understand that full scans read metadata from every FLAC file, whereas fast scans read metadata from only the first FLAC file, in a folder, it then becomes obvious why the two scans could result in different outcomes.

Imagine, for example, a symphony, made up of 4 tracks. The metadata for tracks 1, 2 and 3 are identical: Beethoven and Symphony No. 5 (Bernstein – 1972). For some reason, however, track 4 was tagged as Beethoven and Symphony No. 5 (Bernstein – 1963). (i.e., the recording year was entered differently for the fourth track alone).

The fast scan only reads track 1’s metadata, and so will declare there is one composer and one album: the 1972 recording of the symphony.

The full scan will read all four tracks’ metadata and will therefore see one composer but two albums, because the album name in track 4 is subtly different from that contained in the other 3 files. Therefore, the scan will declare that is one composer and two albums.

Whenever the fast and full scans produce different numbers for composers or albums, therefore, it almost always points to a tagging/metadata error somewhere in your music collection. Tracking such errors down is tricky, but can be done with a tool such as the DB Browser for SQLite and direct access to the AMP database tables -but you will need to be good at SQL and database management to achieve much in that regard, I’m afraid.

Fortunately, number discrepancies between the two scan modes generally do not affect functionality. In both example scans described above, the same physical folder is recorded for the album(s) found by either scan mode. The full scan will, for example, find that album 1 lives in a folder called /music/Symphony No. 5 (Bernstein – 1972) and album 2 lives in a folder also called /music/Symphony No. 5 (Bernstein – 1972): though the metadata for the two albums is different, the physical folder ‘they’ live in is the same in both cases. AMP’s playback function always consists of moving to a physical folder and playing all FLAC files found there, regardless of their metadata. So the different number of albums returned by the full scan doesn’t prevent the entire symphony being played afterwards.

3.0 Can AMP play non-FLAC files?

No. It only searches for and plays FLAC files. It simply wasn’t written with the intention of ever playing any other type of music file. Will it ever be able to play non-FLAC files? No. I believe in free, open source and non-proprietary audio codecs that lose none of the original audio signal. FLAC is about the only audio codec that meets all those criteria.

4.0 Why do I need a database?

You don’t. The default mode of operation is, in fact, not to use a database at all. Point AMP at a folder of music files (with the ––musicdir parameter) or physically move to such a directory (with your operating system’s cd command) and it will play what it finds there. Point it to a folder that doesn’t itself contain music files, but contains sub-folders and sub-sub-folders which do, and it will randomly select one of those folders to play its contents. No database is necessary in any of these scenarios.

The trouble with the last scenario, however, is that it involves a physical trawl through the folders and sub-folders to find FLAC files before it decides to play anything. In a large music collection, that physical ‘walk’ through your folder structure will take time -and that means there will be an appreciable delay before randomised playback begins.

There is another problem with the ‘physical walk’ approach, too: if you have a huge Mozart collection, a large Handel collection and a tiny Alan Rawsthorne collection, the chances of the randomised selection ever being of something that Rawsthorne wrote is equally tiny. In other words, the relative sizes of your composers’ music contribution to your music collection affects the probability that they will be selected for random play. Which means ‘physical walk’ randomisation isn’t very random after all!

The use of a database fixes both these problems. Instead of (say) 50,000 physical FLAC files to walk through, stored in (say) 8,000 different folders, AMP with a database now has a single table containing 8,000 rows to search through. That takes sub-second time to search, so the delay before playback is massively reduced.

Secondly, AMP’s database is comprised of two fundamental tables: composers (called ‘libraryartists’) and recordings (called ‘albums’). Each composer gets 1 row in the composers table, no matter how many recordings are attributable to them. That means each composer is just as important as any other -and the probability of selecting any one of them randomly is thus equalised. Having selected a composer at random, AMP then randomly selects from recordings belonging to that composer -but the choice of composer in the first place means true randomisation of whose music to play has already taken place.

Using a database with AMP is therefore encouraged if you ever want to do randomised play, because the playback will start more quickly and will be the result of ‘true’ randomisation, unaffected by the quantity of music attributed to any given composer.

5.0 Can I prevent AMP selecting a particular composer’s work?

Yes. If you create a text file called excludes.txt in the $HOME/.local/config/amp folder, then AMP will always read that and incorporate it into its randomisation process as composers whose work should not be selected for playback. The text file must contain one composer’s name per line -and the composers’ names should be spelled out exactly as they are used when you tagged your music files.

That is, if excludes.txt says ‘Wolfgang Mozart’ and you tagged all your Mozart operas as being composed by ‘Mozart, W’, then the exclude will not take effect. Only when the exclude matches exactly what is in the ARTIST tag will it work.

6.0 Can I make/prevent AMP selecting a particular genre of music?

No. Not at this time, though it might be possible in a future release.

7.0 Can I make/prevent AMP selecting music conducted by a particular conductor or performed by a particular orchestra?

Not at this time, no: but the idea has been given some thought and beta attempts to do this have already been made. This capability might therefore become available in a future release.

8.0 Where is the AMP database stored and what is it called?

You have to ask for an AMP database to be created with the ––createdb runtime option: at that time, if you also specify the ––dbname=<something> runtime option, you get to choose the name of the database: it will be whatever name you specify after the equals sign of the ‘––dbname=’ parameter. If you don’t specify a name, it will be called “music” by default.

If you do want to specify a name, you should stick to single-word names without spaces (though, if you insist on spaces, you can do so by wrapping the whole name in double quotes. Thus ––dbname=”My music database” would be valid). Names without spaces do not need to be wrapped in double quotes.

In all cases, whether the default name or a customised name is specified, the database ends up being stored as a single file in the $HOME/.local/share/amp folder. Note the period/full-stop before the ‘local’ part of the path: it means the ‘local’ folder is hidden, and you’ll need to turn on the ‘show hidden files and folders’ feature of your file manager to see it.

Also in all cases, the extension “.db” is added to the database name. So the default database file is called ‘music.db’, and if you said ––dbname=main, the database file would be called ‘main.db’.

9.0 What type of database does AMP use if one is created?

AMP uses a SQLite3 database. That means the database file (see Question 7 above) can be opened by any SQLite3-compatible client (such as DB Browser for SQLite) or at the command line with the command sqlite3.

The database is very simple: there are no indexes of foreign keys created and there are only a maximum of four tables involved (and usually only three): libraryartists, albums, plays and (optionally) tracks. The tracks table will only exist after a full-scan; the other three exist whether you do a full or fast-scan.

The libraryartists and albums tables are only ever read, never updated, except in the case of a new ––refreshdb operation being run, in which case they are completely wiped and re-created essentially from scratch. The plays table is inserted into every time some music is played when database use has been specified. It records when an album was played, and what artist, genre and performer pertain to that album. Note that it records album plays, not track plays. So if you play a 4 movement Beethoven symphony and a 65-track Verdi opera, both plays will add one row to the plays table.

Even with a large music collection played frequently, the database will be very small: in the order of a few tens of megabytes (MB).

10.0 AMP doesn’t display what tracks I’m listening to. Can it?

No. First of all, it’s a side-effect of the fact that AMP performs gapless playback (i.e., without introducing additional pauses in playback as it switches from playing one track to the next). To do this, it concatenates or joins all the tracks in a folder into a single ‘virtual’ FLAC, which is then played. At that point, AMP is playing a single virtual file, not separate tracks, so it cannot report on specific tracks, since it isn’t aware of their existence.

Secondly, AMP is designed to be a classical music player and a deliberate design decision was made when writing it that, really, classical music listeners shouldn’t really need or want to see “tracks”: they listen to concertos, or symphonies, or operas. They don’t (or shouldn’t, really!) be listening to “bits” of a concerto, or specific “movements” of a symphony. If that paradigm has any validity, then it is apparent that displaying track information in a classical music setting would be rather inappropriate!

It’s also why AMP only records whole-album plays in the ‘plays’ table in its database (assuming you use one): “bits” of compositions simply don’t fly in the world of classical music. It’s either the whole composition or nothing!

Anyway: whether it’s appropriate or not is not the main consideration. The over-riding requirement to do gapless playback means that it physically isn’t possible for AMP to report on specific tracks.

11.0 What are ‘local’ and ‘remote’ modes?

AMP can be run in two ways. If you cd to a folder containing FLAC files and then type ‘amp’, AMP will launch and play whatever FLAC files it finds in the folder it’s launched from. There is no randomisation or selectivity involved: it simply plays all the FLACs it finds in its current working folder sequentially and completely. That is termed running AMP in local mode.

Alternatively, you can run AMP without first cd’ing to a folder of FLACs and instead point AMP to that folder by using the ––musicdir=</path/to/FLACs> run-time parameter. AMP is therefore not being launched from ‘within’ a folder of music files, but is being pointed to them from elsewhere. Hence, this is termed running AMP in remote mode.

Functionally, there’s not a lot of difference: even in remote mode, if pointed to a specific folder containing FLACs, AMP will play all the FLACs contained in that folder, sequentially and completely.

The difference between the two modes is that remote mode can be invoked by pointing AMP not to a folder of FLACs, but to a folder that contains sub-folders and sub-sub-folders that in turn contain FLACs. When that happens, AMP will search within the folder structure to find any FLACs it can and then select one set of them to play back randomly.

Remote mode can permit random playback, in other words, where local mode cannot. Remote mode doesn’t mandate randomness, however. It only implies randomness if the ––musicdir folder specified at run-time does not itself contain FLACs.

As an example: imagine you had a folder called /music that contained a sub-folders called /Bach, and within /Bach you had a folder called /Brandenburg Concertos and another called /Goldberg Variations -and within those sub-folders, you had FLACs of the Brandenburgs and Goldbergs. There are then three scenarios:

  1. You could type cd /music/Bach/Goldbergs and then amp and you would be running AMP in local mode, playing the Goldberg Variations completely and in sequence.
  2. Or you could type amp ––musicdir=/music/Bach/Goldbergs. You’d then be running AMP in remote mode, playing the Goldberg Variations completely and in sequence, but from a specific folder directly containing FLAC files.
  3. Or you could type amp ––musicdir=/music. Now you’d be running AMP in remote mode and getting it to randomly play either the Brandenburg Concertos completely and in sequence or the Goldberg Variations completely and in sequence. The pointing to a folder that itself does not contain FLAC, but which is the ‘root’ of a folder structure that does have FLACs in it somewhere triggers randomised ‘remote’ operation.

In scenario 3, you wouldn’t know which of the compositions would be selected for playback, but AMP would choose for you. Having made its choice, however, it plays back whatever it has chosen completely and in sequence. It doesn’t randomise the order of tracks to playback, in other words; only the choice of which album to play is randomised.

12.0 What is the point of randomised playback?

Only that with a large music collection, you will often tend to keep playing ‘old familiars’ over and over again. It becomes harder to dig through the more obscure corners of your collection the larger it grows (in my experience, anyway). By randomising which compositions to play, AMP helps you play the more obscure repertoire and not merely keep playing the old favourites over and over again.

However, it’s entirely optional. If you don’t want randomised playback, you don’t have to have it. See question 11: in 2 of the 3 scenarios discussed there, randomised playback doesn’t happen.

13.0 What is Scrobbling and why would I want to do it?

Scrobbling is the name given to the process of sending details to a database of the music you’ve been listening to. Usually, that database lives in ‘the cloud’, meaning it’s provided by someone over an Internet connection. The usual ‘someone’ providing this service is Last.fm.

Though Last.fm is strongly geared towards non-classical music listeners, it will accept ‘scrobbles’ (i.e., listening reports) from anyone who is a member, no matter what music they listen to.

Last.fm’s main goal is to get a ‘community’ of music listeners sharing their music listening habits -and watching the adverts they serve as they do so! But there’s nothing to stop you simply using it to record what you listen to over time. It’s a handy way to find out who your favourite composers and pieces are, and to spot when you’re maybe over-playing one composer and under-playing others.

I’ve use it since 2008 to record my ‘listens’ and in consequence am aware of how prone I am to over-playing Britten and Bach and under-playing the likes of Mahler or Schubert. Whether you let such knowledge alter or affect your listening habits is up to you, of course -but I’ve found it a useful prod to getting me to listen to less-mainstream music and thus to broaden the pool of composers whose music I listen to.

Getting AMP to scrobble, however, is entirely optional. If you’re not interested in doing so, just provide a ––noscrobble run-time parameter any time you run AMP.

If you I want to scrobble, you need first to create a Last.fm account (which costs nothing apart from parting with an email address -and I don’t think I’ve ever received email from them in over 13 years of membership!). You then need to download the amp-scrobbler.sh script and install it as per the instructions in Section 4 of the main article.

14.0 Can I have several databases?

There is no fundamental limit to the number of databases you can create and use with AMP. You could conceivably have separate databases for ‘Bach’, ‘Mozart’, Beethoven’ and ‘Others’, each one pointed to specific directories, provided only that one directory doesn’t imply any of the others (in which case, the databases will simply duplicate their content, somewhat pointlessly). For example, suppose you have this physical folder structure

 

Then it would be possible to create the 4 databases mentioned -but you’d never end up randomly selecting any Britten to play, because his folders aren’t covered by any of the proposed databases. But if I also created a database called ‘allmusic’ that pointed to /home/hjr/music, then I’d have a database that contained Bach, Beethoven, Mozart, Others and Britten, plus individual databases for Bach, Beethoven, Mozart and Others.

I could then do –usedb –dbname=allmusic and possibly get Britten’s music selected at random. Or I could do –usedb –dbname=Mozart and get a random selection of something Mozart had written: I’d have great flexibility in directing AMP’s randomness, in other words.

So, if you have your music folders organised appropriate, there’s nothing to stop you having as many separate databases as you feel you need to match your music listening needs and moods.

15.0 You don’t show Album Art: how do I visually know what is playing?

Good question, I think. The simplest thing I can suggest -since as a command-line player, AMP’s simply not going to be able to display album art- is to right-click the terminal window in which AMP is playing and select the Open File Manager (or whatever precise wording your distro gives you: ‘open file manager’ is what you get in KDE 5) menu option. That will literally do what it says on the tin: open your file manager at the precise folder that AMP happens to be playing at that time. You can then open the PDF booklet from there (assuming you keep PDFs of the CD booklet in the folders with the music files); or you could right click a FLAC file and ask to open it in a program like Kid3:

Once you’ve done that, Kid3 will easily let you display the album art embedded in a FLAC simply by double-clicking on the thumbnail representation of it and then clicking [View]. No, it’s not brilliantly integrated or single-click convenient, but it is fairly easy to go from an AMP window playing something to the files it’s actually playing with a simple right-click and ‘open file manager’, which gives you the opportunity to do a lot more than just view album art …so it’s pros and cons all round!

16.0 Why can’t I pause the music?

Because you are listening to classical music and you shouldn’t be doing that! OK, that’s being a bit school-ma’am-ish, so let’s start by saying that I deliberately didn’t want to festoon AMP with volume and play-pause-rewind-fast-forward controls because I think and believe that classical music is better listened as its composers probably intended it should be: start at the beginning, listen carefully throughout, stop at the end. The idea of pausing music playback certainly suits our distracted, interruped life-styles today, of course… but it’s not what classical music is supposed to be about!

But… having said that, if you know anything at all about how Linux processes work, you’ll know perfectly well that there is, in fact, a way to pause AMD: press Ctrl+Z. That will actually suspend any running process and send it to the background. AMP is no different in that regard.

To resume play, you have to type fg (to bring the AMP process back to the foreground).

Bear in mind that using this feature makes the screen display look pretty dreadful: this is me stopping and starting a test track several times:

The -^Z that’s displayed is Linux’s way of showing the Ctrl+Z key-press; you see me typing ‘fg’ a couple of times, too.  Though the display says ‘Stopped’, it’s really only just paused. The ‘fg’ brings it back to life every time.

It’s also true that it takes a second or two before the initial Ctrl+Z takes effect, because there is music data already in memory cache that have to be consumed before the process can be paused. But yes: if you insist on treating classical music in such a fashion, you can actually pause and resume at will!

Finally, remember that if your press Ctrl+C, AMP playback will be terminated. Ctrl+C really will kill playback, with no possibility of resumption from where you left off (you can always re-run AMP, of course, but it will play from the start again). If you Ctrl+C, too, then no scrobbling is performed of what you’ve listened to up to that point, nor is any entry made in any database you might be using. It will be as if you walked out of the concert half-way through the first movement: that doesn’t count as having listened to anything at all!

17.0 AMP stops playing a folder after some time, without playing everything. Why?

There is one known reasons why this happens: your file names contain two dots, full-stops or period marks in succession. This filename, for example, will play just fine:

09 - Ebben. ne andro lontana-preview.flac

But this one will not:

09 - Ebben... ne andro lontana-preview.flac

The use of even two full-stops in sequence is, in fact, enough to kill AMP.

Unfortunately, of course, multiple full-stops in succession is not unheard of:  they are often used as an ‘ellipsis‘, so you will commonly see them used in opera tracks, where one character stops singing and another picks up the dramatic pace. They will break the audio engine that AMP relies on, unfortunately.

There are three possible workarounds.

First: Don’t use three full stops, but use the proper ellipsis character (Unicode character 2026). This file name uses that character, for example, and does not break AMP:

09 - Ebben… ne andro lontana-preview.flac

Now, you will probably be hard-pressed to spot the difference between that file name and the one listed above it. They both have ‘three dots’ in their name. But in this second case, it’s actually a single character which simply has the form of three dots. In the earlier case, it was genuinely three separate full-stops. Typing an ellipsis on Linux is not hard: it’s just <compose key>+two full stops: … (which produces three dots, even though you only type two of them!). It’s not too hard on Windows, either: ALt+0133. So if you can get into the habit of tagging your files using the proper ellipsis character, and thus getting their physical file names to match also using the single ellipsis, you’ll be fine.

Second: If, like me, you already have lots of albums tagged up using three separate dots instead of the proper ellipsis character, then re-tagging them all is not going to be an attractive proposition. You could, however, without much pain, run CAO over the files. My ‘Composition-At-Once’ utility turns a bunch of FLAC files in a folder into a single ‘super-FLAC’ which contains within it all the information belonging to the individual files. As part of the way it works, however, CAO strips out two- or three-dots in sequence. It replaces them with an ellipsis (a proper one) instead.

Third: If turning all your per-track FLACs into single super-FLACs sounds a bit drastic, but you like the sound of automatic replacement of multiple dots with a proper ellipsis character, then you can run my Auto-Ellipsis Script (AES) against your FLAC files. It will scan all the files in a folder, replace any two- or three-dot characters it finds in both file name and metadata tags with a proper ellipsis character… and not otherwise touch your per-track FLACs.

Fourth: If you tag your music files using my own CCDT utility, that will automatically spot when two or three full-stops are mentioned in track names and will automatically replace them with proper ellipsis characters wherever they occur. If you rip your CDs in the first place with my own CCDR utility, that too will auto-replace multiple full-stops for you, preventing this from being a problem in the first place.

So yes: AMP playback of a folder-full of music will be killed at the point where it encounters the first file name containing 2 or more full stops in sequence. You either manually rename files to remove the multiple dots, or replace them automatically with either the CAO or AES utilities, or use the CCDR and CDDT utilities to rip and  tag your music files, which will prevent the ‘fatal dots’ from ever getting into your file names from the outset.