Deluge Firmware 1.3.0
Build date: 2026.08.22
Loading...
Searching...
No Matches
live_pitch_shifter.h
1/*
2 * Copyright © 2018-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 "processing/live/live_pitch_shifter_play_head.h"
22
23class LiveInputBuffer;
24
25class LivePitchShifter {
26public:
27 LivePitchShifter(OscType newInputType, int32_t phaseIncrement);
28 ~LivePitchShifter();
29 void giveInput(int32_t numSamples, int32_t inputType, int32_t phaseIncrement);
30 void render(int32_t* outputBuffer, int32_t numSamplesThisFunctionCall, int32_t phaseIncrement, int32_t amplitude,
31 int32_t amplitudeIncrement, int32_t interpolationBufferSize);
32
33 bool mayBeRemovedWithoutClick();
34
35#if INPUT_ENABLE_REPITCHED_BUFFER
36 void interpolate(int32_t* sampleRead, int32_t interpolationBufferSize, int32_t numChannelsNow, int32_t whichKernel);
37 int32_t* repitchedBuffer;
38 int32_t repitchedBufferWritePos;
39 uint64_t repitchedBufferNumSamplesWritten;
40 bool stillWritingToRepitchedBuffer;
41 int32_t interpolationBuffer[2][kInterpolationMaxNumSamples];
42 uint32_t oscPos;
43#endif
44
45 int8_t numChannels;
46 OscType inputType;
47
48 uint32_t crossfadeProgress; // Out of kMaxSampleValue
49 // crossfadeIncrement + percThresholdForCut are only set at the first hop (before the crossfade/perc logic that
50 // reads them becomes reachable), so default-initialise them — otherwise a freshly-allocated shifter carries
51 // read-before-write garbage in these fields.
52 uint32_t crossfadeIncrement{0};
53 int32_t nextCrossfadeLength;
54 int32_t samplesTilHopEnd;
55 int32_t samplesIntoHop;
56
57 int32_t percThresholdForCut{0};
58
59 LivePitchShifterPlayHead playHeads[2];
60
61private:
62 void hopEnd(int32_t phaseIncrement, LiveInputBuffer* liveInputBuffer, uint64_t numRawSamplesProcessed,
63 uint64_t numRawSamplesProcessedLatest);
64 void considerRepitchedBuffer(int32_t phaseIncrement);
65 bool olderPlayHeadIsCurrentlySounding();
66};
Definition live_input_buffer.h:23
Definition live_pitch_shifter_play_head.h:34