summaryrefslogtreecommitdiff
path: root/src/JSystem/JAudio/JASDrumSet.cpp
blob: 7fffed2219ced4b25649cd4359d96467d32409de (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//
// Generated by dtk
// Translation Unit: JASDrumSet.cpp
//

#include "JSystem/JSystem.h" // IWYU pragma: keep

#include "JSystem/JAudio/JASDrumSet.h"
#include "JSystem/JAudio/JASBank.h"
#include "JSystem/JAudio/JASCalc.h"
#include "JSystem/JAudio/JASInstEffect.h"
#include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JUtility/JUTAssert.h"

/* 802851D4-80285470       .text getParam__Q28JASystem8TDrumSetCFiiPQ28JASystem10TInstParam */
bool JASystem::TDrumSet::getParam(int key, int param_2, JASystem::TInstParam* param_3) const {
    JUT_ASSERT(24, key >= 0);
    if (key >= sPercCount) {
        OSReport("JASDrumSet: key %d >= sPercCount %d\n", key, sPercCount);
        return false;
    }
    const TPerc* perc = field_0x4 + key;
    param_3->field_0x0 = 0;
    param_3->field_0x38 = 1;
    param_3->field_0x10 *= perc->field_0x0;
    param_3->field_0x14 *= perc->field_0x4;
    param_3->field_0x20 = perc->field_0x8;
    param_3->field_0x3a = perc->field_0xc;
    static TOscillator::Osc_ osc;
    osc.field_0x0 = 0;
    osc.field_0x4 = 1.0f;
    osc.table = NULL;
    osc.rel_table = NULL;
    osc.field_0x10 = 1.0f;
    osc.field_0x14 = 0.0f;
    static TOscillator::Osc_* oscp = &osc;
    param_3->mOscData = &oscp;
    param_3->mOscCount = 1;
    for (int i = 0; i < perc->mEffectCount; i++) {
        TInstEffect* effect = perc->mEffect[i];
        if (effect) {
            f32 y = effect->getY(key, param_2);
            switch (effect->mTarget) {
            case 0:
                param_3->field_0x18 *= y;
                break;
            case 1:
                param_3->field_0x1c *= y;
                break;
            case 2:
                param_3->field_0x2c += y - 0.5;
                break;
            case 3:
                param_3->field_0x30 += y;
                break;
            case 4:
                param_3->field_0x34 += y;
                break;
            default:
                JUT_ASSERT(77, FALSE);
                break;
            }
        }
    }
    for (int i = 0; i < perc->mVelomapCount; i++) {
        TBasicInst::TVeloRegion* region = perc->mVelomap + i;
        if (param_2 > region->mBaseVel) {
            continue;
        }
        param_3->field_0x10 *= region->field_0x08;
        param_3->field_0x14 *= region->field_0x0c;
        param_3->field_0x4 = region->field_0x04;
        return true;
    }
    return false;
}

/* 80285470-80285520       .text getPerc__Q28JASystem8TDrumSetFi */
JASystem::TDrumSet::TPerc* JASystem::TDrumSet::getPerc(int index) {
    JUT_ASSERT(101, index < sPercCount);
    JUT_ASSERT(102, index >= 0);
    return field_0x4 + index;
}

/* 80285520-80285554       .text __ct__Q38JASystem8TDrumSet5TPercFv */
JASystem::TDrumSet::TPerc::TPerc() {
    field_0x0 = 1.0f;
    field_0x4 = 1.0f;
    field_0x8 = 0.5f;
    field_0xc = 1000;
    mEffect = NULL;
    mEffectCount = 0;
    mVelomapCount = 0;
    mVelomap = NULL;
}

/* 80285554-802855B0       .text __dt__Q38JASystem8TDrumSet5TPercFv */
JASystem::TDrumSet::TPerc::~TPerc() {
    delete[] mEffect;
    delete[] mVelomap;
}

/* 802855B0-80285664       .text setEffectCount__Q38JASystem8TDrumSet5TPercFUl */
void JASystem::TDrumSet::TPerc::setEffectCount(u32 param_1) {
    delete[] mEffect;
    mEffectCount = param_1;
    if (param_1 == 0) {
        mEffect = NULL;
        return;
    }
    mEffect = new (TBank::getCurrentHeap(), 0) TInstEffect*[param_1];
    JUT_ASSERT(146, mEffect != NULL);
    Calc::bzero(mEffect, param_1 * 4);
}

/* 80285664-802856F8       .text setVeloRegionCount__Q38JASystem8TDrumSet5TPercFUl */
void JASystem::TDrumSet::TPerc::setVeloRegionCount(u32 param_1) {
    delete[] mVelomap;
    mVelomap = new (TBank::getCurrentHeap(), 0) TBasicInst::TVeloRegion[param_1];
    JUT_ASSERT(155, mVelomap != NULL);
    mVelomapCount = param_1;
}

/* 802856F8-802857AC       .text getVeloRegion__Q38JASystem8TDrumSet5TPercFi */
JASystem::TBasicInst::TVeloRegion* JASystem::TDrumSet::TPerc::getVeloRegion(int index) {
    JUT_ASSERT(161, index < mVelomapCount);
    JUT_ASSERT(162, index >= 0);
    return mVelomap + index;
}

/* 802857AC-80285864       .text setEffect__Q38JASystem8TDrumSet5TPercFiPQ28JASystem11TInstEffect */
void JASystem::TDrumSet::TPerc::setEffect(int index, JASystem::TInstEffect* param_2) {
    JUT_ASSERT(177, index < mEffectCount);
    JUT_ASSERT(178, index >= 0);
    mEffect[index] = param_2;
}

/* 80285864-802858D8       .text setRelease__Q38JASystem8TDrumSet5TPercFUl */
void JASystem::TDrumSet::TPerc::setRelease(u32 release) {
    JUT_ASSERT(195, release < 0x10000);
    field_0xc = release;
}

/* 802858D8-8028595C       .text __dt__Q28JASystem8TDrumSetFv */
JASystem::TDrumSet::~TDrumSet() {}