openshot-audio  0.1.7
juce_Sampler.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_SAMPLER_H_INCLUDED
26 #define JUCE_SAMPLER_H_INCLUDED
27 
28 
29 //==============================================================================
42 {
43 public:
44  //==============================================================================
63  SamplerSound (const String& name,
64  AudioFormatReader& source,
65  const BigInteger& midiNotes,
66  int midiNoteForNormalPitch,
67  double attackTimeSecs,
68  double releaseTimeSecs,
69  double maxSampleLengthSeconds);
70 
72  ~SamplerSound();
73 
74  //==============================================================================
76  const String& getName() const noexcept { return name; }
77 
81  AudioSampleBuffer* getAudioData() const noexcept { return data; }
82 
83 
84  //==============================================================================
85  bool appliesToNote (int midiNoteNumber) override;
86  bool appliesToChannel (int midiChannel) override;
87 
88 
89 private:
90  //==============================================================================
91  friend class SamplerVoice;
92 
93  String name;
95  double sourceSampleRate;
96  BigInteger midiNotes;
97  int length, attackSamples, releaseSamples;
98  int midiRootNote;
99 
101 };
102 
103 
104 //==============================================================================
114 {
115 public:
116  //==============================================================================
118  SamplerVoice();
119 
121  ~SamplerVoice();
122 
123  //==============================================================================
124  bool canPlaySound (SynthesiserSound*) override;
125 
126  void startNote (int midiNoteNumber, float velocity, SynthesiserSound*, int pitchWheel) override;
127  void stopNote (float velocity, bool allowTailOff) override;
128 
129  void pitchWheelMoved (int newValue) override;
130  void controllerMoved (int controllerNumber, int newValue) override;
131 
132  void renderNextBlock (AudioSampleBuffer&, int startSample, int numSamples) override;
133 
134 
135 private:
136  //==============================================================================
137  double pitchRatio;
138  double sourceSamplePosition;
139  float lgain, rgain, attackReleaseLevel, attackDelta, releaseDelta;
140  bool isInAttack, isInRelease;
141 
143 };
144 
145 
146 #endif // JUCE_SAMPLER_H_INCLUDED
Definition: juce_AudioSampleBuffer.h:34
Definition: juce_BigInteger.h:43
virtual void controllerMoved(int controllerNumber, int newControllerValue)=0
#define noexcept
Definition: juce_CompilerSupport.h:141
virtual void stopNote(float velocity, bool allowTailOff)=0
Definition: juce_String.h:43
const String & getName() const noexcept
Definition: juce_Sampler.h:76
#define JUCE_API
Definition: juce_StandardHeader.h:139
AudioSampleBuffer * getAudioData() const noexcept
Definition: juce_Sampler.h:81
virtual bool canPlaySound(SynthesiserSound *)=0
virtual void renderNextBlock(AudioSampleBuffer &outputBuffer, int startSample, int numSamples)=0
virtual bool appliesToChannel(int midiChannel)=0
Definition: juce_AudioFormatReader.h:38
Definition: juce_Sampler.h:113
virtual void startNote(int midiNoteNumber, float velocity, SynthesiserSound *sound, int currentPitchWheelPosition)=0
Definition: juce_Synthesiser.h:42
Definition: juce_Synthesiser.h:86
virtual bool appliesToNote(int midiNoteNumber)=0
Definition: juce_Sampler.h:41
#define JUCE_LEAK_DETECTOR(OwnerClass)
Definition: juce_LeakedObjectDetector.h:141
virtual void pitchWheelMoved(int newPitchWheelValue)=0