No description
Find a file
Kyle Neideck 728a3a7331
build_and_install.sh: Offer fix when xcodebuild can't find Xcode.app.
If the Xcode command line tools were set to use a "command line tools
instance", which can be installed without having Xcode installed,
build_and_install.sh would fail. It prints an error message with a
command that can fix it if you do have Xcode installed, but the message
was kind of confusing and the command would fail if you didn't run it as
root.

build_and_install.sh now offers to run the command for you and then
continues the installation. I've also tried to make the message a bit
clearer and cleaned up some of the code.

Also fixes another bug that occurred with this configuration problem,
where the error from xcodebuild would be printed at an unintended (and
confusing) point in the script.

Fixes #108.
2017-04-09 17:35:27 +10:00
BGM.xcworkspace Update OSX image versions in .travis.yml. Add some files to the Xcode project. 2017-02-15 22:53:02 +11:00
BGMApp Fix nullability warning in BGMXPCHelper. Also add Xcode 8.3 to .travis.yml. 2017-04-05 22:15:54 +10:00
BGMDriver Add a UI tests target for BGMApp. Only has one test so far. 2017-02-19 13:39:34 +11:00
Images Initial commit 2016-02-19 16:25:34 +11:00
SharedSource Merge pull request #98 from rakslice/pan 2017-02-14 23:32:21 +11:00
.gitignore Add script that builds and installs BGMApp, BGMDriver and BGMXPCHelper 2016-04-05 16:56:38 +10:00
.travis.yml Fix nullability warning in BGMXPCHelper. Also add Xcode 8.3 to .travis.yml. 2017-04-05 22:15:54 +10:00
build_and_install.sh build_and_install.sh: Offer fix when xcodebuild can't find Xcode.app. 2017-04-09 17:35:27 +10:00
CONTRIBUTING.md Auto-pause: make the unpause delay proportional to the pause duration. 2016-12-29 02:25:44 +11:00
DEVELOPING.md Add PublicUtility to manual build instructions and... 2017-04-09 15:40:25 +10:00
LICENSE Initial commit 2016-02-19 16:25:34 +11:00
LICENSE-Apple-Sample-Code Auto-pause: make the unpause delay proportional to the pause duration. 2016-12-29 02:25:44 +11:00
MANUAL-INSTALL.md Add PublicUtility to manual build instructions and... 2017-04-09 15:40:25 +10:00
MANUAL-UNINSTALL.md Add some related projects to README and other minor doc clean up. 2016-04-23 14:21:02 +10:00
README.md Add -w option to build_and_install.sh, which passes -Wno-error to the compiler. 2017-02-16 22:54:38 +11:00
TODO.md Remove BGMAppTests, which was essentially empty. 2017-02-18 18:59:32 +11:00
uninstall.sh build_and_install.sh: Offer fix when xcodebuild can't find Xcode.app. 2017-04-09 17:35:27 +10:00

Background Music

macOS audio utility

  • Automatically pauses your music player when other audio starts playing and unpauses it afterwards
  • Per-application volume, boost quiet apps
  • Record system audio

  • No restart required to install
  • Runs entirely in userspace

Version 0.1.0, first release. Probably very buggy. Not very polished or well tested.

Requires OS X 10.10+. Might work on 10.9, but I haven't tried it. Currently unable to build in Xcode 6.

Auto-pause music

Background Music can pause your music player app when other audio starts playing and unpause it afterwards. The idea is that when I'm listening to music and pause it to watch a video or something I always forget to unpause it afterwards. So this keeps me from wearing headphones for hours listening to nothing.

So far iTunes, Spotify, VLC, VOX, Decibel and Hermes are supported. Adding support for a new music player should only take a few minutes1 -- see [BGMMusicPlayer.h](BGMApp/BGMApp/Music Players/BGMMusicPlayer.h). If you don't know how to program, or just don't feel like it, create an issue and I'll try to add it for you.

App volumes

Background Music has a volume slider for each app running on the system. I mostly use this to boost quiet apps above their normal maximum volume.

Recording system audio

With Background Music running, open QuickTime Player and go File > New Audio Recording... (or movie/screen). Then click the arrow next to the record button that looks like and select Background Music Device as the input device.

You should be able to record system audio and a microphone together by creating an aggregate device that combines your input device (usually Built-in Input) with Background Music Device. You can create the aggregate device using the Audio MIDI Setup utility from /Applications/Utilities.

Install

No binaries yet (working on it) but building should take less than a minute.

⚠️ Unfortunately, it won't build if you don't have Xcode installed because xcodebuild doesn't work on its own anymore. If you don't mind a 4GB download, you can get Xcode here.

If you're comfortable with it, you can just paste the following at a Terminal prompt.

