mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
split rpcs3 and hle libraries
merge rpcs3 utilities
This commit is contained in:
parent
b33e2662b6
commit
62ad27d1e2
1233 changed files with 7004 additions and 3819 deletions
55
rpcs3/Emu/Audio/audio_resampler.cpp
Normal file
55
rpcs3/Emu/Audio/audio_resampler.cpp
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#include "stdafx.h"
|
||||
#include "Emu/Audio/audio_resampler.h"
|
||||
#include <algorithm>
|
||||
|
||||
audio_resampler::audio_resampler()
|
||||
{
|
||||
resampler.setSetting(SETTING_SEQUENCE_MS, 20); // Resampler frame size (reduce latency at cost of slight sound quality degradation)
|
||||
resampler.setSetting(SETTING_USE_QUICKSEEK, 1); // Use fast quick seeking algorithm (substantally reduces computation time)
|
||||
}
|
||||
|
||||
audio_resampler::~audio_resampler()
|
||||
{
|
||||
}
|
||||
|
||||
void audio_resampler::set_params(AudioChannelCnt ch_cnt, AudioFreq freq)
|
||||
{
|
||||
flush();
|
||||
resampler.setChannels(static_cast<u32>(ch_cnt));
|
||||
resampler.setSampleRate(static_cast<u32>(freq));
|
||||
}
|
||||
|
||||
f64 audio_resampler::set_tempo(f64 new_tempo)
|
||||
{
|
||||
new_tempo = std::clamp(new_tempo, RESAMPLER_MIN_FREQ_VAL, RESAMPLER_MAX_FREQ_VAL);
|
||||
resampler.setTempo(new_tempo);
|
||||
return new_tempo;
|
||||
}
|
||||
|
||||
void audio_resampler::put_samples(const f32* buf, u32 sample_cnt)
|
||||
{
|
||||
resampler.putSamples(buf, sample_cnt);
|
||||
}
|
||||
|
||||
std::pair<f32* /* buffer */, u32 /* samples */> audio_resampler::get_samples(u32 sample_cnt)
|
||||
{
|
||||
// NOTE: Make sure to get the buffer first because receiveSamples advances its position internally
|
||||
// and std::make_pair evaluates the second parameter first...
|
||||
f32* const buf = resampler.bufBegin();
|
||||
return std::make_pair(buf, resampler.receiveSamples(sample_cnt));
|
||||
}
|
||||
|
||||
u32 audio_resampler::samples_available() const
|
||||
{
|
||||
return resampler.numSamples();
|
||||
}
|
||||
|
||||
f64 audio_resampler::get_resample_ratio()
|
||||
{
|
||||
return resampler.getInputOutputSampleRatio();
|
||||
}
|
||||
|
||||
void audio_resampler::flush()
|
||||
{
|
||||
resampler.clear();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue