Code Monkey home page Code Monkey logo

ashuffle's Introduction

ashuffle

Test GitHub

Table of Contents:

features

ashuffle is an application for automatically shuffling your MPD library in a similar way to a more standard music player's "shuffle library" feature. ashuffle works like any other MPD client, and can be used alongside your other MPD frontends.

usage

In ashuffle's primary mode is to create a 'stream of music'. To do this run:

$ ashuffle

ashuffle will wait until the last song in the queue has finished playing, then randomly choose another song from your MPD library, add it to the queue and continue playing. Songs will be continuously played, at random, to infinity. Since ashuffle adds only one song at a time, after the last song in the playlist has finished playing, you still retain control over your queue. When using ashuffle, more songs can be added to the queue, and once those songs finish, the random music will resume.

ashuffle uses MPD's "idle" command to listen for MPD events so it won't drain cpu polling to check if the current song has advanced.

If you only want to enqueue a set number of songs, use the --only flag like this:

$ ashuffle --only 10   # ashuffle --only <number of songs to add>

This particular command adds 10 random songs to the queue.

In addition to these two basic modes, ashuffle supports many other features like:

  • Custom shuffle filter rules, using --exclude.
  • Shuffling based on a list of MPD URIs, like would be output from mpc search using the --file option.
  • MPD authentication.
  • Crossfade support using --queue-buffer.
  • Shuffling by album or other groupings of songs using the --by-album or --group-by option.

If any of these sound interesting, read on!

running in a non-standard configuration

When running MPD on a non-standard port or on a remote machine, ashuffle will respect the standard MPD_HOST and MPD_PORT environment variables, used to specify the host and port respectively of the MPD server.

Also following standard MPD tools, a password can be supplied in the MPD_HOST environment variable by putting an @ between the password and the host name.

For example, one can run ashuffle as follows:

$ env MPD_HOST="<password>@<hostname>" MPD_PORT="<port>" ashuffle ...

Or without the password by just omitting the <password> and @ from the MPD_HOST variable.

ashuffle also supports providing a host or port via the command line with the --host and --port options. --host, and --port, will override MPD_HOST or MPD_PORT if provided.

For example:

$ ashuffle --host <password>@<hostname> --port <port>

Once again, the password can be omitted.

shuffling from files and --no-check

By supplying the -f option and a file containing a list of song URIs to shuffle, you can make ashuffle use an arbitrary list of songs. For example, by passing -f - to ashuffle, you can have it shuffle over songs passed to it via standard in:

$ mpc search artist "Girl Talk" | ashuffle -f -

