Giter VIP home page Giter VIP logo

shuffle's Introduction

shuffle

A pre-compiled command-line audio player for macOS. Very light-weight music player, lots of options. Default mode is to shuffle music randomly, but you can also play in non-shuffle mode.

in action

Tab to toggle seeing the song list:

in action

Unique features:

  • Use any collections of audio/music folders at it any time you run it (no pre-ordained music locations)
  • Shuffle by albums (optionally within a genre)
  • Play music within multiple genres at once
  • Instantly starts even for huge collections of music (in shuffle mode)
  • Indefinite rewind in shuffle mode
  • Jump forward/back by album (when in non-shuffle mode)
  • Regex filters applied to filenames (optional)
  • Uses roughly 1/10th the RAM of iTunes, and hardly any CPU resources

Additional features:

  • Supports 16 file types, including FLAC music
  • Can easily create playlists by just making a folder full of aliases, symlinks or Finder SavedSearches
  • Can start audio books at a specified play rate and/or time offset
  • Can play music in year order regardless of album or folder

Install

To install:

brew install hyperjeff/tools/shuffle

Subsequent updates via:

brew upgrade shuffle

About

shuffle was written purely in Swift using AVFoundation, and hence is Mac-only.

shuffle -h for help, which is this currently:

shuffle 1.9.1 -- Plays a shuffled list of music files
                 © 2019-2022 HyperJeff, Inc

Usage: shuffle [options] [--genre Genre] [--regex "..."]
       [--mdfind "..."] [--start hh:mm:ss] [--rate x] directories/files

 --genre  | only include items within a specific genre(s) (implies -r)
 --mdfind | add any standard mdfind filter (no need to type "kMDItem")
 --rate   | set the initial playback speed multiplier
 --regex  | filter filenames using a regular expression
 --start  | begin at specified offset time (first track only)

options for music playback:

       -a | album shuffle (implies -r)
       -n | non-shuffle mode
       -y | year order, then artist

options for info display:

       -e | print examples and exit (--ex, --examples)
       -f | show filepath
       -g | show genre
       -h | print this help and exit (--help)
       -i | force inverted colors
       -l | list all genres in directories and exit (--list-genres)
       -m | metadata not shown
       -q | don't clear song info on quit
       -s | short filepath display
       -t | track and year info not shown
       -v | print version number and quit (--version)
       -0 | no printed output
       -1 | monochrome output
       -2 | 24-bit color output

Live controls during playback:

    space | pause/continue song
     [ ]  | skip back/ahead 15 seconds
     { }  | skip to previous/next album
     ← →  | previous/next song
     ↑ ↓  | volume up/down
     < >  | adjust rate slower/faster
     2-9  | change the look-ahead item count
      =   | set rate back to default
      ∞   | loop current track (option-5)
      f   | toggle showing filepath
      g   | toggle showing genre
      x   | remove next song from queue
      y   | remove song after next song from queue
      Q   | quit without clearing info
      q   | quit
          |
     tab  | show current music queue
shift-tab | show current album queue (when available)
    ctl-r | reveal current tune in enclosing folder

Albums and genre only available on Spotlight-indexed volumes.
To index your music so genres work: mdimport [directory]
shuffle can't currently read year info from FLAC files.

Several genres can be specified if in quotes and comma-separated.

Playlists can be created by making a folder full of Finder aliases
or unix symlinks, or by defining and saving Finder Smart Folders.
Speed tip: don't keep playlists within main music library folder.

Handy mdfind aliases: Year, Genre, Track, Rate, Length.

Examples

Shuffle play all music in one directory:

shuffle ~/Music

Play tracks in order:

shuffle -n ~/Music/AudioBooks/Other-Minds/

Shuffle play all music in many directories:

shuffle ~/Music /Volumes/Exocat/Music /Volumes/SomeNetworkVolume/Music/

Shuffle whole albums in a given genre:

shuffle -a --genre Ambient ~/Music

Shuffle among multiple genres:

shuffle ~/Music --genre "Glam Rock, Experimental Pop, Speed Bluegrass"

Play all songs in chronological order:

shuffle -y ~/Music/Compilations

Play all complete albums by Devo in order they came out:

shuffle ~/Music/Devo -ay

Shuffle all songs with the word Feelin', Feeling, Feelings:

