From 774815a97901fe9d5ce2767a8c479c52a5ad0ce8 Mon Sep 17 00:00:00 2001 From: - Date: Thu, 9 May 2013 17:54:45 +0200 Subject: Lazy load of audio. Unloads when there's nothing else to do. --- src/drumgizmo.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/drumgizmo.cc') 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; } -- cgit v1.2.3