Files
dusklight/libs/JSystem/src/JAudio2/JASBasicInst.cpp
T
Pieter-Jan Briers 15732e241c Pjb dev 3 (#48)
* Undo array allocation changes from #43

Doesn't work

* Expand dmeter heap sizes, give names

* Fix manual operator delete call in resource.cpp

* Disable map rendering for now

Aurora can't handle lines

* Re-enable assert heap on DVD thread

Should be fine?

* Some basic debug groups with the new Aurora API

* Allow Aurora backend to be set via CLI

* Give materials debug groups

* More debug groups

* JKRHeap separation: array edition

Pain
2026-03-11 13:40:21 -07:00

83 lines
1.9 KiB
C++

//
// JASBasicInst
//
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/JAudio2/JASBasicInst.h"
#include "JSystem/JAudio2/JASCalc.h"
#include "JSystem/JKernel/JKRHeap.h"
JASBasicInst::JASBasicInst() {
mVolume = 1.0;
mPitch = 1.0;
mKeymapCount = 0;
mKeymap = NULL;
JASCalc::bzero(field_0xc, sizeof(field_0xc));
}
JASBasicInst::~JASBasicInst() {
JKR_DELETE_ARRAY(mKeymap);
}
bool JASBasicInst::getParam(int param_0, int param_1, JASInstParam* param_2) const {
UNUSED(param_1);
param_2->field_0x1c = 0;
param_2->field_0x1e = 0;
param_2->field_0x14 = (JASOscillator::Data**)&field_0xc;
param_2->field_0x1d = 2;
param_2->mVolume = mVolume;
param_2->mPitch = mPitch;
TKeymap* keyMap = NULL;
for (int i = 0; i < mKeymapCount; i++) {
if (param_0 <= mKeymap[i].mHighKey) {
keyMap = &mKeymap[i];
break;
}
}
if (keyMap == NULL) {
return false;
}
param_2->mVolume *= keyMap->field_0x8;
param_2->mPitch *= keyMap->field_0xc;
param_2->field_0x1a = u16(keyMap->field_0x4);
return true;
}
void JASBasicInst::setKeyRegionCount(u32 count, JKRHeap* param_1) {
JKR_DELETE_ARRAY(mKeymap);
mKeymap = JKR_NEW_ARRAY_ARGS(TKeymap, count, param_1, 0);
JUT_ASSERT(114, mKeymap != NULL);
mKeymapCount = count;
}
void JASBasicInst::setOsc(int index, JASOscillator::Data const* param_1) {
JUT_ASSERT(128, index < OSC_MAX);
JUT_ASSERT(129, index >= 0);
field_0xc[index] = param_1;
}
JASBasicInst::TKeymap* JASBasicInst::getKeyRegion(int index) {
JUT_ASSERT(146, index >= 0);
if (index >= mKeymapCount) {
return NULL;
}
return mKeymap + index;
}
JASBasicInst::TKeymap* JASBasicInst::getKeyRegion(int index) const {
JUT_ASSERT(155, index >= 0);
if (index >= mKeymapCount) {
return NULL;
}
return mKeymap + index;
}
JASBasicInst::TKeymap::~TKeymap() {
}