Giocoso : The Play Menu

The Giocoso Play Menu

The "Play Music" menu in Giocosois the real core of the program, giving the program purpose: it provides multiple ways in which to trigger the playback of music. It also provides two menu options that allow you to work and interact with 'playlists' -text files that describe what music should be played and in what order.

The various menu options available on this menu are as follows:

  • Play with Defaults
  • Play from Selection Filters
  • Play a specific folder
  • Play by means of advanced selection via SQL
  • Play from a playlist
  • Create or edit playlists
  • Delete playlists

"Play with Defaults" is Giocoso's 'standard' method of playing music: it's what you'd get if you launched Giocoso with the --play runtime argument and is the play-mode which does truly randomised selection of music without user-input. The other play options allow the user to direct or influence what music gets played, in various ways.

1. Play with Defaults

Left to its own devices, Giocoso will randomly select something to play in a two-part process. First, it selects a composer to play by random selection from its database, where each composer has as much chance of any other of being selected. At this point, Wolfgang Mozart is no more likely to be selected than (say) Georg Benda: their musical or historical significance doesn't count, and neither does the fact that you own 675 recordings of Mozart and only 4 by Benda. Note that for the purposes of selection, Giocoso looks in the ARTIST tag to determine what composers exist.

Having picked a composer, Giocoso will then randomly select a folder of music files by that composer to play.

Note that the folder is the 'unit of play'. The two-part random selection process simply ends up instructing Giocoso to 'go to this folder and start playing whatever FLACs are contained within it'. If you have ripped 8 tracks from a CD, that happen to be 8 movements from two Beethoven symphonies, into a single folder which Giocoso randomly selects to visit, then Giocoso will play all 8 movements, one after the other, without a gap. It's up to you are your cataloguing, in other words, to make sure that physically one folder means one composition, otherwise Giocoso will end up playing multiple compositions in one go, if they happen to share the same physical folder on disk.

Separate tracks stored within the folder selected for play, represented by separate FLAC files, are first virtually concatenated into a single file before play commences. Nothing is altered about the separate physical files themselves, but their contents are first streamed into a temporary file, in sequence, to create a single virtual file, from which playback is then performed. This has the effect of making playback 'gapless': one track will flow immediately on to the other without noticeable pause (unless, of course, the recording engineers have ensured that each track ends with a period of silence on the original CD).

