summaryrefslogtreecommitdiff
path: root/src/audiofile.h
diff options
context:
space:
mode:
author- <nemo@alice.(none)>2013-05-09 17:54:45 +0200
committer- <nemo@alice.(none)>2013-05-09 17:54:45 +0200
commit774815a97901fe9d5ce2767a8c479c52a5ad0ce8 (patch)
tree325793f2c2f76d2efe3af3d980005d074af035f8 /src/audiofile.h
parenta4d73c0cb2321bd61bd31d2922ae469389e5825e (diff)
Lazy load of audio. Unloads when there's nothing else to do.
Diffstat (limited to 'src/audiofile.h')
-rw-r--r--src/audiofile.h49
1 files changed, 48 insertions, 1 deletions
diff --git a/src/audiofile.h b/src/audiofile.h
index e4b8410..d203781 100644
--- a/src/audiofile.h
+++ b/src/audiofile.h
@@ -29,10 +29,44 @@
#include <string>
#include <map>
+#include <vector>
+
+#include <sndfile.h>
#include "mutex.h"
#include "audio.h"
+#if 0
+ Plan for lazy loading of audio (Brainstorming)
+ * Encapsulate data array?
+ - Speed issues?
+ - Other suggestion
+ * Trigger on read begin and read done
+ - readnext(instrument)?
+ * size_t current latest loaded sample
+ * run in own thread? threads in drumgizmo??
+ - Add soundfile-loader-class which run in its own thread
+ * Add pre-loading constant
+ * Pointer to pos in audio stream (maybe just last position read)
+ * Strategy for how to handle pre-loading of remaining file
+ - Is it acceptable only to handle sequential reading of data (no random access)?
+
+ Thread A Thread B
+
+ :preload constant (user defined)
+ :speed modifier constant (in which time must
+ sample n be loaded relative to trigger time)
+ ---------- ------
+ | Loader | <------- Trigger load of InstrumentSample n --------- | DG |
+ ---------- ------
+ Load (int- right most loaded sample --> If current sample pos loaded
+ | --------- | |
+ Wave Into --> | SndFile | <----- Read data (directly from array)
+ ---------
+#endif/*0*/
+
+#define LAZYLOAD
+
class AudioFile {
public:
AudioFile(std::string filename);
@@ -43,12 +77,25 @@ public:
bool isLoaded();
- sample_t *data;
size_t size;
+
+ sample_t *data;
std::string filename;
+ bool locked;
+#ifdef LAZYLOAD
+ SF_INFO sf_info;
+ SNDFILE *fh;
+ bool completely_loaded;
+ void init();
+ void reset();
+ void loadNext();
+ sample_t* preloaded_data;
+#endif/*LAZYLOAD*/
+
bool isValid();
+ int ref_count;
private:
void *magic;