openMSX
SamplePlayer.hh
Go to the documentation of this file.
1#ifndef SAMPLEPLAYER_HH
2#define SAMPLEPLAYER_HH
3
5#include "WavData.hh"
6#include "dynarray.hh"
7
8namespace openmsx {
9
11{
12public:
13 SamplePlayer(const std::string& name, static_string_view desc,
14 const DeviceConfig& config,
15 std::string_view samplesBaseName, unsigned numSamples,
16 std::string_view alternativeName = {});
18
19 void reset();
20
23 void play(unsigned sampleNum);
24
32 void repeat(unsigned sampleNum);
33
39 void stopRepeat() { nextSampleNum = unsigned(-1); }
40
42 [[nodiscard]] bool isPlaying() const { return currentSampleNum != unsigned(-1); }
43
44 template<typename Archive>
45 void serialize(Archive& ar, unsigned version);
46
47private:
48 void setWavParams();
49 void doRepeat();
50
51 // SoundDevice
52 void generateChannels(std::span<float*> bufs, unsigned num) override;
53
54private:
55 const dynarray<WavData> samples;
56
57 unsigned index = 0; // avoid UMR on serialize
58 unsigned bufferSize;
59 unsigned currentSampleNum;
60 unsigned nextSampleNum;
61};
62
63} // namespace openmsx
64
65#endif
bool isPlaying() const
Is there currently playing a sample.
void serialize(Archive &ar, unsigned version)
void play(unsigned sampleNum)
Start playing a (new) sample.
void repeat(unsigned sampleNum)
Keep on repeating the given sample data.
void stopRepeat()
Stop repeat mode.
static_string_view
This file implemented 3 utility functions:
Definition Autofire.cc:11