Giocoso's default method of random selection can be altered by several factors.

  • First, a time-bar may be in force. A time-bar is simply a number of hours that Giocoso will wait after first playing composer X before composer X is allowed to be randomly selected again. By default, a time-bar of 6 hours applies, meaning that if you play something by Britten at 9AM, Giocoso won't randomly select anything else by Britten to be played until 3PM. The time-bar is configured in the persistent configuration file, however: the parameter TIMEBAR can be set to any numeric value from 0 upwards (the number representing hours the time-bar applies). A setting of 0 means that no time-bar applies at all; a setting of 48 means that any Britten played on Monday prevents any new Britten being played until at least sometime on Wednesday.
  • Second, an exclusion may apply. In the Giocoso configuration folder ($HOME/.local/share/giocoso3/txt), there is a file called excludes.txt, which can be edited in any text editor of your choice (or by using the Administration -> 1 menu options within Giocoso itself). If the file doesn't exist, you can simply create one. Inside the file, you can then type the exact name of a composer, as it is found in your music catalogue, one name per line. Any composer listed in the excludes.txt is completely barred from being randomly selected for playback. The bar is not time-limited and will remain in place until the excludes.txt file is re-edited and the line containing the relevant name is removed. There is no limit to the number of composers who can be mentioned in the excludes.txt file. The names listed in the excludes.txt have to be exact and precise echoes of what's in your music catalogue, though, for an exclusion to apply. If you have tagged your music as being by 'Franz Joseph Haydn', then adding 'Joseph Haydn' to the excludes.txt will not stop the Surprise Symphony from being selected for play. If you tagged it 'Rachmaninoff', then excluding 'Rachmaninov' won't work either.
  • Third, an exemption may apply. Again in the Giocoso configuration folder, a text file called exempt.txt exists (or can be created). Like the excludes file, it takes exact composer names, one per line, and can either be edited in a standard text editor of your choice, or by taking Administration -> 2 menu options within Giocoso itself. Any composer listed in the exempts file is immune from the effect of the TIMEBAR parameter. So, if TIMEBAR is set to 12, playing Bax at 9AM would usually prevent any new Bax from being selected until 9PM. If "Arnold Bax" is listed in the exempts file, however, then something else by Bax might be randomly selected for play at 10.30AM. Being listed in the exempts file doesn't make it more or less likely that Giocoso will randomly select that composer for the next play; it simply means that a composer could be randomly selected again where the time-bar in force would ordinarily prevent it.
  • Fourth, the persistent configuration file may contain selection filters which alter which things may randomly be selected. There are four such parameters: MINDURATION, MAXDURATION, UNPLAYEDCOMPOSER and UNPLAYEDWORKS. Min and Max durations are set as numbers, representing minutes. By default, they are set to numbers which mean they have no practical effect on anything. If you were to set MINDURATION=5, though, you'd be saying 'only randomly select recordings which have been determined to last for at least 5 minutes'. If you then also set MAXDURATION=20, you'd be telling Giocoso only to select things that last between 5 and 20 minutes. Within that range, Giocoso will still pick things at random, but a piece that lasts 23 minutes long definitely will not be randomly selected for playback. The other two filters are parameters requiring yes or no settings (and both are set to 'no' by default, meaning they are of no practical effect). Unplayedcomposer when set to a value of 'yes' means 'only randomly select something to play that is attributed to a composer who has never previously been played': it's a way of making sure new recordings you've purchased by obscure composers you've never previously listened to take precedence over the Haydns, Mozarts and Beethovens of the world! The unplayedworks parameter, if set to 'yes', means 'only play recordings that I've never previously played'. Giocoso then randomly selects something to play, checks the folder name of the proposed play and sees if that exact folder name appears in its history of prior plays: if it does, that recording is skipped and a new random selection is made. Only once it can be confirmed not to appear in the history of plays does Giocoso accept it for playback. This parameter is therefore useful in ensuring the hitherto obscure and overlooked corners of your music collection finally get a hearing.

All these four factors (if enabled and set appropriately) will change the scope of what may be randomly selected will alter, but the fact of random selection remains.

If you launch Giocoso Version 3 with the --play runtime parameter, this 'play with defaults' mode is what will happen, including the use of time-bar, exclusions, exemptions and selection filters to alter what is allowed to be randomly selected for playing. It is Giocoso's 'standard play mode'.

2. Play with Selection Filters

This option completely up-ends the way Giocoso works: it will still randomly select things, but only from a pool of recordings which meet the selection criteria that you supply on the form that's presented to you:

There are ten filter fields that can be completed, together with five '+ or -' flags that apply to five of the main filters. You can fill in as many or as few of these fields as you like: the eventual random selection will be from recordings that meet the combination of all of the ones you've chosen to fill in. Fields are case-insensitive and wild-carded, so an entry for 'Britten' will have the same meaning as 'britten', and 'mozart' would match 'Wolfgang Amadeus Mozart' as effectively as it would match 'Leopold Mozart'.

The five '+ or -' fields are filled in with asterisks: if an asterisk is present, it means the field it's next to is 'negated' in meaning. If an asterisk is not present, the field it's next to has a normal, positive meaning. For example, if 'Composer Name' is filled in with 'Benjamin Britten' and an asterisk is placed next to it, the selection filter means 'play me music by a composer who is not Benjamin Britten'. If the composer name is 'Mozart' and no asterisk is present, the meaning is then 'play me something by a composer called Mozart'.

You move between fields by pressing the up and down-arrow keys. You skip to the OK and Cancel buttons by pressing the TAB key (and a second press of that key gets you back into the 'field editing' part of the form).

Most of the filter fields take free-form text entry and the precise nature of the entries you make will depend on your understanding of and knowledge as to how you went about tagging your music collection in the first place. Thus, where my genre filter might say 'symphonic' when I want to listen to symphonies, yours might instead say 'symphony', if that's the preferred tag you've used when cataloguing your music.

