Table of Contents ================= 1. Introduction 2. Dependencies 3. Building 4. Bugs 5. Translations 6. Covers 7. CUE Files 8. Streams 9. MultiMedia Keys 10. DBUS Actions 11. Dynamic Helper Script - Local Mode 12. Dynamic Helper Script - Server Mode 13. Source Code 14. Debug Logging 15. Credits 16. Windows 17. macOS 1. Introduction =============== Cantata is a graphical client for MPD. It contains the following features: 1. Support for Linux, macOS, and Windows. 2. Multiple MPD collections. 3. Highly customisable layout. 4. Songs grouped by album in play queue. 5. Context view to show artist, album, and song information of current track. 6. Simple tag editor. 7. File organizer - use tags to organize files and folders. 8. Ability to calculate ReplyGain tags. (if enabled at build-time) 9. Dynamic playlists. 10. Online services; Jamendo, Magnatune, and Podcasts. 11. Radio stream support - with the ability to search for streams via TuneIn, ShoutCast, or IceCast. 12. USB-Mass-Storage and MTP device support. (if enabled at build-time) 13. Audio CD ripping and playback. (if enabled at build-time) 14. Playback of non-MPD songs - via simple in-built HTTP server if connected to MPD via a standard socket, otherwise filepath is sent to MPD. 15. MPRISv2 DBUS interface. 16. Basic support for touch-style interface (views are made 'flickable') 17. Scrobbling. 18. Ratings support. This version of Cantata continues on CDrummond's work, which was originally a fork of QtMPC. The code (and user interface) is now *very* different to that of QtMPC. Unlike most other MPD clients, Cantata caches a copy of the MPD music library. This is so that it can create a proper hierarchy of artists and albums (where Cantata will use the AlbumArtist tag if found, otherwise it will fallback to the Artist tag), to provide album counts, tracks counts, etc in the browser views and tooltips, and also to help with copying songs to/from devices. This cache is updated only when MPD indicates that its version of the collection is different to Cantata's. 2. Dependencies =============== Cantata requires the following Qt libraries: 1. QtCore 2. QtGui 3. QtNetwork 4. QtXml 5. QtSql 6. QtDBus (Only for Linux builds) 7. QtWidgets 8. QtMultimedia / libVLC - depends on ENABLE_HTTP_STREAM_PLAYBACK and ENABLE_LIBVLC 9. QtSvg Cantata may also use the following optional libraries: 1. TagLib - Tag edit dialog, replaygain, track organizer, and UMS device support. 2. LibMTP - MTP devices. 3. FFMPEG (libavcodec) - ReplayGain detection code. 4. MPG123 - ReplayGain detection code. 5. CDParanoia - Read/rip Audio CDs. 6. CDDB - either this or MusicBrainz5 required for Audio CDs 7. MusicBrainz5 - either this or CDDB required for Audio CDs 8. LibEbur128 - ReplayGain detection code. If this is not found on the system then Cantata will use its own bundled copy. 9. libavahi-common / libavahi-client - Avahi support (automatic mpd discovery) 3. Building =========== Please refer to the INSTALL file for general build instructions. Details on how Cantata is build for Windows can be found in section 16, and macOS in section 17. 4. Bugs ======= Before reporting bugs, please check that this is not an MPD related issue with your system - e.g. please try recreating the issue with another MPD client, such as MPDroid, GMPC, etc. To report bugs please visit https://github.com/nullobsi/cantata When reporting a bug, please mention the Cantata version number, the Cantata build type (Linux, Windows, Mac), any cmake options you specified (other than the defaults listed at the top of the INSTALL file), and the version of MPD you are using. 5. Translations =============== As of version 2.1.0, Cantata uses Qt's translation framework. To generate a new translation for Cantata: 1. Copy translations/blank.ts to cantata_LANG_CODE.ts (Replace LANG_CODE with the language code for the desired language, e.g. 'fr' for French - so this would be cantata_fr.ts) 2. Open your new ts file with Qt Linguist. 3. In Qt Linguist set the target language and country. 4. Update the translations. 5. Either email me the new translation (address is in the AUTHORS file), or create a pull request on github. 6. Covers ========= When displaying covers, Cantata will load album covers in the following order: ${configuredName} is either: a. cover - if not configured in Cantata's config dialog b. Setting from cantata with the following replacements: %albumartist% => Album Artist %artist% => Track Artist %album% => Album Name Any other % removed ...if configured to 'Cache scaled covers', Cantata will check its scaled-covers cache folder (~/.cache/cantata/covers-scaled/SIZE) for: 1. ${albumArtist}/${album}.png ...if MPD folder exists, is not specified as a http URL, and is readable, then cantata will look for the following within the folder containing the song: 2. ${configuredName}.jpg - if set 3. ${configuredName}.png - if set 4. cover.jpg 5. cover.png 6. AlbumArt.jpg 7. AlbumArt.png 8. folder.jpg 9. folder.png 10. ${albumArtist} - ${album}.jpg 11. ${albumArtist} - ${album}.png 12. ${album}.jpg 13. ${album}.png 14. Image embedded within current song's tags. 15. ANY other jpg, or png ...then Cantata will check its cache folder (~/.cache/cantata/covers), for : 16. ${albumArtist}/${album}.jpg 17. ${albumArtist}/${album}.png ...if the MPD folder was specified as a http URL 18. ${url}/${dirFromFile}/cover.jpg - or ${url}/${dirFromFile}/${configuredName}.jpg (if set) 19. ${url}/${dirFromFile}/cover.png - or ${url}/${dirFromFile}/${configuredName}.png (if set) ...lastly, if user has enabled downloading via last.fm 20. Query last.fm using ${albumArtist} and ${album}. Cantata will attempt to download the image specified with the "extralarge" size. Downloaded images will be saved as ${configuredName}.jpg/png (if set), or cover.jpg/png, within the song folder if possible. If not, then they will be saved in Cantata's cache folder. If configured to 'Cache scaled covers', then the resized cover (as displayed) will be saved as a PNG within covers-scaled. For artist images: ${configuredName} is either: a. artist - if configured Album cover ${configuredName} is empty, or does not contain % b. ${albumArtist} - if configured Album cover ${configuredName} contains % and ${albumArtist} is not 'Various Artists' c. ${basicArtist} if configured Album cover ${configuredName} contains % and ${albumArtist} is 'Various Artists' ...if configured to 'Cache scaled covers', Cantata will check its scaled-covers cache folder (~/.cache/cantata/covers-scaled/SIZE) for: 1. ${albumArtist}.png ...if MPD folder exists, is not specified as a http URL, and is readable, then cantata will look for the following within the folder containing the song: 2. ${basicArtist}.jpg 3. ${basicArtist}.png 4. ${configuredName}.jpg 5. ${configuredName}.png ...the above will be repeated for the parent folder ...if song is from a Various Artists album, or file is a non-MPD file, then cantata will look for the following within the MPD root folder: 6. ${basicArtist}/${basicArtist}.jpg 7. ${basicArtist}/${basicArtist}.png 8. ${basicArtist}/${configuredName}.jpg 9. ${basicArtist}/${configuredName}.png ...then Cantata will check its cache folder (~/.cache/cantata/covers), for : 10. ${albumArtist}.jpg 11. ${albumArtist}.png ...if the MPD folder was specified as a http URL 12. ${url}/${dirFromFile}/${configuredName}.jpg 13. ${url}/${dirFromFile}/${configuredName}.png ...the above will be repeated for the parent folder ...lastly, if user has enabled downloading via last.fm 14. Query last.fm using ${albumArtist}. Cantata will attempt to download the image specified with the "extralarge" size. Downloaded images will be saved as artist.jpg/png, within the artist folder if the folder hierarchy is 2 levels (artist/album/) and the user has write permissions. If not, then they will be saved in Cantata's cache folder. If configured to 'Cache scaled covers', then the resized cover (as displayed) will be saved as a PNG within covers-scaled. For composer images: ...if configured to 'Cache scaled covers', Cantata will check its scaled-covers cache folder (~/.cache/cantata/covers-scaled/SIZE) for: 1. ${composer}.png ...if MPD folder exists, is not specified as a http URL, and is readable, then cantata will look for the following within the folder containing the song: 2. composer.jpg 3. composer.png ...the above will be repeated for the parent folder ...then Cantata will check its cache folder (~/.cache/cantata/covers), for : 4. ${composer}.jpg 5. ${composer}.png ...if the MPD folder was specified as a http URL 6. ${url}/${dirFromFile}/composer.jpg 7. ${url}/${dirFromFile}/composer.png ...the above will be repeated for the parent folder Downloaded images will be saved as composer.jpg/png, within the artist folder if the folder hierarchy is 2 levels (artist/album/) and the user has write permissions. If not, then they will be saved in Cantata's cache folder. If configured to 'Cache scaled covers', then the resized cover (as displayed) will be saved as a PNG within covers-scaled. For context view backdrops: ...if MPD folder exists, is not specified as a http URL, and is readable, OR the song's filename starts with '/', then cantata will look for the following within the folder containing the song: 1. ${currentArtist}-backdrop.jpg 2. ${currentArtist}-backdrop.png 3. backdrop.jpg 4. backdrop.png ...the above will be repeated for the parent folder ...if song is from a Various Artists album, or file is a non-MPD file, then cantata will look for the following within the MPD root folder: 5. ${currentArtist}/${currentArtist}-backdrop.jpg 6. ${currentArtist}/${currentArtist}-backdrop.png 7. ${currentArtist}/backdrop.jpg 8. ${currentArtist}/backdrop.png ...then Cantata will check its cache folder (~/.cache/cantata/backdrops), for : 9. ${currentArtist}.jpg ...internet services: 10. MusizBrainz is queried for an artist ID. If returned, this artist ID is used to locate a cover from fanart.tv 11. Download image from discogs ...lastly: 12. If all the above fails, a backdrop is created from all the album covers featuring the artist. Downloaded images will be saved as backdrop.jpg, within the artist folder if the current song is not from a Various Artists album, the file is from MPD, the folder hierarchy is 2 levels (artist/album/), and the user has write permissions. If not, then they will be saved in Cantata's cache folder. 7. CUE Files ============ If Cantata is running with MPD>=0.17, then it will attempt to parse the contents of CUE files. The CUE file will be parsed to ascertain the album and track details. The track durations for all bar the last should be accurate, and Cantata will attempt to determine the duration of the last track - but this might not be 100% accurate. If the CUE file references an audio file that does not exist in the MPD music folder, then the CUE file contents will NOT be used. There is no reliable way for Cantata to ascertain the text encoding that a CUE file uses - so, for portability, it would be best if your CUE files used UTF-8 encoding. When loading a CUE file, Cantata will attempt to load the file as if it was UTF-8 encoded, if this fails it will try with the "System" codec. You may add to this list of encodings to try by using the 'cueFileCodecs' config item (as detailed in section 7 above). If Cantata fails with all configured encodings, then it will 'peek' at the 1st 1k bytes, and ask Qt to see if it can determine the encoding - and fallback to UTF-8 otherwise. (This peeking and fallback was how Cantata behaved in pre 1.2 versions - and is how Clementine behaves (where Cantata's CUE file support originates from.)) NOTE: If Cantata cannot access the CUE file (as MPD is running on a remote host, or you have not configured the music folder correctly, etc.) then Cantata will add the CUE File to the album's track listing. 8. Streams ========== As of 1.4.0, Cantata only comes with TuneIn, ShoutCast, and IceCast stream providers. To install new providers, you can either use Cantata's download dialog (to install for Cantata's extras github repo), or install from file. To import new stream categories into Cantata, these files need to be GZip compressed tarballs of the following format. Filename: CATEGORY_NAME.streams (e.g. German Radio.streams) Contents: Either streams.xml, streams.xml.gz, OR settings.json, AND Either icon.png OR icon.svg streams.xml.gz should be GZip compressed. icon.svg should be a non-compressed SVG file. Icons for sub-categories (first level only) - these should be named the same as the category (with / replaced by _) - e.g. 'Hard_Soft Rock.svg' for 'Hard/Soft Rock') settings.json is really only intended to be used by Cantata for providers stored in its extras github repo. This JSON file has the following syntax: { "type": "streamType", "url": "Stream listing URL" } "streamType" can be either di, soma, or listenlive. Cantata contains code to download from "Stream listing URL" and parse the response based upon "streamType" In general, for externally provided stream lists, it is more convenient to just list all a providers streams within stream.xml.gz. This has the following format: <?xml version="1.0" encoding="UTF-8"?> <streams version="1.0" addCategoryName="true"> <stream name="Station Name" url="http://station.stream.url"/> </streams> if "addCategoryName" is set to true, then when Cantata adds a station from this category to either favourites or the playqueue, it will prepend the Category name to the station name. e.g. To create a stream category named "Wicked Radio" that has 2 sub-categeries, and 3 stream URLs you would need: streams.xml.gz with: <?xml version="1.0" encoding="UTF-8"?> <streams version="1.0" addCategoryName="true"> <category name="Rock"> <stream name="Hard Rock" url="http://127.0.0.1/hard.ogg"/> <stream name="Soft Rock" url="http://127.0.0.1/soft.ogg"/> </category> <stream name="Blues" url="http://127.0.0.1/blues.ogg"/> </streams> streams.xml.gz & icon.svg need to be placed into a GZip compressed tarball named "Wicked Radio.streams" With the above example, Cantata would list the following in the streams view: > Wicked Radio > Rock Hard Rock Soft Rock Blues When "Hard Rock" is added to the playqueue, it will be listed as "Wicked Radio - Hard Rock" If Rock.png (or Rock.svg) and/or Blues.png (or Blues.svg) also exist in the tarball, then they will be copied to the install location and used as icons for the respective category. To create .streams file: 1. Place all files in a temp folder 2. cd into temp folder 3. tar cfz NAME.tar.gz * 4. mv NAME.tar.gz NAME.streams cantata-extra on github ----------------------- **CDrummond no longer maintains Cantata.** In the future, these links will be updated. Please do not contact CDrummond for assitance, instead open a GitHub issue on the new repository. The streams page on Cantata's settings dialog, will allow you to install new providers from Cantata's extras github repo. To do this, the dialog first downloads the list of providers, this is obtained from the following URL: https://raw.githubusercontent.com/CDrummond/cantata-extra/master/streams/2.1/list.xml The contents of this file will be something like: <providers> <category type="0"> <provider name="1.fm" md5="cbd6ad834d4493662952a653cea5c779"/> ... If you want to manually download a provider, use the listed URL to download the .streams file. e.g. for the above: wget https://raw.githubusercontent.com/CDrummond/cantata-extra/master/streams/2.1/1.fm.streams.gz Extract the contents with: tar zxvf 1.fm.streams.gz If you wish to distribute a new stream provider via Cantata's extras github repo, please send me an email with the .streams.gz file. My address is in the AUTHORS file. 9. MultiMedia Keys ================== Linux and Windows builds, as of 1.2, now also support basic media-keys shortcuts. Linux use the GNOME settings daemon's MediaKeys interface. This interface is normally started automatically under GNOME/Unity. 10. DBUS Actions ================ All of Cantata's internal actions are accessible via DBUS. The cantata-remote helper script may be used to invoke these, e.g. to toggle playback: cantata-remote cantata playpausetrack The list of action names maybe obtained by calling the listActions DBUS method, e.g.: qdbus dog.unix.cantata.Cantata /cantata listActions 11. Dynamic Helper Script - Local Mode ====================================== When a dynamic playlist is loaded in Cantata, the cantata-dynamic helper script is executed in the background to do the actual song selection. In this way the dynamic playlist can still function even when cantata is terminated. It is possible for this script to be controlled on the command line (although it was never written with this in mind). The list of dynamic playlists may be obtained by looking in ~/.local/share/cantata/dynamic To 'load' a dynamic playlist, all you need to do is symlink the desired one in ~/.local/share/cantata/dynamic to ~/.cache/cantata/dynamic/rules. Then you can start the helper by calling '/usr/share/cantata/scripts/cantata-dynamic start' (or first call '/usr/share/cantata/scripts/cantata-dynamic stop' to stop any current playlist). To pass connection details, cantata-dynamic reads the same environment variables as mpc - namely MPD_HOST and MPD_PORT e.g. the following bash script (not tested!) will stop any current dynamic playlist, load the 'MyPlaylist' playlist, and start this on the mpd at 'hostname:1234' with password 'pass' # Stop current dynamic playlist /usr/share/cantata/scripts/cantata-dynamic stop # Clear the playqueue (this requires mpc) MPD_HOST=pass@hostname MPD_PORT=1234 mpc clear # 'Load' new playlist if [ -f "$HOME/.cache/cantata/dynamic/rules" ] ; then rm "$HOME/.cache/cantata/dynamic/rules" fi ln -s "$HOME/.local/share/cantata/dynamic/MyPlaylist.rules" "$HOME/.cache/cantata/dynamic/rules" # Restart dynamic script MPD_HOST=pass@hostname MPD_PORT=1234 /usr/share/cantata/scripts/cantata-dynamic start 12. Dynamic Helper Script - Server Mode ======================================= In addition to the above, the helper script may be installed on the system containing MPD, and run in 'server' mode. This requires MPD>=0.17, as communications are via MPD's client-to-client messages. When run in this mode, it is intended that the script be run system-wide and started when the system (or MPD) is started. e.g. The script should be started as: <prefix>/share/cantata/scripts/cantata-dynamic server <location of config file> e.g.: /usr/share/cantata/scripts/cantata-dynamic server /etc/cantata-dynamic.conf When run as described above, the script will automatically daemonize itself. To stop the dynamizer: <prefix>/share/cantata/scripts/cantata-dynamic stopserver e.g.: /usr/share/cantata/scripts/cantata-dynamic stopserver When MPD informs Cantata that the 'cantata-dynamic-in' channel has been created, Cantata will automatically switch itself to server mode. The list of rules is then loaded from the server, and Cantata will change the backdrop of the dynamic page to indicate that the rules are comming from the server. Server mode is currently the only way for dynamic playlists to be used under Windows. Configuration ------------- The server mode has a simple ini-style configuration file, that has the following parameters (shown here with the default values): pidFile=/var/run/cantata-dynamic/pid filesDir=/var/lib/mpd/dynamic activeFile=/var/run/cantata-dynamic/rules mpdHost=localhost mpdPort=6600 mpdPassword= httpPort=0 'pidFile' When started, the script will store its PID within the file configured here. This is then used to detect if the script is running, etc. 'filesDir' This controls where the dynamic rules are stored. The user the script is run as should have read/write permissions to this folder. 'activeFile' When a set of rules is made 'active', all cantata does is create a symbolic link from the rules file to the file specified in 'activeFile'. Again, the user the script is run as should have read/write permissions to this file. 'mpdHost', 'mpdPort', and 'mpdPassword' are the connection details of the MPD server. 'httpPort' if this is set to non-zero, then the script will serve up a *very* simple HTTP control page - allowing playlists to be started and stopped. Installation ------------- Within the playlists folder is a systemd service file. NOTE: This service file assumes cantata has been installed to /usr, and that cantata-dynamic is in /usr/share/cantata/scripts. If this is not the case, then this will need to be edited. Copy playlists/cantata-dynamic.conf to /etc, and edit as appropriate. 13. Source Code =============== The Cantata source folder contains the following structure: 3rdparty - Third party libraries cmake - CMake scripts context - Context view classes dbus - DBUS related classes and XML files devices - Device related classes playlists - Playlists gui - General GUI classes, e.g. MainWindow, LibraryPage, etc. http - HTTP server icons - Icons models - Most models, apart from dynamic playlist and shortcut models mpd - MPD related classes; connection, status, song, etc. network - Generic Network classes (and proxy support for Qt builds) online - Jamendo, Magantune, SoundCloud, and Podcasts po - Translations replaygain - ReplayGain calculation streams - Internet radio streams support - Generic classes that /may/ be useful to other projects. Mainly used for Qt and Gtk support. tags - Tag reading, editing, etc. widgets - Widgets that are probably Cantata specific. windows - Files specfic to Windows builds.. mac - Files specfic to MacOSX builds. Cantata's SVG icons have been 'cleaned' using: scour --strip-xml-prolog --indent=none -i in.svg -o out.svg Symbolc media icons are taken from gnome icon theme, but have been scaled with rsvg-convert -a -w 128 -f svg in.svg -o out.svg 14. Debug Logging ================= Cantata contains some debug logging that might help to diagnose certain issues. To enable this, you need to use the --debug commandline option. This option takes a comma-separated list of debug areas. Therefore, its probably better to start Cantata from the commandline. The following debug areas may be used: MPD communications mpd MPD Parsing mpdparse Covers covers (or covers-verbose) Wikipedia context info context-wikipedia Last.fm context info context-lastfm Combined context info context-info Context widget context-widget Context lyrics context-lyrics Dynamic dynamic Stream fetching stream-fetcher Http server http-server Song dialog file checks song-dialog Network access network-access Threads threads External tags tags Scrobbling scrobbler Devices devices SQL sql MPD HTTP stream playback http-stream MPD auto discover avahi Media keys media-keys Cusrtom actions custom-actions To log debug to a file use --debug-to-file. e.g. To log MPD communications and cover access to a file, start cantata as follows: cantata --debug=mpd,covers --debug-to-file The loccation of the debug file will vary dependant upon OS. On Linux systems this will be ~/.cache/cantata/cantata.log For Windows this will be C:\Users\USERNAME\AppData\Local\mpd\cantata\cache\cantata.log And for OSX it will be /Users/$USER/Library/Caches/cantata/cantata/cantata.log NOTE: Debug logging will function regardless of whether you have created a Debug or Release build. 15. Credits =========== Cantata contains code/icons from: Amarok - amarok.kde.org (Transcoding, Cover fetching code in cover dialog) Clementine - www.clementine-player.org (Lyrics searches, CUE file parsing, digitally imported support, and stretched header view) Be::MPC - Wikipedia parsing code Quassel - quassel-irc.org (Qt-only keyboard short-cut config support) Solid - solid.kde.org (Device detection for Qt-only builds) Asunder - CDDB code libkcddb - MusicBrainz code libebur128 - https://github.com/jiixyj/libebur128 (Replay gain calculation) IcoMoon - http://icomoon.io/#icons (Monochrome sidebar icons) Qxt - Multi-media key support QtSolutions - QtIOCompressor, and QtSingleApplication QMPDClient - Last.fm scrobbling 16. Windows =========== The easiest way to develop Cantata for Windows is to use the MSYS2 environment. MSYS2 provides a ready-made development environment with all of the libraries that Cantata needs as packages which can be installed. Consult the GitHub actions configuration for more information; the MSYS2 packages required are taglib, cmake, ninja, and the Qt libraries. Then, Cantata can be compiled like any other CMake project: cmake -Bbuild -G Ninja -DCMAKE_BUILD_TYPE=Release cmake --build build -j 4 ... The Cantata installer is made with WiXv3 and CPack. Install and add WiX to your PATH, then you can simply run `cpack` in the build directory to create a standalone .MSI installer for Cantata. 17. macOS ========= Cantata builds on macOS using either Homebrew or the official Qt packages. When building a Universal binary for ARM64 and x86_64, it's reccomended to use the Qt distribution because their binaries come with both architectures. Unfortunately, the TagLib currently in the Homebrew repositories is an older version. Installing a newer version of TagLib from source is reccomended, as Cantata now required TagLib version 2. Once the Qt libraries are installed, ensure you also have CMake and Ninja installed. Then, you can build Cantata using CMake: cmake -Bbuild -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$HOME/Qt (if using Qt distribution) cmake --build build -j4 To create a DMG file for distribution, simply run `cpack` in the build directory. The Qt libraries will be copied to make a standalone executable.