Music and sounds relative issues and questions

General

Codnpix

3 weeks ago

Hi, 

I wanted to create this topic because I thaught it would be greate to gather the sound and music relative questions in one discussion. Considering that a lot of questions and topics regarding these subjects are pretty similar.


So I start first.. :

I put some music tracks in a little breackout game. There is one track for each level, the program reads the track from the sd card with gb.level.play("mytrack", true);. The tracks are displayed globally fine, but since I put the music it happens regularly to the game to crash with an "ERROR 2 - hard fault" (ram overflow, or memory alignment, or undefined instruction, or exec XN address...).

So I imagine that's probably a RAM overflow problem because of the loading of the tracks or something like that...

My tracks are 8bits wav files, about 3.5Mo size each. Maybe this is too heavy ? Is there a size limit to watch when reading external files ? Or something to know about RAM managment ?

Or else, if this is not the problem so what could it be ?

Thank you for your help.

Codnpix

NEW 2 weeks ago

Finally I answer my own question :

It got much better since I optimize a little the memory occupation in my code.


Je réponds un peu à ma propre question finalement : 

Ça s'est nettement arrangé depuis que j'ai fait un petit effort d'optimisation de la mémoire dans mon code.

Mais ceci dit je voudrais quand même bien savoir ce qu'engage la lecture d'un fichier wav externe en terme d'occupation de la RAM. Est-ce qu'un buffer se charge un quelque chose comme ça ?

jicehel

NEW 2 weeks ago

Oui Codnpix, il y a un buffer. Il y a un sujet la dessus qui a été traité ici: https://gamebuino.com/fr/community/topic/can-t-use-bmp-and-wav-at-the-same-time#c2328

Sorunome

NEW 2 weeks ago

to play back a wav file of any size you only need ~2k of free ram, the library will automatically allocate that ram if needed, thus a few MB file size shouldn't matter in that regard.

It can always be helpful to display the free amount of ram you have on-screen for debugging (same goes for CPU usage!)

Codnpix

2 weeks ago

Thank for your answer Sorumne.

It can always be helpful to display the free amount of ram you have on-screen for debugging (same goes for CPU usage!)

So I tried to output the remaining free RAM and the CPU load :

The gb.getFreeRam() outputs a perfectly constant value of 7219 bytes (I was a little surprised not to see any variation in the value, is that normal ?)

And the gb.getCpuLoad() outputs a value moving between 70 and 90%. It seems a little high, so maybe the problem comes from there ?

Codnpix

NEW 2 weeks ago

Sorunome Sorunome

Thank for your answer Sorumne.

It can always be helpful to display the free amount of ram you have on-screen for debugging (same goes for CPU usage!)

So I tried to output the remaining free RAM and the CPU load :

The gb.getFreeRam() outputs a perfectly constant value of 7219 bytes (I was a little surprised not to see any variation in the value, is that normal ?)

And the gb.getCpuLoad() outputs a value moving between 70 and 90%. It seems a little high, so maybe the problem comes from there ?

jicehel

NEW 2 weeks ago

If you're 90% of CPU usage and never upper it's fine.

Codnpix

2 weeks ago

If you're 90% of CPU usage and never upper it's fine.

Indeed I didn't see that value climb up over 90, but maybe it's possible to have a 10% peak once in a while a make the game crash ? Either I don't understand why it would crash... Also it's not every time, I have to play two or three different levels, and sometimes it crashes... I think my code may still be a little dirty, I don't think I managed very well the calculation and memory optization...

Here is a link to my source : https://github.com/Codnpix/casse_brique_evolution

Maybe if someone could take a quick look to it, could you tell me if you see a major problem in there ? Or an idea of what could be the reason..

It started to crash at the moment I added the music tracks on each levels. That's why I thaught about a RAM problem, but....


Codnpix

NEW 2 weeks ago

jicehel jicehel

If you're 90% of CPU usage and never upper it's fine.

Indeed I didn't see that value climb up over 90, but maybe it's possible to have a 10% peak once in a while a make the game crash ? Either I don't understand why it would crash... Also it's not every time, I have to play two or three different levels, and sometimes it crashes... I think my code may still be a little dirty, I don't think I managed very well the calculation and memory optization...

Here is a link to my source : https://github.com/Codnpix/casse_brique_evolution

Maybe if someone could take a quick look to it, could you tell me if you see a major problem in there ? Or an idea of what could be the reason..

It started to crash at the moment I added the music tracks on each levels. That's why I thaught about a RAM problem, but....


jicehel

NEW 2 weeks ago

Nope, your % can go upper than 100%. It's just that it's longer. No crash but you could have sounds problems if it's goes upper than 100% (not for this reason but it's can contribute). Ithink more about a problem of memory or problem of access in a not authorized zone or invalid value of a counter in an array, but it's just an idea as i don't have look the code yet. (Sorry, i have a real problem of time and i'll have it for some more days or months...). If i can i'll have a look on it tonight but don't count to much on it, but if i can, i'll do  ;)

You must be logged in in order to post a message on the forum

Log in