Javanaise / mrboom-libretro

Mr.Boom is an 8 player Bomberman clone for RetroArch/Libretro
http://mrboom.mumblecore.org
MIT License
200 stars 61 forks source link

Libretro: playing music doesn't work [Emscripten + Nintendo switch] #36

Open frranck opened 6 years ago

frranck commented 6 years ago

I tried to load .MOD and .XM in that branch https://github.com/Javanaise/mrboom-libretro/tree/adding_music using ibxm but I'm getting some "audio_mixer_play_mod cannot retrieve duration !" errors.

If I change https://github.com/Javanaise/mrboom-libretro/blob/adding_music/libretro-common/audio/audio_mixer.c#L599 to replay = new_replay( module, 48000, 1 ); // ( module, s_rate, 1); I don't get the error message but still don't get the module played...

PS: If you compile the game by default you'll use the data from retro_data.h If you compile the game with: make LOAD_FROM_FILES=1 You will get the data decrunched and read from files inside a temporary directory

inactive123 commented 6 years ago

Finally added $50 to this, it's now a bounty!

https://www.bountysource.com/issues/59020062-libretro-playing-music-doesn-t-work

ghost commented 6 years ago

The reason audio doesnt currently play with the mixer is because the functions for getting the audio and chunk size are not implemented. You will need to use the mixer functions in audio_mixer.c iirc to set up a mixing loop for all music.

frranck commented 6 years ago

Hi @mudlord What do you mean ? linking with https://github.com/libretro/libretro-common/blob/master/audio/audio_mixer.c, doesn't change anything.

ghost commented 6 years ago

You are using the functions from audio_mix.c it seems. Those functions are incomplete.

frranck commented 6 years ago

@mudlord Sorry I have no idea how to do that. Could you please submit a PR for this ? There's a bounty.

frranck commented 5 years ago

@twinaphex this has been done here: https://github.com/Javanaise/mrboom-libretro/pull/41 @DevilFrost can claim this bounty...

inactive123 commented 5 years ago

OK, sure thing.

frranck commented 5 years ago

Seems it's breaking on ios: http://p.0bl.net/64615

DevilFrost commented 5 years ago

Please test the branch ios.

frranck commented 5 years ago

still fails:

cc -arch armv7 -isysroot /Volumes/T2/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk -miphoneos-version-min=5.0 -miphoneos-version-min=5.0 -DIOS -O3 -DMRBOOM -DHAVE_IBXM -D_FORTIFY_SOURCE=0 -DPLATFORM=\"Darwin\" -DGIT_VERSION=\"" fdffce4"\" -DLIBRETRO -I./libretro-common/include -I./libretro-common -I./ai -I. -Wall -pedantic -fPIC -std=gnu99 -fPIC -c -o libretro-common/audio/conversion/float_to_s16_neon.o libretro-common/audio/conversion/float_to_s16_neon.c cc -arch armv7 -isysroot /Volumes/T2/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk -miphoneos-version-min=5.0 -miphoneos-version-min=5.0 -DIOS -O3 -DMRBOOM -DHAVE_IBXM -D_FORTIFY_SOURCE=0 -DPLATFORM=\"Darwin\" -DGIT_VERSION=\"" fdffce4"\" -DLIBRETRO -I./libretro-common/include -I./libretro-common -I./ai -I. -Wall -pedantic -fPIC -std=gnu99 -fPIC -c -o libretro-common/ibxm/ibxm.o libretro-common/ibxm/ibxm.c

