31 #define RIFF_ID(x) (*((uint32_t*) x))
34 #define RIFF_TYPE_SF2 RIFF_ID("sfbk")
37 #define LIST_TYPE_SDTA RIFF_ID("sdta")
38 #define LIST_TYPE_PDTA RIFF_ID("pdta")
42 #define CHUNK_ID_IFIL RIFF_ID("ifil")
43 #define CHUNK_ID_ISNG RIFF_ID("isng")
44 #define CHUNK_ID_IROM RIFF_ID("irom")
45 #define CHUNK_ID_IVER RIFF_ID("iver")
48 #define CHUNK_ID_SM24 RIFF_ID("sm24")
51 #define CHUNK_ID_PHDR RIFF_ID("phdr")
52 #define CHUNK_ID_PBAG RIFF_ID("pbag")
53 #define CHUNK_ID_PMOD RIFF_ID("pmod")
54 #define CHUNK_ID_PGEN RIFF_ID("pgen")
55 #define CHUNK_ID_INST RIFF_ID("inst")
56 #define CHUNK_ID_IBAG RIFF_ID("ibag")
57 #define CHUNK_ID_IMOD RIFF_ID("imod")
58 #define CHUNK_ID_IGEN RIFF_ID("igen")
59 #define CHUNK_ID_SHDR RIFF_ID("shdr")
64 static uint NONE = 0x1ffffff;
68 double ToHz(
int cents);
313 unsigned long SetPos(
unsigned long SampleCount);
315 unsigned long Read(
void* pBuffer,
unsigned long SampleCount);
319 unsigned long FrameCount,
320 PlaybackState* pPlaybackState,
427 int EG1PreAttackDelay;
434 int EG2PreAttackDelay;
550 std::vector<Preset*> Presets;
551 std::vector<Instrument*> Instruments;
552 std::vector<Sample*> Samples;
559 #endif // __SF2_SF_H__
double GetEG1Release(Region *pPresetRegion=NULL)
int GetVibLfoToPitch(Region *pPresetRegion=NULL)
int GetInitialFilterFc(Region *pPresetRegion)
String Software
[<ISFT-ck>] ; The SoundFont tools used to create and alter the bank
double GetEG1Attack(Region *pPresetRegion=NULL)
double GetFreqVibLfo(Region *pPresetRegion=NULL)
void DeleteSample(Sample *pSample)
unsigned long SetPos(unsigned long SampleCount)
Sets the position within the sample (in sample points, not in bytes).
void DeleteRegion(Region *pRegion)
struct sf2::_RangesType RangesType
int GetEG2Sustain(Region *pPresetRegion=NULL)
String RomName
[<irom-ck>] ; Refers to the Sound ROM Name
double GetEG2Decay(Region *pPresetRegion=NULL)
String libraryVersion()
Returns version of this C++ library.
struct sf2::_InstBag InstBag
double ToRatio(int Centibels)
int startloopAddrsCoarseOffset
Sample(RIFF::Chunk *ck, RIFF::Chunk *pCkSmpl, RIFF::Chunk *pCkSm24)
int GetCoarseTune(Region *pPresetRegion=NULL)
String libraryName()
Returns the name of this C++ library.
int startAddrsCoarseOffset
int GetModLfoToPitch(Region *pPresetRegion=NULL)
unsigned long position
Current position within the sample.
Modulator(SFModulator mod)
struct sf2::_ModList ModList
String Copyright
[<ICOP-ck>] ; Contains any Copyright message
Query(InstrumentBase &instrument)
String Comments
[<ICMT-ck>] ; Contains any Comments on the Bank
String Product
[<IPRD-ck>] ; Product for which the Bank was intended
unsigned long NullExtensionSize
The buffer might be bigger than the actual data, if that's the case that unused space at the end of t...
buffer_t GetCache()
Returns current cached sample points.
double GetDelayModLfo(Region *pPresetRegion=NULL)
double GetEG2Release(Region *pPresetRegion=NULL)
std::vector< Region * > regions
Reflects the current playback state for a sample.
unsigned long loop_cycles_left
How many times the loop has still to be passed, this value will be decremented with each loop cycle...
double GetEG2PreAttackDelay(Region *pPresetRegion=NULL)
double GetModLfoToVolume(Region *pPresetRegion=NULL)
double GetDelayVibLfo(Region *pPresetRegion=NULL)
Exception(String Message)
Version * pRomVer
[<iver-ck>] ; Refers to the Sound ROM Version
double GetEG1Hold(Region *pPresetRegion=NULL)
void DeleteInstrument(Instrument *pInstrument)
void LoadRegions(int idx1, int idx2)
Load all regions (zones, bags) in the range idx1 - idx2.
void LoadRegions(int idx1, int idx2)
Load all regions (zones, bags) in the range idx1 - idx2.
union sf2::_GenAmountType GenAmountType
std::vector< GenList > PresetGenLists
std::vector< InstBag > InstBags
std::vector< ModulatorItem > modulators
buffer_t LoadSampleData()
Loads the whole sample wave into RAM.
Preset * GetPreset(int idx)
unsigned long Read(void *pBuffer, unsigned long SampleCount)
Reads SampleCount number of sample points from the current position into the buffer pointed by pBuffe...
std::vector< ModList > PresetModLists
int endloopAddrsCoarseOffset
double GetEG2Hold(Region *pPresetRegion=NULL)
Preset(sf2::File *pFile, RIFF::Chunk *ck)
ModulatorItem(ModList &mod)
unsigned long GetPos()
Returns the current position in the sample (in sample points).
void * pStart
Points to the beginning of the buffer.
Instrument(sf2::File *pFile, RIFF::Chunk *ck)
std::vector< ModList > InstModLists
buffer_t LoadSampleDataWithNullSamplesExtension(uint NullSamplesCount)
Loads the whole sample wave into RAM.
int GetPan(Region *pPresetRegion=NULL)
int GetFineTune(Region *pPresetRegion=NULL)
Instrument * GetInstrument(int idx)
Version * pVer
<ifil-ck> ; Refers to the version of the Sound Font RIFF file
File(RIFF::File *pRIFF)
Constructor.
double GetEG1PreAttackDelay(Region *pPresetRegion=NULL)
struct sf2::_PresetBag PresetBag
buffer_t RAMCache
Buffers samples (already uncompressed) in RAM.
Pointer address and size of a buffer.
virtual ~InstrumentBase()
String CreationDate
[<ICRD-ck>] ; Refers to the Date of Creation of the Bank
struct sf2::_GenList GenList
int GetInitialFilterQ(Region *pPresetRegion)
int GetEG1Sustain(Region *pPresetRegion=NULL)
long GetTotalFrameCount()
double GetEG1Decay(Region *pPresetRegion=NULL)
double ToSeconds(int Timecents)
Instrument * GetParentInstrument()
SFModulator ModAmtSrcOper
InstrumentBase(sf2::File *pFile)
Will be thrown whenever an error occurs while handling a RIFF file.
String SoundEngine
<isng-ck> ; Refers to the target Sound Engine
String Engineers
[<IENG-ck>] ; Sound Designers and Engineers for the Bank
std::vector< PresetBag > PresetBags
double GetFreqModLfo(Region *pPresetRegion=NULL)
double GetEG2Attack(Region *pPresetRegion=NULL)
unsigned long Size
Size of the actual data in the buffer in bytes.
Region * GetRegion(int idx)
int GetModEnvToPitch(Region *pPresetRegion=NULL)
int GetModLfoToFilterFc(Region *pPresetRegion=NULL)
unsigned long ReadAndLoop(void *pBuffer, unsigned long FrameCount, PlaybackState *pPlaybackState, Region *pRegion)
Reads SampleCount number of sample points from the position stored in pPlaybackState into the buffer ...
std::vector< GenList > InstGenLists
bool reverse
If playback direction is currently backwards (in case there is a pingpong or reverse loop defined)...
String BankName
<INAM-ck> ; Refers to the Sound Font Bank Name
Info(RIFF::List *list)
Constructor.
void ReleaseSampleData()
Frees the cached sample from RAM if loaded with LoadSampleData() previously.
int GetModEnvToFilterFc(Region *pPresetRegion=NULL)
Sample * GetSample(int idx)