//: # (build_and_install.sh doesn't call things by absolute paths (yet?) anyway.) //: # ( ) //: # (Uses "gzcat - | tar x" instead of "tar xz" because gzcat will also check the file's integrity. (Gzip files) //: # (include a checksum.))

(set -eo pipefail; URL='https://github.com/kyleneideck/BackgroundMusic/archive/master.tar.gz'; \
    cd $(mktemp -d); echo Downloading $URL to $(pwd); curl -qfL# $URL | gzcat - | tar x && \
    /bin/bash BackgroundMusic-master/build_and_install.sh -w && rm -rf BackgroundMusic-master)

Otherwise, to build and install:

  • Clone or download the project.
  • If the project is in a zip, unzip it.
  • Open Terminal.app and change directory to the directory containing the project.
  • Run the following the command: /bin/bash build_and_install.sh.

The script restarts the system audio process (coreaudiod) at the end of the installation, so you might want to pause any apps playing audio.

Additional detailed installation instructions can be found on the Wiki.

Uninstall

  • Run the uninstall.sh script to remove Background Music from your system.
  • Go to the Sound section in System Preferences and change your default output device at least once. (If you only have one device now, either use Audio MIDI Setup.app to create a temporary aggregate device, restart any audio apps that have stopped working or just restart your system.)

Manual Uninstall

Try following the instructions in MANUAL-UNINSTALL.md if uninstall.sh fails. (You might consider submitting a bug report, too.)

Troubleshooting

If Background Music crashes and system audio stops working, open the Sound panel in System Preferences and change your system's default output device to something other than Background Music Device. If it already is, it might help to change the default device and then change it back again. Failing that, you might have to uninstall.

Known issues

  • VLC automatically pauses iTunes/Spotify when it starts playing something, but that stops Background Music from unpausing your music afterwards. To workaround it, open VLC's preferences, click Show All, go Interface > Main interfaces > macosx and change Control external music players to either Do nothing or Pause and resume iTunes/Spotify.

    Similarly, Skype pauses iTunes during calls. If you want to disable that, uncheck Pause iTunes during calls on the General tab of Skype's preferences.

  • Plugging in or unplugging headphones when Background Music isn't running can silence system audio. To fix it, go to the Sound section in System Preferences, click the Output tab and change your default output device to something other than Background Music Device. Alternatively, you may Option+Click on the Sound icon in the menu bar to select a different output device.

    This happens when macOS remembers that Background Music Device was your default audio device the last time you last used (or didn't use) headphones.

  • A recent Chrome bug can stop Chrome from switching to Background Music Device after you open Background Music. Chrome's audio will still play, but Background Music won't be aware of it.

  • Some apps play notification sounds that are only just long enough to trigger an auto-pause. The only workaround right now is to increase the kPauseDelayNSec constant in BGMAutoPauseMusic.mm. That will make your music overlap the other audio for longer, though, so you don't want to increase it too much. See #5 for details.

  • Plenty more. Some are in listed in TODO.md.

  • Core Audio User-Space Driver Examples The sample code from Apple that BGMDriver is based on.
  • Soundflower - "MacOS system extension that allows applications to pass audio to other applications."
  • WavTap - "globally capture whatever your mac is playing—-as simply as a screenshot"
  • llaudio - "An old piece of work to reverse engineer the Mac OSX user/kernel audio interface. Shows how to read audio straight out of the kernel as you would on Darwin (where most the OSX goodness is missing)"
  • mute.fm, GitHub (Windows) - Auto-pause music
  • Jack OS X - "A Jack audio connection kit implementation for Mac OS X"
  • PulseAudio OS X - "PulseAudio for Mac OS X"
  • Sound Pusher - "Virtual audio device, real-time encoder and SPDIF forwarder for Mac OS X"
  • eqMac - "System-wide Audio Equalizer for Mac OSX"
  • Zirkonium - "An infrastructure and application for multi-channel sound spatialization on MacOS X."

Non-free

  • Audio Hijack - "Capture Audio From Anywhere on Your Mac"
  • Volume Mixer For Mac - "Application specific volume control for Mac OS Yosemite and El Capitan"
  • Sound Siphon - System/app audio recording, per-app volumes, system audio equaliser
  • SoundBunny - "Control application volume independently."
  • Boom 2 - "The Best Volume Booster & Equalizer For Mac"

License

Copyright © 2016 Background Music contributors. Licensed under GPLv2, or any later version.

Background Music includes code from:


[1] However, if the music player doesn't support AppleScript, or doesn't support the events Background Music needs (isPlaying, isPaused, play and pause), it can take significantly more effort to add. (And in some cases would require changes to the music player itself.)