shuffle ~/Music/ --regex "Feelin.*"

or use regex to pick out groups of terms into a playlist:

shuffle ~/Music/ --regex "Sun|Moon|Star|Planet"

Advanced mdfind-base searches can save you from some convoluted piping. Use any clause you might want to send to mdfind to filter for songs. And best of all, no need to type "MDItem"! High quality music from 1970 to 1976:

shuffle ~/Music --mdfind 'AudioSampleRate > 44000 && Year >= 1970 && Year <= 1976'

Notes

Flags can be input separately:

shuffle -f -i -1

or grouped together:

shuffle -1if

shuffle attempts to determine if it should invert colors automatically if you are using Terminal or iTerm2, so you may see, only once, an alert about it trying to make a call to AppleScript.

Regexes are applied (currently at least) only to filenames, and technically are formed by prepending .*\b and postpending \b.* in order to make it easier to just put in a word that one might want to make a playlist theme out of.

If you get a message that shuffle cannot find any music files when you declare a genre, but you can play music when you don't, then try the following in Terminal:

mdimport [directory with your music files]

Tips

What are all the genres in your music library? Try this:

find /Your/Music/ -type f -print0 | xargs -0 mdls -name kMDItemMusicalGenre | awk '{ split($0, a, "\""); print a[2] }' | sort | uniq -i | tr '\n' ,

And this variation will show you the relative frequency each has in your collection:

find /Your/Music/ -type f -print0 | xargs -0 mdls -name kMDItemMusicalGenre | awk '{ split($0, a, "\""); print a[2] }' | sort | uniq -i -c | sort -r

(You may find, like me, that there is a lot of garbage genres that you may want to fix up with some metadata file editor. There are many, and you can always use iTunes/Music for this.)

Known Issues

  • Cannot read year info from FLAC files
  • Remote/networked drives often don't have Spotlight indexing, causing albums shuffles and year information to fail
  • genre and mdfind options don't work with aliases / playlists
  • Smart Folders can't use date constraints

shuffle's People

Contributors

hyperjeff avatar

Stargazers

Fosewell  avatar Dave Newton avatar Travis Whitton avatar  avatar Genaro Pennone avatar Naimul Kabir avatar Steven Woolgar avatar Cui Mingda avatar Simon Yawin avatar William Luke avatar Ahmet Karalar avatar Roger Ogden avatar Jeremy Johnson avatar Monk3i avatar J.C. avatar Brandon Evans avatar  avatar eg avatar Marinko Pešo avatar Dario Vladović avatar Indrajit Chakrabarty avatar Dale Bradshaw avatar Alec Vance avatar Cristian Díaz avatar Stephen Ryner Jr. avatar

Watchers

James Cloos avatar

Forkers

logaan

shuffle's Issues

Crash trying to play library in shuffle mode

shuffle -a /Volumes/Media/Music/iTunes/iTunes\ Music

produces:

2019-07-22 12:35:32.646 shuffle[10016:85443] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to set posix_spawn_file_actions for fd -1 at index 0 with errno 9'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff45b78439 __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff702f63c6 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff45b7826b +[NSException raise:format:] + 193
	3   Foundation                          0x00007fff47d89ec8 -[NSConcreteTask launchWithDictionary:error:] + 3172
	4   shuffle                             0x000000010a31e53c shuffle + 21820
	5   shuffle                             0x000000010a34c400 shuffle + 209920
	6   shuffle                             0x000000010a32f8b5 shuffle + 92341
	7   shuffle                             0x000000010a32f8ef shuffle + 92399
	8   shuffle                             0x000000010a320ad2 shuffle + 31442
	9   shuffle                             0x000000010a31b54a shuffle + 9546
	10  libdyld.dylib                       0x00007fff71abb3d5 start + 1
	11  ???                                 0x0000000000000003 0x0 + 3
)
libc++abi.dylib: terminating with uncaught exception of type NSException
[1]    10016 abort      shuffle -a /Volumes/Media/Music/iTunes/iTunes\ Music

Hope that helps.

Crash during album shuffle of my library

shuffle -nri /Volumes/Media/Music/iTunes/iTunes\ Music/ works without crash
shuffle -ai /Volumes/Media/Music/iTunes/iTunes\ Music/ crashes on my library

