Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
sample_playback_guide.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 <cstddef>
21#include <cstdint>
22
23class SampleHolder;
24class Sample;
25class VoiceSample;
26class AudioFileHolder;
27
28class SamplePlaybackGuide {
29public:
30 SamplePlaybackGuide();
31 int32_t getFinalClusterIndex(Sample* sample, bool obeyMarkers, int32_t* getEndPlaybackAtByte = nullptr);
32 virtual int32_t getBytePosToStartPlayback(bool justLooped) { return startPlaybackAtByte; }
33 virtual int32_t getBytePosToEndOrLoopPlayback() {
34 return endPlaybackAtByte;
35 } // This is actually an important function whose output is the basis for a lot of stuff
36 virtual void setupPlaybackBounds(bool reversed);
37 virtual uint32_t getLoopStartPlaybackAtByte() { return startPlaybackAtByte; }
38 virtual uint32_t getLoopEndPlaybackAtByte() { return endPlaybackAtByte; }
39 uint64_t getSyncedNumSamplesIn();
40 int32_t getNumSamplesLaggingBehindSync(VoiceSample* voiceSample);
41 int32_t adjustPitchToCorrectDriftFromSync(VoiceSample* voiceSample, int32_t phaseIncrement);
42
43 int8_t playDirection;
44 AudioFileHolder* audioFileHolder; // If this is NULL, it means Voice that contains "me" (this Guide) is not
45 // currently playing this Source/Sample, e.g. becacuse its volume was set to 0.
46
47 // And, this might look a bit hackish, but we'll use this to point to the WaveTable if that's what we're using -
48 // even though that's not a Sample, and doesn't otherwise need any of this "playback guide" stuff.
49
50 // These byte numbers are all relative to the audio file start, which includes all the headers at the top.
51 // If playing reversed, then end will be left of start.
52 uint32_t startPlaybackAtByte;
53 uint32_t endPlaybackAtByte;
54
55 int32_t sequenceSyncStartedAtTick;
56 uint32_t sequenceSyncLengthTicks; // When 0, means no syncing happening
57};
Definition audio_file_holder.h:30
Definition sample_holder.h:32
Definition sample.h:50
Definition voice_sample.h:36