Load midi files from SD consecutively, in order


#21

I'm just thinking that I might be able to do the memory allocation in the way the normal delaylines and tables are done. Not sure though, but this might fix the problem.. trying to recode it now


#22

I found out the problem lies in the "TinyMidiLoader" code, which is part of the header file.
Seems this one allocates to sdram and just adds each newly loaded midi file to the table without removing the old one.
So to fix this, I should edit the header file, so it removes the old file before going on or uses a pre-defined table which you can pre-initialise in the local and init sections, giving it a fixed allowed buffersize, IF I can find out where the mistake lies at all..


#23

tried out lots of things, but don't seem to be able to free the memory and reset the allocation pointer..


#24

Hello, thank you for trying.

i believe that is a midi library. Perhaps there is a github page or similar, for issues.

I'll take a look

Thank you


#25

the problem is that it is allocating memory by itself using "malloc", this creates a new memory with each assignment.
I looked into the code and even though there are structures for "realloc" (that would overwrite the same buffer) it seems the code actually still just uses the malloc instead of the realloc. But I still haven't been able to find out where this happens..


#26

why not add a free() before the malloc() of the next file?

https://www.tutorialspoint.com/how-do-malloc-and-free-work-in-c-cplusplus


#27

tried it on several different things in the module, but couldn't get it to work and on some things even crashed the axoloti.
It's some table that being created inside the TinyMidiLoader code.
But instead of altering the code in there and use the free(), I think it might be more useful if we could assign a table that the code may use and declare it ourself at local&init code.
also, in the tinymidiloader code, there are several places where it uses free(), so I think it's bit weird that it doesn't free up the allocated memory..


#28

I see. So maybe free() is not implemented in axolotiland. Or not correctly.


#29

@johannes
as you added the original module, do you might have some idea for this?


#30

Apologies for not being able to add anything useful here, I am more of a client server type of guy, can't program in C

Will keep an eye for anything I can do.

Thank you


#31

Can you try and substitute malloc for sdram_malloc() ?


#32

it's already using the sdram memory.
But if you have some ideas, take a look into the header files that are included with the jt/midi/midiplayer, perhaps you can see if something goes wrong or could be changed..?