Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
wave_table.h
1/*
2 * Copyright © 2020-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include "definitions_cxx.hpp"
21#include "model/sample/sample.h"
22#include "storage/audio/audio_file.h"
23#include "storage/wave_table/wave_table_band_data.h"
24#include "util/container/array/ordered_resizeable_array.h"
25
26class Sample;
27class WaveTableReader;
28
30public:
32 uint32_t maxPhaseIncrement;
33 int32_t fromCycleNumber;
34 int32_t toCycleNumber;
35 uint16_t cycleSizeNoDuplicates;
36 uint8_t cycleSizeMagnitude;
37 bool intendedForLinearInterpolation;
38 int16_t* dataAccessAddress;
39 WaveTableBandData* data; // Might be different than the above if memory has been shortened
40};
41
42class WaveTable final : public AudioFile {
43public:
44 WaveTable();
45 ~WaveTable() override;
46 int32_t cloneFromSample(Sample* sample);
47 uint32_t render(int32_t* outputBuffer, int32_t numSamples, uint32_t phaseIncrementNow, uint32_t phase,
48 bool doOscSync, uint32_t resetterPhase, uint32_t resetterPhaseIncrement,
49 int32_t resetterDivideByPhaseIncrement, uint32_t retriggerPhase, int32_t waveIndex,
50 int32_t waveIndexIncrement);
51 Error setup(Sample* sample, int32_t nativeNumSamplesPerCycle = 0, uint32_t audioDataStartPosBytes = 0,
52 uint32_t audioDataLengthBytes = 0, int32_t byteDepth = 0,
53 RawDataFormat rawDataFormat = RawDataFormat::NATIVE, WaveTableReader* reader = nullptr);
54 void deleteAllBandsAndData();
55 void bandDataBeingStolen(WaveTableBandData* bandData);
56
57 // Stealable Implementation
58 bool mayBeStolen(void* thingNotToStealFrom = nullptr) override;
59 void steal(char const* errorCode) override;
60
61 int32_t numCycles;
62 int32_t numCyclesMagnitude;
63
64 int32_t numCycleTransitionsNextPowerOf2;
65 int32_t numCycleTransitionsNextPowerOf2Magnitude;
66 int32_t waveIndexMultiplier;
68
69protected:
70 void numReasonsIncreasedFromZero() override;
71 void numReasonsDecreasedToZero(char const* errorCode) override;
72
73private:
74 void doRenderingLoop(int32_t* __restrict__ thisSample, int32_t const* bufferEnd, int32_t firstCycleNumber,
75 WaveTableBand* __restrict__ bandHere, uint32_t phase, uint32_t phaseIncrement,
76 uint32_t waveIndexScaled, int32_t waveIndexIncrementScaled,
77 const int16_t* __restrict__ kernel);
78
79 void doRenderingLoopSingleCycle(int32_t* __restrict__ thisSample, int32_t const* bufferEnd,
80 WaveTableBand* __restrict__ bandHere, uint32_t phase, uint32_t phaseIncrement,
81 const int16_t* __restrict__ kernel);
82};
Definition ordered_resizeable_array.h:72
Definition sample.h:50
Definition wave_table_band_data.h:25
Definition wave_table.h:29
Definition wave_table_reader.h:23