summaryrefslogtreecommitdiff
path: root/src/factories/naudio/v1/SampleFactory.h
blob: a72dd7e9220687c781d4d29a2fe045026f30de68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once

#include <factories/BaseFactory.h>
#include "AudioContext.h"

class NSampleData : public IParsedData {
public:
    uint32_t codec : 4;
    uint32_t medium : 2;
    uint32_t unk : 1;
    uint32_t isRelocated : 1;
    uint32_t size : 24;
    uint32_t sampleAddr;
    uint32_t loop;
    uint32_t book;

    // Custom fields
    uint32_t sampleBankId;
    uint32_t sampleRate;
    float tuning;
};

class NSampleHeaderExporter : public BaseExporter {
    ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};

class NSampleBinaryExporter : public BaseExporter {
    ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};

class NSampleCodeExporter : public BaseExporter {
    ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};

class NSampleModdingExporter : public BaseExporter {
    ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};

class NSampleXMLExporter : public BaseExporter {
    ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};

#ifdef BUILD_UI
class NSampleFactoryUI : public BaseFactoryUI {
public:
    float GetItemHeight(const ParseResultData& data) override;
    void DrawUI(const ParseResultData& data) override;
};
#endif

class NSampleFactory : public BaseFactory {
public:
    std::optional<std::shared_ptr<IParsedData>> parse(std::vector<uint8_t>& buffer, YAML::Node& data) override;
    inline std::unordered_map<ExportType, std::shared_ptr<BaseExporter>> GetExporters() override {
        return {
            REGISTER(Header, NSampleHeaderExporter)
            REGISTER(Binary, NSampleBinaryExporter)
            REGISTER(Code, NSampleCodeExporter)
            REGISTER(Modding, NSampleModdingExporter)
            REGISTER(XML, NSampleXMLExporter)
        };
    }
    bool SupportModdedAssets() override { return true; }
};