Homebrew Homebrew Development

Enovale

Hey. I exist. Woo
Member
Joined
Jul 12, 2016
Messages
833
Trophies
0
Location
Narnia
XP
946
Country
United States
You can load whatever file you want from RomFS, as long as:
  • you crate a RomFS package with the content you want to load (this is automated in the buid proces if you put your files in a data folder - e.g DATA - use the right makefile with the ROMFS variable defined as your data folder, and, for the CIA package, if you use a rsf file with the romfs option enabled
  • you init the romfs service before trying to access it (remember to close it befor exiting the program)
  • you use a path beginning with romfs:/ for your file (fopen, fclose, fread works as usual, but remember you can't list directory content)
  • remember that file and folder names are case sensitive
alright... ill mess around some more.

I set ROMFS as a ROMFS folder respectively, I tried both Result rc = romfsInit(); and just romfsInit();, and loaded a raw sound from romfs:/resources/menu.raw, and theres no missing file error in Citra but the sound doesnt play
 

Enovale

Hey. I exist. Woo
Member
Joined
Jul 12, 2016
Messages
833
Trophies
0
Location
Narnia
XP
946
Country
United States
You can load whatever file you want from RomFS, as long as:
  • you crate a RomFS package with the content you want to load (this is automated in the buid proces if you put your files in a data folder - e.g DATA - use the right makefile with the ROMFS variable defined as your data folder, and, for the CIA package, if you use a rsf file with the romfs option enabled
  • you init the romfs service before trying to access it (remember to close it befor exiting the program)
  • you use a path beginning with romfs:/ for your file (fopen, fclose, fread works as usual, but remember you can't list directory content)
  • remember that file and folder names are case sensitive
Im trying my best, i really am lol. No luck. For context, heres the repo of the code im using https://github.com/ElijahZAwesome/Minicraft3DS/

the notable files are https://github.com/ElijahZAwesome/Minicraft3DS/blob/master/build.bat

and https://github.com/ElijahZAwesome/Minicraft3DS/blob/master/source/Sound.c

and
Code:
void loadSound(Sound * snd, char * filename){
    romfsInit();
    FILE *file = fopen(filename, "rb");
    if(file != NULL){
        fseek(file, 0, SEEK_END);
        snd->size = ftell(file);
        fseek(file, 0, SEEK_SET);
        snd->buffer = linearAlloc(snd->size);
        fread(snd->buffer, 1, snd->size, file);
    }
    fclose(file);
    romfsExit();
}
in https://github.com/ElijahZAwesome/Minicraft3DS/blob/master/source/main.c
 

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
Im trying my best, i really am lol. No luck. For context, heres the repo of the code im using https://github.com/ElijahZAwesome/Minicraft3DS/

the notable files are https://github.com/ElijahZAwesome/Minicraft3DS/blob/master/build.bat

and https://github.com/ElijahZAwesome/Minicraft3DS/blob/master/source/Sound.c

and
Code:
void loadSound(Sound * snd, char * filename){
    romfsInit();
    FILE *file = fopen(filename, "rb");
    if(file != NULL){
        fseek(file, 0, SEEK_END);
        snd->size = ftell(file);
        fseek(file, 0, SEEK_SET);
        snd->buffer = linearAlloc(snd->size);
        fread(snd->buffer, 1, snd->size, file);
    }
    fclose(file);
    romfsExit();
}
in https://github.com/ElijahZAwesome/Minicraft3DS/blob/master/source/main.c

Gave only a fast look to you code, and the first thing I notice is:

Code:
loadSound(&snd_playerHurt, "resources/playerhurt.raw");

the file name miss the starting romfs:/. it should be:

Code:
loadSound(&snd_playerHurt, "romfs:/resources/playerhurt.raw");

Second think, don't call romfsInit() and romfsExit(); inside a functio. Put the at the beginning and at the end of main().

Sorry, I don't have time now to deeply check your code.
 

Enovale

Hey. I exist. Woo
Member
Joined
Jul 12, 2016
Messages
833
Trophies
0
Location
Narnia
XP
946
Country
United States
Gave only a fast look to you code, and the first thing I notice is:

Code:
loadSound(&snd_playerHurt, "resources/playerhurt.raw");

the file name miss the starting romfs:/. it should be:

Code:
loadSound(&snd_playerHurt, "romfs:/resources/playerhurt.raw");

Second think, don't call romfsInit() and romfsExit(); inside a functio. Put the at the beginning and at the end of main().

Sorry, I don't have time now to deeply check your code.
Thanks, ill move romfsInit to the beginning of main, but as for not including romfs:/ some of them are romfs: and some arent, for testing. sorry.
 

Enovale

Hey. I exist. Woo
Member
Joined
Jul 12, 2016
Messages
833
Trophies
0
Location
Narnia
XP
946
Country
United States
Gave only a fast look to you code, and the first thing I notice is:

Code:
loadSound(&snd_playerHurt, "resources/playerhurt.raw");

the file name miss the starting romfs:/. it should be:

Code:
loadSound(&snd_playerHurt, "romfs:/resources/playerhurt.raw");

Second think, don't call romfsInit() and romfsExit(); inside a functio. Put the at the beginning and at the end of main().

Sorry, I don't have time now to deeply check your code.
I moved the initiations and exits to main() and still nothing. also added romfs:/ to every sound. nothing.
 

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
Other two hints:

you set the CSND format as SOUND_FORMAT_16BIT, than you set the snd->size as the raw file size (number of bytes) and pass it as the sound lenght (number of 16 samples). somewhere you have to divide that value by two, or you'll read out of allocated memory and your code will crash (on a real 3ds).

Other important thing, check that your raw sound stream are:
1) mono
2) 16 bit samples
3) little endian encoded

I suggest to use 8 bit mono streans, this lower the final volume, but your files will be smaller and you don't have to worry about endianess.

About file sizes, loading a big amount of data on linear memory, can easily over it's availability, and when you linearalloc() the memory, you're noth chhecking if you have a valid pointer or a null value (meaning no memory left). Very dangerous :evil:
 

Enovale

Hey. I exist. Woo
Member
Joined
Jul 12, 2016
Messages
833
Trophies
0
Location
Narnia
XP
946
Country
United States
Other two hints:

you set the CSND format as SOUND_FORMAT_16BIT, than you set the snd->size as the raw file size (number of bytes) and pass it as the sound lenght (number of 16 samples). somewhere you have to divide that value by two, or you'll read out of allocated memory and your code will crash (on a real 3ds).

Other important thing, check that your raw sound stream are:
1) mono
2) 16 bit samples
3) little endian encoded

