Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
cluster.h
1/*
2 * Copyright © 2017-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.h"
21#include "definitions_cxx.hpp"
22#include "memory/general_memory_allocator.h"
23#include "memory/stealable.h"
24#include <array>
25#include <cstdint>
26
27class Sample;
28class SampleCluster;
29class SampleCache;
30
34class Cluster final : public Stealable {
35public:
36 constexpr static size_t kSizeFAT16Max = 32768;
37 enum class Type {
38 EMPTY,
39 SAMPLE,
40 GENERAL_MEMORY,
41 SAMPLE_CACHE,
42 PERC_CACHE_FORWARDS,
43 PERC_CACHE_REVERSED,
44 OTHER,
45 };
46
47 static Cluster* create(Cluster::Type type = Cluster::Type::SAMPLE, bool shouldAddReasons = true,
48 void* dontStealFromThing = nullptr);
49 void destroy();
50
51 static size_t size;
52 static size_t size_magnitude;
53 static void setSize(size_t size);
54
57 Cluster() = default;
59 bool mayBeStolen(void* thingNotToStealFrom) override;
60 void steal(char const* errorCode) override;
61 [[nodiscard]] StealableQueue getAppropriateQueue() const override;
62 void addReason();
63
64 Cluster::Type type;
65 uint32_t clusterIndex = 0;
66
67 int32_t numReasonsToBeLoaded = 0;
68 int8_t numReasonsHeldBySampleRecorder = 0;
69
70 bool extraBytesAtStartConverted = false;
71 bool extraBytesAtEndConverted = false;
72
73 Sample* sample = nullptr;
74 SampleCache* sampleCache = nullptr;
75
76 char firstThreeBytesPreDataConversion[3];
77 bool loaded = false;
78
79 // MUST BE THE LAST TWO MEMBERS
80 char dummy[CACHE_LINE_SIZE];
81 char data[CACHE_LINE_SIZE];
82};
void convertDataIfNecessary()
This function goes through the contents of the cluster, and converts them to the Deluge's native PCM ...
Definition cluster.cpp:68
Cluster()=default
Definition sample_cache.h:25
Definition sample_cluster.h:27
Definition sample.h:50