If 14222 is file size length of time, but 13600 is the real length of time (in the player), then multiply the file size time (14222) by the drift, which is... (13600 / 14222 = 0.95626494164). That should get you closer to the right time.
But how to write this 0.95 value to get it introduced within code
Using the code from Post #14, add a line to multiply ms
by .95.
unsigned long m = 4; // 4 minutes
unsigned long s = 20; // 20 seconds
unsigned long ms; // resulting milliseconds
void setup() {
ms = ((m*60)+s)*1000;
Serial.begin(9600);
Serial.print("Audio file length of ");
Serial.print(m);
Serial.print(":");
Serial.print(s);
Serial.print(" is ");
Serial.print(ms);
Serial.println(" milliseconds.");
Serial.println("The adjusted value is: ");
Serial.println(ms * .95);
}
void loop() {}
In your code, add the multiplication immediately by replacing:
delay(14222);
to become
delay(14222 * .95);
But, to make this so you do not have to add ".95" to every delay(), add to the top of your sketch:
unsigned long m = 4;
unsigned long s = 20;
unsigned long ms;
float drift = .95;
Then, calculate your audio file length:
ms = ((m*60)+s)*1000;
and then add it to your delay()
delay(ms * drift);
Practicals are on the way right now and with value .977 its a bit approximate
Not much fine
and that 1 ms delay is still effecting the joint between 2 files
Putting different values here , but not able to get the real thing and that is the complete continuity between files
Yes, the delay(ms*drift) is clumsy. I just read:
If you use DFPlayerMini_Fast.h , you can poll the MP3 module with <DFPlayerMini_Fast>.isPlaying(). The function call will return true as long as the module is playing the file. As soon as it returns false, you know the current file is done and can start the next file.
Maybe install that library and use .isPlaying()
Ya I did it firstly but it had so many other issues that need to solve but will try to check with that . .
Well
I just made some changes and its here :
I firstly disable the line player.disableLoop();
then placed the drift value as 1.99 to get it multiplied with ms
Now the result is totally fine and smooth and its started working suddenly with not a single point delay
Hurrayyy !!!
But its effecting the second file in this way :
Second file after the very first file starts smoothly but runs half the length of original one for second file value
then a delay of again 1 ms
Then Second file play itself fully
then a delay of 1 ms again
then again second file plays itself fully and this time loop continues with no delay and full continuity
Just got this result !!!
I am having a doubt that this line
player.disableLoop();
& player.enableLoop();
is also creating a delay while the system is reading these commands
How can we design it using df player Fast library ?
The second file (and others) will need their own "ms*drift" calculated.
About DFPlayerMini_Fast... this link has small example about isPlaying(true)
/ isPlaying(false)
... give it a try?
Ya this enable disable loop system is totally effecting the system in a certain way there
Ya Le me go through this Fast one
what about this codes ??
# define Start_Byte 0x7E
# define Version_Byte 0xFF
# define Command_Length 0x06
# define End_Byte 0xEF
# define Acknowledge 0x00 //Returns info with command 0x41 [0x01: info, 0x00: no info]
Where it finds the usage actually ??
Those are used in their checksum at the function/method execute_CMD()
(at the bottom of the sketch). You probably do not need them and will not use them.... which is used everywhere... okay, time to look for a easier sketch...
void execute_CMD(byte CMD, byte Par1, byte Par2)
// Excecute the command and parameters
{
// Calculate the checksum (2 bytes)
word checksum =
-(Version_Byte + Command_Length + CMD + Acknowledge + Par1 + Par2);
// Build the command line
byte Command_line[10] = {Start_Byte, Version_Byte, Command_Length,
CMD, Acknowledge, Par1,
Par2, highByte(checksum), lowByte(checksum),
End_Byte};
// Send the command line to the module
for (byte k = 0; k < 10; k++) {
mySerial.write(Command_line[k]);
}
}
Ya added at bottom after void loop
so showing error msg
'Version_Byte' was not declared in this scope
So how to define
If you added the #define lines, check their spelling...
Would this solve the whole problem, without the delay() or execute_CMD()?
void loop() {
if (digitalRead(IN22) == LOW) {
player.play(1);
if (isPlaying) {
pause();
isPlaying = false;
} else {
isPlaying = true;
play();
}
}
player.play(2);
}
how to define is playing ??
is it like
boolean isPlaying = true;
????
isPlaying() is defined in the library. You only need to "call" it, as you "call" delay()
... no need to define it.
Hmm
error msg here :
DF_Player_SINGLE_INPUT_MEGA_MS_PRACTICAL_002:71:19: error: cannot convert 'bool' to 'bool()' in assignment
exit status 1
assignment of function 'bool isPlaying()'
Can you post your code here? Looks like a re-define somewhere. (be sure to click the </> code tag and paste your code where it says "paste code here")
Ok
Is this code at post 32 is designed for fast ??
or just old one . . . mini ?
The sketch you are using that gave you this recent error.
ya this one also asking for play n pause to define
Okay. You need the "fast" library installed. play(), pause() and isPlaying() are defined in DFPlayerMini_Fast.h library.