Gin
Loading...
Searching...
No Matches
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:

  • Pitch-shifted sample playback (follows MIDI note input)
  • Loop modes: forward, backward, ping-pong
  • Configurable loop points and sample range
  • Automatic high-quality resampling
  • Crossfade support for smooth loop transitions
  • Note on/off triggering

Direction Modes:

  • forwards: Normal forward playback
  • backwards: Reverse playback
  • pingpong: Alternates between forward and backward

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);
void setSampleRateAndBlockSize(double sr, int bs)
@ forwards
Definition gin_sampleoscillator.h:60
void setLooping(bool l, int s=0, int e=-1)
SampleOscillator()=default
void setSample(Sample *)
bool read(double note, juce::AudioSampleBuffer &buffer, int start=0, int length=-1)
void setDirection(Direction d)
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 )

References forwards.


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