OpenShot Audio Library | OpenShotAudio: juce_Sampler.h Source File

OpenShot Audio Library | OpenShotAudio 0.3.1

Loading...
Searching...
No Matches
juce_Sampler.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 5 End-User License
11 Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
12 27th April 2017).
13
14 End User License Agreement: www.juce.com/juce-5-licence
15 Privacy Policy: www.juce.com/juce-5-privacy-policy
16
17 Or: You may also use this code under the terms of the GPL v3 (see
18 www.gnu.org/licenses).
19
20 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22 DISCLAIMED.
23
24 ==============================================================================
25*/
26
27namespace juce
28{
29
30//==============================================================================
44 class JUCE_API SamplerSound : public SynthesiserSound
45{
46public:
47 //==============================================================================
66 SamplerSound (const String& name,
67 AudioFormatReader& source,
68 const BigInteger& midiNotes,
69 int midiNoteForNormalPitch,
70 double attackTimeSecs,
71 double releaseTimeSecs,
72 double maxSampleLengthSeconds);
73
75 ~SamplerSound() override;
76
77 //==============================================================================
79 const String& getName() const noexcept { return name; }
80
84 AudioBuffer<float>* getAudioData() const noexcept { return data.get(); }
85
86 //==============================================================================
88 void setEnvelopeParameters (ADSR::Parameters parametersToUse) { params = parametersToUse; }
89
90 //==============================================================================
91 bool appliesToNote (int midiNoteNumber) override;
92 bool appliesToChannel (int midiChannel) override;
93
94private:
95 //==============================================================================
96 friend class SamplerVoice;
97
98 String name;
99 std::unique_ptr<AudioBuffer<float>> data;
100 double sourceSampleRate;
101 BigInteger midiNotes;
102 int length = 0, midiRootNote = 0;
103
104 ADSR::Parameters params;
105
106 JUCE_LEAK_DETECTOR (SamplerSound)
107};
108
109
110//==============================================================================
121 class JUCE_API SamplerVoice : public SynthesiserVoice
122{
123public:
124 //==============================================================================
126 SamplerVoice();
127
129 ~SamplerVoice() override;
130
131 //==============================================================================
132 bool canPlaySound (SynthesiserSound*) override;
133
134 void startNote (int midiNoteNumber, float velocity, SynthesiserSound*, int pitchWheel) override;
135 void stopNote (float velocity, bool allowTailOff) override;
136
137 void pitchWheelMoved (int newValue) override;
138 void controllerMoved (int controllerNumber, int newValue) override;
139
140 void renderNextBlock (AudioBuffer<float>&, int startSample, int numSamples) override;
141 using SynthesiserVoice::renderNextBlock;
142
143private:
144 //==============================================================================
145 double pitchRatio = 0;
146 double sourceSamplePosition = 0;
147 float lgain = 0, rgain = 0;
148
149 ADSR adsr;
150
151 JUCE_LEAK_DETECTOR (SamplerVoice)
152};
153
154} // namespace juce
juce::ADSR
Definition: juce_ADSR.h:37
juce::ADSR::Parameters
Definition: juce_ADSR.h:53
juce::AudioBuffer
Definition: juce_AudioSampleBuffer.h:34
juce::AudioFormatReader
Definition: juce_AudioFormatReader.h:45
juce::BigInteger
Definition: juce_BigInteger.h:39
juce::SamplerSound
Definition: juce_Sampler.h:45
juce::SamplerSound::getAudioData
AudioBuffer< float > * getAudioData() const noexcept
Definition: juce_Sampler.h:84
juce::SamplerSound::setEnvelopeParameters
void setEnvelopeParameters(ADSR::Parameters parametersToUse)
Definition: juce_Sampler.h:88
juce::SamplerSound::getName
const String & getName() const noexcept
Definition: juce_Sampler.h:79
juce::SamplerVoice
Definition: juce_Sampler.h:122
juce::String
Definition: juce_String.h:39
juce::SynthesiserSound
Definition: juce_Synthesiser.h:42
juce::SynthesiserVoice
Definition: juce_Synthesiser.h:88