Loading...
Searching...
No Matches
juce::SamplerSound Class Reference

## Detailed Description

A subclass of SynthesiserSound that represents a sampled audio clip.

This is a pretty basic sampler, and just attempts to load the whole audio stream into memory.

To use it, create a Synthesiser, add some SamplerVoice objects to it, then give it some SamplerSound objects to play.

See also
  SamplerVoice, Synthesiser, SynthesiserSound

The documentation for this class was generated from the following file:

- juce_audio_formats/sampler/juce_Sampler.h

Inheritance diagram for juce::SamplerSound:

## Public Member Functions

| SamplerSound (const String &name, AudioFormatReader &source, const BigInteger &midiNotes, int midiNoteForNormalPitch, double attackTimeSecs, double releaseTimeSecs, double maxSampleLengthSeconds)
| Creates a sampled sound from an audio reader.
| ~SamplerSound () override
| Destructor.
const String & | getName () const noexcept
| Returns the sample's name.
AudioBuffer< float > * | getAudioData () const noexcept
| Returns the audio sample data.
void | setEnvelopeParameters (ADSR::Parameters parametersToUse)
| Changes the parameters of the ADSR envelope which will be applied to the sample.
bool | appliesToNote (int midiNoteNumber) override
| Returns true if this sound should be played when a given midi note is pressed.
bool | appliesToChannel (int midiChannel) override
| Returns true if the sound should be triggered by midi events on a given channel.
Public Member Functions inherited from juce::SynthesiserSound
| ~SynthesiserSound () override
| Destructor.
Public Member Functions inherited from juce::ReferenceCountedObject
void | incReferenceCount () noexcept
| Increments the object's reference count.
void | decReferenceCount () noexcept
| Decreases the object's reference count.
bool | decReferenceCountWithoutDeleting () noexcept
| Decreases the object's reference count.
int | getReferenceCount () const noexcept
| Returns the object's current reference count.

## Additional Inherited Members

Public Types inherited from juce::SynthesiserSound
using | Ptr = ReferenceCountedObjectPtr<SynthesiserSound>
| The class is reference-counted, so this is a handy pointer class for it.
Protected Member Functions inherited from juce::SynthesiserSound
| SynthesiserSound ()
Protected Member Functions inherited from juce::ReferenceCountedObject
| ReferenceCountedObject ()=default
| Creates the reference-counted object (with an initial ref count of zero).
| ReferenceCountedObject (const ReferenceCountedObject &) noexcept
| Copying from another object does not affect this one's reference-count.
| ReferenceCountedObject (ReferenceCountedObject &&) noexcept
| Copying from another object does not affect this one's reference-count.
ReferenceCountedObject & | operator= (const ReferenceCountedObject &) noexcept
| Copying from another object does not affect this one's reference-count.
ReferenceCountedObject & | operator= (ReferenceCountedObject &&) noexcept
| Copying from another object does not affect this one's reference-count.
virtual | ~ReferenceCountedObject ()
| Destructor.
void | resetReferenceCount () noexcept
| Resets the reference count to zero without deleting the object.

## Constructors and Destructors

## SamplerSound()

juce::SamplerSound::SamplerSound | ( | const String & | name,
|  | AudioFormatReader & | source,
|  | const BigInteger & | midiNotes,
|  | int | midiNoteForNormalPitch,
|  | double | attackTimeSecs,
|  | double | releaseTimeSecs,
|  | double | maxSampleLengthSeconds )

Creates a sampled sound from an audio reader.

This will attempt to load the audio from the source into memory and store it in this object.

Parameters

  name | a name for the sample
  source | the audio to load. This object can be safely deleted by the caller after this constructor returns
  midiNotes | the set of midi keys that this sound should be played on. This is used by the SynthesiserSound::appliesToNote() method
  midiNoteForNormalPitch | the midi note at which the sample should be played with its natural rate. All other notes will be pitched up or down relative to this one
  attackTimeSecs | the attack (fade-in) time, in seconds
  releaseTimeSecs | the decay (fade-out) time, in seconds
  maxSampleLengthSeconds | a maximum length of audio to read from the audio source, in seconds

Referenced by SamplerVoice.

## ~SamplerSound()

juce::SamplerSound::~SamplerSound | ( |  | ) |

override

Destructor.

## Member Functions

## getName()

const String & juce::SamplerSound::getName | ( |  | ) | const

inline noexcept

Returns the sample's name.

## getAudioData()

AudioBuffer< float > * juce::SamplerSound::getAudioData | ( |  | ) | const

inline noexcept

Returns the audio sample data.

This could return nullptr if there was a problem loading the data.

## setEnvelopeParameters()

void juce::SamplerSound::setEnvelopeParameters | ( | ADSR::Parameters | parametersToUse | ) |

inline

Changes the parameters of the ADSR envelope which will be applied to the sample.

## appliesToNote()

bool juce::SamplerSound::appliesToNote | ( | int | midiNoteNumber | ) |

override virtual

Returns true if this sound should be played when a given midi note is pressed.

The Synthesiser will use this information when deciding which sounds to trigger for a given note.

Implements juce::SynthesiserSound.

## appliesToChannel()

bool juce::SamplerSound::appliesToChannel | ( | int | midiChannel | ) |

override virtual

Returns true if the sound should be triggered by midi events on a given channel.

The Synthesiser will use this information when deciding which sounds to trigger for a given note.

Implements juce::SynthesiserSound.

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited