Krotos Modules 3
Loading...
Searching...
No Matches
KrotosSynthesiserSound.h
Go to the documentation of this file.
1#pragma once
2
3namespace krotos
4{
5#include <openssl/evp.h>
6#include <openssl/err.h>
7
9 class KrotosSynthesiserSound : public SynthesiserSound
10 {
11 public:
13 virtual void newBlockStart() {}
14 virtual SampleEngine* getSampleEngine() { return nullptr; }
15 };
16
19 {
20 public:
21 struct Listener
22 {
23 virtual ~Listener() = default;
24 virtual void soundChanged(KrotosSampleOscillatorSound* sound) = 0;
25 };
26
27 KrotosSampleOscillatorSound(); // basic sound that doesn.t have any data.
28 KrotosSampleOscillatorSound(const String& soundName, AudioFormatReader& source, int midiNoteForNormalPitch,
29 float dawSampleRate);
30
31 void Prepare(int midiNoteForNormalPitch, float dawSampleRate);
32
36 int loadSounds(juce::Array<File> audioSampleFiles, bool getNearest);
37
38 bool appliesToNote(int midiNoteNumber) override;
39 bool appliesToChannel(int midiChannel) override;
41
43
45
46 void canReadSpecificFiles(bool canRead) { m_specificExtension = canRead ? ".kaf" : ".abc"; }
47
48 void addListener(Listener* l) { m_listeners.add(l); }
49 void removeListener(Listener* l) { m_listeners.remove(l); }
50
52 void clearAndFreeBuffer();
53
54 private:
55 String m_name;
59 ListenerList<Listener> m_listeners;
60
61 // Limit the number/size of samples loaded
62 static constexpr int64 MAX_DATA_SIZE = 2147483648; // 2GB
63 static constexpr int MAX_NUMBER_SAMPLES = 250;
64
65 static constexpr size_t BUF_SIZE = 32; // Key size - must be 32
66 std::vector<std::array<unsigned char, BUF_SIZE>> m_sampleData;
67
68 // obfuscated
69 std::unique_ptr<MemoryBlock> loadSample(const juce::File& path, int sampleCount);
70
71 // obfuscated - this is the string used to specify what a .kaf file is. It is initialised
72 // as blank, and can be set via canReadSpecificFiles(true).
74
75 const float DECIBELS_MINUS_0_1{0.998763561f};
76 };
77
78} // namespace krotos
InterpolationType
Definition KrotosAudioBuffer.h:120
Definition KrotosSynthesiserSound.h:19
void newBlockStart() override
Definition KrotosSynthesiserSound.h:42
void clearAndFreeBuffer()
Definition KrotosSynthesiserSound.cpp:115
std::unique_ptr< MemoryBlock > loadSample(const juce::File &path, int sampleCount)
Definition KrotosSynthesiserSound.cpp:45
void canReadSpecificFiles(bool canRead)
Definition KrotosSynthesiserSound.h:46
bool appliesToNote(int midiNoteNumber) override
Definition KrotosSynthesiserSound.cpp:347
KrotosSampleOscillatorSound()
Definition KrotosSynthesiserSound.cpp:9
static constexpr int MAX_NUMBER_SAMPLES
Definition KrotosSynthesiserSound.h:63
static constexpr size_t BUF_SIZE
Definition KrotosSynthesiserSound.h:65
void removeListener(Listener *l)
Definition KrotosSynthesiserSound.h:49
const float DECIBELS_MINUS_0_1
Definition KrotosSynthesiserSound.h:75
SampleEngine * getSampleEngine() override
Definition KrotosSynthesiserSound.h:44
int m_midiRootNote
Definition KrotosSynthesiserSound.h:58
void Prepare(int midiNoteForNormalPitch, float dawSampleRate)
Definition KrotosSynthesiserSound.cpp:39
bool appliesToChannel(int midiChannel) override
Definition KrotosSynthesiserSound.cpp:348
static constexpr int64 MAX_DATA_SIZE
Definition KrotosSynthesiserSound.h:62
void setInterpolationType(KrotosAudioBuffer::InterpolationType interpType)
Definition KrotosSynthesiserSound.cpp:342
String m_specificExtension
Definition KrotosSynthesiserSound.h:73
std::vector< std::array< unsigned char, BUF_SIZE > > m_sampleData
Definition KrotosSynthesiserSound.h:66
ListenerList< Listener > m_listeners
Definition KrotosSynthesiserSound.h:59
int loadSounds(juce::Array< File > audioSampleFiles, bool getNearest)
Definition KrotosSynthesiserSound.cpp:139
double m_sourceSampleRate
Definition KrotosSynthesiserSound.h:57
SampleEngine m_sampleEngine
Definition KrotosSynthesiserSound.h:56
String m_name
Definition KrotosSynthesiserSound.h:55
void addListener(Listener *l)
Definition KrotosSynthesiserSound.h:48
Definition KrotosSynthesiserSound.h:10
virtual SampleEngine * getSampleEngine()
Definition KrotosSynthesiserSound.h:14
virtual void newBlockStart()
Definition KrotosSynthesiserSound.h:13
KrotosSynthesiserSound()
Definition KrotosSynthesiserSound.h:12
Class used to manage access to a resource from multiple users / threads In this version,...
Definition ResourceLock.h:19
Definition SampleEngine.h:84
void newBlockStart()
Definition SampleEngine.h:86
Definition AirAbsorptionFilter.cpp:2
Definition KrotosSynthesiserSound.h:22
virtual void soundChanged(KrotosSampleOscillatorSound *sound)=0