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
  • SylverReZ @ SylverReZ:
    @genistopitauniverfrocrami, What drugs is this dude on?
    +1
  • NinStar @ NinStar:
    CRAZY HAMBURGER
  • The Real Jdbye @ The Real Jdbye:
    @NinStar both nes remix 1 and 2 had some stinkers in there
    +1
  • The Real Jdbye @ The Real Jdbye:
    but at least 2 doesn't have sports games
  • The Real Jdbye @ The Real Jdbye:
    loved nes remix, but hated having to play Baseball, Tennis and Golf in order to progress
    +1
  • The Real Jdbye @ The Real Jdbye:
    or fucking Clu Clu Land for that matter
  • Psionic Roshambo @ Psionic Roshambo:
    Not a big fan of NES kid Icarus either... I know it was popular but I didn't care for it.
  • Psionic Roshambo @ Psionic Roshambo:
    Yesterday I learned my BD Burner drive can burn CD's at 56X lol
  • cearp @ cearp:
    What stuff were you burning?
    I used to burn tons of dvds (data files) many years ago, but haven't burnt a disk in ages.
  • Psionic Roshambo @ Psionic Roshambo:
    My car actually reads MP3 CD's lol
  • Psionic Roshambo @ Psionic Roshambo:
    So mix CDs for myselt :)
  • Psionic Roshambo @ Psionic Roshambo:
    Pantera, Metallica, Hollywood Undead, Five Finger Death Punch, some others lol
  • Psionic Roshambo @ Psionic Roshambo:
    I can put like 90 songs on a CD lol
  • The Real Jdbye @ The Real Jdbye:
    if only it could read dvds then you would just need 1 disc
    +1
  • BakerMan @ BakerMan:
    i tell ya what, i could go for a fuckin gyro right about now
    +1
  • cearp @ cearp:
    I hope your brother is doing ok Mr BakerMan
    +1
  • cearp @ cearp:
    and Psi - I had a cd player / radio that played mp3 cds once, very cool
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    BakerMan yeah me too.... maybe that's gonna be dinner for me there is this place near me I have been dying to try and they have them lol
  • K3Nv2 @ K3Nv2:
    I miss usb mp3 players they were shit but at the time a go to
  • 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
    Xdqwerty @ Xdqwerty: Wanted to download the Sonic manía plus android versión cuz i have Netflix but my phone isnt...