The four filter fields at the bottom of the form take specific types of entry, however: minutes for the duration fields, and y or n entries for the two 'unplayed' filters. If you type in the 'wrong' sort of entry (say you type in 'A' for the minimum duration field), it's ignored completely. Note, too, that these four filters replace the equivalent parameters stored in the persistent configuration file. For example, you may have MINDURATION-20 and MAXDURATION=120 set in the persistent configuration file: that means randomly-selected music (chosen using Play menu Option 1) will only be of pieces that last between 20 and 120 minutes. But those parameters have zero effect on what can be selected using this Play menu Option 2: if you choose to leave to Minimum Duration and Maximum Duration filters empty on this form, then no duration criteria are applied at all to your music selection. The equivalent parameters in the configuration file are completely ignored when processing this form, in other words. The same is true of this form's 'Unplayed Composer' and 'Unplayed Works' filters: if present, they over-ride the UNPLAYEDCOMPOSER and UNPLAYEDWORKS persistent configuration file parameters. If not present, then no filtering on these attributes is applied at all, regardless of the fact that equivalents are set in the persistent configuration file.

It is possible to combine filters on this form in very imaginitive -and restrictive!- ways. Here, for example, I am asking Giocoso to randomly select anything composed by someone whose name starts with the letters 'bri', that's orchestral in form, that was performed by an orchestra from London, so long as it lasts less than 2 hours:

When I press [OK] on that, provided that more than a single recording meets the selection criteria, I'm asked if I'd like to save the search results as a playlist:

You don't have to say yes to doing this, but a playlist is a 'stored search': keeping it allows you to re-play the results at any future time (using Play Menu Option 5) without having to fill in all the filter fields again. If you say 'yes' at this point, you are asked to supply a name for the playlist, which can be anything you want that's memorable to you:

If you include spaces in the proposed name, as I've done here, Giocoso will automatically replace them with underscores and then store the results in the $HOME/.local/share/giocoso3/play folder, as a plain text file, listing one recording that matches your selection criteria, per line:

The order of the lines within the file is random, but will be the order in which Giocoso then plays the results of your search. You can, of course, edit the play list using a text editor of your choice and cut/paste/move lines around within it to fine-tune the content and order in which pieces will be played, should you come back to do an Option 5 play from a stored playlist.

If you choose not to create a playlist to store the results of the search, the same recordings that would have been listed in a playlist are immediately played, in whatever random order Giocoso comes up with.

Note that the element of randomisation that takes place when performing a filter search for music to play means that performing the exact same search multiple times will result in the same pieces being played in a different order every time.

When completing the search filter form, be aware that it's possible to make things logically impossible! That is, suppose you say 'Mozart' in the composer field and 'Peter Grimes' in the composition name filter: well, since Mozart wrote no work called 'Peter Grimes', your search is obviously going to result in zero matches. You'll be informed of this:

Pressing [OK] at this point will then simply return you to Giocoso's main menu. Logical impossibilities from multiple selection criteria cannot result in the play of anything meaningful, and Giocoso won't attempt to make sense of the contradictions for you!

Finally, you need to know your tagging strategy and how it relates to the filter form fields. For example, suppose you want to search for 'Britten' and 'Idomeneo': Britten never wrote an opera called Idomeneo, which of course was composed by Mozart... but he conducted it. So, how do you tell the filter form that when you say 'Britten' you mean 'Britten the conductor, not Britten the composer'? Well, you have to understand where you place tags to that effect when cataloguing your music in the first place. Specifically, if you follow this site's tagging advice, you'd know from Axiom 3 that details of performers on a recording are stored in the COMMENT tag, distinct from the ARTIST one. Thus, on the filter form, you'd say this:

The name 'Britten' goes into the performer filter, not the composer name one, in other words.

Similarly, if you wanted to listen to Callas' recording of La Taviata rather than Sutherland's, you'd know to (perhaps) filter on 'Distinguishing Artist=Callas', and so on. If you know your tagging model, the filter form lets you interact with it -but type the same data in the wrong field and a completely different meaning may arise!

 

3. Play Specified Folder

