How can I record a voice at a custom time? #309
-
#define RECORD_TIME (5) //Seconds int16_t sBuffer[FLASH_RECORD_SIZE ]; What to do next? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You can use millis() which provides the time in milliseconds since the start of the microcontroller. Then you just copy the audio data when millis()>start && millis<end; If you want to use time in hours and minutes you will need to install an NTP library or RTC module: Google will help you! |
Beta Was this translation helpful? Give feedback.
-
hi #include <Arduino.h> float sBuffer[FLASH_RECORD_SIZE]; I2SStream i2s; // Output to I2S ... |
Beta Was this translation helpful? Give feedback.
-
You don't need the StreamCopyT. Just read the bytes from i2s like you would do it e.g. with files:
Please note that you get an array with in16_t values, so you will need to convert it to floats yourself. Audio float samples are usually scaled so that they are in the range of -1.0 and +1.0. |
Beta Was this translation helpful? Give feedback.
You can use millis() which provides the time in milliseconds since the start of the microcontroller.
uint64_t now = millis();
uint64_t start = now + 5000; // in 5 seconds
uint64_t end = now + 15000; // in 15 seconds
Then you just copy the audio data when millis()>start && millis<end;
If you copy to a file you need to add some additional logic to close the file (only once!) when it is done.
If you want to use time in hours and minutes you will need to install an NTP library or RTC module: Google will help you!