summaryrefslogtreecommitdiff
path: root/src/port/resource/type/AudioBank.h
blob: 778e2fc4054b5b5a04eeace139f3914614f75119 (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
#pragma once

#include <cstdint>
#include "AudioSample.h"
#include "ship/resource/Resource.h"

struct AudioBankSound {
    AudioBankSample *sample;
    float tuning; // frequency scale factor
}; // size = 0x8

struct AdsrEnvelope {
    int16_t delay;
    int16_t arg;
}; // size = 0x4

struct Instrument {
    /*0x00*/ uint8_t loaded;
    /*0x01*/ uint8_t normalRangeLo;
    /*0x02*/ uint8_t normalRangeHi;
    /*0x03*/ uint8_t releaseRate;
    /*0x04*/ AdsrEnvelope *envelope;
    /*0x08*/ AudioBankSound lowNotesSound;
    /*0x10*/ AudioBankSound normalNotesSound;
    /*0x18*/ AudioBankSound highNotesSound;
}; // size = 0x20

struct Drum {
    uint8_t releaseRate;
    uint8_t pan;
    uint8_t loaded;
    AudioBankSound sound;
    AdsrEnvelope *envelope;
};

struct CtlEntry {
    uint8_t bankId;
    uint8_t numInstruments;
    uint8_t numDrums;
    struct Instrument **instruments;
    struct Drum **drums;
}; // size = 0xC

namespace SM64 {
class AudioBank : public Ship::Resource<CtlEntry> {
  public:
    using Resource::Resource;

    AudioBank() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
    ~AudioBank() override;

    CtlEntry* GetPointer();
    size_t GetPointerSize();

    CtlEntry mData;

    std::vector<Instrument*> instruments;
    std::vector<Drum*> drums;
};
}