diff options
author | - <nemo@alice.(none)> | 2013-05-09 17:54:45 +0200 |
---|---|---|
committer | - <nemo@alice.(none)> | 2013-05-09 17:54:45 +0200 |
commit | 774815a97901fe9d5ce2767a8c479c52a5ad0ce8 (patch) | |
tree | 325793f2c2f76d2efe3af3d980005d074af035f8 /src/drumgizmo.cc | |
parent | a4d73c0cb2321bd61bd31d2922ae469389e5825e (diff) |
Lazy load of audio. Unloads when there's nothing else to do.
Diffstat (limited to 'src/drumgizmo.cc')
-rw-r--r-- | src/drumgizmo.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 72b3811..df2fd31 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -331,6 +331,10 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) while(j != kit.channels.end()) { Channel &ch = *j; AudioFile *af = s->getAudioFile(&ch); + if(af) { + printf("Requesting preparing of audio file\n"); + loader.prepare(af); + } if(af == NULL || !af->isValid()) { //printf("Missing AudioFile.\n"); } else { @@ -364,6 +368,7 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) } if(buf) { memset(buf, 0, nsamples * sizeof(sample_t)); + getSamples(c, pos, buf, nsamples); if(!internal) oe->run(c, samples, nsamples); } @@ -426,8 +431,9 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz) if(evt->rampdown == NO_RAMPDOWN) { #ifdef SSE - size_t optend = ((end - n) / N) * N + n; - for(; n < optend; n += N) { +// printf("%d\n", evt->t); fflush(stdout); + size_t optend = ((end - n) / N) * N + n; + for(; n < optend; n += N) { *(vNsf*)&(s[n]) += *(vNsf*)&(af->data[evt->t]); evt->t += N; } @@ -446,7 +452,10 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz) } - if(evt->t >= af->size) removeevent = true; + if(evt->t >= af->size) { + removeevent = true; + loader.reset(af); + } } break; } |