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

VirusProcessor.h (2401B)


      1 #pragma once
      2 
      3 #include "synthLib/plugin.h"
      4 #include "virusLib/device.h"
      5 
      6 #include "baseLib/event.h"
      7 
      8 #include "jucePluginEditorLib/pluginProcessor.h"
      9 
     10 namespace virus
     11 {
     12 	class VirusProcessor : public jucePluginEditorLib::Processor
     13 	{
     14 	public:
     15 	    VirusProcessor(const BusesProperties& _busesProperties, const juce::PropertiesFile::Options& _configOptions, const pluginLib::Processor::Properties& _properties, virusLib::DeviceModel _defaultModel);
     16 	    ~VirusProcessor() override;
     17 
     18 	    void processBpm(float _bpm) override;
     19 
     20 		// _____________
     21 		//
     22 
     23 		std::string getRomName() const
     24 	    {
     25 	        const auto* rom = getSelectedRom();
     26 	        if(!rom)
     27 				return "<invalid>";
     28 	        return juce::File(juce::String(rom->getFilename())).getFileNameWithoutExtension().toStdString();
     29 	    }
     30 
     31 	    const virusLib::ROMFile* getSelectedRom() const
     32 		{
     33 	        if(m_selectedRom >= m_roms.size())
     34 	            return {};
     35 	        return &m_roms[m_selectedRom];
     36 		}
     37 
     38 	    virusLib::DeviceModel getModel() const
     39 	    {
     40 	        auto* rom = getSelectedRom();
     41 			return rom ? rom->getModel() : virusLib::DeviceModel::Invalid;
     42 	    }
     43 
     44 	    const auto& getRoms() const { return m_roms; }
     45 
     46 	    bool setSelectedRom(uint32_t _index);
     47 	    uint32_t getSelectedRomIndex() const { return m_selectedRom; }
     48 
     49 	    uint32_t getPartCount() const
     50 	    {
     51 		    return getModel() == virusLib::DeviceModel::Snow ? 4 : 16;
     52 	    }
     53 
     54 	protected:
     55 	    void postConstruct(std::vector<virusLib::ROMFile>&& _roms);
     56 
     57 	    // _____________
     58 		//
     59 	private:
     60 	    synthLib::Device* createDevice() override;
     61 		void getRemoteDeviceParams(synthLib::DeviceCreateParams& _params) const override;
     62 
     63 	    pluginLib::Controller* createController() override;
     64 
     65 	    void saveChunkData(baseLib::BinaryStream& s) override;
     66 	    void loadChunkData(baseLib::ChunkReader& _cr) override;
     67 
     68 		void zynthianExportLv2Presets() const;
     69 		void exportLv2Presets(const virusLib::ROMFile& _rom, const std::string& _rootPath) const;
     70 
     71 	    //==============================================================================
     72 		JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VirusProcessor)
     73 
     74 		std::vector<virusLib::ROMFile>      m_roms;
     75 	    const virusLib::DeviceModel			m_defaultModel;
     76 	    uint32_t                            m_selectedRom = 0;
     77 
     78 		uint32_t							m_clockTempoParam = 0xffffffff;
     79 
     80 	public:
     81 	    baseLib::Event<const virusLib::ROMFile*> evRomChanged;
     82 	};
     83 }