Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
frranck opened this issue May 30, 2018 · 57 comments
Open

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

frranck opened this issue May 30, 2018 · 57 comments

Comments

@frranck
Copy link
Collaborator

frranck commented May 30, 2018

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
Copy link
Collaborator

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

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

@ghost
Copy link

ghost commented Oct 13, 2018

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
Copy link
Collaborator Author

frranck commented Oct 14, 2018

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
Copy link

ghost commented Oct 14, 2018

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

@frranck
Copy link
Collaborator Author

frranck commented Oct 21, 2018

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

@frranck
Copy link
Collaborator Author

frranck commented Nov 22, 2018

@twinaphex this has been done here:
#41
@DevilFrost can claim this bounty...

@frranck frranck closed this as completed Nov 22, 2018
@inactive123
Copy link
Collaborator

OK, sure thing.

@frranck
Copy link
Collaborator Author

frranck commented Nov 23, 2018

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

@DevilFrost
Copy link
Contributor

Please test the branch ios.

@frranck
Copy link
Collaborator Author

frranck commented Nov 23, 2018

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"" -D__LIBRETRO__ -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"" -D__LIBRETRO__ -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....

@frranck frranck reopened this Nov 23, 2018
@DevilFrost
Copy link
Contributor

Update. Please test.

@frranck
Copy link
Collaborator Author

frranck commented Nov 24, 2018

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"" -D__LIBRETRO__ -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"" -D__LIBRETRO__ -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
Copy link
Contributor

There should be no s16_to_float_neon.c and float_to_s16_neon.c

make clean?

@frranck
Copy link
Collaborator Author

frranck commented Nov 24, 2018

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"" -D__LIBRETRO__ -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
Copy link
Collaborator Author

frranck commented Nov 24, 2018

Already up to date.

@frranck
Copy link
Collaborator Author

frranck commented Nov 24, 2018

$ 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 0384120 (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
Copy link
Contributor

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

@frranck
Copy link
Collaborator Author

frranck commented Nov 25, 2018

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

@frranck
Copy link
Collaborator Author

frranck commented Nov 25, 2018

you expect SOURCES_ASM not to be compiled?

@DevilFrost
Copy link
Contributor

I think I understand what the problem is.

@DevilFrost
Copy link
Contributor

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

@DevilFrost
Copy link
Contributor

Please test the branch ios-dont.

@frranck
Copy link
Collaborator Author

frranck commented Nov 25, 2018

@DevilFrost yes ios-dont worked

@frranck
Copy link
Collaborator Author

frranck commented Nov 25, 2018

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

@frranck
Copy link
Collaborator Author

frranck commented Nov 26, 2018

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
Copy link
Contributor

It is really strange.

@frranck
Copy link
Collaborator Author

frranck commented Nov 27, 2018

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
Copy link
Contributor

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
Copy link
Contributor

make mrboom LIBSDL2=1

Works with a gcc for x86_64.

@frranck
Copy link
Collaborator Author

frranck commented Dec 2, 2018

@DevilFrost yes I fixed it

@frranck
Copy link
Collaborator Author

frranck commented Dec 2, 2018

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

@DevilFrost
Copy link
Contributor

@frranck there is no such bug. Debian.

@frranck
Copy link
Collaborator Author

frranck commented Dec 15, 2018

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

@frranck frranck removed the bounty label Jan 27, 2019
@frranck frranck changed the title Libretro: playing music doesn't work Libretro: playing music doesn't work [Nintendo switch] Jan 27, 2019
@frranck frranck changed the title Libretro: playing music doesn't work [Nintendo switch] Libretro: playing music doesn't work [Emscripten + Nintendo switch] Oct 30, 2020
@SimpleTease
Copy link
Contributor

SimpleTease commented Nov 16, 2020

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
Copy link
Contributor

SimpleTease commented Nov 16, 2020

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
Copy link
Contributor

SimpleTease commented Nov 17, 2020

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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

@frranck
Copy link
Collaborator Author

frranck commented Nov 21, 2020

@SimpleTease what do you mean ctr platform?

@frranck
Copy link
Collaborator Author

frranck commented Nov 21, 2020

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

@SimpleTease
Copy link
Contributor

@SimpleTease what do you mean ctr platform?

I was mistaking Switch (libnx, libtransistor) with 3DS (ctr)
https://github.com/Javanaise/mrboom-libretro/blob/master/Makefile#L237
https://github.com/Javanaise/mrboom-libretro/blob/master/Makefile#L215
https://github.com/Javanaise/mrboom-libretro/blob/master/Makefile#L230

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

Maybe it's intentional. Other libretro forks do same thing. No idea why.
https://github.com/libretro/libretro-handy/blob/dba810a87ebae87392259c68dcab7a35f6000aac/Makefile#L240

Emscripten is not playing music because frontend Makefile.emscripten needs HAVE_IBXM=1

Both Switch dev kits have same problem.
https://github.com/libretro/RetroArch/blob/175205c1e6e6904ffacb1fb0b48c2bcd1369a603/Makefile.libnx
https://github.com/libretro/RetroArch/blob/47e22d69bf2d803a3e47b75e2c8ef6a3a7cf1b4d/Makefile.switch

Because Griffin = 0, we have to manually add HAVE_IBXM=1 switch also. I'll take this care of this.

I'll keep you updated after the PRs go through. ;)

@SimpleTease
Copy link
Contributor

Emscripten and Switch should have music now, although I can't test either.

@frranck
Copy link
Collaborator Author

frranck commented Nov 22, 2020

Emscripten can be tested online https://web.libretro.com/ when it's merged and we can ask someone for Switch.

@SimpleTease
Copy link
Contributor

SimpleTease commented Nov 22, 2020

I tried the web player with several browsers but it always hangs on me when trying to start the core.

For the gamecube music problem, ibxm - replay_get_audio is returning $280 (Gamecube) vs $3C0 (Normal). And I'm also getting AI bots (Gamecube) that sometimes freeze when dropping bombs. Reliably when it's this pattern (A -> B). Happens with builds 2 months ago also.

xxB
x
A

Trying to figure out both problems.

@SimpleTease
Copy link
Contributor

Because static linking, frontend is sharing audio mixer with core. Frontend is setting rate to 32000 which is creating our tempo problems.

retroarch.c

#ifdef HAVE_AUDIOMIXER
   audio_mixer_init(settings->uints.audio_out_rate);
#endif

I think we can move the mixer init around in common.cpp but I'll need to do some checking first, to make sure Retroarch can re-init the mixer when switching cores or internal music player.

@SimpleTease
Copy link
Contributor

SimpleTease commented Dec 10, 2020

Libretro web player ""should"" have working music, but I still can't get player to run any cores.

@vaguerant
Copy link

Just adding a note here that Wii U also has no music.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants