-
Notifications
You must be signed in to change notification settings - Fork 14
/
patch_manager.ino
788 lines (679 loc) · 20.3 KB
/
patch_manager.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
/*
* Copyright (c) 2023 Marcel Licence
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Dieses Programm ist Freie Software: Sie können es unter den Bedingungen
* der GNU General Public License, wie von der Free Software Foundation,
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder neueren
* veröffentlichten Version, weiter verteilen und/oder modifizieren.
*
* Dieses Programm wird in der Hoffnung bereitgestellt, dass es nützlich sein wird, jedoch
* OHNE JEDE GEWÄHR,; sogar ohne die implizite
* Gewähr der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
* Siehe die GNU General Public License für weitere Einzelheiten.
*
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
* Programm erhalten haben. Wenn nicht, siehe <https://www.gnu.org/licenses/>.
*/
/*
* this file contains the implementation of the "patch" manager
* It allows loading and saving the samples including parameters
*
* Saved data will appear as pairs: .wav and .bin
* The parameters are in the .bin file
*
* Hot swap of sd card is supported. SD is busy only during read/write operation
*
* Support of loading wav files without parameters
* - in case no parameters are existing default values are used
*
* only signed 16 bit wav files are supported at the moment
* sampleRate is ignored -> you can pitch it afterwards
*
* Author: Marcel Licence
*/
#ifdef __CDT_PARSER__
#include <cdt.h>
#endif
#include <FS.h>
#ifdef USE_SPIFFS_LEGACY
#include <SPIFFS.h> /* Using library SPIFFS at version 1.0 from https://github.com/espressif/arduino-esp32 */
#define LittleFS SPIFFS
#else /* USE_SPIFFS_LEGACY */
#include <FS.h>
#ifdef ARDUINO_RUNNING_CORE /* tested with arduino esp32 core version 2.0.2 */
#include <LittleFS.h> /* Using library LittleFS at version 2.0.0 from https://github.com/espressif/arduino-esp32 */
#else
#include <LITTLEFS.h> /* Using library LittleFS_esp32 at version 1.0.6 from https://github.com/lorol/LITTLEFS */
#define LittleFS LITTLEFS
#endif
#endif /* USE_SPIFFS_LEGACY */
#include <SD_MMC.h>
#define FST fs::FS
enum patchDst
{
patch_dest_littlefs,
patch_dest_sd_mmc,
};
struct patchParamV0_s
{
float pitch;
float loop_start;
float loop_end;
};
struct patchParamV1_s
{
float attack;
float decay;
float sustain;
float release;
};
struct patchParam_s
{
union
{
struct
{
uint32_t version;
struct patchParamV0_s patchParamV0;
struct patchParamV1_s patchParamV1;
};
uint8_t buffer[512]; /*! raw data */
};
char filename[64];
};
/*
* union is very handy for easy conversion of bytes to the wav header information
*/
union wavHeader
{
struct
{
char riff[4]; /*!< 'RIFF' */
uint32_t fileSize; /*!< bytes to write containing all data (header + data) */
char waveType[4]; /*!< 'WAVE' */
char format[4]; /*!< 'fmt ' */
uint32_t lengthOfData; /*!< length of the fmt header (16 bytes) */
uint16_t format_tag; /*!< 0x0001: PCM */
uint16_t numberOfChannels; /*!< 'WAVE' */
uint32_t sampleRate;
uint32_t byteRate;
uint16_t bytesPerSample;
uint16_t bitsPerSample;
char dataStr[4];
uint32_t dataSize; /* 22052 */
};
uint8_t wavHdr[44];
};
static void PatchManager_SaveWavefile(FST &fs, char *filename, int16_t *buffer, uint32_t bufferSize);
static void PatchManager_FilenameFromIdx(FST &fs, const char *dirname, uint8_t index);
static int PatchManager_GetFileList(FST &fs, const char *dirname, void(*fileInd)(char *filename, int offset), int offset);
static uint32_t PatchManager_LoadWavefile(FST &fs, char *filename, int16_t *buffer, uint32_t bufferSize);
static void PatchManager_CreateDir(FST &fs, const char *path);
static void PatchManager_SavePatchParam(FST &fs, char *filename, struct patchParam_s *patchParam);
static void PatchManager_LoadPatchParam(FST &fs, char *filename, struct patchParam_s *patchParam);
static void PatchManager_CreateNewFileNames(FST &fs);
uint32_t patch_selectedFileIndex = 0;
char currentFileNameWav[64] = "/samples/testSample.wav\0";
char currentFileNameBin[64] = "/samples/testSample.bin\0";
enum patchDst patchManagerDest = patch_dest_littlefs;
/*
* last written files
*/
char wavNewFileName[64];
char parNewFileName[64];
void PatchManager_Init(void)
{
/* nothing to do */
}
static int PatchManager_GetFileList(FST &fs, const char *dirname, void(*fileInd)(char *filename, int offset), int offset)
{
#ifdef PATCHMANAGER_DEBUG
Serial.printf("Listing directory: %s\n", dirname);
#endif
File root = fs.open(dirname);
if (!root)
{
Status_LogMessage("Failed to open directory");
return 0;
}
if (!root.isDirectory())
{
Status_LogMessage("Not a directory");
return 0;
}
File file = root.openNextFile();
int foundFiles = 0;
while (file)
{
if (file.isDirectory())
{
#if 0
Serial.print(" DIR : ");
Serial.println(file.name());
#endif
}
else
{
#if 0
Serial.printf("%03d - FILE: ", patch_selectedFileIndex);
Serial.print(file.name());
Serial.print(" SIZE: ");
Serial.println(file.size());
#endif
strcpy(currentFileNameWav, file.name());
strcpy(currentFileNameBin, file.name());
strcpy(¤tFileNameBin[strlen(currentFileNameBin) - 3], "bin");
if (strcmp(".wav", &file.name()[strlen(file.name()) - 4]) == 0)
{
#if 0
Serial.printf("ignore %s, %s\n", ".wav", &file.name()[strlen(file.name()) - 4]);
#endif
if (offset > 0)
{
offset--;
}
else
{
fileInd(currentFileNameWav, foundFiles++);
}
}
}
file = root.openNextFile();
}
return foundFiles;
}
int PatchManager_GetFileListExt(void(*fileInd)(char *filename, int offset), int offset)
{
if (patchManagerDest == patch_dest_sd_mmc)
{
if (PatchManager_PrepareSdCard())
{
return PatchManager_GetFileList(SD_MMC, "/samples", fileInd, offset);
}
}
#ifdef ESP32
else
{
if (PatchManager_PrepareLittleFs())
{
return PatchManager_GetFileList(LittleFS, "/samples", fileInd, offset);
}
}
#endif
return 0;
}
static void PatchManager_FilenameFromIdx(FST &fs, const char *dirname, uint8_t index)
{
#ifdef PATCHMANAGER_DEBUG
Serial.printf("Listing directory: %s\n", dirname);
#endif
File root = fs.open(dirname);
if (!root)
{
Status_LogMessage("Failed to open directory");
return;
}
if (!root.isDirectory())
{
Status_LogMessage("Not a directory");
return;
}
File file = root.openNextFile();
patch_selectedFileIndex = 0;
while (file)
{
if (file.isDirectory())
{
#if 0
Serial.print(" DIR : ");
Serial.println(file.name());
#endif
}
else
{
#if 0
Serial.printf("%03d - FILE: ", patch_selectedFileIndex);
Serial.print(file.name());
Serial.print(" SIZE: ");
Serial.println(file.size());
#endif
strcpy(currentFileNameWav, file.name());
strcpy(currentFileNameBin, file.name());
strcpy(¤tFileNameBin[strlen(currentFileNameBin) - 3], "bin");
if (strcmp(".wav", &file.name()[strlen(file.name()) - 4]) == 0)
{
#if 0
Serial.printf("ignore %s, %s\n", ".wav", &file.name()[strlen(file.name()) - 4]);
#endif
if (index > 0)
{
index--;
}
else
{
return;
}
patch_selectedFileIndex++;
}
}
file = root.openNextFile();
}
patch_selectedFileIndex--;
}
char lastSelectedFile[128] = "";
void PatchManager_UpdateFilename(void)
{
if (patchManagerDest == patch_dest_sd_mmc)
{
if (PatchManager_PrepareSdCard())
{
PatchManager_FilenameFromIdx(SD_MMC, "/samples", patch_selectedFileIndex);
#ifdef ESP32
SD_MMC.end();
#endif
#ifdef PATCHMANAGER_DEBUG
Serial.printf("Active file: %03d - %s\n", patch_selectedFileIndex, currentFileNameWav);
Serial.printf("Active file: %03d - %s\n", patch_selectedFileIndex, currentFileNameBin);
#endif
sprintf(lastSelectedFile, "SD_MMC: %s", currentFileNameWav);
Status_FileName(lastSelectedFile);
sprintf(lastSelectedFile, "%s", currentFileNameWav);
}
}
#ifdef ESP32
else
{
if (PatchManager_PrepareLittleFs())
{
PatchManager_FilenameFromIdx(LittleFS, "/samples", patch_selectedFileIndex);
LittleFS.end();
#ifdef PATCHMANAGER_DEBUG
Serial.printf("Active file: %03d - %s\n", patch_selectedFileIndex, currentFileNameWav);
Serial.printf("Active file: %03d - %s\n", patch_selectedFileIndex, currentFileNameBin);
#endif
sprintf(lastSelectedFile, "LittleFS: %s", currentFileNameWav);
Status_FileName(lastSelectedFile);
sprintf(lastSelectedFile, "%s", currentFileNameWav);
}
}
#endif
}
void PatchManager_FileIdxInc(uint8_t unused, float value)
{
if (value > 0)
{
patch_selectedFileIndex++;
PatchManager_UpdateFilename();
}
}
void PatchManager_FileIdxDec(uint8_t unused, float value)
{
if (value > 0)
{
if (patch_selectedFileIndex > 0)
{
patch_selectedFileIndex--;
}
PatchManager_UpdateFilename();
}
}
static void PatchManager_SaveWavefile(FST &fs, char *filename, int16_t *buffer, uint32_t bufferSize)
{
File f = fs.open(filename, FILE_WRITE);
if (!f)
{
Status_LogMessage("Could not create new file\n");
return;
}
uint32_t dataSizeOfbuffer = sizeof(int16_t) * bufferSize;
union wavHeader wavHeader;
memcpy(wavHeader.riff, "RIFF", 4);
wavHeader.fileSize = 44 + dataSizeOfbuffer;
memcpy(wavHeader.waveType, "WAVE", 4);
memcpy(wavHeader.format, "fmt ", 4);
wavHeader.lengthOfData = 16; /* length of the fmt header */
wavHeader.format_tag = 0x0001; /* 0x0001: PCM */
wavHeader.numberOfChannels = 1;
wavHeader.sampleRate = 44100;
wavHeader.byteRate = 44100 * 2;
wavHeader.bytesPerSample = 2;
wavHeader.bitsPerSample = 16;
memcpy(wavHeader.dataStr, "data", 4);
wavHeader.dataSize = dataSizeOfbuffer;
#ifdef ESP32
f.seek(0, SeekSet);
#else
f.seek(0);
#endif
f.write(wavHeader.wavHdr, 44);
/* avoid watchdog */
delay(1);
f.write((uint8_t *)buffer, dataSizeOfbuffer);
f.close();
/* avoid watchdog */
delay(1);
}
static uint32_t PatchManager_LoadWavefile(FST &fs, char *filename, int16_t *buffer, uint32_t bufferSize)
{
File f = fs.open(filename, FILE_READ);
if (!f)
{
Status_LogMessage("Could not read file\n");
return 0;
}
union wavHeader wavHeader;
memset(wavHeader.wavHdr, 0, sizeof(wavHeader));
#ifdef ESP32
f.seek(0, SeekSet);
#else
f.seek(0);
#endif
f.read(wavHeader.wavHdr, 44);
/* avoid watchdog */
delay(1);
uint32_t bufferIn = 0;
if (wavHeader.numberOfChannels == 1)
{
#ifdef ESP32
f.read((uint8_t *)buffer, wavHeader.dataSize);
#else
uint32_t leftSize = wavHeader.dataSize;
uint32_t bin = 0;
while (leftSize > 256)
{
f.read((uint8_t *)&buffer[bin], 256);
bin += 128; // because its int16 takes to bytes
leftSize -= 256;
}
if (leftSize > 0)
{
f.read((uint8_t *)&buffer[bin], leftSize);
}
#endif
bufferIn += wavHeader.dataSize;
}
else
{
uint32_t dataLeft = wavHeader.dataSize;
uint32_t dataRead;
while (true)
{
uint8_t tempBuffer[512];
if (dataLeft > 512)
{
dataRead = 512;
}
else
{
dataRead = dataLeft;
}
f.read(tempBuffer, dataRead);
dataLeft -= dataRead;
for (int i = 0; i < dataRead; i++)
{
/*
* reading only the left channel
* right channel will be ignored and data just skipped
*/
((uint8_t *)buffer)[bufferIn] = tempBuffer[i];
bufferIn += 1;
i += 1;
((uint8_t *)buffer)[bufferIn] = tempBuffer[i];
bufferIn += 1;
i += 1;
i += 1;
}
if (dataLeft == 0)
{
break;
}
}
}
f.close();
/* avoid watchdog */
delay(1);
return bufferIn / sizeof(int16_t);
}
static void PatchManager_CreateDir(FST &fs, const char *path)
{
Serial.printf("Creating Dir: %s\n", path);
if (fs.mkdir(path))
{
Serial.println("Dir created");
}
else
{
Status_LogMessage("mkdir failed");
}
}
bool PatchManager_PrepareSdCard(void)
{
#ifdef ESP32
if (!SD_MMC.begin("/sdcard", true)) /* makes less noise on recording! */
#else
if (!card.init(SD_DETECT_NONE))
#endif
{
Status_LogMessage("Card Mount Failed");
delay(1000);
return false;
}
#ifdef ESP32
uint8_t cardType = SD_MMC.cardType();
if (cardType == CARD_NONE)
{
Status_LogMessage("No SD card attached");
delay(1000);
return false;
}
if (cardType == CARD_MMC)
{
Status_LogMessage("Card Access: MMC");
}
else if (cardType == CARD_SD)
{
Status_LogMessage("Card Access: SDSC");
}
else if (cardType == CARD_SDHC)
{
Status_LogMessage("Card Access: SDHC");
}
else
{
Status_LogMessage("Card Access: UNKNOWN");
}
#endif
return true;
}
#ifdef ESP32
bool PatchManager_PrepareLittleFs(void)
{
if (!LittleFS.begin())
{
Status_LogMessage("LittleFS Mount Failed");
return false;
}
return true;
}
#endif
static void PatchManager_SavePatchParam(FST &fs, char *filename, struct patchParam_s *patchParam)
{
File f = fs.open(filename, FILE_WRITE);
if (!f)
{
Status_LogMessage("Could not create new file\n");
return;
}
f.write((uint8_t *)patchParam, sizeof(*patchParam));
f.close();
}
static void PatchManager_LoadPatchParam(FST &fs, char *filename, struct patchParam_s *patchParam)
{
File f = fs.open(filename, FILE_READ);
if (!f)
{
#ifdef PATCHMANAGER_DEBUG
Serial.printf("No patch parameter\nUsing default values\n");
#endif
patchParam->version = 0;
patchParam->patchParamV0.pitch = 1;
patchParam->patchParamV0.loop_start = 0;
patchParam->patchParamV0.loop_end = 9999999; /* using sample length would be better */
patchParam->patchParamV1.attack = 1;
patchParam->patchParamV1.decay = 1;
patchParam->patchParamV1.release = 0;
patchParam->patchParamV1.sustain = 1;
return;
}
f.read((uint8_t *)patchParam, sizeof(*patchParam));
#ifdef PATCHMANAGER_DEBUG
Serial.printf("patchParam:\n");
Serial.printf(" version: %d\n", patchParam->version);
Serial.printf(" pitch: %0.06f\n", patchParam->patchParamV0.pitch);
Serial.printf(" loop_start: %0.06f\n", patchParam->patchParamV0.loop_start);
Serial.printf(" loop_end: %0.06f\n", patchParam->patchParamV0.loop_end);
if (patchParam->version >= 1)
{
Serial.printf(" attack: %0.06f\n", patchParam->patchParamV1.attack);
Serial.printf(" decay: %0.06f\n", patchParam->patchParamV1.decay);
Serial.printf(" sustain: %0.06f\n", patchParam->patchParamV1.sustain);
Serial.printf(" release: %0.06f\n", patchParam->patchParamV1.release);
}
#endif
f.close();
}
void PatchManager_SetDestination(uint8_t destination, float value)
{
if (value > 0)
{
switch (destination)
{
case 0:
patchManagerDest = patch_dest_littlefs;
Status_TestMsg("Patch storage: little fs");
break;
case 1:
patchManagerDest = patch_dest_sd_mmc;
Status_TestMsg("Patch storage: sd mmc");
break;
}
PatchManager_UpdateFilename();
}
}
static void PatchManager_CreateNewFileNames(FST &fs)
{
int i = 0;
while (true)
{
sprintf(wavNewFileName, "/samples/newSample%03d.wav", i);
sprintf(parNewFileName, "/samples/newSample%03d.bin", i);
if (fs.exists(wavNewFileName))
{
i++;
continue;
}
if (fs.exists(parNewFileName))
{
i++;
continue;
}
break;
}
}
void PatchManager_SaveNewPatch(struct patchParam_s *patchParam, int16_t *buffer, int bufferSize)
{
if (patchManagerDest == patch_dest_sd_mmc)
{
if (PatchManager_PrepareSdCard())
{
PatchManager_CreateDir(SD_MMC, "/samples");
PatchManager_CreateNewFileNames(SD_MMC);
PatchManager_SavePatchParam(SD_MMC, parNewFileName, patchParam);
PatchManager_SaveWavefile(SD_MMC, wavNewFileName, buffer, bufferSize);
#ifdef ESP32
SD_MMC.end();
#endif
#ifdef PATCHMANAGER_DEBUG
Serial.printf("Written %d to %s on SD_MMC\n", bufferSize, wavFileName);
#else
Status_ValueChangedInt("Written to SD_MMC", bufferSize);
#endif
}
}
#ifdef ESP32
else
{
if (PatchManager_PrepareLittleFs())
{
PatchManager_CreateDir(LittleFS, "/samples");
PatchManager_CreateNewFileNames(LittleFS);
PatchManager_SavePatchParam(LittleFS, parNewFileName, patchParam);
PatchManager_SaveWavefile(LittleFS, wavNewFileName, buffer, bufferSize);
LittleFS.end();
#ifdef PATCHMANAGER_DEBUG
Serial.printf("Written %d to %s on LittleFS\n", bufferSize, wavFileName);
#else
Status_ValueChangedInt("Written to LittleFS", bufferSize);
#endif
}
}
#endif
}
void PatchManager_SetFilename(const char *filename)
{
strcpy(currentFileNameWav, filename);
strcpy(currentFileNameBin, filename);
strcpy(¤tFileNameBin[strlen(currentFileNameBin) - 3], "bin");
}
uint32_t PatchManager_LoadPatch(struct patchParam_s *patchParam, int16_t *buffer, int bufferSize)
{
memset(patchParam, 0, sizeof(*patchParam));
uint32_t readBufferBytes = 0 ;
if (patchManagerDest == patch_dest_sd_mmc)
{
if (PatchManager_PrepareSdCard())
{
PatchManager_LoadPatchParam(SD_MMC, currentFileNameBin, patchParam);
readBufferBytes = PatchManager_LoadWavefile(SD_MMC, currentFileNameWav, buffer, bufferSize);
#ifdef ESP32
SD_MMC.end();
#endif
#ifdef PATCHMANAGER_DEBUG
Serial.printf("Read %d from %s on SD_MMC\n", readBufferBytes, currentFileNameWav);
#else
Status_ValueChangedInt("Read from SD_MMC", readBufferBytes);
#endif
}
}
#ifdef ESP32
else
{
if (PatchManager_PrepareLittleFs())
{
PatchManager_LoadPatchParam(LittleFS, currentFileNameBin, patchParam);
readBufferBytes = PatchManager_LoadWavefile(LittleFS, currentFileNameWav, buffer, bufferSize);
LittleFS.end();
#ifdef PATCHMANAGER_DEBUG
Serial.printf("Read %d from %s on LittleFS\n", readBufferBytes, currentFileNameWav);
#else
Status_ValueChangedInt("Read from LittleFS", readBufferBytes);
#endif
}
}
#endif
memcpy(patchParam->filename, currentFileNameBin, sizeof(patchParam->filename));
return readBufferBytes;
}