21 const float cutOffFreq = 800.0f;
22 R = 1.0f - ((float(2 *
Math::pi) * cutOffFreq) / narrow_cast<float>(sampleFreq));
25 float t1 =
R * t0 + narrow_cast<float>(x);
59 unsigned refCount = 0;
62 std::map<std::string, Entry, std::less<>> cache;
65WavImageCache::~WavImageCache()
67 assert(cache.empty());
81 if (it == cache.end()) {
86 it = cache.try_emplace(filename.
getResolved(), std::move(entry)).first;
88 auto& entry = it->second;
97 auto it =
ranges::find(cache, wav, [](
auto& pr) {
return &pr.second.info.wav; });
98 assert(it !=
end(cache));
99 auto& entry = it->second;
101 if (entry.refCount == 0) {
134 std::array<float, 4> p = {
135 float(wav->
getSample(
unsigned(sample) - 1)),
157 if (pos < wav->getSize()) {
158 for (
auto i :
xrange(num)) {
void setSha1Sum(const Sha1Sum &sha1sum)
void setFreq(unsigned sampleFreq)
int16_t operator()(int16_t x)
Represents a clock with a variable frequency.
IntegralFractional getTicksTillAsIntFloat(EmuTime::param e) const
unsigned getFreq() const
Returns the frequency (in Hz) at which this clock ticks.
void setFreq(unsigned freq)
Change the frequency at which this clock ticks.
EmuTime::param getTime() const
Gets the time at which the last clock tick occurred.
Sha1Sum getSha1Sum(File &file)
Calculate sha1sum for the given File object.
This class represents a filename.
const std::string & getResolved() const &
This class represents the result of a sha1 calculation (a 160-bit value).
int16_t getSample(size_t pos) const
void release(const WavData *wav)
WavImageCache(WavImageCache &&)=delete
static WavImageCache & instance()
WavImageCache & operator=(const WavImageCache &)=delete
WavImageCache & operator=(WavImageCache &&)=delete
WavImageCache(const WavImageCache &)=delete
const WavInfo & get(const Filename &filename, FilePool &filePool)
WavImage(const Filename &filename, FilePool &filePool)
void fillBuffer(unsigned pos, std::span< float *, 1 > bufs, unsigned num) const override
float getAmplificationFactorImpl() const override
int16_t getSampleAt(EmuTime::param time) const override
EmuTime getEndTime() const override
unsigned getFrequency() const override
constexpr float cubicHermite(std::span< const float, 4 > y, float x)
int16_t clipToInt16(T x)
Clip x to range [-32768,32767].
This file implemented 3 utility functions:
auto find(InputRange &&range, const T &value)
constexpr auto xrange(T e)
constexpr auto end(const zstring_view &x)