You may have just ripped a freshly-purchased CD and not yet got around to tagging it properly and formally admitting it to your collection -but nevertheless are impatient to hear it! In that case, getting Giocoso to find things in its database to play is of no use to you: the CD contents aren't in the database yet!

This is why the Play Menu Option 3 exists: so long as the digital files exist on your hard disk somewhere, you can point Giocoso at the relevant folder and have it play the contents of that folder directly. For example:

Here I have a bunch of FLACs purchased online representing some Holst choral music CD. There is some rudimentary tagging provided (all of it is probably rubbish and needs to be corrected), but I've downloaded the purchase and am keen to listen to it. When you take Giocoso Play Menu Option 3, you'll see this:

The folder selection dialog you see here always starts in your $HOME folder. Folders and sub-folders are listed in the main pane of the display: you arrow up and down to choose one and press the Space Bar to select one. When you are 'in' the folder you want to play, you can press Enter to submit the selection back to Giocoso. If you want to go 'back up' a folder, you can select the '..' double dots displayed towards the top of the main pane. It may take some practice (and several mistakes!) to navigate confidently through your file system, but persistence will pay off!

If you prefer, you can simply TAB into the horizontal panel beneath the main one and simply type the full path to the folder you're interested in, followed by a press of the Space Bar. You can switch back and forth between the two modes of navigation at will, too.

Either way, you end up 'inside' the folder you're interested in, with the full path being displayed in the horizontal panel and nothing at all being displayed in the main one:

When you get to this state of affairs, you can press Enter (or tab around until the OK button is highlighted and then press Enter) to submit your selection:

Here, Giocoso has begun to play the contents of the selected folder. Since I haven't yet tagged my music, there's no information to display in the left-hand panel of the Giocoso main display. There's also no album art to display -but Giocoso nevertheless presents a picture of 'generic' album art, so the screen isn't completely devoid of interest!

As per its usual practice, Giocoso will play the entire contents of the selected folder in one sitting (in this case, as the data in the top right-corner of the main display tells you, that means playing 1 hour and 11 minutes of music). You can press Ctrl+C to stop playback at any time, of course.

Music played via this option will generally not be recorded in Giocoso's play history, as direct play of a folder is by definition intended to bypass the Giocoso database. The mention of 'generally' there, however, is deliberate.

  • If you are using an unconverted Giocoso Version 2 database, then the folder play will be recorded, even though most of the tag information required to store a meaningful history of the play will probably be missing
  • If you are using a converted Giocoso Version 2 database, the folder play may be recorded, provided that at least both a composer and a composition tag (i.e., ARTIST and ALBUM) can be read. If those two bits of information are empty or unreadable, however, then no record of the play will take place
  • If you are using a brand new Giocoso Version 3 database, the folder play won't be recorded unless, again, at least both a composer and composition tag are present.

For the technically minded, the difference in behaviour between Version 2 and Version 3 on this point is that in Version 2's database, there were no NOT NULL constraints on COMPOSER and COMPOSITION fields, so completely blank 'play' records could be created. The Version 3 database (and the converted Version 2 database) does have such constraints, so a 'play' of music lacking composer and composition tags cannot be entered into the play history table. The installation script for Version 3 will automatically convert Version 2 databases to the Version 3 format, but it's always possible to revert the upgrade and run the Version 3 program whilst using a Version 2 database, in which case the lack of not null constraints permits blank play records once more.

 

4. Play Music by Advanced SQL Selection

Fundamentally, Giocoso works by querying a database which lists what recordings have been detected as files on a hard disk. The language used to query databases of all kinds is called 'Structured (or 'Standard') Query Language', or SQL for short. The fourth menu option on Giocoso's Play Music menu allows users to write their own SQL queries, thereby allowing for the selection of combinations of records which the selection form available under Option 2 cannot allow for.

As an example: suppose you want to play a mix of Britten and Holst choral works one afternoon. On Option 2's form, you can type in a composer's name: but only the one. If you try to type something like 'Britten or Holst', you'll be instructing Giocoso to find music composed by someone called 'Britten Or Holst', and as no such composer ever lived, the search will turn up zero results. Similarly, Option 2 lets you specify a genre, but if you wanted 'Ballet or Opera', you'd be out of luck.

