amuse/VST/AudioGroupFilePresenter.hpp

103 lines
3.3 KiB
C++
Raw Normal View History

2018-10-07 03:40:25 +00:00
#pragma once
#include <map>
#include <memory>
2019-06-12 02:02:52 +00:00
#include <optional>
#include <amuse/amuse.hpp>
#include <athena/FileReader.hpp>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <CommCtrl.h>
2018-12-08 05:20:09 +00:00
namespace amuse {
class VSTBackend;
class VSTEditor;
class AudioGroupFilePresenter;
2018-12-08 05:20:09 +00:00
struct AudioGroupDataCollection {
std::wstring m_path;
std::wstring m_name;
std::vector<uint8_t> m_projData;
std::vector<uint8_t> m_poolData;
std::vector<uint8_t> m_sdirData;
std::vector<uint8_t> m_sampData;
struct MetaData {
amuse::DataFormat fmt;
uint32_t absOffs;
uint32_t active;
MetaData(amuse::DataFormat fmtIn, uint32_t absOffsIn, uint32_t activeIn)
2020-04-11 22:49:30 +00:00
: FMT_STRING(fmtIn), absOffs(absOffsIn), active(activeIn) {}
2018-12-08 05:20:09 +00:00
MetaData(athena::io::FileReader& r)
2020-04-11 22:49:30 +00:00
: FMT_STRING(amuse::DataFormat(r.readUint32Little())), absOffs(r.readUint32Little()), active(r.readUint32Little()) {}
2018-12-08 05:20:09 +00:00
};
2019-06-12 02:02:52 +00:00
std::optional<MetaData> m_metaData;
2018-12-08 05:20:09 +00:00
2019-06-12 02:02:52 +00:00
std::optional<amuse::AudioGroupData> m_loadedData;
2018-12-08 05:20:09 +00:00
const amuse::AudioGroup* m_loadedGroup;
struct GroupToken {
int m_groupId;
const amuse::SongGroupIndex* m_song = nullptr;
const amuse::SFXGroupIndex* m_sfx = nullptr;
GroupToken(int id, const amuse::SongGroupIndex* song) : m_groupId(id), m_song(song) {}
GroupToken(int id, const amuse::SFXGroupIndex* sfx) : m_groupId(id), m_sfx(sfx) {}
};
std::vector<GroupToken> m_groupTokens;
bool loadProj();
bool loadPool();
bool loadSdir();
bool loadSamp();
bool loadMeta();
AudioGroupDataCollection(std::wstring_view path, std::wstring_view name);
bool isDataComplete() const {
return m_projData.size() && m_poolData.size() && m_sdirData.size() && m_sampData.size() && m_metaData;
}
bool _attemptLoad();
bool _indexData();
void addToEngine(amuse::Engine& engine);
void removeFromEngine(amuse::Engine& engine) const;
};
2018-12-08 05:20:09 +00:00
struct AudioGroupCollection {
using GroupIterator = std::map<std::wstring, std::unique_ptr<AudioGroupDataCollection>>::iterator;
std::wstring m_path;
std::wstring m_name;
2018-12-08 05:20:09 +00:00
std::map<std::wstring, std::unique_ptr<AudioGroupDataCollection>> m_groups;
std::vector<GroupIterator> m_iteratorVec;
2018-12-08 05:20:09 +00:00
AudioGroupCollection(std::wstring_view path, std::wstring_view name);
void addCollection(std::vector<std::pair<std::wstring, amuse::IntrusiveAudioGroupData>>&& collection);
void update(AudioGroupFilePresenter& presenter);
void populateFiles(VSTEditor& editor, HTREEITEM colHandle, size_t parentIdx);
};
2018-12-08 05:20:09 +00:00
class AudioGroupFilePresenter {
friend class VSTBackend;
2016-07-14 04:54:46 +00:00
public:
2018-12-08 05:20:09 +00:00
using CollectionIterator = std::map<std::wstring, std::unique_ptr<AudioGroupCollection>>::iterator;
2016-07-14 04:54:46 +00:00
private:
2018-12-08 05:20:09 +00:00
VSTBackend& m_backend;
std::map<std::wstring, std::unique_ptr<AudioGroupCollection>> m_audioGroupCollections;
std::vector<CollectionIterator> m_iteratorVec;
2016-07-14 04:54:46 +00:00
public:
2018-12-08 05:20:09 +00:00
AudioGroupFilePresenter(VSTBackend& backend) : m_backend(backend) {}
void update();
void populateCollectionColumn(VSTEditor& editor);
void populateGroupColumn(VSTEditor& editor, int collectionIdx, int fileIdx);
void populatePageColumn(VSTEditor& editor, int collectionIdx, int fileIdx, int groupIdx);
void addCollection(std::wstring_view name,
std::vector<std::pair<std::wstring, amuse::IntrusiveAudioGroupData>>&& collection);
void removeCollection(unsigned idx);
VSTBackend& getBackend() { return m_backend; }
};
2018-12-08 05:20:09 +00:00
} // namespace amuse