As explained in more detail below, if song URIs are passed to ashuffle using this mechanism, ashuffle will still try to apply exclusion rules to these songs. If the song URIs you want ashuffle to shuffle over do not exist in your MPD library (for example if you are trying to shuffle URIs with the file:// schema), ashuffle will exclude them by default. If you pass the --no=check option to ashuffle, it will not apply the filtering rules, allowing you to shuffle over songs that are not in your library.

crossfade support and the --queue-buffer

By default, ashuffle will only enqueue another song once the current queue has ended. This gives the user a lot of control over what will be playing next. One unfortunate side-effect of this is that it breaks MPD's built-in crossfade support. If the next song is only added once the previous song has finished playing, MPD doesn't know how to crossfade between the two songs. As a tradeoff between queue control and cross-fade support, you can supply the --queue-buffer n flag. This flag will have ashuffle ensure that there are always n songs in the queue after the currently playing song. This way you still retain some queue control, while making sure that MPD can crossfade effectively. Most crossfade users will probably want to use this flag like so:

$ ashuffle --queue-buffer 1

shuffling by album, or other groups, with --group-by

If you'd rather shuffle songs in groups, instead of individually, ashuffle can group songs by any combination of tag values using the -g/--group-by option. For example, you could run:

$ ashuffle --group-by album

In this mode, when loading songs from MPD or a file, ashuffle will first group the songs by the given tag. Album in this case. Then, when a song needs to be added to the queue, ashuffle will pick a random group (e.g., album) and enqueue all songs from that group. Once the end of the queue is reached, a new group is picked and the process is repeated.

Multiple tags can be provided to --group-by, and songs will be grouped together as long as all the given tags match. A --by-album option is provided for convenience that is probably what you want to use when shuffling by album. It's equivalent to --group-by album date.

Note that -g/--group-by/--by-album can only be provided once.

advanced options for specialized preferences, with --tweak

Tweaks are infrequently used, specialized, or complicated options that most users probably don't want to use. These options are all set via a single --tweak/-t flag to avoid cluttering help pages. All tweaks have the form <key>=<value>. For example: --tweak window-size=7. Here is a table of tweaks, and their meanings:

Name Values Default Description
exit-on-db-update Boolean no If set to a true value, then ashuffle will exit when the MPD database is updated. This can be useful when used in conjunction with the -f - option, as it allows you to re-start ashuffle with a new music list.
play-on-startup Boolean yes If set to a true value, ashuffle starts playing music if MPD is paused, stopped, or the queue is empty on startup. If set to false, then ashuffle will not enqueue any music until a song is enqueued for the first time.
reconnect-timeout Duration > 0 10s Configures the amount of time ashuffle will spend attempting to reconnect to MPD after a temporary disconnection. After this amount of time, ashuffle will give up attempting to reconnect and quit.
suspend-timeout Duration > 0 0ms Enables "suspend" mode, which may be useful to users that use ashuffe in a workflow where they clear their queue. In this mode, if the queue is cleared while ashuffle is running, ashuffle will wait for suspend-timeout. If songs were added to the queue during that period of time (i.e., the queue is no longer empty), then ashuffle suspends itself, and will not add any songs to the queue (even if the queue runs out) until the queue is cleared again, at which point normal operations resume. This was add to support use-cases like the one given in issue #13, where a music player had a "play album" mode that would clear the queue, and then play an album. See below for the duration format.
window-size Integer >=1 7 Sets the size of the "window" used for the shuffle algorithm. See the section on the shuffle algorithm for more details. In-short: Lower numbers mean more frequent repeats, and higher numbers mean less frequent repeats.

Value types:

Name Representation
Integer An integral number, like -1, 0, or 15.
Boolean The strings on, true, yes or 1 mean "true" or "enable", and the strings off, false, no, or 0 mean "false" or "disable".
Duration A duration of time that can be parsed by Abseil's ParseDuration. The general format is <number><unit>. <number> can be floating point, and negative. <unit> is whatever time units Abseil supports, but the expected ones like ms, s, and m should work. Example: 250ms would represent 250 milliseconds.

help text

usage: ashuffle [-h] [-n] [-v] [[-e PATTERN ...] ...] [-o NUMBER]
    [-f FILENAME] [-q NUMBER] [-g TAG ...] [[-t TWEAK] ...]

Optional Arguments:
   -h,-?,--help      Display this help message.
   --by-album        Same as '--group-by album date'.
   -e,--exclude      Specify things to remove from shuffle (think
                     blacklist). A PATTERN should follow the exclude
                     flag.
   --exclude-from    Read exclude rules from the given file. Rules
                     should be given in the YAML format described in
                     the included readme.md
   -f,--file         Use MPD URI's found in 'file' instead of using the
                     entire MPD library. You can supply `-` instead of a
                     filename to retrive URI's from standard in. This
                     can be used to pipe song URI's from another program
                     into ashuffle.
   -g,--group-by     Shuffle songs grouped by the given tags. For
                     example 'album' could be used as the tag, and an
                     entire album's worth of songs would be queued
                     instead of one song at a time.
   --host            Specify a hostname or IP address to connect to.
                     Defaults to `localhost`.
   --log-file        Path to write log output to. Defaults to stderr.
   -n,--no-check     When reading URIs from a file, don't check to
                     ensure that the URIs match the given exclude rules.
                     This option is most helpful when shuffling songs
                     with -f, that aren't in the MPD library.
   -o,--only         Instead of continuously adding songs, just add
                     'NUMBER' songs and then exit.
   -p,--port         Specify a port number to connect to. Defaults to
                     `6600`.
   -q,--queue-buffer Specify to keep a buffer of `n` songs queued after
                     the currently playing song. This is to support MPD
                     features like crossfade that don't work if there
                     are no more songs in the queue.
   -t,--tweak        Tweak an infrequently used ashuffle option. See
                     `readme.md` for a list of available options.
   -v,--version      Print the version of ashuffle, and then exit.
See included `readme.md` file for PATTERN syntax.

patterns

Patterns are a list of key-value pairs given to the --exclude flag. A pair is composed of a 'field' and a 'value'. A 'field' is the name of an MPD tag (e.g. artist, title, album) to match on (case insensitive) and 'value' is a string to match against that field. So, if I wanted to exclude MGMT's album 'Congratulations' in ashuffle I could supply a command line like the following:

$ ashuffle --exclude artist MGMT album "Congratulations"

Since typing in an exact match for all songs could become quite cumbersome, the 'value' field will match on substrings. You only have to specify part of the search string. For example, if I wanted to match Arctic Monkeys album 'Whatever People Say I Am, That's What I'm Not' I could shorten that to just:

$ ashuffle --exclude artist arctic album whatever

Multiple --exclude flags can be given. If a song matches any exclude pattern, it will be excluded. For example, if I wanted to exclude songs by MGMT and songs by the Arctic Monkeys, I could write:

$ ashuffle --exclude artist MGMT --exclude artist arctic

MPC and the -f flag can be used with --exclude to shuffle over more complex matches. For example, if we wanted to listen to only songs by Girl Talk except the Secret Diary album, we could use mpc to generate a list of Girl Talk songs and then use an --exclude statement to filter out the Secret Diary album:

$ mpc search artist "Girl Talk" | ashuffle --exclude album "Secret Diary" --file -

exclude patterns from a file

ashuffle allows exclude patterns to be passed via a YAML formatted file with the following structure:

rules:
- <tag1>: <value1>
  <tag...>: <value...>
  <tagN>: <valueN>
- ...

Where <tag> is replaced with the tag to match on (e.g. artist) and <value> is replaced with the value to match (e.g. arctic). Tags are matched to values based on the rules described in the patterns section above: a case-insensitive substring match. All tag values must match their values for a given rule (one item of the rules list) to match and exclude a track. Rules are not updated when the underlying rule file changes. ashuffle must be re-started for changes to take effect.

For example, if there was an exclusion rules file excludes.yaml, with the contents:

rules:
- artist: arctic
  album: whatever
- artist: MGMT
  album: Congratulations

And ashuffle was invoked like:

$ ashuffle --exclude-from excludes.yaml

Then ashuffle would not include tracks from the album 'Whatever People Say I Am, That's What I'm Not' by the 'Arctic Monkeys', or the album 'Congratulations' by the artist 'MGMT' in the pool of songs to shuffle.

shuffle algorithm

ashuffle uses a fairly unique algorithm for shuffling songs. Most applications fall into one of two camps:

  • true random shuffle: With true random shuffle, no restrictions are placed on what songs can be selected for play. It's possible that a single song could be played two or even three times in a row because songs are just drawn out of a hat.
  • random list shuffle: With 'random list' shuffle, songs to be shuffled are organized into a list of songs behind the scenes. This list is then scrambled (imagine a deck of cards), and then the scrambled playlist is played like normal. Using this method songs won't be played twice in a row, but the once the playlist has been played it will either loop (playing the same random set again), or be re-scrambled and played again, so it can still get repetitive. Also, since there's no chance that a song can be played again, it won't feel very random, especially when listening for a long time. Every song has to be played once before any song can be repeated. I often start noticing song order once the random-list wraps around.

ashuffle's approach is an attempt at a happy medium between these two styles. It keeps two lists of songs: a 'pool' of the songs it's shuffling, and a 'window' which is a short, ordered, playlist of songs. When the program starts, ashuffle builds the window by randomly taking songs out of the pool, and adding them to the window. When a new random song needs to be added to the MPD queue, the 'top' song of the window is removed, added to the queue, and then put back into the pool. Then, another song is taken from the pool and added to the window so that the next request can be fulfilled. This ensures that no songs are repeated (every song in the window is unique), but you also don't have to listen to every song in your library before a song comes up again. I like this style a lot better, because I can "skip" between songs I want to listen to.

MPD version support

ashuffle aims to be compatible with several versions of MPD, and libmpdclient, so users don't have to bend-over-backwards to get ashuffle to work. Specifically, ashuffle aims to be compatible with the latest MPD/libmpdclient release, as well as all MPD/libmpdclient versions used in active Ubuntu releases. If you have an issue using ashuffle with any of these versions, please open an issue.

getting ashuffle

ashuffle is officially distributed via pre-compiled binaries, and via its source. Linux-compatible binaries are currently available for x86_64, and several ARM flavors that should support most ARM users, including Raspberry Pi.

pre-built binaries

First, install 'libmpdclient', the library ashuffle uses to interact with MPD. It can be obtained from most package managers. E.g. via sudo apt install libmpdclient2, or brew install libmpdclient. Once libmpdclient is installed you can download the latest binary release for your platform on the releases page. Binaries are currently available for the following platforms:

Binary Architecture Minimum CPU Popular Devices
ashuffle.x86_64-linux-gnu x86_64 Most Desktops, Laptops, and Servers
ashuffle.aarch64-linux-gnu aarch64 cortex-a53 Raspberry Pi 3B+ running 64-bit OS (not RPi OS)
ashuffle.armv7h-linux-gnueabihf armv7hl cortex-a7 Raspberry Pi 2B+ Running RPi OS (f.k.a. Raspbian)
ashuffle.armv6h-linux-gnueabihf armv6hl arm1176jzf-s Raspberry Pi 0/1+ Running RPi OS (f.k.a. Raspbian)

Once you've downloaded the binary, it should "just work" when run (e.g. $ ./ashuffle.x86_64-linux-gnu). If they do not, please file an issue or send an email to the ashuffle users list at [email protected].

If you'd like to add binary support to another platform, pull requests are welcome.

installing from source

For platforms without a binary release, you'll have to build from source. ashuffle is designed to have a small number of dependencies, and we try to keep the build relatively straightforward. That said, you will need a relatively recent C++ compiler. Clang 7+, or GCC 8+ should work.

If you have any trouble building ashuffle, please file an issue on Github, or email the ashuffle users group. Make sure to your compiler version, meson version, the commands you tried to execute, and any errors that were produced.

dependencies

The only dependency is 'libmpdclient' which, you can probably install via your package manager. For example on debian based distributions (like ubunutu) use:

sudo apt-get install libmpdclient-dev

or on OS X using brew:

brew install libmpdclient

ashuffle is built using ninja, and the meson build system, you can obtain meson by following the instruction's on meson's site. Meson version >=0.54.0 is required. Ninja is available on most distributions. On debian-based distributions (including ubuntu) it can be installed like so:

sudo apt-get install ninja-build

building

ashuffle relies on git submodules to track libraries it depends on. These libraries are not distributed in the source tarballs provided by Github, so you need to use git to get ashuffle when building from source.

Start by cloning ashuffle:

git clone https://github.com/joshkunz/ashuffle.git
cd ashuffle

The check what the latest release is on the releases page, and checkout the corresponding git tag. For example, If the latest release was v1.22.3 you would run:

git checkout v1.22.3

Then init and update the submodules:

git submodule update --init --recursive

Now you have the source needed to build ashuffle. Next, you need to configure the build, using meson. Luckily this is easy:

meson -Dbuildtype=release build

Then run

ninja -C build install

to build and install the binary. If you want to use a prefix other than /usr/local you can supply an alternate by running meson like so:

meson build -Dbuildtype=release --prefix <prefix>

You can uninstall the program later by running

sudo ninja -C build uninstall

Note: See meson's documentation for more information on configuration.

Oh, and in case you're wondering why it's called 'ashuffle' it's because it implements 'automatic shuffle' mode for mpd.

third party repositories

These repositores are not maintained by ashuffle. I cannot vouch for any of them, your mileage may vary.

contact

If you find bugs in ashuffle, or have a feature suggestion, please file a Github issue. ashuffle also has two mailing lists you can subscribe to for discussion and announcements:

  • [email protected]: For (very) infrequent announcements of major ashuffle releases. Posts only allowed by the project maintiner.
  • [email protected]: For general ashuffle questions, or discussion of ashuffle features. Allows posts from all users.

users

Below are some projects that use ashuffle. If your are using ashuffle as part of another project, feel free to open a pull request to include it in this list.

related projects

These projects do not use ashuffle directly, but are related to ashuffle in some way.

ashuffle's People

Contributors

brainpower avatar fwsmit avatar hamuko avatar joshkunz avatar l2dy avatar martinetd avatar renovate-bot avatar renovate[bot] avatar zyzzyxdonta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ashuffle's Issues

Password not working

Hi great application for MPD works great except I have one issue.

ashuffle tells me it cant play the track after adding a new song. Seems to be related to the password.

I use ashuffle with the command: env MPD_HOST="[email protected]" MPD_PORT="6600" ./ashuffle

When the playing track finishes then it adds a new track then wont play it.
I get the error: MPD error: you don't have permission for "play"

The password I am using is correct and works on all my mpdclients.

I am using the newest MPD build 0.21.3

getline issue

Hello!

The problem is that getline() is a standard library function. (defined in stdio.h) Your function has the same name and is thus clashing with it.

The solution is to simply change the name.

Thanks!

Building on FreeBSD 11.2: An experience

I was having some trouble building ashuffle on FreeBSD 11.2. I confirmed that I have libmpdclient installed and its .h files are available on the system. For some reason, though, I think that maybe they're not getting passed to CC?

[freebsd@icecast-source ~/ashuffle]$ make
 CC ashuffle
ashuffle.c:2:10: fatal error: 'mpd/client.h' file not found
#include <mpd/client.h>
         ^~~~~~~~~~~~~~
1 error generated.
*** Error code 1

Stop.
make[1]: stopped in /usr/home/freebsd/ashuffle/src
*** Error code 1

Stop.
make: stopped in /usr/home/freebsd/ashuffle

Running make -d A reveals that the actual command being run is cc '-std=c99' -Wall -Wextra -pedantic ashuffle.c -o ashuffle, which doesn't look like it's being passed any of the libraries.

Then I tried running gmake instead, which worked:

[freebsd@icecast-source ~/ashuffle]$ gmake
gmake[1]: Entering directory '/usr/home/freebsd/ashuffle/src'
 CC ashuffle.o
 CC args.o
 CC rule.o
 CC shuffle.o
 CC list.o
 CC getpass.o
 CC ashuffle
gmake[1]: Leaving directory '/usr/home/freebsd/ashuffle/src'
 COPY ./src/ashuffle .
[freebsd@icecast-source ~/ashuffle]$

But when I went to make install, I ran into another issue:

[freebsd@icecast-source ~/ashuffle]$ sudo gmake install
gmake[1]: Entering directory '/usr/home/freebsd/ashuffle/src'
gmake[1]: 'ashuffle' is up to date.
gmake[1]: Leaving directory '/usr/home/freebsd/ashuffle/src'
 COPY ./src/ashuffle .
install -t /usr/local/bin ashuffle
install: illegal option -- t
usage: install [-bCcpSsUv] [-f flags] [-g group] [-m mode] [-o owner]
               [-M log] [-D dest] [-h hash] [-T tags]
               [-B suffix] [-l linkflags] [-N dbdir]
               file1 file2
       install [-bCcpSsUv] [-f flags] [-g group] [-m mode] [-o owner]
               [-M log] [-D dest] [-h hash] [-T tags]
               [-B suffix] [-l linkflags] [-N dbdir]
               file1 ... fileN directory
       install -dU [-vU] [-g group] [-m mode] [-N dbdir] [-o owner]
               [-M log] [-D dest] [-h hash] [-T tags]
               directory ...
gmake: *** [Makefile:18: install] Error 64

I had to modify this part of the main Makefile to adjust to how install seems to work on FreeBSD:

install: $(BIN)
        install $(BIN) $(prefix)/bin/$(BIN)

This got it to work:

[freebsd@icecast-source ~/ashuffle]$ sudo gmake install
gmake[1]: Entering directory '/usr/home/freebsd/ashuffle/src'
gmake[1]: 'ashuffle' is up to date.
gmake[1]: Leaving directory '/usr/home/freebsd/ashuffle/src'
 COPY ./src/ashuffle .
install ashuffle /usr/local/bin/ashuffle
[freebsd@icecast-source ~/ashuffle]$

It would be nice if future revisions of ashuffle were ready for FreeBSD out of the box. Thanks again for all your hard work on this piece of software!!!

High CPU usage on startup when using --file option

Hi,

I'm using a file with songs, that ashuffle should use (generated with mpc). The file has ~17.000 songs. I'm starting ashuffle like this: ashuffle --queue_buffer 2 --file /tmp/ashuffle-songlist.txt
After ashuffle has started the CPU usage of mpd goes up to 100 % (one core fully loaded) for several minutes (measured 8 minutes on last try). Time increases with longer song lists.
CPU is a i5-4570 @ 3.20GHz.

During this time no songs are added to the queue.

There probably is some communication between ashuffle and mpd about the song list. Why and can it be deactivated?

3.10.0 binaries

Hi,

For ARM platforms are three separate binaries required or is there an easy way to compile the sources into a single binary that runs on arm6, 7, and 64?

-Tim

feature: "shuffle albums instead of songs" mode

Hi there! Seeing that you've been doing all this work on a music-shuffling program, would it be relatively easy to add a mode that, rather than playing songs picked at random, randomly picks an album from the library, plays the album straight through, and then moves on to another randomly selected album?

Personally I find that full shuffle is often too jarring, and I like listening to albums all the way through, but it would be really nice if I could get a program to just keep that stream of albums playing without me having to think about what to put on! In case this does happen to interest you, I should point out that for usability, the full-album shuffle mode really needs to have simple ways both to skip the current song and to jump to another album immediately. (Sometimes you're just not in the mood for what the RNG picked.)

This is a feature I would have expected to be common in mainstream music players, but that hasn't been my experience.

Maybe add an EditorConfig file

In regards to formatting/style like it's specified in PR #62:

An .editorconfig file could define some of the style in a machine readable format,
so editors or IDEs with support for this (most have plugins) can load their settings from there
and developers won't have to change settings by hand.

These definitions include tabs vs. spaces, how many spaces for indents and more,
See: https://editorconfig.org/

Connection closed by the server

Hi, I get the following error;
Picking random songs out of a pool of 8954
MPD error: Connection closed by the server

Standard mpd install on jessie 8

Thanks

Autoshuffle vs. Crossfade

Hi,

I really like auto-shuffle with my mo0de audioplayer (raspi 3 + allo boss).
But it seems that the mpd crossfade feature dosn't collaborate well with ashuffle.

Is there an easy way to tell ashuffle to add a new song to the playlist, as soon as the second to last song has already finished (and not the last one)? Than there would constantly be one file left as a "buffer" in the playlist and in this case I think that the crossfade would work fine.

That would be a killer feature for those like me who like three things:

  • shuffle playback
  • crossfade
  • really big playlists

Thank you very much.

No song gets queued when mpd is in consume mode

Likely has to do with how we calculate when a song is done playing.

Steps to reproduce:

  1. run mpc consume on
  2. run ashuffle
  3. wait till the first song is done playing. At this point ashuffle should queue and begin playing another song, but instead play stops.

Release Tarball fails to configure

The meson.build file with default options includes the t/meson.build which searches for libtap/tap.c .
The latter is not included in githubs release tarball, thus ashuffle fails to "configure" with the following error:

t/meson.build:2:0: ERROR: File libtap/tap.c does not exist.

Steps to reproduce:

  1. Go to github releases
  2. Download "Source code (tar.gz)" from assets
  3. Unpack, cd into it
  4. run meson build
  5. Observe above error

Workaround: Replace Step 4 with: meson build -Dtidy_mode=true , but this disables tests...

Does not build on Alpine Linux (musl C lib)

Hi,
I've tried to build ashuffle on Alpine Linux with musl C library. Following error comes up:

make[1]: Entering directory '/root/ashuffle-1.0.1/src'
 CC getpass.o
getpass.c:23:13: error: conflicting types for 'getline'
 static void getline(char ** lineptr, size_t *n, FILE *stream) {
             ^~~~~~~
In file included from getpass.c:5:
/usr/include/stdio.h:153:9: note: previous declaration of 'getline' was here
 ssize_t getline(char **__restrict, size_t *__restrict, FILE *__restrict);
         ^~~~~~~
make[1]: *** [<builtin>: getpass.o] Error 1
make[1]: Leaving directory '/root/ashuffle-1.0.1/src'
make: *** [Makefile:8: ashuffle] Error 2

I've fixed it by replacing getline with mygetline in getpass.c

Add 32 bit ARM release

Raspberry Pi OS (formerly Raspbian) is only built in a 32-bit variant, even though the more recent raspberry pis are running 64-bit compatible chips. This means that our aarch64 release is likely not useful to a majority of Raspberry Pi users. We should release a 32-bit ARM version as well.

Trying to play a file with an empty queue doesn't work

Likely caused by a race with the player.

Steps to reproduce:

  1. Start ashuffle
  2. run mpc clear. At this point the music stops. (should ashuffle add another song here?)
  3. run mpc add <song-file>. At this point, ashuffle will queue another song and begin playing it instead of the song we just added.

Can't build on Raspberry Pi 3

I get meson error while trying to build ashuffle 3.5.0 on RPI3 following step-by-step instructions.

Here is the meson log:

`Build started at 2020-06-08T18:40:01.583197
Main binary: /usr/bin/python3
Python system: Linux
The Meson build system
Version: 0.49.2
Source dir: /home/pi/ashuffle
Build dir: /home/pi/ashuffle/build
Build type: native build
Project name: ashuffle
Project version: undefined
Sanity testing C compiler: cc
Is cross compiler: False.
Sanity check compiler command line: cc /home/pi/ashuffle/build/meson-private/sanitycheckc.c -o /home/pi/ashuffle/build/meson-private/sanitycheckc.exe
Sanity check compile stdout:


Sanity check compile stderr:


Running test binary command: /home/pi/ashuffle/build/meson-private/sanitycheckc.exe
Native C compiler: cc (gcc 8.3.0 "cc (Raspbian 8.3.0-6+rpi1) 8.3.0")
Sanity testing C++ compiler: c++
Is cross compiler: False.
Sanity check compiler command line: c++ /home/pi/ashuffle/build/meson-private/sanitycheckcpp.cc -o /home/pi/ashuffle/build/meson-private/sanitycheckcpp.exe
Sanity check compile stdout:


Sanity check compile stderr:


Running test binary command: /home/pi/ashuffle/build/meson-private/sanitycheckcpp.exe
Native C++ compiler: c++ (gcc 8.3.0 "c++ (Raspbian 8.3.0-6+rpi1) 8.3.0")
Build machine cpu family: arm
Build machine cpu: armv7l

meson.build:25:2: ERROR: Module "cmake" does not exist`

GROUP BY-like functionality

It would be nice if you could pass a flag to ashuffle like --group album and it would do something like shuffle the albums instead of the songs individually. I don't really know what the best way to expose this would be.

Questions:

  • What kind of groups would you want to express? Albums? Artists? Maybe combinations like Artist + Year?
  • What does it mean to "shuffle a group". Do we play all the songs in that group? In what order?

Would appreciate help packaging for Void Linux.

Hi. Love this software. I use it everyday.

I am trying to package it for the Void Repos. I had to add abseil-cpp to the repos and update gtest. These two build fine but ashuffle runs into issues. This is the output: http://dpaste.com/1YCK6XW

If you'd like to, you can look at the tentative templates for ashuffle and abseil-cpp.

I don't know what this means so any input would be appreciated. Thank you.


Edit

The previous problem seemed to be related to packaging abseil-cpp which I have managed to fix. But I get this error now: http://dpaste.com/02XRTS0

Looking at the source, looks like the function ends without returning but you assert that that situation would be unreachable.

Any advice on dealing with this would be appreciated. The links to the templates above have been updated. Thanks.


Edit 2

For now I have worked around that problem by adding [a patch[(https://github.com/kartikynwa/void-packages/blob/ashuffle/srcpkgs/ashuffle/patches/fix-werror.patch) that replaces the assert statement with a "return invalid argument" statement. If you can think of more elegant solutions feel free to let me know.

Absl subproject dos not respect libdir

meson arguments:

meson --prefix=/usr --bindir=/usr/x86_64-pc-linux-musl/bin --sbindir=/usr/x86_64-pc-linux-musl/bin --libdir=/usr/x86_64-pc-linux-musl/lib --libexecdir=/usr/x86_64-pc-linux-musl/libexec --includedir=/usr/x86_64-pc-linux-musl/include --sysconfdir=/etc --datadir=/usr/share --mandir=/usr/share/man --default-library=shared --native-file meson-native.txt --wrap-mode=nodownload /tmp/paludis/build/media-sound-ashuffle-3.3.0/work/ashuffle-3.3.0

From meson logs:

Installing subprojects/absl/librandom_internal_distribution_test_util.a to /tmp/paludis/build/media-sound-ashuffle-3.3.0/image//usr/lib64

Speed up time-to-first-enqueue

Right now, we performance test ashuffle startup (time to first enqueue) at <750ms for a 20k track library. This is still surprisingly slow. We should try and improve this.

I think a reasonable target would be <200ms startup with a 100k track library. That should be fast enough that the user never notices ashuffle startup.

Output buffer is full

When using ashuffle on a collection of about 80,000 songs on a Raspi with 512 MB RAM, I got the following error in mpd.log:

May 27 17:29 : buffered_socket: error on client 2: Output buffer is full

And ashuffle says:

MPD error: Connection closed by the server

Is the collection too big? The Raspi's memory too small? Both? :)

FR: Add option to automatically curtail MPD playlist to a certain maximum length

Hi there,

I use ashuffle in an automated, unsupervised environment. What typically happens is that I will forget about it for several months, and MPD will eventually crash when its playlist grows large enough, leading the automation to stop working and require MPD and ashuffle to be manually restarted. I cannot seem to find any information on the internet about a built-in configuration option for MPD that would allow it to remove old tracks from the playlist automatically. It would be great if ashuffle could contain this functionality, though I understand if it might be a bit too niche for what you're doing. Either way, thank you so much for all your hard work! It's been completely indispensable to me.

Wait a moment before adding a new song

I am using the Android client M.A.L.P. which has the option of replacing the current playlist with an album. I assume that it uses something like mpc clear; mpc add ALBUM (which is how I do it in scripts as well) and I can't think of a better way to do this. In conjunction with ashuffle however this results in a random song being added inbetween because for a short moment the playlist is empty and thus ashuffle adds a new random song followed by MALP adding its album.

I'd like to propose that when ashuffle detects an empty playlist to have it wait a few milliseconds and check if the playlist still is empty and only then add a new random song.

libmpdclient errors with MPD response lines longer than 4KiB

ashuffle reports connecting to MPD version 0.22.0

Does ashuffle have a version number? Can't report that.

Raspberry Pi 2B with MPD library on NAS via SMB and accessing through wifi.

Start ashuffle on the commandline:

ian@boombox:~ $ ashuffle
MPD error: Response line too large

The resulting MPD log at verbose level:

Feb 09 16:33 : client: [11] opened from 127.0.0.1:44122
Feb 09 16:33 : client: [11] process command "notcommands"
Feb 09 16:33 : client: [11] command returned 0
Feb 09 16:33 : client: [11] process command "listallinfo"
Feb 09 16:33 : client: [11] command returned 0
Feb 09 16:33 : client: [11] closed

This is supposed to be running with moode audio version 7.0.1.

This bug looks to be the same issue as

Add systemd service

In order to have ashuffle ran at boot, I've configured following systemd service in /etc/xdg/systemd/user/ashuffle.service on my PC:

[Unit]
Description=Shuffle service for mpd
Requires=mpd.service
After=mpd.service

[Service]
ExecStart=/usr/bin/ashuffle

[Install]
WantedBy=default.target

Once #72 is resolved it may make sense to distribute such unit file together with ashuffle.

Let users tweak the window size

The "window" is the playlist of songs that are guaranteed to not repeat. This prevents instant-repeats, but allows repeats over a longer time horizon. It's currently hard-coded to 7 this generally works fine, but I think some users would like to tweak this, to allow more repeats, or make repeats even less likely. There's not technical reason we can't make this a flag, so we should probably expose it.

My one reservation about this... Most users probably don't care about this flag. This flag should be easy to ignore for most users. Maybe instead of a top-level flag, we can add some "tweaks" mechanism. By default these won't show up in --help, but if a user cares, they can look them up and mess with them. Something like --tweak window-size=100 perhaps...

Support RPi-Zero (armv6h)

Hi. I am trying to install ashuffle on a Raspberry pi zero. I already had libmpdclient2 installed (version 2.16-1). When I run ./ashuffle.armv6h-linux-gnueabihf I receive an error message "Segmentation fault". I also get this if I run as root. I'm sure that I am doing something wring, but I can't work out what.

Any ideas?

Thanks.

Duncan

Ashuffle stops when a file is not found

I am experimenting with a web radio so I have a continuous broadcast of a large library playing at random with ashuffle.

Sometimes a file is not found (did not find the reason yet, maybe just need an mpc update to run).

In such cases, the playlist is started over and replayed. If I delete the unfound file and play the last track on the playlist, then ashuffle takes over again.

I would expect/like ashuffle to skip through the unfound file and pick another one instead, and in any case to keep on going.

I use ashuffle with a queue buffer of 1.

mpd_run_status failing in try_first() function called during shuffle_idle()

Issue Description
The following code fragment in ashuffle.c is failing for me (the fprintf on stderr have been obviously added by me for debug reason)

int try_first(struct mpd_connection * mpd, struct shuffle_chain * songs) {
    struct mpd_status * status;
fprintf(stderr, "before mpd run status 1...\n");
    status = mpd_run_status(mpd);
fprintf(stderr, "after mpd run status 2...\n");
    if (status == NULL) {
        fprintf(stderr, "STATUS IS NULL!!!...\n");
        puts(mpd_connection_get_error_message(mpd));
        return -1;
    }

Example error returned:

before mpd run status 1...
after mpd run status 2...
STATUS IS NULL!!!...
Connection closed by the server

Other info

pi@moode4b4:~ $ mpc version
mpd version: 0.20.0

Number of tracks in MPD library: 43291

Playlist is restarted when a file is not found

I am experimenting with a web radio so I have a continuous broadcast of a large library playing at random with ashuffle.

Sometimes a file is not found (did not find the reason yet, maybe just need an mpc update to run).

In such cases, the playlist is started over and replayed. If I delete the unfound file and play the last track on the playlist, then ashuffle takes over again.

I would expect/like ashuffle to skip through the unfound file and pick another one instead, and in any case to keep on going.

I use ashuffle with a queue buffer of 1 to allow mpd crossfade.

Limitations on ashuffle

Hi, I'm using the wonderful moOde to stream music from my NAS using a RPi3 and RPi3B+.
My collection of albums exceeds the number of 4200 with over 74000 songs.
When I now want to "ashuffle" through this complete library, ashuffle won't work anymore. This already happens when I have more than 42000 songs in my library. As soon as I start the random selection icon, I can see in SSH that ashuffle uses up to 99.9% of the CPU but after a minute the process ashuffle disappears from the list (Did it stop? Did it crash? I don't know).
So now I'm wondering: is there a limitation on the number of songs (42000 in my case, someone said 33000 on a PiZero) or is there a time limit, meaning if the system still hasn't selected a song after one minute, then the whole process stops.
Thx in advance for your fast response.

Johan

Add an option to disable automatic play

When starting ashuffle, it adds a random song to the playlist and immediately starts to play it. This makes my PC automatically start playing at each boot, since I have it configured to start mpd and ashuffle at boot as shuffling through library is how I usually use mpd.

It would be really great to be able to disable automatic playback at ashuffle's launch.

Lazily evaluate filter rules on ashuffle startup

ashuffle attempts to apply filter rules to the user's MPD library right at startup. This usually involves a round-trip to MPD per-song, which can have a substantial impact on startup time for users with moderately large libraries, as shown in issue #31.

This issue tracks the implementation of lazy filter rules for ashuffle, to ensure that ashuffle can quickly start queueing music, regardless of the size of the user's library.

off-the-cuff ideas for how this could be achieved:

  • Use threads to evaluate songs/song-uris against the filter rules.
  • Only attempt to evaluate filter rules at queue time (i.e. right before playing, or maybe right before they are added to the window). This way we can avoid a dependency on threads, but we only need to check a couple songs.

Response line too large

Hi,
I am using moOde/MPD 0.21.16 together with ashuffle.
If the NAS (NFS) is mounted to the library, ashuffle stops running, giving the error message:
"Response line too large".
Any suggestions to solve this problem?
Thanks,
Regards, Herman
Klembord02

Release binary version of ashuffle on OSX

Right now, the only way for most users to get ashuffle is by compiling the software from source. We should make this easier by also releasing binary distributions. Though, likely only targeting a subset of platforms.

Add option to store song list on disk

In order to pick a random song out of the MPD library, ashuffle stores a list of all of the user’s songs in-memory. In memory-constrained environments, users with large libraries can experience OOMs or other crashes.

I think the most straightforward implementation would just be using temporary files and something like cdb. The source is public domain, and should be easy to embed in ashuffle.

queue_buffer: does not work in background

Hi,
for some reason the queue_buffer argument does not work, when I launch ashuffle in background:
ashuffle --queue_buffer 2 &

Same problem when I pipe output to /dev/null:
ashuffle --queue_buffer 2 > /dev/null

In both cases songs are added to the queue, but only one song when the queue finishes. If I just start ashuffle --queue_buffer 2 in foreground there are always 2 songs at the end of the queue as expected.

Connect with password?

As far as I can tell this project doesn't offer any way to connect to a MPD instance that is password-protected. Is there any possibility that this can be implemented? I would love to use this software for a project I'm working on.

Thanks very much!

Pattern request

Hi,

I was looking through some of the user requests from the moOde community about Auto Shuffle and a a fairly common one is to have the ability to only include certain genres for example only Genre = Classical.

Currently the only way to achieve this that I'm aware of is by using --exclude to exclude all but the desired genre.

If there were a --include option it would make this very easy.

-Tim

Arguments parsing using strtoul incorrectly giving errors

I'm not sure if this is arch/build/environment dependent but I can sometimes get shuffle --queue_buffer 1 to complain it could not convert queue_buffer's argument (it happened for me when building with meson -Db_sanitize=address on arm7l linux gnu)

The reason for this is that strotul does not reset errno to 0 if there is no error, so the current way of checking errno only works if it wasn't EINVAL or ERANGE before.
There are multiple ways of solving this, for example reseting errno before calling strtoul should work in principle, but that won't complain if the user passes something that starts with digits e.g. --queue_buffer 42waswrong will not error.
The "correct" way of checking for strtoul success is to pass a endptr argument and check that it points to a nul byte; anything else and the string was not fully parsed.

(While looking at this, I also noticed we're not checking that there are enough arguments, e.g. ashuffle --queue_buffer does not error out either; it probably should)

Likewise, happy to submit a PR, but it's likely just as fast to fix directly - your call. Sorry for the "spam" :)

Fully remove Makefile

Now that ashuffle supports building through meson. We should remove the old makefile. This will be done with the next major release.

song pool empty

Hi,

I have MPC databse fully loaded, but when I run ashuffle I just get "song pool empty".

Auto-Shuffle needs to be modified imho...

Hi,
I'm a big fan of Tim Curtis' moOde software but there is something I really don't like. I explained him the problem but he said I had to contact you because you are the developer of this feature.
I'm still struggling with your feature "Auto-shuffle". Don't get me wrong, it works without hickups.
But I don't like the fact that the whole library of moOde is taken into account. I want to limit to certain parts of my library.
Let me explain: I'm using moOde at home, but also at work. And at home I don't really care what plays. But since I have the same library at the office, I want to select certain parts to choose from in the auto shuffle.
I have "normal" rock in my library, but also pop, metal, heavy metal, punk, funk, disco...actually a bit of everything, even classical music. And also some live albums.
Now, everything is well organized in different categories, folders and so on, all with year, genre, cover art....
So the problem now is, that at the office I'm not allowed to play for instance Rammstein, or even Metallica. Classical music is also not appreciated (dunno why, but hey...).
What I want is, since everything is well categorized, is to activate auto-shuffle, and in that window select the folders that I want into this auto-shuffle feature.
I really believe you should think about this. The feature Auto-Shuffle as it is now, is really useless at the office, because I constantly need skipping numbers.
What do you think? Please let me know asap...
Thx for your time!
Johan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.