:5:3: error: unknown directive .type convert_s16_float_asm, %function ^ :11:3: error: unknown directive .type _convert_s16_float_asm, %function ^ libretro-common/audio/conversion/float_to_s16_neon.c:30:1: warning: extension used [-Wlanguage-extension-token] asm( ^ :5:3: error: unknown directive .type convert_float_s16_asm, %function ^ :11:3: error: unknown directive .type _convert_float_s16_asm, %function ^ 1 warning and 2 errors generated. 1 warning and 2 errors generated. make: *** [libretro-common/audio/conversion/float_to_s16_neon.o] Error 1 make: *** Waiting for unfinished jobs....
DevilFrost commented 5 years ago

Update. Please test.

frranck commented 5 years ago

1 file changed, 3 insertions(+), 3 deletions(-) franck-mac-book-air:mrboom-libretro franck$ make -f Makefile platform=ios -j6 2018-11-24 13:13:23.833 xcodebuild[30831:507120] [MT] PluginLoading: Required plug-in compatibility UUID 426A087B-D3AA-431A-AFDF-F135EC00DE1C for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XCActionBar.xcplugin' not present in DVTPlugInCompatibilityUUIDs 2018-11-24 13:13:23.835 xcodebuild[30831:507120] [MT] PluginLoading: Required plug-in compatibility UUID 426A087B-D3AA-431A-AFDF-F135EC00DE1C for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin' not present in DVTPlugInCompatibilityUUIDs cc -arch armv7 -isysroot /Volumes/T2/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk -miphoneos-version-min=5.0 -c -o libretro-common/audio/resampler/drivers/sinc_resampler_neon.o libretro-common/audio/resampler/drivers/sinc_resampler_neon.S cc -arch armv7 -isysroot /Volumes/T2/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk -miphoneos-version-min=5.0 -miphoneos-version-min=5.0 -DIOS -O3 -DMRBOOM -DHAVE_IBXM -D_FORTIFY_SOURCE=0 -DPLATFORM=\"Darwin\" -DGIT_VERSION=\"" 0384120"\" -DLIBRETRO -I./libretro-common/include -I./libretro-common -I./ai -I. -Wall -pedantic -fPIC -std=gnu99 -fPIC -c -o libretro-common/audio/conversion/s16_to_float_neon.o libretro-common/audio/conversion/s16_to_float_neon.c cc -arch armv7 -isysroot /Volumes/T2/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk -miphoneos-version-min=5.0 -miphoneos-version-min=5.0 -DIOS -O3 -DMRBOOM -DHAVE_IBXM -D_FORTIFY_SOURCE=0 -DPLATFORM=\"Darwin\" -DGIT_VERSION=\"" 0384120"\" -DLIBRETRO -I./libretro-common/include -I./libretro-common -I./ai -I. -Wall -pedantic -fPIC -std=gnu99 -fPIC -c -o libretro-common/audio/conversion/float_to_s16_neon.o libretro-common/audio/conversion/float_to_s16_neon.c libretro-common/audio/conversion/s16_to_float_neon.c:30:libretro-common/audio/conversion/float_to_s16_neon.c1::30 :1: warning: warning: extension extensionused used[-Wlanguage-extension-token] [-Wlanguage-extension-token]

asm( ^ asm( ^

::55::33:: errorerror: : unknownunknown directivedirective .type convert_float_s16_asm, %function .type convert_s16_float_asm, %function ^ ^ :11:3: error: unknown directive: 11:3: error: unknown directive .type _convert_float_s16_asm, %function ^ .type _convert_s16_float_asm, %function ^ 11 warning and 2 errors generated. warning and 2 errors generated. make: *** [libretro-common/audio/conversion/float_to_s16_neon.o] Error 1 make: *** Waiting for unfinished jobs.... make: *** [libretro-common/audio/conversion/s16_to_float_neon.o] Error 1
DevilFrost commented 5 years ago

There should be no s16_to_float_neon.c and float_to_s16_neon.c

make clean?

frranck commented 5 years ago

yes I did a make clean

^ cc -arch armv7 -isysroot /Volumes/T2/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk -miphoneos-version-min=5.0 -miphoneos-version-min=5.0 -DIOS -O3 -DMRBOOM -DHAVE_IBXM -D_FORTIFY_SOURCE=0 -DPLATFORM=\"Darwin\" -DGIT_VERSION=\"" 0384120"\" -DLIBRETRO -I./libretro-common/include -I./libretro-common -I./ai -I. -Wall -pedantic -fPIC -std=gnu99 -fPIC -c -o libretro-common/audio/conversion/float_to_s16_neon.o libretro-common/audio/conversion/float_to_s16_neon.c libretro-common/audio/conversion/float_to_s16_neon.c:30:1: warning: extension used [-Wlanguage-extension-token] asm( ^

:5:3: error: unknown directive .type convert_s16_float_asm, %function ^ :5:3: error: unknown directive .type convert_float_s16_asm, %function ^ :11:3: error: unknown directive .type _convert_float_s16_asm, %function ^ :11:3: error: unknown directive .type _convert_s16_float_asm, %function ^ 1 warning and 2 errors generated. 1 warning and 2 errors generated. make: *** [libretro-common/audio/conversion/float_to_s16_neon.o] Error 1 make: *** Waiting for unfinished jobs.... make: *** [libretro-common/audio/conversion/s16_to_float_neon.o] Error 1 ^Cmake: *** [mrboom.o] Interrupt: 2 franck-mac-book-air:mrboom-libretro franck$ git pull
frranck commented 5 years ago

Already up to date.

frranck commented 5 years ago

$ cat Makefile.common | grep -i neon

SOURCES_ASM := $(LIBRETRO_COMM_DIR)/audio/resampler/drivers/sinc_resampler_neon.S \ $(LIBRETRO_COMM_DIR)/audio/conversion/s16_to_float_neon.S \ $(LIBRETRO_COMM_DIR)/audio/conversion/float_to_s16_neon.S

$ git status On branch ios Your branch is up to date with 'origin/ios'.

nothing to commit, working tree clean

$ git log commit 038412015859bfacbd054002d5f02b7003d608bd (HEAD -> ios, origin/ios) Author: Frost 44336975+DevilFrost@users.noreply.github.com Date: Sat Nov 24 09:01:39 2018 +0000

Update Makefile.common
DevilFrost commented 5 years ago

It seems strange that the old version is used when compiling. I updated the file Makefile.common. Please test.

frranck commented 5 years ago

just tried with 6fd524ab2f1a26f682e93ea906288a391d7f5471 its the same. I also double checked the clean was deleting all .o

frranck commented 5 years ago

you expect SOURCES_ASM not to be compiled?

DevilFrost commented 5 years ago

I think I understand what the problem is.

DevilFrost commented 5 years ago

The compiler compiles .c files instead of .S files.

DevilFrost commented 5 years ago

Please test the branch ios-dont.

frranck commented 5 years ago

@DevilFrost yes ios-dont worked

frranck commented 5 years ago

btw would be cool to have a "no music" option...

frranck commented 5 years ago

btw the SDL2 seems broken in ios-dont

make mrboom LIBSDL2=1

Undefined symbols for architecture x86_64: "_convert_float_to_s16", referenced from: _audio_mix_load_wav_file in audio_mix.o "_convert_s16_to_float", referenced from: _audio_mix_load_wav_file in audio_mix.o "_retro_resampler_realloc", referenced from: _audio_mixer_load_wav in audio_mixer.o _audio_mix_load_wav_file in audio_mix.o "_rwav_free", referenced from: _audio_mixer_load_wav in audio_mixer.o _audio_mix_free_chunk in audio_mix.o "_rwav_load", referenced from: _audio_mixer_load_wav in audio_mixer.o _audio_mix_load_wav_file in audio_mix.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [mrboom] Error 1

DevilFrost commented 5 years ago

It is very strange that it breaks the x86_64. I updated the Makefile.

frranck commented 5 years ago

there's two x86_64 versions, a libretro and a SDL2, It's getting a bit confusing (the sdl2 version is currently broken in master too, will fix it), can you please make a PR that fixes the ios version ?

DevilFrost commented 5 years ago

Something strange with the PR. Try to create and see.

frranck commented 5 years ago

There was an issue with the make clean, let me check

frranck commented 5 years ago

Current master still fails, can you make a PR with your latest changes?

DevilFrost commented 5 years ago

I can not.

frranck commented 5 years ago

Why not ?

DevilFrost commented 5 years ago

I can not merge any branch.

frranck commented 5 years ago

Ok I added DONT_WANT_ARM_OPTIMIZATIONS and it compiled on iOS. I noticed one weird thing though: on android there's no music only FX.

DevilFrost commented 5 years ago

It is really strange.

frranck commented 5 years ago

On OS X it's weird also, sometime I run it an there's no music only FX. Sometimes there is both.

Something else: you're not using musics_volume? https://github.com/Javanaise/mrboom-libretro/blob/master/common.cpp#L103 Doesn't every song has a different volume?

DevilFrost commented 5 years ago

musics_volume used with the SDL2. The libretro is not used. Volume is set here: voice = audio_mixer_play(musics[index], true, 1, NULL);

DevilFrost commented 5 years ago

make mrboom LIBSDL2=1

Works with a gcc for x86_64.

frranck commented 5 years ago

@DevilFrost yes I fixed it

frranck commented 5 years ago

@DevilFrost do you have the random bug where the music is not on? which platform are you using?

DevilFrost commented 5 years ago

@frranck there is no such bug. Debian.

frranck commented 5 years ago

OK I fixed the android issue. There still no music on Nintendo switch though.

SimpleTease commented 3 years ago

Made an interesting discovery. Gamecube music sounds really fast, like 2x Windows builds. And it turns out Windows builds are 2x faster than several standalone MOD players. Which explains why some riffs sound so rushed. Changed libretro rate to 22050 and music tempo now feels more relaxed everywhere. So there's a problem in the ibxm player. :shocked:

edit: Or it's the libretro mixer.

SimpleTease commented 3 years ago

Worth pointing out that the XM player got a small update (2017 -> 2019) https://github.com/martincameron/micromod/tree/master/ibxm-ac

And it correctly puts out wave files that sound okay. So now we analyze what libretro is doing that speeds it up.

SimpleTease commented 3 years ago

https://github.com/libretro/libretro-common/blob/828be1d3db59d21a50af7133bfad61506f651ba5/audio/audio_mixer.c#L997

That should be int16_t. I'll patch upstream libretro-common and update 2019 mod player. I thought that would work being 16-bit stereo but not. I'll keep looking at this.

SimpleTease commented 3 years ago

Finally found the music issue. It was skipping samples. https://github.com/libretro/libretro-common/blob/a810c57f8c4e51659ae776beb25d7bd4a7b86251/audio/audio_mixer.c#L999

It should refill when if (voice->types.mod.samples == 0)

Will test later if gamecube music is fixed.

SimpleTease commented 3 years ago

Submitted a PR to libretro-common. Windows is fixed. Gamecube sounds better but still has stereo separation + very fast tempo, so might be some ibxm endian problem. I don't know if Emscripten or Switch is changed, but I'll PR over here too after common is merged.

SimpleTease commented 3 years ago

Emscripten is not playing music because frontend Makefile.emscripten needs HAVE_IBXM=1. I'll PR that too. Is Switch ctr platform?

frranck commented 3 years ago

@SimpleTease what do you mean ctr platform?

frranck commented 3 years ago

seems Switch is erasing the CFLAGS https://github.com/Javanaise/mrboom-libretro/blob/master/Makefile#L221