Crash log:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to set posix_spawn_file_actions for fd -1 at index 0 with errno 9'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff4e972b79 __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff791103c6 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff4e9729ab +[NSException raise:format:] + 193
	3   Foundation                          0x00007fff50b84a88 -[NSConcreteTask launchWithDictionary:error:] + 3172
	4   shuffle                             0x00000001060f465c shuffle + 22108
	5   shuffle                             0x00000001061224c0 shuffle + 210112
	6   shuffle                             0x0000000106105975 shuffle + 92533
	7   shuffle                             0x00000001061059af shuffle + 92591
	8   shuffle                             0x00000001061059af shuffle + 92591
	9   shuffle                             0x00000001060f6bf2 shuffle + 31730
	10  shuffle                             0x00000001060f166a shuffle + 9834
	11  libdyld.dylib                       0x00007fff7a8d53d5 start + 1
	12  ???                                 0x0000000000000003 0x0 + 3
)
libc++abi.dylib: terminating with uncaught exception of type NSException
[1]    41694 abort      shuffle -ai /Volumes/Media/Music/iTunes/iTunes\ Music/

Please ask if I can help diagnose.

NB: I can pick a subfolder and it works fine.
NB: This used to work a few weeks ago when I tried it. I had since added 20 or so albums.

Just a feedback

Excellent job! I'm using it full time. My music collection is .mp3 and correctly tagged (not FLAC). I let you know that the Year tag doesn't shows for all tracks. Actually it shows only for a few tracks (about once every ten). I'm running Shuffle on Monterey. I already tried mdimport. Am I doing something wrong? Thanks anyway.

Open Source?

This is a great app! I'm really enjoying it. Is it open source, or are you just providing pre-compiled downloads?

Fails with empty sound files

~/Documents/Coffitivity $ shuffle
Filepath: paris-paradise.mp3
Volume: ▁▂▃▄▅▆▇█ Duration: 0 of 0
2019-07-12 10:28:08.660 shuffle[75692:2109818] *** Assertion failure in -[NSDateComponentsFormatter stringFromTimeInterval:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1575.12/Foundation/String.subproj/NSDateComponentsFormatter.m:361
2019-07-12 10:28:08.662 shuffle[75692:2109818] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: isfinite(timeInterval) && !isnan(timeInterval)'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff4808ccfd __exceptionPreprocess + 256
1 libobjc.A.dylib 0x00007fff7273ca17 objc_exception_throw + 48
2 CoreFoundation 0x00007fff480a7a1a +[NSException raise:format:arguments:] + 98
3 Foundation 0x00007fff4a346c85 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
4 Foundation 0x00007fff4a3e29f9 -[NSDateComponentsFormatter stringFromTimeInterval:] + 369
5 shuffle 0x0000000108a3f338 shuffle + 66360
6 shuffle 0x0000000108a49796 shuffle + 108438
7 shuffle 0x0000000108a6c060 shuffle + 249952
8 shuffle 0x0000000108a373d0 shuffle + 33744
9 libdispatch.dylib 0x00007fff73ebc5f8 _dispatch_call_block_and_release + 12
10 libdispatch.dylib 0x00007fff73ebd63d _dispatch_client_callout + 8
11 libdispatch.dylib 0x00007fff73ec868d _dispatch_main_queue_callback_4CF + 1135
12 CoreFoundation 0x00007fff47fd6cd7 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9
13 CoreFoundation 0x00007fff47fd6401 __CFRunLoopRun + 2289
14 CoreFoundation 0x00007fff47fd58be CFRunLoopRunSpecific + 455
15 Foundation 0x00007fff4a2398ef -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 280
16 Foundation 0x00007fff4a2397c4 -[NSRunLoop(NSRunLoop) run] + 76
17 shuffle 0x0000000108a31222 shuffle + 8738
18 libdyld.dylib 0x00007fff73f0a3d5 start + 1
19 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

Crashes on keypress

Starting the app with shuffle -a ~/Music/GirlTalk/ if I press either the right arrow key or { the app will quit with no error message.

Hitting tab shows:



  current ⟶   04 - Girl Talk - Jump on Stage.mp3


Shift tab shows nothing.

All other keys appear to work correctly.

Restarting the app always plays the same track from the middle of the album.

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.