MCPcopy Create free account
hub / github.com/EasyRPG/Player / AudioDecoderBase

Class AudioDecoderBase

src/audio_decoder_base.h:37–287  ·  view source on GitHub ↗

* The AudioDecoder class provides an abstraction over the decoding of * common audio formats. * This is the base class containing shared logic. * See AudioDecoder for sample based decoding and AudioDecoderMidi for * Midi event based decoding. */

Source from the content-addressed store, hash-verified

35 * Midi event based decoding.
36 */
37class AudioDecoderBase {
38public:
39 /**
40 * Takes a linear volume and converts it to a logarithmic used by
41 * RPG_RT (Direct Sound).
42 * Do not use this for Midi, is already logarithmic by design.
43 *
44 * @param volume linear volume
45 * @return logarithmic volume
46 */
47 static float AdjustVolume(float volume);
48
49 virtual ~AudioDecoderBase() = default;
50
51 /** Sample format */
52 enum class Format {
53 S8,
54 U8,
55 S16,
56 U16,
57 S32,
58 U32,
59 F32
60 };
61
62 /**
63 * Writes 'size' bytes in the specified buffer. The data matches the format
64 * reported by GetFormat.
65 * When size is is smaller then the amount of written bytes or an error occurs
66 * the remaining buffer space is cleared.
67 *
68 * @param buffer Output buffer
69 * @param size Size of the buffer in bytes
70 * @return Number of bytes written to the buffer or -1 on error
71 */
72 int Decode(uint8_t* buffer, int size);
73
74 /**
75 * Decodes the whole audio sample. The data matches the format reported by
76 * GetFormat.
77 *
78 * @return output buffer
79 */
80 std::vector<uint8_t> DecodeAll();
81
82 /**
83 * Rewinds the audio stream to the beginning.
84 */
85 void Rewind();
86
87 /**
88 * Gets if the audio stream will loop when the stream finishes.
89 *
90 * @return if looping
91 */
92 virtual bool GetLooping() const;
93
94 /**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected