wavelength 1.0.0
Loading...
Searching...
No Matches
bank.h
Go to the documentation of this file.
1#pragma once
2
7#include "synth_s/sample.h"
8
17class Bank {
18public:
19 static constexpr int kMaxBanks = 7;
20 static constexpr int kMaxPrograms = 100;
21 static constexpr int kMaxSampleDescs = 700;
22 static constexpr int kMaxSamples = 700;
23
26 mHeader.Init();
27 for (int i = kMaxPrograms - 1; i >= 0; --i) {
28 mPrograms[i] = nullptr;
29 }
30 for (int i = kMaxSampleDescs - 1; i >= 0; --i) {
31 mSampleDescs[i] = nullptr;
32 }
33 for (int i = kMaxSamples - 1; i >= 0; --i) {
34 mSamples[i] = nullptr;
35 }
36 }
37
46 void Init();
47
59 void SetProgram(BankProgram *program, int index);
60
69 void SetSampleDesc(BankSampleDesc *sampleDesc, int index);
70
80 bool SetSample(Sample *sample, int index);
81
91
102
109 void Clear();
110
118 static void NewProgram(BankProgram **program);
119
127 static void NewSampleDesc(BankSampleDesc **sampleDesc);
128
136 static void NewSample(Sample **sample);
137
146 static int Find(unsigned short id);
147
154 static void InitPools();
155
163 static int ReleasePools();
164
165 unsigned char mLoaded;
170 unsigned int mSpuAddress;
171 unsigned int mSpuSize;
172
174
175private:
176 static PoolAllocator sProgramPool;
177 static PoolAllocator sSampleDescPool;
178 static PoolAllocator sSamplePool;
179};
Identity and mix settings of an instrument bank, as the bank file records them.
Definition bankheader.h:9
A program loaded into a bank, linked to its run of sample descriptors.
Definition bankprogram.h:12
A sample descriptor loaded into a bank, linked to the sample it plays.
Definition banksampledesc.h:12
static constexpr int kMaxSampleDescs
Definition bank.h:21
static constexpr int kMaxSamples
Definition bank.h:22
bool SetSample(Sample *sample, int index)
Store a sample.
BankSampleDesc * mSampleDescs[kMaxSampleDescs]
Definition bank.h:168
Sample * mSamples[kMaxSamples]
Definition bank.h:169
static void InitPools()
Allocate the shared pools.
static void NewProgram(BankProgram **program)
Take a program from the pool and Init() it.
void Clear()
Return every program, descriptor, and sample to the pools, then Init().
static constexpr int kMaxBanks
Definition bank.h:19
BankSampleDesc * GetSampleDesc(BankProgram *program, int index)
Look up one descriptor of a program's run.
static int Find(unsigned short id)
Find the loaded bank with an identifier.
unsigned int mSpuSize
Definition bank.h:171
static Bank sBanks[kMaxBanks]
Definition bank.h:173
void Init()
Reset the header, forget every program, descriptor, and sample, and mark the bank unloaded.
static void NewSample(Sample **sample)
Take a sample from the pool and Init() it.
static void NewSampleDesc(BankSampleDesc **sampleDesc)
Take a descriptor from the pool and Init() it.
static constexpr int kMaxPrograms
Definition bank.h:20
Bank()
Construct an empty, unloaded bank.
Definition bank.h:25
unsigned char mLoaded
Definition bank.h:165
BankProgram * GetProgram(int index)
Look up a program by slot.
static int ReleasePools()
Release the shared pools.
BankProgram * mPrograms[kMaxPrograms]
Definition bank.h:167
BankHeader mHeader
Definition bank.h:166
void SetSampleDesc(BankSampleDesc *sampleDesc, int index)
Store a descriptor and link it to its sample.
unsigned int mSpuAddress
Definition bank.h:170
void SetProgram(BankProgram *program, int index)
Store a program and point it at its run of descriptors.
A fixed-size allocator over one block of IOP memory.
Definition poolallocator.h:15
One waveform of a bank, as the bank file records it.
Definition sample.h:10