Tauon icon indicating copy to clipboard operation
Tauon copied to clipboard

macOS support (experimental)

Open Taiko2k opened this issue 3 years ago • 25 comments

Welcome to Tauon Music Box support for macOS.

Note that this is experimental and there are some caveats:

Caveats:

  • No fancy precompiled .dmg. You’ll need to build from source.
  • No desktop panel control. (Get in touch if you're familiar with mac development and think you can help with this.)
  • No output device selection, only default output.
  • More likely to crash than on Linux

How to build and install:

The build instructions below will give you a .app so once done you can use it like a normal desktop app.

  1. Install Homebrew
  2. Install main dependencies brew install pygobject3 gtk+3 python ffmpeg pyinstaller libao sdl2 sdl2_image flac mpg123 opusfile libopenmpt libsamplerate libvorbis librsvg wavpack
  3. Clone Tauon repo git clone --recursive https://github.com/Taiko2k/TauonMusicBox.git
  4. cd TauonMusicBox
  5. Install python dependencies pip3 install -r requirements.txt
  6. Run bash compile-phazor.sh (some warnings in the output are ok, as long as there was no error)
  7. You can run using python3 tauon.py
  8. ~~Build .app by running pyinstaller mac.spec --clean --noconfirm~~ Package script currently broken, have to run from terminal.

That should give you a (hopefully working) .app in the TauonMusicBox/dist directory that you can run as is or move to your applications folder.

Note that the script currently has a limitation in that the built .app is still linked to the homebrew prefix, so removing or updating the prefix may cause the .app to stop working.

Note that user data is kept in ~/.local/share/TauonMusicBox

Taiko2k avatar Oct 03 '21 04:10 Taiko2k

I succeeded
it also need to brew install librsvg and edit mac.spec modify hiddenimports=[], to hiddenimports=['sdl2', 'pylast'],

fangxx3863 avatar Dec 25 '21 16:12 fangxx3863

I succeeded it also need to brew install librsvg and edit mac.spec modify hiddenimports=[], to hiddenimports=['sdl2', 'pylast'],

Neat. Ive now updated the instructions and script with the modifications you made.

Taiko2k avatar Dec 26 '21 03:12 Taiko2k

I tried again with the new instructions, now on Monterey (12.1). Got through the build process without errors, other than pip reminding me about the deprecation of distutils. I tried to run the resulting TMB executable and got the following error:

[23812] Error loading Python lib '/Users/jkglenn/src/TauonMusicBox/build/mac/Python': dlopen: dlopen(/Users/jkglenn/src/TauonMusicBox/build/mac/Python, 0x000A): tried: '/Users/jkglenn/src/TauonMusicBox/build/mac/Python' (no such file), '/usr/local/lib/Python' (no such file), '/usr/lib/Python' (no such file)

I currently have a homebrew-installed Python which is symlinked to /usr/local/opt/[email protected]/libexec/bin/python.

I think you can try a virtual environment
Use anaconda or python venv
https://docs.python.org/3/library/venv.html
Also note that the python version cannot be 3.10.0
Because pyinstaller cannot run normally under version 3.10.0
https://github.com/pyinstaller/pyinstaller/issues/5693
In addition, the .app file generated by my build (BigSur 11.0) is in the dist directory
I wish you success (my English is not good, sorry)

fangxx3863 avatar Dec 28 '21 13:12 fangxx3863

todo: unlink app from homebrew prefix, it can break on homebrew update. (SDL2 libs causing the issue?)

@Taiko2k You might have better luck adding the pysdl2-dll Python package as a dependency for macOS, it contains the latest official signed SDL2 and Mixer binaries from libSDL.org in a Python wheel that PySDL2 can automatically find and use! It's the current recommended way to use PySDL2 on all major platforms, since installing the SDL2 binaries system-wide on Windows is a big pain and so many Linux distros bundle very out-of-date SDL/ttf/mixer/image versions.

Also, if you have any other questions/comments/complaints/feature requests for the PySDL2 project, please let me know! I'm the current maintainer and want to be sure I'm doing good outreach for projects that use it. 🙂

a-hurst avatar Jan 15 '22 16:01 a-hurst

@a-hurst Indeed I noticed pysdl2-dll, I was going to give it a try but I'm waiting on Apple Silicon support.

Thanks for working on PySDL2, its a great library and I haven't had any issues with it.

Taiko2k avatar Jan 17 '22 01:01 Taiko2k

I'd absolutely love a precompiled Tauon pkg, app, or cask for Mac.

I can run it fine if I start it from terminal with 'python3 tauon.py'. However, when following these directions I'm getting the same issue as @cschx

I'm running macOS 12.3.1 x86_64 If there is any info I can add please let me know and I'll happily supply it.

fyrefiend avatar May 28 '22 03:05 fyrefiend

@fyrefiend If you run the built app from terminal it might give us a more helpful error message which we could take a look at. From the project root try run:

"dist/TauonMusicBox.app/Contents/MacOS/Tauon Music Box"

Taiko2k avatar May 28 '22 04:05 Taiko2k

Gladly. Sorry, I should have done that to begin with.

Traceback (most recent call last): File "tauon.py", line 8, in <module> from sdl2 import * ModuleNotFoundError: No module named 'sdl2' [27344] Failed to execute script 'tauon' due to unhandled exception: No module named 'sdl2' [27344] Traceback: Traceback (most recent call last): File "tauon.py", line 8, in <module> from sdl2 import * ModuleNotFoundError: No module named 'sdl2'

However it is installed as 'python3 tauon.py' works fine

fyrefiend avatar May 28 '22 16:05 fyrefiend

Could try see if pysdl2-dll helps.

Try pip install pysdl2-dll, then hmm, might need to edit mac.spec file and add sdl2dll to the "hiddenimports" line.

Taiko2k avatar May 28 '22 17:05 Taiko2k

Thank you for the reply. I've installed pysld12-dkk and added it to the mac.spec file but still getting:

Traceback (most recent call last): File "tauon.py", line 8, in <module> from sdl2 import * ModuleNotFoundError: No module named 'sdl2' [32126] Failed to execute script 'tauon' due to unhandled exception: No module named 'sdl2' [32126] Traceback: Traceback (most recent call last): File "tauon.py", line 8, in <module> from sdl2 import * ModuleNotFoundError: No module named 'sdl2'

Attached in the warn-mac.txt that pyinstaller generated. It's saying sdl2 is not installed but if I can run the python file itself fine so it's obviously installed. warn-mac.txt

fyrefiend avatar May 28 '22 17:05 fyrefiend

@fyrefiend Hi there, PySDL2 maintainer here: looks like you've installed pysdl2-dll (the package with the pre-compiled SDL2 binaries for your OS) but not pysdl2 itself (the Python bindings for SDL2 and its addon libraries). Try running pip install pysdl2 and try again!

Also note that the latest pysdl2-dll binaries aren't yet fully natively compatible with Apple Silicon: since pysdl2-dll just bundles the official code-signed libSDL binaries for Windows and macOS, I've been waiting patiently for the SDL people to release universal binaries of SDL2_image and SDL2_mixer so I can update pysdl2-dll accordingly. Luckily it looks like new releases of both are imminent, so you shouldn't have to wait long.

a-hurst avatar May 31 '22 15:05 a-hurst

@a-hurst Thank you for replying. When I ran that I got:

DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 Requirement already satisfied: pysdl2 in /Users/fyre/Library/Python/3.9/lib/python/site-packages (0.9.11) DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621

I'm going to be completely honest, I'm not a programmer nor do I play one on TV so I'm grateful for y'all trying to help.

fyrefiend avatar May 31 '22 15:05 fyrefiend

@fyrefiend I don't have much experience with PyInstaller, but did you put pysdl2 in your mac.spec file along with pysdl2-dll? It'll need both to be self-contained.

a-hurst avatar May 31 '22 15:05 a-hurst

@a-hurst Tried including both in mac.spec but still getting the same error. Thank you though

fyrefiend avatar May 31 '22 15:05 fyrefiend

bash ./compile-phazor.sh

complains about missing wavpack pkg

brew install wavpack

fixes that, but then I get:

clang: error: no such file or directory: 'src/phazor/kissfft/kiss_fftr.c' clang: error: no such file or directory: 'src/phazor/kissfft/kiss_fft.c'

removing references to these (bad idea, I know) from the build script, produces another error:

src/phazor/phazor.c:41:10: fatal error: 'miniaudio/miniaudio.h' file not found

dl the header file and placing it in src/phazor

mkdir src/phazor/miniaudio cd src/phazor/miniaudio curl -O https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h

results in:

... /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareBase.h:208:5: note: 'kAudioObjectPropertyElementMaster' has been explicitly marked deprecated here kAudioObjectPropertyElementMaster API_DEPRECATED_WITH_REPLACEMENT("kAudioObjectPropertyElementMain", macos(10.0, 12.0), ios(2.0, 15.0), watchos(1.0, 8.0), tvos(9.0, 15.0)) = kAudioObjectPropertyElementMain ^ src/phazor/phazor.c:52:10: fatal error: 'kissfft/kiss_fftr.h' file not found #include "kissfft/kiss_fftr.h"

So the build process seems broken for now ;/

boromil avatar Jul 08 '22 18:07 boromil

@boromil yeah the instructions were a little out of date. Ive updated them now, note the change to step 3.

Though the built package is currently crashing it seems, so this all might not be very useful.

Taiko2k avatar Jul 09 '22 00:07 Taiko2k

M1 Mac Mini Mac OS Montery 12.5

Ran the bash command but 14 warnings and 4 errors occurred:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareBase.h:208:5: note: 'kAudioObjectPropertyElementMaster' has been explicitly marked deprecated here
    kAudioObjectPropertyElementMaster API_DEPRECATED_WITH_REPLACEMENT("kAudioObjectPropertyElementMain", macos(10.0, 12.0), ios(2.0, 15.0), watchos(1.0, 8.0), tvos(9.0, 15.0)) = kAudioObjectPropertyElementMain
    ^
src/phazor/phazor.c:1671:9: error: implicit declaration of function 'stop_out' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        stop_out();
        ^
src/phazor/phazor.c:1811:48: error: implicit declaration of function 'start_out' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    if (reconnect == 1 && sample_rate_src > 0) start_out();
                                               ^
src/phazor/phazor.c:1814:6: error: conflicting types for 'start_out'
void start_out(){
     ^
src/phazor/phazor.c:1811:48: note: previous implicit declaration is here
    if (reconnect == 1 && sample_rate_src > 0) start_out();
                                               ^
src/phazor/phazor.c:1823:6: error: conflicting types for 'stop_out'
void stop_out(){
     ^
src/phazor/phazor.c:1671:9: note: previous implicit declaration is here
        stop_out();
        ^
14 warnings and 4 errors generated.

denppa avatar Aug 16 '22 14:08 denppa

Ive committed a fix for the above compile issue now.

Taiko2k avatar Aug 16 '22 23:08 Taiko2k

Worked with a single typo in step 6: phazor not phasor Also the pyinstaller step does work, I get a standalone .app Thanks!

melvyn2 avatar Aug 22 '22 03:08 melvyn2

i'm getting these errors when i try to install it on a macos ...

src/phazor/phazor.c:1082:9: warning: unused variable 'b' [-Wunused-variable]
    int b = get_audio(frameCount * 2, pOutput);
        ^
src/phazor/phazor.c:1179:9: error: implicit declaration of function 'decode_seek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        decode_seek(position_count / current_sample_rate * 1000, sample_rate_src);
        ^
src/phazor/phazor.c:1198:6: error: conflicting types for 'decode_seek'
void decode_seek(int abs_ms, int sample_rate) {
     ^
src/phazor/phazor.c:1179:9: note: previous implicit declaration is here
        decode_seek(position_count / current_sample_rate * 1000, sample_rate_src);

But my arch linux install is rocking hard :)

Looooopy avatar Sep 24 '22 14:09 Looooopy

I inserted a predeclaration up on top on the file src/phazor/phazor.c and got it to work

inserted this at line 70 void decode_seek(int abs_ms, int sample_rate);

Looooopy avatar Sep 24 '22 14:09 Looooopy