SynthLab SDK
SynthLab::SynthLabPCMSource Class Reference

Storage for a set of PCM samples that constitute a patch or instrument. More...

#include <synthlabpcmsource.h>

Inheritance diagram for SynthLab::SynthLabPCMSource:
SynthLab::IPCMSampleSource

Public Member Functions

 SynthLabPCMSource (const char *_sampleFolderPath, const char *_sampleFolderName, double _sampleRate, bool pitchlessLoops=false, bool aubioSlices=false)
 Parses a folder full of wave files and extracts the PCM samples. More...
 
void init (const char *_sampleFolderPath, const char *_sampleFolderName, double _sampleRate, bool pitchlessLoops=false, bool aubioSlices=false)
 Separated initializer, parses a folder full of wave files and extracts the PCM samples. More...
 
virtual void deleteSamples ()
 Delete all samples from memory.
 
virtual uint32_t getValidSampleCount ()
 query for valid sample count (not used in SynthLab but avialable)
 
virtual bool haveValidSamples ()
 Find all non-null sample pointers.
 
 ~SynthLabPCMSource ()
 Destructor nothing to do, samples were deleted prior to destruction here.
 
virtual double selectSample (double oscFrequency)
 Selects a PCM sample based on the target oscillator frequency. More...
 
virtual PCMSampleOutput readSample (double &readIndex, double inc)
 Read and interpolate the table; uses linear interpolation but could be changed to 4th order LaGrange interpolation instead. More...
 
virtual void setSampleLoopMode (SampleLoopMode _loopMode)
 

Protected Attributes

PCMSamplesampleSet [NUM_MIDI_NOTES]
 one PCM sample pointer per note
 
PCMSampleselectedSample = nullptr
 currently selected sample
 
std::string sampleFolderPath
 folder of wave files
 
std::string sampleFolderName
 name of patch
 
double sampleRate = 0.0
 fs
 
SampleLoopMode loopMode = SampleLoopMode::sustain
 different looping modes
 

Detailed Description

Storage for a set of PCM samples that constitute a patch or instrument.

  • exposes the IPCMSampleSource interface
  • initialized with folders full of wave files that are multi-samples
  • the owning object (a wavetable core) selects the PCM sample based on pitch during the update() phase which is ignored since the source only has one table. Then, the owning object makes calls to read the sample during the render() phase
  • see also PCMSample
Author
Will Pirkle http://www.willpirkle.com
Remarks
This object is included and described in further detail in Designing Software Synthesizer Plugins in C++ 2nd Ed. by Will Pirkle
Version
Revision : 1.0
Date
Date : 2021 / 04 / 26

Constructor & Destructor Documentation

◆ SynthLabPCMSource()

SynthLab::SynthLabPCMSource::SynthLabPCMSource ( const char *  _sampleFolderPath,
const char *  _sampleFolderName,
double  _sampleRate,
bool  pitchlessLoops = false,
bool  aubioSlices = false 
)
inline

Parses a folder full of wave files and extracts the PCM samples.

Parameters
_sampleFolderPaththe fully qualified path to the sample folder
_sampleFolderNamethe name of the sample folder; this will be the name of the bank of samples
_sampleRatefs
pitchlessLoopsset true to make pitchless where phaseInc always equals 1.0
aubioSlicesset true if the folder holds wave files made with aubio

Member Function Documentation

◆ init()

void SynthLab::SynthLabPCMSource::init ( const char *  _sampleFolderPath,
const char *  _sampleFolderName,
double  _sampleRate,
bool  pitchlessLoops = false,
bool  aubioSlices = false 
)
inline

Separated initializer, parses a folder full of wave files and extracts the PCM samples.

Parameters
_sampleFolderPaththe fully qualified path to the sample folder
_sampleFolderNamethe name of the sample folder; this will be the name of the bank of samples
_sampleRatefs
pitchlessLoopsset true to make pitchless where phaseInc always equals 1.0
aubioSlicesset true if the folder holds wave files made with aubio

◆ readSample()

virtual PCMSampleOutput SynthLab::SynthLabPCMSource::readSample ( double &  readIndex,
double  inc 
)
inlinevirtual

Read and interpolate the table; uses linear interpolation but could be changed to 4th order LaGrange interpolation instead.

  • checks loop points and looping mode
  • for one shot will set the flag once event is done
Parameters
readIndexthe floating point index (may be fractional); this value will be changed during the function call
incthe phase increment for this read operation; the readIndex will be automatically bumped by this value

Implements SynthLab::IPCMSampleSource.

◆ selectSample()

virtual double SynthLab::SynthLabPCMSource::selectSample ( double  oscFrequency)
inlinevirtual

Selects a PCM sample based on the target oscillator frequency.

Parameters
oscFrequencytarget frequency

Implements SynthLab::IPCMSampleSource.

◆ setSampleLoopMode()

virtual void SynthLab::SynthLabPCMSource::setSampleLoopMode ( SampleLoopMode  _loopMode)
inlinevirtual

set loop mode

Implements SynthLab::IPCMSampleSource.


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