Homebrew [POC][Developer-Only] Background 3ds mp3 player

Kartik

Well-Known Member
OP
Member
Joined
Jun 6, 2015
Messages
653
Trophies
0
Location
github
XP
2,747
Country
India
What is this:-
People for the longest time have wanted to play mp3(s) while games are running. Up until now, it was unknown whether this was possible, but as it turns out it is possible to do this.As anyone who has developed for 3ds before, should know that 3ds has two ways of playing audios, one through CSND and one through DSP. Apparently, it is possible to use CSND with modules to play music.

Attached is a functional POC of the music player, it just plays a mp3 off your sd card. You need to put a mp3 file named as `sound.mp3` on the root of your sd card and then enable game patching. I rewrote the PDN sysmodule, so now it spawns a thread in appcore for mp3 decoding and playing. The POC works (atleast on n3ds, for o3ds you might need to change appcore to syscore or change the prio) but not smoothly, every time the system/game spawns a new thread there is a small break in audio due to the audio thread freezing and there are constant "pop" sounds. My guess is the audio decoding and playing code will need soft-tuning(do note I'm not the best when it comes to audio stuff). The code for the POC is located here:- https://github.com/hax0kartik/3ds_pdn/tree/music-player.


Notes:-
  • Please remove patches for any other sysmodule before trying this as they can cause issues.
  • It might be better if we do not use PDN for our purposes but create a entirely new sysmodule which will be launched by the homebrew audio player app.
  • 3ds sleep mode will be broken by this, you'll need to restart your console.
  • On a n3ds, enabling "Clock + L2C" seems to make the code run a bit more smoother.
I hope the scene will be able to work its magic and fix the issues my POC has and then incorporate the code in other homebrew audio players!:yay3ds:

Also if you test this and if this works/does not work for you, please let me know!
 

Attachments

  • 0004013000002102.zip
    173 KB · Views: 201
Last edited by Kartik,

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,321
Country
United Kingdom
Shiny. Always liked being able to play own audio during games so nice to see you don't have to necessarily get down and dirty with the games themselves for this one.

Wonder whether this will be able to stick as a generic plugin or if it will be better to go for a more low power audio codec -- SD card space relative to such things is not a great concern these days really.

I should also note that various game undub, dubbing and music replacement types might appreciate a way for the game itself to reach out and touch something or trigger playback of specific files from within a set. It is not my favourite approach to ROM hacking but it is effective and seemingly can be done on hardware so there is that.
 

Wavy

Splatana Stamper Enjoyer
Member
Joined
Aug 24, 2020
Messages
302
Trophies
0
Location
MAP13: Downtown
XP
1,571
Country
Australia
It doesn't loop the mp3, and the sound starts playing before even the home menu starts, how were you able to use this with ctrquake? :P
I haven't actually tried this on my 3DS yet. I just saw that you released this and I thought that I could have the Quake MP3's play. Still cool though
 

Kartik

Well-Known Member
OP
Member
Joined
Jun 6, 2015
Messages
653
Trophies
0
Location
github
XP
2,747
Country
India
I haven't actually tried this on my 3DS yet. I just saw that you released this and I thought that I could have the Quake MP3's play. Still cool though
Well what you're trying is not completely impossible to do. You'll need to recompile ctrquake as well ad the POC though.
 

AliceCE

Rookie 3DS Homebrew Dev
Member
Joined
Aug 7, 2019
Messages
203
Trophies
0
Location
Amogus World Theme Park, BR
XP
544
Country
United States
Necrobump, but would it be possible to add controls to this in some form, using the same sort of menu format as Wumiibo does? I'm absolutely hooked on the idea of being able to play Slayer and shit while i play Terraria, but i can't see myself using it in a state where the only thing it can do is play one song with no controls.
 

Od3stroyer

Member
Newcomer
Joined
Dec 12, 2022
Messages
12
Trophies
0
Age
20
XP
98
Country
Canada
I'm not going to lie to you... I am completely lost on how to compile this. I am well versed on where to put compiled software for the 3DS and how to install them, but how exactly do you compile this? The instructions are very vague.
 

Pk11

A catgirl with a DSi
Member
Joined
Jun 26, 2019
Messages
1,285
Trophies
1
Age
22
Location
米国
Website
pk11.us
XP
3,892
Country
United States
I'm not going to lie to you... I am completely lost on how to compile this. I am well versed on where to put compiled software for the 3DS and how to install them, but how exactly do you compile this? The instructions are very vague.
To build just install devkitPro's toolchain, run pacman -S 3ds-mpg123 to install that library, and get ctrtool and put it in your PATH, then just run make.

There is a compiled build in the OP if you didn't notice fyi
 

Od3stroyer

Member
Newcomer
Joined
Dec 12, 2022
Messages
12
Trophies
0
Age
20
XP
98
Country
Canada
Is the compiled build the weird folder with the string of characters? In that case, do I just put that in the luma folder or something? I thought this was going to be a 3dsx build lol.

Also when I try to compile it myself, with ctrtool in the same directory as the Makefile and while using cmd, this is the result, whatever it means.

c:\3ds_pdn-music-player>make
make[1]: makerom: No such file or directory
make[1]: *** [/c/3ds_pdn-music-player/Makefile:127: /c/3ds_pdn-music-player/3ds_pdn-music-player.cxi] Error 127
make: *** [Makefile:104: build] Error 2
 

Pk11

A catgirl with a DSi
Member
Joined
Jun 26, 2019
Messages
1,285
Trophies
1
Age
22
Location
米国
Website
pk11.us
XP
3,892
Country
United States
Is the compiled build the weird folder with the string of characters? In that case, do I just put that in the luma folder or something? I thought this was going to be a 3dsx build lol.
Yeah, put that in sdmc:/luma/titles I belive

Also when I try to compile it myself, with ctrtool in the same directory as the Makefile and while using cmd, this is the result, whatever it means.

c:\3ds_pdn-music-player>make
make[1]: makerom: No such file or directory
make[1]: *** [/c/3ds_pdn-music-player/Makefile:127: /c/3ds_pdn-music-player/3ds_pdn-music-player.cxi] Error 127
make: *** [Makefile:104: build] Error 2
It needs to be in your PATH, not the current directory. See https://www.computerhope.com/issues/ch000549.htm or such
 

Od3stroyer

Member
Newcomer
Joined
Dec 12, 2022
Messages
12
Trophies
0
Age
20
XP
98
Country
Canada
Yeah, put that in sdmc:/luma/titles I belive
Hey, I got the compiled version you referenced running, just a nice experiment I wanted to try out. Obviously I do not need to compile the decompiled build, but I'm still getting those exact errors even when adding ctrtool.exe to my paths in Windows 10. It would be nice to be able to compile stuff whenever I need to, but I understand if you can't/don't want to help me. In whatever case, do you know what could be triggering these errors? I've been googling for a while to no avail.
 

Pk11

A catgirl with a DSi
Member
Joined
Jun 26, 2019
Messages
1,285
Trophies
1
Age
22
Location
米国
Website
pk11.us
XP
3,892
Country
United States
Hey, I got the compiled version you referenced running, just a nice experiment I wanted to try out. Obviously I do not need to compile the decompiled build, but I'm still getting those exact errors even when adding ctrtool.exe to my paths in Windows 10. It would be nice to be able to compile stuff whenever I need to, but I understand if you can't/don't want to help me. In whatever case, do you know what could be triggering these errors? I've been googling for a while to no avail.
Hmm, is msys2 PATH different from Windows PATH? I use macOS so I'm not sure exactly... You could try putting it in C:\devkitPro\tools\bin, I usually don't recommend that as that folders only really supposed to be for devkitPro's tools but Windows is a bit of a pain...
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: https://youtu.be/MddR6PTmGKg?si=mU2EO5hoE7XXSbSr