Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dosbox-staging/dosbox-staging.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Novak <jnovak@skedulo.com>2022-07-24 08:50:12 +0300
committerJohn Novak <jnovak@skedulo.com>2022-07-24 08:50:12 +0300
commit06518156da56f50c5795656f198816e6027baf2f (patch)
tree74baf2277c06344b8abd8e396649ef1129fd2409
parentd8201bcf8a894f27bfa0e0dd3967c0028d85596c (diff)
Simplify buffer swapping & scaling logicjn/remove-soft-limiter
-rw-r--r--src/midi/midi_fluidsynth.cpp17
-rw-r--r--src/midi/midi_mt32.cpp17
2 files changed, 8 insertions, 26 deletions
diff --git a/src/midi/midi_fluidsynth.cpp b/src/midi/midi_fluidsynth.cpp
index fcee59558..5bbe4ad01 100644
--- a/src/midi/midi_fluidsynth.cpp
+++ b/src/midi/midi_fluidsynth.cpp
@@ -402,19 +402,10 @@ void MidiHandlerFluidsynth::Render()
// Grab the next buffer from backstock and populate it ...
playable_buffer = backstock.Dequeue();
- // Scale and copy to playable buffer
- auto in_pos = render_buffer.begin();
- auto out_pos = playable_buffer.begin();
-
- while (in_pos != render_buffer.end()) {
- AudioFrame frame = {*in_pos++, *in_pos++};
-
- frame.left *= INT16_MAX;
- frame.right *= INT16_MAX;
-
- *out_pos++ = frame.left;
- *out_pos++ = frame.right;
- }
+ // Swap buffers & scale
+ std::swap(render_buffer, playable_buffer);
+ for (auto &s : playable_buffer)
+ s *= INT16_MAX;
// and then move it into the playable queue
playable.Enqueue(std::move(playable_buffer));
diff --git a/src/midi/midi_mt32.cpp b/src/midi/midi_mt32.cpp
index d3f4566b0..bc911d912 100644
--- a/src/midi/midi_mt32.cpp
+++ b/src/midi/midi_mt32.cpp
@@ -690,19 +690,10 @@ void MidiHandler_mt32::Render()
// Grab the next buffer from backstock and populate it ...
playable_buffer = backstock.Dequeue();
- // Scale and copy to playable buffer
- auto in_pos = render_buffer.begin();
- auto out_pos = playable_buffer.begin();
-
- while (in_pos != render_buffer.end()) {
- AudioFrame frame = {*in_pos++, *in_pos++};
-
- frame.left *= INT16_MAX;
- frame.right *= INT16_MAX;
-
- *out_pos++ = frame.left;
- *out_pos++ = frame.right;
- }
+ // Swap buffers & scale
+ std::swap(render_buffer, playable_buffer);
+ for (auto &s : playable_buffer)
+ s *= INT16_MAX;
// and then move it into the playable queue
playable.Enqueue(std::move(playable_buffer));