OXYGENHUB
◆ main openmsx / src / cassette / CassetteImage.hh
1.5 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#ifndef CASSETTEIMAGE_HH
2
#define CASSETTEIMAGE_HH
3
4
#include "EmuTime.hh"
5
#include "sha1.hh"
6
7
#include <cstdint>
8
#include <span>
9
#include <string>
10
11
namespace openmsx {
12
13
class Filename;
14
15
class CassetteImage
16
{
17
public:
18
	enum class FileType : uint8_t { ASCII, BINARY, BASIC, UNKNOWN };
19
20
	virtual ~CassetteImage() = default;
21
	[[nodiscard]] virtual int16_t getSampleAt(EmuTime time) const = 0;
22
	[[nodiscard]] virtual EmuTime getEndTime() const = 0;
23
	[[nodiscard]] virtual unsigned getFrequency() const = 0;
24
	virtual void fillBuffer(unsigned pos, std::span<float*, 1> bufs, unsigned num) const = 0;
25
	[[nodiscard]] virtual float getAmplificationFactorImpl() const = 0;
26
27
	[[nodiscard]] FileType getFirstFileType() const { return firstFileType; }
28
	[[nodiscard]] std::string getFirstFileTypeAsString() const;
29
30
	/** Get sha1sum for this image.
31
	 * This is based on the content of the file, not the logical meaning of
32
	 * the file. IOW: it's possible for different files (with different
33
	 * sha1sum) to represent the same logical cassette data (e.g. wav with
34
	 * different bits per sample). This method will give a different
35
	 * sha1sum to such files.
36
	 */
37
	[[nodiscard]] const Sha1Sum& getSha1Sum() const;
38
39
protected:
40
	CassetteImage() = default;
41
	// Please make sure this method is called from the constructor of each
42
	// subclass! (And only from there.)
43
	void setFirstFileType(FileType type, const Filename& fileName);
44
	void setSha1Sum(const Sha1Sum& sha1sum);
45
46
private:
47
	FileType firstFileType = FileType::UNKNOWN;
48
	Sha1Sum sha1sum;
49
};
50
51
} // namespace openmsx
52
53
#endif