If you know how to write a SQL query, however, then this sort of 'either/or' search becomes quite easy -though, of course, knowing how to write valid SQL in the first place is not easy (and this manual is not the place to teach it to you). Specifically, Giocoso's Play menu, Option 4 lets you write the WHERE clause in a SQL select query. What you write has to be grammatically and syntactically correct, otherwise the entire select query will fail. You don't need (and in fact must not try) to write the select bit of the query: that's hard-coded. You don't even type in the word 'WHERE': all you type is the actual selection criteria you want to apply.

Going back to my earlier examples, for example:

  • A combination of pieces by both Britten and Holst would be fetched by writing: composer like '%britten%' or composer like '%holst%'
  • A selection of either ballets or operas would be fetched by writing: genre like '%ballet%' or genre like '%opera%'

In each case, I've used the 'like' comparative operator, because I'm wanting to allow the database engine to match things as wild cards. The 'like '%holst%' test, for example, would match both Gustav and Imogen Holst. If I wanted to be stricter about it, I'd use the 'equals' operator: composer='Gustav Holst', for example -but then, there's no wild-carding and therefore the name being searched for has to be spelled out, exactly and completely.

Incidentally, the database is case-insensitive, so 'Gustav Holst' matches the exact same number of records as 'gustav holst' or 'GuStAv HoLsT' would do!

As ever in SQL, subtler queries get syntactically complex and may require the use of brackets to force meaning to be deduced in the correct way. For example, I originally wanted just choral pieces by either Britten or Holst, so the 'in principle' SQL for that might be thought to be:

composer like '%britten%' or composer like '%holst%' and genre like '%choral%'

...but what you'd find is that this is interpreted to mean 'select anything by Britten, but only select choral works by Holst', which is subtly different from 'select choral works by either Britten or Holst'. It's the logical problem that, in maths, means that 6+6/2 might have an answer of 6 or 9, depending on whether you interpret it as (6+6)/2 or 6+(6/2)! In SQL, the correct form of the actually-desired query would be:

(composer like '%britten%' or composer like '%holst%') and genre like '%choral%'

The use of brackets compels the evaluation of the two composer's name first, and only then a filtering by genre.

I won't go on any further about how to write complex WHERE clauses in SQL: either you know how to do it, or you'll need to learn -or you can stick with using the filter form available from taking Play menu Option 2.

If you do manage to write a correct SQL WHERE clause, however, that matches more than one recording, then Giocoso will ask you if you wish to save the results of your query as a playlist: you can agree to do so (and then giving it a name), or decline to do so, as you like. If you accept the offer to create a playlist, your music selection will begin to play as soon as the playlist has been saved. If you choose not to create a playlist, music playback will begin immediately. Playlist created in this way, like any playlist, are simply text files stored in $HOME/.local/share/giocoso3/play, and can be edited in any text editor of your choosing. Each line in the file lists one full path to a recording. Lines can be deleted or moved around as you please.

As ever, Giocoso randomises the results of its selecting from the database -so, the exact same WHERE clause typed twice will result in the same number of recordings being selected from playback, but the order in which they will be played back will vary each time.

5. Play Music from a Playlist

Playlists are simply text files, but with a .play extension, stored in $HOME/.local/share/giocoso3/play. They can be created for you, as ways of storing your selections, when you take Play menu Options 2 or 4. They can also be manually constructed by taking Play menu Option 6 -or you can just create them by opening a text editor of your choice and starting to type.

However they are created, each line in a playlist lists one full path to a folder that contains FLAC files to play. For example:

There are no practical limits to how many lines a playlist can contain. The order in which lines appear is the order in which recordings will be played back: to change the play order, you'll need to re-organise the lines within the text file, using the text editor of your choice.

Once a playlist exists, taking Play menu Option 5 lets you point to it and start music playback using its contents, by listing the contents of the $HOME/.local/share/giocoso3/play folder which have .play extensions:

An item can be selected from the displayed list by pressing the Space Bar. Press Enter to submit the selection: playback will begin immediately, provided that the contents of the playlist do actually exist and can be found in your file system.

