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
  • BigOnYa @ BigOnYa:
    Not from more than 2 feet tho
    +1
  • K3Nv2 @ K3Nv2:
    You confuse shooting for milking
    +3
  • K3Nv2 @ K3Nv2:
    @AncientBoi, hasn't shot anything since 1938
    +2
  • AncientBoi @ AncientBoi:
    I think that was "The great depression" time
  • BigOnYa @ BigOnYa:
    It like one of those fake guns, that shoot, then a flag comes out and says, "splash"
    +2
  • K3Nv2 @ K3Nv2:
    Yeah a world War wasn't going on or anything
  • K3Nv2 @ K3Nv2:
    Americans lied about camps for propaganda
  • Xdqwerty @ Xdqwerty:
    @AncientBoi, where is your gun at?
  • K3Nv2 @ K3Nv2:
    I thought he already showed you his gun
  • BigOnYa @ BigOnYa:
    "This is my rifle, this is my gun. This is for fighting, this is for fun." - Full Metal Jacket
    +1
  • AncientBoi @ AncientBoi:
    We actually said that in Boot Camp, waaay before the movie :mellow:
    +1
  • K3Nv2 @ K3Nv2:
    I gotta raid0 these m.2s yay
  • BigOnYa @ BigOnYa:
    Do a raid10
  • K3Nv2 @ K3Nv2:
    That's tomorrow
    +1
  • Xdqwerty @ Xdqwerty:
    Yawn
  • BigOnYa @ BigOnYa:
    Damn Wal-Mart has 42" 4k TVs for only $150
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, i bet it will not fit inside your bedroom
  • BigOnYa @ BigOnYa:
    Yea here in North Korea, we are only allowed 1 19" tv per household. And the only channel we get is, MLT (Missile Launch Today)
  • K3Nv2 @ K3Nv2:
    @BigOnYa, doesn't fit in his bedroom he's American
    +1
  • BigOnYa @ BigOnYa:
    I hate ordering stuff online if I can go buy it somewhere close to me, and everywhere anymore will give you a discount only if you order it online, bs. Should be a discount if I go pick it up, not order online.
  • K3Nv2 @ K3Nv2:
    I love it for most things most stores you just shows the receipt online and they scan it
    +1
  • K3Nv2 @ K3Nv2:
    Makes it easy for incompetent restaurant staff that don't know how to hear an order
  • BigOnYa @ BigOnYa:
    Mostly for big purchases, I want it in my hands before I pay. Like a tv, I trust picking it up myself, before I'd trust it being sent thru mail/delivery. (Broken screen, etc) But yea if I can order online, then pickup at store is ok, but not all places offer that.
    BigOnYa @ BigOnYa: Mostly for big purchases, I want it in my hands before I pay. Like a tv, I trust picking it up...