Gin
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Sample Class Reference

Audio sample container for loading and playing back sample data. More...

#include <gin_sample.h>

Public Member Functions

int getLength ()
 
int getRootNote ()
 
double getSampleRate ()
 
juce::AudioSampleBuffer & getSamples ()
 
void read (juce::AudioSampleBuffer &buffer, int samplePos, int bufferPos=0, int length=-1)
 
void readSamplesAt (int pos, float &lOut, float &rOut)
 

Static Public Member Functions

static std::unique_ptr< SamplefromFile (const juce::File &f)
 

Detailed Description

Audio sample container for loading and playing back sample data.

Sample holds audio data loaded from files and provides methods for reading the sample data. It's designed to work with SampleOscillator for pitch-shifted playback and supports storing sample metadata like root note and sample rate.

Key Features:

The root note is used by SampleOscillator to determine pitch shift amounts when playing the sample at different MIDI notes.

Usage:

auto sample = Sample::fromFile(File("/path/to/sample.wav"));
if (sample)
{
DBG("Length: " + String(sample->getLength()));
DBG("Root note: " + String(sample->getRootNote()));
DBG("Sample rate: " + String(sample->getSampleRate()));
// Read portion of sample
AudioBuffer<float> buffer(2, 512);
sample->read(buffer, 0); // Read from sample position 0
// Or use with SampleOscillator
osc.setSample(sample.get());
osc.noteOn();
}
A lightweight 2D point class for projects that don't use juce_graphics.
Definition gin_point.h:25
Sample-based oscillator with pitch tracking and looping capabilities.
Definition gin_sampleoscillator.h:54
static std::unique_ptr< Sample > fromFile(const juce::File &f)
See also
SampleOscillator

Member Function Documentation

◆ fromFile()

static std::unique_ptr< Sample > Sample::fromFile ( const juce::File &  f)
static

◆ getLength()

int Sample::getLength ( )

◆ getRootNote()

int Sample::getRootNote ( )

◆ getSampleRate()

double Sample::getSampleRate ( )

◆ getSamples()

juce::AudioSampleBuffer & Sample::getSamples ( )

◆ read()

void Sample::read ( juce::AudioSampleBuffer &  buffer,
int  samplePos,
int  bufferPos = 0,
int  length = -1 
)

◆ readSamplesAt()

void Sample::readSamplesAt ( int  pos,
float lOut,
float rOut 
)

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