diff options
Diffstat (limited to 'drumgizmo')
-rw-r--r-- | drumgizmo/drumgizmoc.cc | 19 | ||||
-rw-r--r-- | drumgizmo/output/alsa/alsa.cc | 12 |
2 files changed, 30 insertions, 1 deletions
diff --git a/drumgizmo/drumgizmoc.cc b/drumgizmo/drumgizmoc.cc index d6fea9e..612973f 100644 --- a/drumgizmo/drumgizmoc.cc +++ b/drumgizmo/drumgizmoc.cc @@ -322,6 +322,8 @@ int CliMain::run(int argc, char *argv[]) DrumGizmo gizmo(oe, ie); + gizmo.setFrameSize(oe->getBufferSize()); + if(kitfile == "" || !gizmo.loadkit(kitfile)) { printf("Failed to load \"%s\".\n", kitfile.c_str()); return 1; @@ -349,7 +351,22 @@ int CliMain::run(int argc, char *argv[]) return 1; } - gizmo.run(endpos); + size_t pos = 0; + size_t nsamples = oe->getBufferSize(); + sample_t *samples = (sample_t *)malloc(nsamples * sizeof(sample_t)); + + ie->start(); + oe->start(); + + while(gizmo.run(pos, samples, nsamples) == true) { + pos += nsamples; + if(endpos != -1 && pos >= (size_t)endpos) break; + } + + ie->stop(); + oe->stop(); + + free(samples); printf("Quit.\n"); fflush(stdout); diff --git a/drumgizmo/output/alsa/alsa.cc b/drumgizmo/output/alsa/alsa.cc index dc2ac73..0de3cdb 100644 --- a/drumgizmo/output/alsa/alsa.cc +++ b/drumgizmo/output/alsa/alsa.cc @@ -49,6 +49,7 @@ public: void pre(size_t size); void run(int channel, sample_t* data, size_t size); void post(size_t size); + size_t bufsize(); size_t samplerate(); private: @@ -158,6 +159,11 @@ void Alsa::post(size_t size) snd_pcm_writei(handle, data, size); } +size_t Alsa::bufsize() +{ + return frames; +} + size_t Alsa::samplerate() { return srate; @@ -217,6 +223,12 @@ extern "C" { alsa->post(s); } + size_t bufsize(void *h) + { + Alsa *alsa = (Alsa*)h; + return alsa->bufsize(); + } + size_t samplerate(void *h) { Alsa *alsa = (Alsa*)h; |