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

Sample-based oscillator with pitch tracking and looping capabilities. More...

#include <gin_sampleoscillator.h>

Public Types

enum  Direction { forwards , backwards , pingpong }
 

Public Member Functions

 SampleOscillator ()=default
 
void setSampleRateAndBlockSize (double sr, int bs)
 
void setSample (Sample *)
 
void setRange (int s, int e)
 
void setLooping (bool l, int s=0, int e=-1)
 
void setDirection (Direction d)
 
void setCrossfadeDuration (double s)
 
void noteOn ()
 
void noteOff ()
 
bool read (double note, juce::AudioSampleBuffer &buffer, int start=0, int length=-1)
 

Detailed Description

Sample-based oscillator with pitch tracking and looping capabilities.

SampleOscillator plays back audio samples at different pitches, similar to a sampler. It supports looping, bidirectional playback, sample range selection, and automatic resampling to match the target pitch.

Key Features:

Direction Modes:

Usage:

osc.setSampleRateAndBlockSize(44100.0, 512);
osc.setSample(&mySample);
osc.setLooping(true, 1000, 5000); // Loop between samples 1000-5000
osc.noteOn(); // Trigger playback
// Pitch-shifted playback - plays at MIDI note 60 (C4)
bool isStillPlaying = osc.read(60.0, audioBuffer);
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
@ forwards
Definition gin_sampleoscillator.h:60
See also
Sample, ResamplingFifo

Member Enumeration Documentation

◆ Direction

Enumerator
forwards 
backwards 
pingpong 

Constructor & Destructor Documentation

◆ SampleOscillator()

SampleOscillator::SampleOscillator ( )
default

Member Function Documentation

◆ setSampleRateAndBlockSize()

void SampleOscillator::setSampleRateAndBlockSize ( double  sr,
int  bs 
)

◆ setSample()

void SampleOscillator::setSample ( Sample )

◆ setRange()

void SampleOscillator::setRange ( int  s,
int  e 
)

◆ setLooping()

void SampleOscillator::setLooping ( bool  l,
int  s = 0,
int  e = -1 
)

◆ setDirection()

void SampleOscillator::setDirection ( Direction  d)

◆ setCrossfadeDuration()

void SampleOscillator::setCrossfadeDuration ( double  s)

◆ noteOn()

void SampleOscillator::noteOn ( )

◆ noteOff()

void SampleOscillator::noteOff ( )

◆ read()

bool SampleOscillator::read ( double  note,
juce::AudioSampleBuffer &  buffer,
int  start = 0,
int  length = -1 
)

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