diff options
author | 2020-09-17 00:45:29 -0700 | |
---|---|---|
committer | 2020-09-17 00:46:06 -0700 | |
commit | dc0ede3c90717ed25de0695c555b861f06344f18 (patch) | |
tree | cbc28d80cb2ebe963a3b068148aa78e4ebdaa6ce /src/devices/sound/samples.cpp | |
parent | 4118f19c48ceaa71c1aa6ab8b1a34e8907c98563 (diff) |
sound: Improved view interfaces to match usage patterns
* read/write_stream_views now have an internal index
* get/put/add/fill/copy now implicitly use and advance this index
* new method reset() can (re)set the internal index
* new method done() checks if index is past the end
* new method remaining() indicates how many samples remain
* get_indexed/put_indexed/etc available for random access
* updated all consumers to new interfaces
Diffstat (limited to 'src/devices/sound/samples.cpp')
-rw-r--r-- | src/devices/sound/samples.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/devices/sound/samples.cpp b/src/devices/sound/samples.cpp index 5c8d129b799..bfe7c02bb6b 100644 --- a/src/devices/sound/samples.cpp +++ b/src/devices/sound/samples.cpp @@ -334,7 +334,7 @@ void samples_device::sound_stream_update(sound_stream &stream, std::vector<read_ double endpos = chan.source_len; const int16_t *sample = chan.source; - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + while (!buffer.done()) { // do a linear interp on the sample double pos_floor = floor(chan.pos); @@ -343,7 +343,7 @@ void samples_device::sound_stream_update(sound_stream &stream, std::vector<read_ stream_buffer::sample_t sample1 = stream_buffer::sample_t(sample[ipos++]); stream_buffer::sample_t sample2 = stream_buffer::sample_t(sample[(ipos + 1) % chan.source_len]); - buffer.put(sampindex, sample_scale * ((1.0 - frac) * sample1 + frac * sample2)); + buffer.put(sample_scale * ((1.0 - frac) * sample1 + frac * sample2)); // advance chan.pos += step; @@ -357,7 +357,7 @@ void samples_device::sound_stream_update(sound_stream &stream, std::vector<read_ { chan.source = nullptr; chan.source_num = -1; - buffer.fill(0, sampindex); + buffer.fill(0); break; } } |