Jump to content

File_ReadBuffer --- (over) jump to a specific sector?


Recommended Posts


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
		// 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 );

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	();

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.


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...