gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

wRom.h (1222B)


      1 #pragma once
      2 
      3 #include <cstdint>
      4 #include <string>
      5 #include <vector>
      6 
      7 namespace wLib
      8 {
      9 	class ROM
     10 	{
     11 	public:
     12 		ROM() = default;
     13 		explicit ROM(const std::string& _filename, const uint32_t _expectedSize, std::vector<uint8_t> _data = {}) : m_buffer(std::move(_data)), m_filename(_filename)
     14 		{
     15 			if (m_buffer.size() != _expectedSize)
     16 				loadFromFile(_filename, _expectedSize);
     17 		}
     18 		virtual ~ROM() = default;
     19 
     20 		const auto& getData() const { return m_buffer; }
     21 		bool isValid() const { return !m_buffer.empty(); }
     22 		virtual uint32_t getSize() const = 0;
     23 
     24 		void clear() { m_buffer.clear(); }
     25 
     26 		const auto& getFilename() const { return m_filename; }
     27 
     28 		static bool loadFromMidi(std::vector<uint8_t>& _buffer, const std::string& _filename);
     29 		static bool loadFromMidiData(std::vector<uint8_t>& _buffer, const std::vector<uint8_t>& _midiData);
     30 		static bool loadFromSysExFile(std::vector<uint8_t>& _buffer, const std::string& _filename);
     31 		static bool loadFromSysExBuffer(std::vector<uint8_t> &_buffer, const std::vector<uint8_t> &_sysex, bool _isMidiFileData = false);
     32 
     33 	private:
     34 		bool loadFromFile(const std::string& _filename, uint32_t _expectedSize);
     35 
     36 		std::vector<uint8_t> m_buffer;
     37 		std::string m_filename;
     38 	};	
     39 }