28 lines
475 B
C++
28 lines
475 B
C++
#include <stdio.h>
|
|||
|
|
#include <stdint.h>
|
||
|
|
|
||
|
|
class AudioSourceFile {
|
||
|
|
public:
|
||
|
|
FILE* fp;
|
||
|
|
|
||
|
|
AudioSourceFile(const char* path) {
|
||
|
|
fp = fopen(path, "rb");
|
||
|
|
}
|
||
|
|
|
||
|
|
int read(uint8_t* buf, int len) {
|
||
|
|
if (!fp) return 0;
|
||
|
|
return fread(buf, 1, len, fp);
|
||
|
|
}
|
||
|
|
|
||
|
|
void seek(int offset) {
|
||
|
|
if (fp) fseek(fp, offset, SEEK_SET);
|
||
|
|
}
|
||
|
|
|
||
|
|
bool isOpen() {
|
||
|
|
return fp != nullptr;
|
||
|
|
}
|
||
|
|
|
||
|
|
~AudioSourceFile() {
|
||
|
|
if (fp) fclose(fp);
|
||
|
|
}
|
||
|
|
};
|