I suggest to use 8 bit mono streans, this lower the final volume, but your files will be smaller and you don't have to worry about endianess.

About file sizes, loading a big amount of data on linear memory, can easily over it's availability, and when you linearalloc() the memory, you're noth chhecking if you have a valid pointer or a null value (meaning no memory left). Very dangerous :evil:
but... it works just fine if you have the sound in a folder on the SD...
 

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
And the answer is:

you try to open the file playerdeath.raw that isn't in the romfs package. This probably stop the service and the other sound file aren't loaded.
 

Enovale

Hey. I exist. Woo
Member
Joined
Jul 12, 2016
Messages
833
Trophies
0
Location
Narnia
XP
946
Country
United States
And the answer is:

you try to open the file playerdeath.raw that isn't in the romfs package. This probably stop the service and the other sound file aren't loaded.
but i changed it to get all the sounds from romfs

--------------------- MERGED ---------------------------

wait crap your right, i read that wrong. one second
 

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
Tested the 3dsx file compiled from your updated code on my new3ds and the sound works, but the sounds file seem bad encoded.

In the wwekend I can test the difference loading the files from the SD, if any.
 
Last edited by nop90,

Enovale

Hey. I exist. Woo
Member
Joined
Jul 12, 2016
Messages
833
Trophies
0
Location
Narnia
XP
946
Country
United States
Tested the 3dsx file compiled from your updated code on my new3ds and the sound works, but the sounds file seem bad encoded.

In the wwekend I can test the difference loading the files from the SD, if any.
but it worked! Im going to have to test CIA, but thats super hype for me lol
 

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
but it worked! Im going to have to test CIA, but thats super hype for me lol
I had time to check the code again, and the problem for the weird sound is the one I reported previously, you pass to CSND a wrong sound size.

Change the code as below

Code:
void loadSound(Sound * snd, char * filename){
    FILE *file = fopen(filename, "rb");
    if(file != NULL){
        fseek(file, 0, SEEK_END);
        snd->size = ftell(file)/2;
       fseek(file, 0, SEEK_SET);
        snd->buffer = linearAlloc(snd->size*sizeof(u16));
       fread(snd->buffer, 1, snd->size, file);
    }
    fclose(file);
}

For me this fix the 3dsx build.
 

Enovale

