Not able to do char* to char**

So I got the length but how about this

char StrTitle[cnt][maxsize];

That would be allocated on the stack and depending on your arduino, could be an issue.

On the previous point, sizeof is a compile time operator which tells you how many bytes have been allocated to the variable (or type).

It is not accepting the cnt

char StrTitle[cnt][maxsize];

because it's not constant. I tried to do

const int ccnt= cnt;
char StrTitle[ccnt][maxsize];

but it won't work.

I am running out of idees with this.

Depending on the compiler, dynamically sized array are not supported…

I suggest you go for the global array, with fixed size, as discussed previously.

Yeah, what I did is wrong like you explaned it before. I just diden't see it then. what I can do is preserve that memory, but that isen't make me a 2D array with a variable size.

So what what I have learned today is, take both sizes fix... most easy solution and handle overload or I do one variable size for the Filename or I one variable size of number of files. It's a choose I have to made depending on from what I have the most to save so much memory I can for the mcu.

PS: I will run this at startup to minimize memory issues. And as we discussed before with the risk when I take a pointer that the memorie could cause strange phenomenons like malloc error in the stack.

You have 1024 bytes of EEPROM to fit information for some number of mp3 files, right?

If the file names will always be 3 digits and ".mp3" then that can be generated from song number at playtime, no need to store. If you want to store human-read titles up to 31 chars (plus terminating zero), 1024 bytes can hold 32 of those.

If you want to store variable-length names then specify how many max. With 15(+1) average, 64 titles could fit EEPROM --

needing a 128 byte pointer array in RAM -or-
reading through the list, counting zeroes to find the nth title and save or print, a speed for RAM tradeoff.

If you knew the list at compile time, it could be stored to flash memory using PROGMEM. You should be able to have 24K or more free space on an Uno.

If you only have 2 titles...

const byte titles = 2;
const byte maxlen = 63; // you make the call, there's only 2
char strTitle[ titles ][ maxlen ]; // now strTitle is a char**

The best way to handle text is with state machines, each char as it arrives.
I have a list-word match that is finished matching or no-match by the arrival of the last char being matched and able to match and "act" on the stream.
Compare to reading the text into a buffer and then look for a match which can't stream, must stop. I started doing this in the 80's to get speed out of the hardware.

Serial at 115200 baud arrives about 1 every ~87us, 1388 cpu cycles. That's enough to follow links, I have an algorithm that speeds up finding alternate-spelled list words in sorted lists depending on where the input differs from the tentative matched-so-far list word. It steps past matching in alternate words what was matched before the current char.
I have a speed test that shows an average of ~9us, 144 cycles per char matched.

I have some difficulties to stream audio files with a bitrate of 320kb/s if I don't use a playlist. That's why I have created them also for knowing if the song is there. There is also an option shortfiles names I could use. Note: that I am not using spi ram for now.

You where right. I had to do it to handle my custom strings and leave the to many /n (new lines) out I don't want. Do you know How I can see "/n" in my serial monitor?

Ok, think I found it in hex or a single byte (unsigned char).

"\n" is a 3 byte string; 10, 10, 0

The compiler sees '\n' as 10 and '\r' as 13. It saves keeping an ASCII Table around, in the back of most programming references there was (still might be) an ASCII table. ASCII text chars are a way to get more out of numbers, another representation.

You read what is sent and

char alpha = chr & 0b11011111; // makes alphas lower case
if (( chr >= 'A' ) && ( chr <= 'Z' )
{
// chr is an alphabet -- code for it
}
else if (( chr >= '0' ) && ( chr <= '9' )
{
// chr is a digit -- code for it
}
else if ( chr >= ' ' )
{
// chr is printable -- code for it
}
else
{
// chr is non-printable -- code for it
// maybe you print " 2 digit value "
// in a hex editor I'll see line by line 16 bytes as hex, tab, 16 bytes as printable text or a space. Have you written a hex editor ever? They make file hacking easier.
}

I got DFPlayer minis to handle music but can't get at meta-data like titles from the on-module micro-SD let alone files I would keep on there. Oh well, saves on a display.

No, but I know stuf... Did some partition tables and all kind of wireless transmissions be
before. I learned a lot out off that. But there is always something new...

I have that too, but with the knowlegge I have now (wireless) I building it myself.

I don't get that. It's a 2 byte string. 10 and 0

I'm pretty sure that if you run this

const char* data = "\n";

void setup() {
  Serial.begin(115200); Serial.println();
  Serial.print("size of data = "); Serial.println(sizeof data);
  for (byte i = 0; i < sizeof data; i++)  {
    Serial.print(i); Serial.print(" -> "); Serial.println((byte) data[i]);
  }
}

void loop() {}

the Serial monitor will tell you

size of data = 2
0 -> 10
1 -> 0
1 Like

Are you running an ARMduino? Maybe Teensy3.2 or higher?

I prefer simpler, slower, more robust and come in DIP AVR's.
Can't do this with ARM!

Oh... that could be it. I only get 10. Than I need to see or it is an array or not... Not sure how I going to do that with DbFile.available()) But I don't know. I did some research and this is what I found

Line feed (LF)

and this is for the 0

Boundary Neutral BN

Note: I can't find it together in the asci table under 2 bytes. and I can't find much about formating field seperators in bytes.

10 is the ASCII linefeed character.
0 is an ASCII null, but in this case it is used as the value that indicates the end of a null-terminated char array.
Only the linefeed will be send, the null terminates the print function.

With a single character, '\n' with single quotes will work as well.

Seems a reasonable explanation where I was looking for. Thanks.

"\n" is a C string, ends with a NULL char, 0. Hence a 10 and a 0.

'\n' is a char with value 10.

" is not '

since I got it the fix size working and I know I have engoug allocated and I could have max 65,534 files in one folder with a fat32 . I want to make something like this.

Make an array with int_32 for the amound of titles and char array for the title itself.

Or as text...

char (*pTitle)[MaxTitleLength]
char Title[MaxTitleLength] ;
char chr;

Title[cntLetter] = chr;//for filling each character

Title[cntLetter+1] = '\0'
pTitle= &Title;

What I get is that the first is filled and the rest are empty, so I m not filling in the right I think. Or I diden't preserve the memorie right.

You should ask yourself what is a realistic usable max number of file and go for that and just ignore files beyond that number for example (and issue a warning).

Ok. I will do that. Could you answer my question... I am just curious to know that..

In de meantime I dit this an see I am not getting furder that overriding the first one each time. How can I add multieple string to a pointer?