hei.
I have a “huge” Array: u8 SongSQ[8][1024]
it should be greater like [8][4096] … it is used as Song-Step-Sequencer… but this would run out of RAM… (its a big ProjecT)
so i thought loading in 1024 Parts from a SD, after each 1024 Steps, i make a “SONG_Extend++”
and there is my “solution”:
// Read Data from file MUTEX\_SDCARD\_TAKE; // Read Data from file FILE\_ReadOpen ( &midifile\_fi, path\_song); FILE\_ReadBuffer( (u8 \*)file\_type,4); //"SIGL" = 4 Positons FILE\_ReadBuffer( (u8 \*)&SongSQ,sizeof(SongSQ) );// The Frist 1024 Steps of a Song if(SONG\_Extend \>= 1) { FILE\_ReadBuffer( (u8 \*)&SongSQ,sizeof(SongSQ) );}// if there is no other way... if(SONG\_Extend \>= 2) { FILE\_ReadBuffer( (u8 \*)&SongSQ,sizeof(SongSQ) );}// of adressing different sections on SD-Card ? if(SONG\_Extend \>= 3) { FILE\_ReadBuffer( (u8 \*)&SongSQ,sizeof(SongSQ) );}// this way: it will load and overwrite until we come to the right section FILE\_ReadClose ( &midifile\_fi ); MUTEX\_SDCARD\_GIVE;
ok this is a workaround, it reads each 1024-block over and over until it is blocked… In Lack of Knowledge to Jump to a Bufferposition - without loading into RAM - which i dont have (no place for a Dummy[8][1024]
but the workaround doesnt work because when i Write the File:
// Write Data into file FILE\_WriteOpen ( path\_tm,8); FILE\_WriteBuffer( (u8 \*)file\_type,4); //"SIGL" = 4 Positons FILE\_WriteBuffer( (u8 \*)&SongSQ,sizeof(SongSQ) ); if(SONG\_Extend \>= 1) { FILE\_WriteBuffer( (u8 \*)&SongSQ,sizeof(SongSQ) );}// this overwrites...other solution? if(SONG\_Extend \>= 2) { FILE\_WriteBuffer( (u8 \*)&SongSQ,sizeof(SongSQ) );} if(SONG\_Extend \>= 3) { FILE\_WriteBuffer( (u8 \*)&SongSQ,sizeof(SongSQ) );} FILE\_WriteClose (); MUTEX\_SDCARD\_GIVE;
it will overwrite already written 1024er-Blocks
So the only solution is - what i see to jump to a specif sector aka
SONG_Extend=0; ReadSector = 0 (or 4 when overjump the file_type section)
SONG_Extend=1; sizeof(SongSQ) = ReadSector = 1024*8 = 8192
SONG_Extend=2; sizeof(SongSQ)+ sizeof(SongSQ) = ReadSector = 16384
SONG_Extend=3; sizeof(SongSQ) + sizeof(SongSQ) + sizeof(SongSQ) = ReadSector = 24576;
but where and how to write the sectors to read
can someone explain:
FILE\_WriteBuffer( (u8 \*)&SongSQ,sizeof(SongSQ) );
where i write the Adress off Buffer and in which format ?
file.c says:
///////////////////////////////////////////////////////////////////////////// //! Writes into a file with caching mechanism (actual write at end of sector) //! File has to be closed via FILE\_WriteClose() after the last byte has been written ///////////////////////////////////////////////////////////////////////////// s32 FILE\_WriteBuffer(u8 \*buffer, u32 len) { UINT successcount; if( (file\_dfs\_errno=f\_write(&file\_write, buffer, len, &successcount)) != FR\_OK ) { }
so first Argument is the DATA to write, and the second the length… so it is not possible to overjump since it writes one after a nother? correct?
Other Possibilitys? make 4 Files on Disk for each 1024 Steps. hopefully not.
thx