From the above screenshot, you'll notice one salient detail: there are no spaces in the playlist names. Where spaces are sort-of 'intended', underscores are present (as in 'Britten_&_Holst_Choral.play', for example). This happens automatically when Giocoso asks you if you'd like to save a selection as a playlist and you agree to do so. If you are manually creating your own playlists (by typing into a text file), it's up to you to remember to do this. If you don't, you'll break the playlist selection form: trying to take Option 5 at all will simply make the main menu flash a bit and nothing else will then happen. So, the golden rule to remember is: no spaces in playlist file names, please!

 

6. Create or Edit a Playlist

The contents of a playlist are playable by taking Play menu Option 5. How you create a playlist in the first place, however, is dealt with in various places and by various means.

First and foremost, a playlist is simply a text file (albeit one with a .play) extension, that lives in $HOME/.local/share/giocoso3/play. As text files, they can be created by simply firing up the text editor of your choice, and starting to type, one full path to a folder containing FLACs per line. Provided you save them in the ../play folder, with a .play extension, and don't include spaces in their filenames, they'll be perfectly valid and usable.

Play menu Option 6 makes the task a little bit easier only in the sense of it opening a text editor (the one that the EDITOR environment variable is set to for your operating system, which these days tends to be nano by default), and saving it with a name that it will automatically convert to not having spaces, and saving it in the correct location with the correct file extension.

When you first take Option 6, you'll swiftly meet this dialog:

You type in a suitable name (presumably, a name that will remind you of what the eventual contents of the playlist will represent). You just type the name: there's no need to type the ".play" extension, since Giocoso will add that for you automatically. If the name you type does not match that of an already-existing playlist, Giocoso will interpret that to mean that you're wanting to create a new one. If it does match the name of an existing playlist, Giocoso will interpret that as an instruction to open that pre-existing playlist for editing.

In either case, Giocoso will open a new text editor session: the specific text editor used depends on the value of your EDITOR environment variable, which is usually nano in most distros -but as environment variable, you can set it (in .bashrc or something similar) to make it open whatever editor you prefer.

If you're editing an existing playlist, its contents will be revealed in the new editor window; if you're creating a new one, the editor window will initially be completely empty:

You can see from the top line of this screen that the ".play" extension has been added to whatever playlist name I originally supplied.

Your job at this point is simply to type (or copy/paste) the name of folders which contain FLACs. Note that you don't supply the path and filename to FLAC files. Just the folder they're contained in. This is correct:

The colours that sometimes appear at points within the name are irrelevant, so don't pay any attention to them. This example, however, would be incorrect:

Specifying a particular FLAC won't work. Giocoso won't throw a fit if you do it, but any subsequent attempt to play such a playlist will fail.

The order in which folders are listed within the playlist will be the order in which recordings are subsequently played (via Play menu Option 5). It's this fact which makes playlists sometimes very useful in a classical music context. How else do you ensure the four parts are of Wagner's Ring Cycle are played in the correct order:

Alphabetical ordering by opera name won't cut it, but listing things in a particular, user-selected order within a playlist ensures the ring gets stolen before Brünnhilde immolates herself!

 

7. Delete Old Playlists

You may end up creating a lot of playlists, some of which no longer have particular usefulness to you and which you therefore wish to delete. Since a playlist is just a text file, you can of course simply visit $HOME/.local/share/giocoso3/play in the file manager of your choice and delete the appropriate files.

Play menu Option 7 gives you an in-Giocoso ability to achieve the same thing by pointing-and-clicking the files you want to delete:

As you can see, each playlist file is listed in a dialog box that you can scroll up and down within (using the up- and down-arrow cursor keys). By pressing the Space Bar when any file is highlighted, you cause an asterisk to appear next to that file: that's an indicator the file should be deleted. Press the Space Bar a second time to remove an asterisk if you placed it there by accident. Multiple files can be selected for deletion in one go, as the above screenshot shows. When all appropriate files have been marked for deletion, press Enter (or TAB round to the OK button and then press Enter). All marked files will, at that point, be deleted without further warning and without any possibility of recovering the files.