Loading...
Searching...
No Matches
juce_Sampler.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 7 End-User License
Agreement and JUCE Privacy Policy.
End User License Agreement: www.juce.com/juce-7-licence
Privacy Policy: www.juce.com/juce-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class JUCE_API SamplerSound : public SynthesiserSound
{
public:
//==============================================================================
SamplerSound (const String& name,
AudioFormatReader& source,
const BigInteger& midiNotes,
int midiNoteForNormalPitch,
double attackTimeSecs,
double releaseTimeSecs,
double maxSampleLengthSeconds);
~SamplerSound() override;
//==============================================================================
const String& getName() const noexcept { return name; }
AudioBuffer<float>* getAudioData() const noexcept { return data.get(); }
//==============================================================================
void setEnvelopeParameters (ADSR::Parameters parametersToUse) { params = parametersToUse; }
//==============================================================================
bool appliesToNote (int midiNoteNumber) override;
bool appliesToChannel (int midiChannel) override;
private:
//==============================================================================
friend class SamplerVoice;
String name;
std::unique_ptr<AudioBuffer<float>> data;
double sourceSampleRate;
BigInteger midiNotes;
int length = 0, midiRootNote = 0;
ADSR::Parameters params;
JUCE_LEAK_DETECTOR (SamplerSound)
};
//==============================================================================
class JUCE_API SamplerVoice : public SynthesiserVoice
{
public:
//==============================================================================
SamplerVoice();
~SamplerVoice() override;
//==============================================================================
bool canPlaySound (SynthesiserSound*) override;
void startNote (int midiNoteNumber, float velocity, SynthesiserSound*, int pitchWheel) override;
void stopNote (float velocity, bool allowTailOff) override;
void pitchWheelMoved (int newValue) override;
void controllerMoved (int controllerNumber, int newValue) override;
void renderNextBlock (AudioBuffer<float>&, int startSample, int numSamples) override;
using SynthesiserVoice::renderNextBlock;
private:
//==============================================================================
double pitchRatio = 0;
double sourceSamplePosition = 0;
float lgain = 0, rgain = 0;
ADSR adsr;
JUCE_LEAK_DETECTOR (SamplerVoice)
};
} // namespace juce
juce::ADSR
Definition juce_ADSR.h:41
juce::AudioBuffer
Definition juce_AudioSampleBuffer.h:34
juce::AudioFormatReader
Definition juce_AudioFormatReader.h:44
juce::BigInteger
Definition juce_BigInteger.h:39
juce::SamplerSound
Definition juce_Sampler.h:44
juce::SamplerSound::SamplerSound
SamplerSound(const String &name, AudioFormatReader &source, const BigInteger &midiNotes, int midiNoteForNormalPitch, double attackTimeSecs, double releaseTimeSecs, double maxSampleLengthSeconds)
Definition juce_Sampler.cpp:29
juce::SamplerSound::getAudioData
AudioBuffer< float > * getAudioData() const noexcept
Definition juce_Sampler.h:83
juce::SamplerSound::setEnvelopeParameters
void setEnvelopeParameters(ADSR::Parameters parametersToUse)
Definition juce_Sampler.h:87
juce::SamplerSound::getName
const String & getName() const noexcept
Definition juce_Sampler.h:78
juce::SamplerVoice
Definition juce_Sampler.h:121
juce::SamplerVoice::startNote
void startNote(int midiNoteNumber, float velocity, SynthesiserSound *, int pitchWheel) override
Definition juce_Sampler.cpp:78
juce::SamplerVoice::controllerMoved
void controllerMoved(int controllerNumber, int newValue) override
Definition juce_Sampler.cpp:114
juce::SamplerVoice::canPlaySound
bool canPlaySound(SynthesiserSound *) override
Definition juce_Sampler.cpp:73
juce::SamplerVoice::renderNextBlock
void renderNextBlock(AudioBuffer< float > &, int startSample, int numSamples) override
Definition juce_Sampler.cpp:117
juce::SamplerVoice::pitchWheelMoved
void pitchWheelMoved(int newValue) override
Definition juce_Sampler.cpp:113
juce::SamplerVoice::SamplerVoice
SamplerVoice()
Definition juce_Sampler.cpp:70
juce::SamplerVoice::stopNote
void stopNote(float velocity, bool allowTailOff) override
Definition juce_Sampler.cpp:100
juce::String
Definition juce_String.h:53
juce::SynthesiserSound
Definition juce_Synthesiser.h:42
juce::SynthesiserVoice::SynthesiserVoice
SynthesiserVoice()
Definition juce_Synthesiser.cpp:30
juce::SynthesiserVoice::renderNextBlock
virtual void renderNextBlock(AudioBuffer< float > &outputBuffer, int startSample, int numSamples)=0
juce::ADSR::Parameters
Definition juce_ADSR.h:56