summaryrefslogtreecommitdiffstats
path: root/src/audio_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio_core')
-rw-r--r--src/audio_core/hle/filter.h2
-rw-r--r--src/audio_core/hle/source.cpp44
-rw-r--r--src/audio_core/hle/source.h2
-rw-r--r--src/audio_core/interpolate.h2
-rw-r--r--src/audio_core/sink.h2
-rw-r--r--src/audio_core/time_stretch.h2
6 files changed, 40 insertions, 14 deletions
diff --git a/src/audio_core/hle/filter.h b/src/audio_core/hle/filter.h
index 4281a5898..5350e2857 100644
--- a/src/audio_core/hle/filter.h
+++ b/src/audio_core/hle/filter.h
@@ -27,7 +27,7 @@ public:
* See also: SourceConfiguration::Configuration::simple_filter_enabled,
* SourceConfiguration::Configuration::biquad_filter_enabled.
* @param simple If true, enables the simple filter. If false, disables it.
- * @param simple If true, enables the biquad filter. If false, disables it.
+ * @param biquad If true, enables the biquad filter. If false, disables it.
*/
void Enable(bool simple, bool biquad);
diff --git a/src/audio_core/hle/source.cpp b/src/audio_core/hle/source.cpp
index 2bbf7146e..92484c526 100644
--- a/src/audio_core/hle/source.cpp
+++ b/src/audio_core/hle/source.cpp
@@ -158,6 +158,14 @@ void Source::ParseConfig(SourceConfiguration::Configuration& config,
static_cast<size_t>(state.mono_or_stereo));
}
+ u32_dsp play_position = {};
+ if (config.play_position_dirty && config.play_position != 0) {
+ config.play_position_dirty.Assign(0);
+ play_position = config.play_position;
+ // play_position applies only to the embedded buffer, and defaults to 0 w/o a dirty bit
+ // This will be the starting sample for the first time the buffer is played.
+ }
+
if (config.embedded_buffer_dirty) {
config.embedded_buffer_dirty.Assign(0);
state.input_queue.emplace(Buffer{
@@ -171,9 +179,18 @@ void Source::ParseConfig(SourceConfiguration::Configuration& config,
state.mono_or_stereo,
state.format,
false,
+ play_position,
+ false,
});
- LOG_TRACE(Audio_DSP, "enqueuing embedded addr=0x%08x len=%u id=%hu",
- config.physical_address, config.length, config.buffer_id);
+ LOG_TRACE(Audio_DSP, "enqueuing embedded addr=0x%08x len=%u id=%hu start=%u",
+ config.physical_address, config.length, config.buffer_id,
+ static_cast<u32>(config.play_position));
+ }
+
+ if (config.loop_related_dirty && config.loop_related != 0) {
+ config.loop_related_dirty.Assign(0);
+ LOG_WARNING(Audio_DSP, "Unhandled complex loop with loop_related=0x%08x",
+ static_cast<u32>(config.loop_related));
}
if (config.buffer_queue_dirty) {
@@ -192,6 +209,8 @@ void Source::ParseConfig(SourceConfiguration::Configuration& config,
state.mono_or_stereo,
state.format,
true,
+ {}, // 0 in u32_dsp
+ false,
});
LOG_TRACE(Audio_DSP, "enqueuing queued %zu addr=0x%08x len=%u id=%hu", i,
b.physical_address, b.length, b.buffer_id);
@@ -247,18 +266,18 @@ bool Source::DequeueBuffer() {
if (state.input_queue.empty())
return false;
- const Buffer buf = state.input_queue.top();
- state.input_queue.pop();
+ Buffer buf = state.input_queue.top();
+
+ // if we're in a loop, the current sound keeps playing afterwards, so leave the queue alone
+ if (!buf.is_looping) {
+ state.input_queue.pop();
+ }
if (buf.adpcm_dirty) {
state.adpcm_state.yn1 = buf.adpcm_yn[0];
state.adpcm_state.yn2 = buf.adpcm_yn[1];
}
- if (buf.is_looping) {
- LOG_ERROR(Audio_DSP, "Looped buffers are unimplemented at the moment");
- }
-
const u8* const memory = Memory::GetPhysicalPointer(buf.physical_address);
if (memory) {
const unsigned num_channels = buf.mono_or_stereo == MonoOrStereo::Stereo ? 2 : 1;
@@ -305,10 +324,13 @@ bool Source::DequeueBuffer() {
break;
}
- state.current_sample_number = 0;
- state.next_sample_number = 0;
+ // the first playthrough starts at play_position, loops start at the beginning of the buffer
+ state.current_sample_number = (!buf.has_played) ? buf.play_position : 0;
+ state.next_sample_number = state.current_sample_number;
state.current_buffer_id = buf.buffer_id;
- state.buffer_update = buf.from_queue;
+ state.buffer_update = buf.from_queue && !buf.has_played;
+
+ buf.has_played = true;
LOG_TRACE(Audio_DSP, "source_id=%zu buffer_id=%hu from_queue=%s current_buffer.size()=%zu",
source_id, buf.buffer_id, buf.from_queue ? "true" : "false",
diff --git a/src/audio_core/hle/source.h b/src/audio_core/hle/source.h
index 3d725f2a3..ccb7f064f 100644
--- a/src/audio_core/hle/source.h
+++ b/src/audio_core/hle/source.h
@@ -76,6 +76,8 @@ private:
Format format;
bool from_queue;
+ u32_dsp play_position; // = 0;
+ bool has_played; // = false;
};
struct BufferOrder {
diff --git a/src/audio_core/interpolate.h b/src/audio_core/interpolate.h
index dd06fdda9..19a7b66cb 100644
--- a/src/audio_core/interpolate.h
+++ b/src/audio_core/interpolate.h
@@ -21,6 +21,7 @@ struct State {
/**
* No interpolation. This is equivalent to a zero-order hold. There is a two-sample predelay.
+ * @param state Interpolation state.
* @param input Input buffer.
* @param rate_multiplier Stretch factor. Must be a positive non-zero value.
* rate_multiplier > 1.0 performs decimation and rate_multipler < 1.0
@@ -31,6 +32,7 @@ StereoBuffer16 None(State& state, const StereoBuffer16& input, float rate_multip
/**
* Linear interpolation. This is equivalent to a first-order hold. There is a two-sample predelay.
+ * @param state Interpolation state.
* @param input Input buffer.
* @param rate_multiplier Stretch factor. Must be a positive non-zero value.
* rate_multiplier > 1.0 performs decimation and rate_multipler < 1.0
diff --git a/src/audio_core/sink.h b/src/audio_core/sink.h
index 558c8c0fe..c69cb2c74 100644
--- a/src/audio_core/sink.h
+++ b/src/audio_core/sink.h
@@ -34,7 +34,7 @@ public:
/**
* Sets the desired output device.
- * @paran device_id Id of the desired device.
+ * @param device_id ID of the desired device.
*/
virtual void SetDevice(int device_id) = 0;
diff --git a/src/audio_core/time_stretch.h b/src/audio_core/time_stretch.h
index e3e4dc353..c98b16705 100644
--- a/src/audio_core/time_stretch.h
+++ b/src/audio_core/time_stretch.h
@@ -25,7 +25,7 @@ public:
/**
* Add samples to be processed.
* @param sample_buffer Buffer of samples in interleaved stereo PCM16 format.
- * @param num_sample Number of samples.
+ * @param num_samples Number of samples.
*/
void AddSamples(const s16* sample_buffer, size_t num_samples);