sezero / mikmod

Mikmod Sound System (mirror of git repo at https://sf.net/projects/mikmod/)
http://mikmod.sourceforge.net/
72 stars 22 forks source link

xm files play at double speed (double sampling?) on macOS 14.1 on Apple Silicon over bluetooth? #78

Closed nevyn closed 5 months ago

nevyn commented 5 months ago

I just brew installed mikmod 3.2.8 on my M3 macbook pro with some classic airpods pro connected, and tuned into some of my old favorite xm modules. They played glitchilly at double speed, indicating to me that every other sample was being discarded or something like that.

Now that I'm trying to replicate with wired headphones, they sound fine. Changing back to bluetooth breaks it again. The timer ticks at two seconds per second of wall time. There are lots of glitchy discontinuities, which is why I think it's dropping samples rather than playing at double sample rate.

sezero commented 5 months ago

That you mention going between headphones and bluetooth unbreaks and breaks it, I think the issue may be with the very obsolete coreaudio driver included in the library. I will be updating the coreaudio driver in a few days and will report back here.

sezero commented 5 months ago

OK, I pushed the initial coreaudio driver update as of https://github.com/sezero/mikmod/commit/a2ac759904a97359603aa71b105f504b415ed341

@nevyn: Can you test? I can build for you too if you want (but I cannot sign/notarize them: you'll need to run xattr -r -d com.apple.quarantine on them.)

TODO:

@AliceLR: Can you please review? Any gotchas? (Commit diff for drv_osx.c is unreadable, just read the code as is, maybe compare to xmp-cli.)

Thanks.

sezero commented 5 months ago

Forgot to note: It refuses to work in mono or 8bit mode: only works in 16bit signed or 32bit floating point stereo mode. (I don't think anyone would want mono or 8bit mode on macosx, anyway...)

AliceLR commented 5 months ago

OK, will test soon and get back to you.

sezero commented 5 months ago

TODO:

. Report more (better) errors. Update its error strings?

Handled this in commits 22b2dea287aea722a8766b0f0432a7a8ce1bb191 and 727eb22d7c0686797571f555266899a4ef77fc19

Also pushed 7e63c588817de66a6312b2f70c285cb5e244ba3a to fix a minor warning from old gcc

AliceLR commented 5 months ago

Some simple testing with the initial commit and with the updates seems fine to me. I wasn't able to find any errors comparing against xmp. (High Sierra tested, will also try Snow Leopard.)

sezero commented 5 months ago

Some simple testing with the initial commit and with the updates seems fine to me. I wasn't able to find any errors comparing against xmp. (High Sierra tested, will also try Snow Leopard.)

Thank you.

@nevyn ?

nevyn commented 5 months ago

@sezero Wow!! Didn't expect this to be handled within 24 hours, thank you for the dedication :D

Unfortunately, it doesn't seem to have helped. Here's exactly what I did:

$ git clone --recursive https://github.com/sezero/mikmod.git
$ git log # we're at 727eb22d7c0686797571f555266899a4ef77fc19
$ mkdir build; cd build
$ cmake ..
$ make mikmod
$ ./src/mikmod ~/Music/MODs/megaXM/*.xm

and I still get double-speed playback when playing back on my Bluetooth headphones, but perfect playback on computer's built-in speakers.

nevyn commented 5 months ago

(also, README said to call ../configure, but there's no file in the repo, so I went for the cmake. README also says there's a macosx/README file, but there isn't :) )

sezero commented 5 months ago

@nevyn : Did you remove the brew version before building mikmod? I think you are linking to libmikmod from brew.

I suggest building like the following, after cloning the repo:

cd <mikmod-git-whereever>
mkdir -p libmikmod/build mikmod/build

## build libmikmod library first: the changes are in there:
cmake -S libmikmod -B libmikmod/build -DCMAKE_BUILD_TYPE=Release
cmake --build libmikmod/build/ --config Release

## now build mikmod player against it:
CMAKE_PREFIX_PATH=./libmikmod:./libmikmod/build cmake -S mikmod -B mikmod/build -DCMAKE_BUILD_TYPE=Release
# watch the line saying "-- Found MikMod: ..." it should point to the new libmikmod build
cmake --build mikmod/build/ --config Release

## now try the new mikmod player build:
./mikmod/build/src/mikmod ....
nevyn commented 5 months ago

@sezero ah how silly! yes ofc it had picked up the homebrew libmikmod. Building with your instructions worked great. Bug fixed! 🤩 well done!!

ps. maybe that script should be in the root of the repo? 😅

sezero commented 5 months ago

@sezero ah how silly! yes ofc it had picked up the homebrew libmikmod. Building with your instructions worked great. Bug fixed! 🤩 well done!!

Great! Thank you for testing.

ps. maybe that script should be in the root of the repo? 😅

Done: https://github.com/sezero/mikmod/commit/4d2c998af27352b564f10cd2b7eadc45070441cd

Closing as fixed.