diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-08-03 20:02:04 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-08-05 16:19:57 +0200 |
commit | a0e2b9398a06ca2ea164c2ffd6fd89f713b93598 (patch) | |
tree | f070de47673f32903eae30ddbc57232e2b13db4e /test/dgreftest | |
parent | ea743668192e0921ab46d5e863df5b754ce82656 (diff) |
Add support for partial buffers in cache and rendering engine - fixes dropouts on framesize changes for example when looping.
Diffstat (limited to 'test/dgreftest')
-rw-r--r-- | test/dgreftest/compareoutputengine.cc | 21 | ||||
-rw-r--r-- | test/dgreftest/compareoutputengine.h | 2 | ||||
-rw-r--r-- | test/dgreftest/dgreftest.cc | 24 |
3 files changed, 39 insertions, 8 deletions
diff --git a/test/dgreftest/compareoutputengine.cc b/test/dgreftest/compareoutputengine.cc index 33dfe2a..04145b0 100644 --- a/test/dgreftest/compareoutputengine.cc +++ b/test/dgreftest/compareoutputengine.cc @@ -33,6 +33,7 @@ CompareOutputEngine::CompareOutputEngine() , info{} , file{"output"} { + info = {}; info.samplerate = 44100; info.channels = 1; info.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT; @@ -44,9 +45,9 @@ CompareOutputEngine::~CompareOutputEngine() sf_close(handle); } -bool CompareOutputEngine::init(const Channels& data) +bool CompareOutputEngine::init(const Channels& channels) { - info.channels = data.size(); + info.channels = channels.size(); handle = sf_open(file.c_str(), SFM_READ, &info); if(handle == nullptr) @@ -116,8 +117,11 @@ void CompareOutputEngine::run(int ch, sample_t* samples, size_t nsamples) void CompareOutputEngine::post(size_t nsamples) { - sample_t ref_buffer[sizeof(buffer) / sizeof(sample_t)]; - sf_readf_float(handle, ref_buffer, nsamples); + nsamples = sf_readf_float(handle, ref_buffer, nsamples); + if(nsamples == 0) + { + return; + } for(std::size_t i = 0; i < nsamples; ++i) { @@ -126,10 +130,17 @@ void CompareOutputEngine::post(size_t nsamples) if(buffer[i * info.channels + ch] != ref_buffer[i * info.channels + ch]) { ++diff_samples; + + // Use this to quit on first bad sample. + //std::cerr << "ch: " << ch << ", pos: " << pos + i << + // " expected: " << ref_buffer[i * info.channels + ch] << + // " got: " << buffer[i * info.channels + ch] << std::endl; + //exit(1); + } } } - + pos += nsamples; } size_t CompareOutputEngine::getSamplerate() const diff --git a/test/dgreftest/compareoutputengine.h b/test/dgreftest/compareoutputengine.h index a82116c..89a3a83 100644 --- a/test/dgreftest/compareoutputengine.h +++ b/test/dgreftest/compareoutputengine.h @@ -53,4 +53,6 @@ private: std::string file; sample_t buffer[4096 * 16]; std::size_t diff_samples{0}; + sample_t ref_buffer[sizeof(buffer) / sizeof(sample_t)]; + size_t pos{0}; }; diff --git a/test/dgreftest/dgreftest.cc b/test/dgreftest/dgreftest.cc index ea38091..a4eb897 100644 --- a/test/dgreftest/dgreftest.cc +++ b/test/dgreftest/dgreftest.cc @@ -135,14 +135,32 @@ int main(int argc, char* argv[]) size_t nsamples = oe->getBufferSize(); sample_t *samples = (sample_t *)malloc(nsamples * sizeof(sample_t)); - drumgizmo.setFrameSize(oe->getBufferSize()); + drumgizmo.setFrameSize(nsamples); ie.start(); oe->start(); - while(drumgizmo.run(pos, samples, nsamples) == true) + size_t framesize = nsamples; + int dir = -1; + while(drumgizmo.run(pos, samples, framesize) == true) { - pos += nsamples; + pos += framesize; + + framesize += dir; + + if(framesize < 1) + { + framesize = 1; + dir = 1; + } + + if(framesize >= nsamples) + { + framesize = nsamples; + dir = -1; + } + + drumgizmo.setFrameSize(framesize); } ie.stop(); |