SynthLab SDK
SynthLab::WaveFolder Class Reference

Opens a folder full of WAV files and gleans information about the files to prep them for parsing and having their sample guts extracted. This object can figure out MIDI unity note numbers from the WAV file names (e.g. Dagga_A#4.wav). This object is used to parse folders of samples to build patches for sample based synths. More...

#include <pcmsample.h>

Public Member Functions

 WaveFolder (const char *_waveFolderPath, const char *_waveFolderName)
 
uint32_t parseFolder (PCMSample **sampleSet, bool pitchlessLoops, bool aubioSlices=false)
 The main function that opens a folder, creates the WAV information map, and then parses the files in succession after that. This uses some platform independent code for iterating through folders and files. More...
 
void addNextFileToMap (std::string fileFolderPath, std::string fileName, bool aubioSlices, std::map< int, std::string > *wavFilePaths, int &fileCount)
 Adds information about a WAV file in the folder to a map that is later used to parse the files in succession. More...
 
void eraseSubStr (std::string &mainStr, const std::string &toErase)
 

Protected Member Functions

void buildNoteTables ()
 Sets up the tables for trying to suss out the MIDI note number from a filename that attempts to include the note name/number in its filename. More...
 
int32_t findNoteNumberInName (const char *filename, bool shiftUpOctave=true)
 figure out MIDI note number from string More...
 

Protected Attributes

const char * waveFolderPath
 
const char * waveFolderName
 
std::string noteTableSharps [120]
 table with characters used to decode filenames with sharps
 
std::string noteTableFlats [120]
 table with characters used to decode filenames with flats
 

Detailed Description

Opens a folder full of WAV files and gleans information about the files to prep them for parsing and having their sample guts extracted. This object can figure out MIDI unity note numbers from the WAV file names (e.g. Dagga_A#4.wav). This object is used to parse folders of samples to build patches for sample based synths.

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

Member Function Documentation

◆ addNextFileToMap()

void SynthLab::WaveFolder::addNextFileToMap ( std::string  fileFolderPath,
std::string  fileName,
bool  aubioSlices,
std::map< int, std::string > *  wavFilePaths,
int &  fileCount 
)

Adds information about a WAV file in the folder to a map that is later used to parse the files in succession.

Parameters
fileFolderPaththe WAV folder path
fileNamethe WAV filename
aubioSlicesset to TRUE if these are aubio slice files
wavFilePathsmap to add information to
fileCountreturn value of the number of files found

◆ buildNoteTables()

void SynthLab::WaveFolder::buildNoteTables ( )
protected

Sets up the tables for trying to suss out the MIDI note number from a filename that attempts to include the note name/number in its filename.

◆ findNoteNumberInName()

int32_t SynthLab::WaveFolder::findNoteNumberInName ( const char *  filename,
bool  shiftUpOctave = true 
)
protected

figure out MIDI note number from string

Try to figure out the MIDI note number from the WAV filename.

Parameters
filenamethe WAV filename
shiftUpOctaveset true to offset by one octave; this is due to the two different MIDI note numbering systems still in use that are off by one octave
Returns
the MIDI note number, if found or -1 if not found

◆ parseFolder()

uint32_t SynthLab::WaveFolder::parseFolder ( PCMSample **  sampleSet,
bool  pitchlessLoops,
bool  aubioSlices = false 
)

The main function that opens a folder, creates the WAV information map, and then parses the files in succession after that. This uses some platform independent code for iterating through folders and files.

Parameters
sampleSetthe return variable, an array of pointers to loaded PCM samples
pitchlessLoopsset TRUE if you know the folder has pitchless loops like drum loops
aubioSlicesset to TRUE if these are aubio slice files
Returns
the number of WAV files successfully opened and parsed

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