Hey. I exist. Woo
Member
Joined
Jul 12, 2016
Messages
833
Trophies
0
Location
Narnia
XP
946
Country
United States
I had time to check the code again, and the problem for the weird sound is the one I reported previously, you pass to CSND a wrong sound size.

Change the code as below

Code:
void loadSound(Sound * snd, char * filename){
    FILE *file = fopen(filename, "rb");
    if(file != NULL){
        fseek(file, 0, SEEK_END);
        snd->size = ftell(file)/2;
       fseek(file, 0, SEEK_SET);
        snd->buffer = linearAlloc(snd->size*sizeof(u16));
       fread(snd->buffer, 1, snd->size, file);
    }
    fclose(file);
}

For me this fix the 3dsx build.

alright ill try that. thanks! Btw, do you know how i can ensure that the music pauses when you press the home button? on the CIA build and such if you go to the home menu without properly pressing "exit" sound will keep playing until you launch something else.
 

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
on the CIA build and such if you go to the home menu without properly pressing "exit" sound will keep playing until you launch something else.

Can't remember at the moment, I'll check my SDL port code.

The answer should be somewher in this thread anyway, if you can't wait try searching all my old posts.
 

Enovale

Hey. I exist. Woo
Member
Joined
Jul 12, 2016
Messages
833
Trophies
0
Location
Narnia
XP
946
Country
United States
Still can't find anything, and google never seems to help with this, or maybe i just don't know what to google. Can nop90 or anyone really refer me to a place where I can learn to fix this problem, or really any homebrew problem in general? Docs would be great.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • Psionic Roshambo @ Psionic Roshambo:
    @The Real Jdbye, I thought about that and I have blank DVD's and Blurays but honestly after like 90 songs I just listen to it a couple of hundred times toss it out and burn something else or have like 2-3 CD's. Florida here the heat in the car tends to ruin the CD's after like a few months even commercial pressed ones don't last too long.
  • The Real Jdbye @ The Real Jdbye:
    my music collection is just too big, i require variety
  • Xdqwerty @ Xdqwerty:
    Wanted to download the Sonic manía plus android versión cuz i have Netflix but my phone isnt compatible
  • NinStar @ NinStar:
    @The Real Jdbye you seem confused, nes remix 2 had nes open
  • Dumpflam @ Dumpflam:
    guys does anyone know anything about usbloadergx? i have a question. (https://gbatemp.net/threads/how-to-use-sd-and-thumb-drive-at-the-same-time-usbloadergx.655497/)
  • The Real Jdbye @ The Real Jdbye:
    oh right forgot about that
  • NinStar @ NinStar:
    you can use both at the same time if the sd is dedicated for gamecube games
  • NinStar @ NinStar:
    you can't do that the other way around
  • BigOnYa @ BigOnYa:
    Nowdays, my Samsung phone holds most my music on a 512gb micro sd. I Bluetooth to my earbuds, BT speaker, or to my car stereo from my phone. I still have a iPod Nano, but have not used in years.
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, i only play music on yt
  • Xdqwerty @ Xdqwerty:
    I download very few songs
  • BigOnYa @ BigOnYa:
    It takes me 3 hours every week to cut my grass, and I have to have music playing, not to mention the noise canceling earbuds, so I don't have to hear that lawnmower noise. I do play iHeart radio often also when get board of my music.
  • Xdqwerty @ Xdqwerty:
    Am I weird for only listening to game music?
  • BigOnYa @ BigOnYa:
    Nuh its whatever you like to hear. Is it weird, I'm a 50 year old that mostly listens to old school hip hop?
    +1
  • K3Nv2 @ K3Nv2:
    I should be walking but legs are still sore
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, I think that listening to the same 15 songs on the music player in my dad's car all the time made me kind of hate "normal" music.
    +1
  • Xdqwerty @ Xdqwerty:
    @K3Nv2, them use your hands
  • K3Nv2 @ K3Nv2:
    Those are tired from last night
  • Xdqwerty @ Xdqwerty:
    @K3Nv2, stop touching yourself
  • K3Nv2 @ K3Nv2:
    I wasn't
  • Xdqwerty @ Xdqwerty:
    @K3Nv2, then stop doing whatever you were doing last night
  • K3Nv2 @ K3Nv2:
    Uremum
  • BigOnYa @ BigOnYa:
    -insert uremum joke here-
  • K3Nv2 @ K3Nv2:
    Too late
    +2
    K3Nv2 @ K3Nv2: Too late +2