Arduino STK 4.6.2
MemoryFS.h
1#include "Stk.h"
2#ifdef __RAW_ARRAYS__
3#ifndef MEMORYFS_H
4#define MEMORYFS_H
5
6#include "Stk.h"
7#if defined(ESP32)
8# include "esp_system.h"
9# include "esp32-hal-log.h"
10# include "pgmspace.h"
11#elif defined(IS_DESKTOP)
12# ifndef memcpy_P
13# define memcpy_P memcpy
14# endif
15#elif defined(ESP8266)
16# include "pgmspace.h"
17#elif defined(ARDUINO) && __has_include(<pgmspace.h>)
18# include <pgmspace.h>
19#endif
20
21#ifndef USE_RAM_DEFAUT
22# define USE_RAM_DEFAUT false
23#endif
24
25#define VFS_INC_SIZE 10
26#ifndef MIN
27#define MIN(a,b) ((a) < (b) ? (a) : (b))
28#endif
29
30namespace stk {
31
33struct VFS_FD;
34extern VFS_FD **registry;
35extern int registry_last_entry;
36extern bool registry_use_ram;
37
38/***************************************************/
51/***************************************************/
52class MemoryFS {
53 public:
54 MemoryFS(const unsigned char *raw=NULL, unsigned int size=0, int bytesPerSample=2, bool swapBytes=true);
55 MemoryFS (const char* fileName);
56
58 static VFS_FD * registerFile(const char* fileName, const unsigned char *raw, unsigned int size);
60 bool open(const char* fileName, int bytesPerSample=2);
62 //VFS_FD* getFD();
64 size_t getSize();
66 void close();
68 bool isOpen();
70 bool fileRead( StkFrames& buffer, unsigned long startFrame, bool doNormalize) ;
72 static void reset();
74 static void useRAM(bool ram) {
75 registry_use_ram = ram;
76 }
77 size_t current_pos_; // current read position in the memory in samples
78
79
80 protected:
81 long fileSize_ = 0;;
82 int16_t *data_ = nullptr;
83 bool swapBytes = true;
84 bool is_open = false;
85
86 static VFS_FD* findByName(const char * path);
87};
88
89}
90
91#endif
92#endif
static VFS_FD * registerFile(const char *fileName, const unsigned char *raw, unsigned int size)
makes the file available so that the open (by name) operation is working
void close()
sets to open flag to false
size_t getSize()
Returns a descriptor with additional information.
static void reset()
Clears all stored tables.
bool fileRead(StkFrames &buffer, unsigned long startFrame, bool doNormalize)
Reads the data into the buffer at the indicated start frame.
static void useRAM(bool ram)
Defines if the audio data is copied from progmem to RAM.
Definition MemoryFS.h:74
bool open(const char *fileName, int bytesPerSample=2)
opens the indicated file
bool isOpen()
checks if the file has been opened
An STK class to handle vectorized audio data.
Definition Stk.h:287
The STK namespace.
Definition ADSR.h:8