2 |
* * |
* * |
3 |
* libgig - C++ cross-platform Gigasampler format file loader library * |
* libgig - C++ cross-platform Gigasampler format file loader library * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003-2005 by Christian Schoenebeck * |
* Copyright (C) 2003-2006 by Christian Schoenebeck * |
6 |
* <cuse@users.sourceforge.net> * |
* <cuse@users.sourceforge.net> * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
90 |
# define CHUNK_ID_IENG 0x474E4549 |
# define CHUNK_ID_IENG 0x474E4549 |
91 |
# define CHUNK_ID_IGNR 0x524E4749 |
# define CHUNK_ID_IGNR 0x524E4749 |
92 |
# define CHUNK_ID_IKEY 0x59454B49 |
# define CHUNK_ID_IKEY 0x59454B49 |
93 |
# define CHUNK_ID_IMED 0x44525049 |
# define CHUNK_ID_IMED 0x44454D49 |
94 |
# define CHUNK_ID_INAM 0x4D414E49 |
# define CHUNK_ID_INAM 0x4D414E49 |
95 |
# define CHUNK_ID_IPRD 0x44525049 |
# define CHUNK_ID_IPRD 0x44525049 |
96 |
# define CHUNK_ID_ISBJ 0x4A425349 |
# define CHUNK_ID_ISBJ 0x4A425349 |
315 |
String Source; ///< <ISRC-ck>. Identifies the name of the person or organization who supplied the original subject of the file. |
String Source; ///< <ISRC-ck>. Identifies the name of the person or organization who supplied the original subject of the file. |
316 |
String SourceForm; ///< <ISRF-ck>. Identifies the original form of the material that was digitized, such as record, sampling CD, TV sound track. This is not neccessarily the same as <i>Medium</i>. |
String SourceForm; ///< <ISRF-ck>. Identifies the original form of the material that was digitized, such as record, sampling CD, TV sound track. This is not neccessarily the same as <i>Medium</i>. |
317 |
String Commissioned; ///< <ICMS-ck>. Lists the name of the person or organization that commissioned the subject of the file, e.g., Pope Julian II. |
String Commissioned; ///< <ICMS-ck>. Lists the name of the person or organization that commissioned the subject of the file, e.g., Pope Julian II. |
318 |
|
String Subject; ///< <ISBJ-ck>. Describes the contents of the file. |
319 |
|
bool UseFixedLengthStrings; ///< Set this to true if the info strings should be stored with a fixed length format. This is used for gig files, not for ordinary DLS files. |
320 |
|
|
321 |
Info(RIFF::List* list); |
Info(RIFF::List* list); |
322 |
|
virtual ~Info(); |
323 |
virtual void UpdateChunks(); |
virtual void UpdateChunks(); |
324 |
private: |
private: |
325 |
RIFF::List* pResourceListChunk; |
RIFF::List* pResourceListChunk; |
326 |
|
|
327 |
void LoadString(uint32_t ChunkID, RIFF::List* lstINFO, String& s); |
static void LoadString(uint32_t ChunkID, RIFF::List* lstINFO, String& s); |
328 |
void SaveString(uint32_t ChunkID, RIFF::List* lstINFO, const String& s, const String& sDefault); |
static void SaveString(uint32_t ChunkID, RIFF::List* lstINFO, const String& s, const String& sDefault, bool bUseFixedLengthStrings, int size); |
329 |
}; |
}; |
330 |
|
|
331 |
/** Abstract base class which encapsulates data structures which all DLS resources are able to provide. */ |
/** Abstract base class which encapsulates data structures which all DLS resources are able to provide. */ |
367 |
/** @brief Encapsulates sample waves used for playback. |
/** @brief Encapsulates sample waves used for playback. |
368 |
* |
* |
369 |
* In case you created a new sample with File::AddSample(), you should |
* In case you created a new sample with File::AddSample(), you should |
370 |
* first call Resize() with the desired sample size. This will create |
* first update all attributes with the desired meta informations |
371 |
|
* (amount of channels, bit depth, sample rate, etc.), then call |
372 |
|
* Resize() with the desired sample size. The latter will create |
373 |
* the mandatory RIFF chunk which will hold the sample wave data. |
* the mandatory RIFF chunk which will hold the sample wave data. |
374 |
*/ |
*/ |
375 |
class Sample : public Resource { |
class Sample : public Resource { |
376 |
public: |
public: |
377 |
uint16_t FormatTag; ///< Format ID of the waveform data (should be WAVE_FORMAT_PCM for DLS1 compliant files). |
uint16_t FormatTag; ///< Format ID of the waveform data (should be WAVE_FORMAT_PCM for DLS1 compliant files, this is also the default value if Sample was created with Instrument::AddSample()). |
378 |
uint16_t Channels; ///< Number of channels represented in the waveform data, e.g. 1 for mono, 2 for stereo (). |
uint16_t Channels; ///< Number of channels represented in the waveform data, e.g. 1 for mono, 2 for stereo (defaults to 1=mono if Sample was created with Instrument::AddSample() previously). |
379 |
uint32_t SamplesPerSecond; ///< Sampling rate at which each channel should be played. |
uint32_t SamplesPerSecond; ///< Sampling rate at which each channel should be played (defaults to 44100 if Sample was created with Instrument::AddSample() previously). |
380 |
uint32_t AverageBytesPerSecond; ///< The average number of bytes per second at which the waveform data should be transferred (Playback software can estimate the buffer size using this value). |
uint32_t AverageBytesPerSecond; ///< The average number of bytes per second at which the waveform data should be transferred (Playback software can estimate the buffer size using this value). |
381 |
uint16_t BlockAlign; ///< The block alignment (in bytes) of the waveform data. Playback software needs to process a multiple of <i>BlockAlign</i> bytes of data at a time, so the value of <i>BlockAlign</i> can be used for buffer alignment. |
uint16_t BlockAlign; ///< The block alignment (in bytes) of the waveform data. Playback software needs to process a multiple of <i>BlockAlign</i> bytes of data at a time, so the value of <i>BlockAlign</i> can be used for buffer alignment. |
382 |
uint16_t BitDepth; ///< Size of each sample per channel (only if known sample data format is used, 0 otherwise). |
uint16_t BitDepth; ///< Size of each sample per channel (only if known sample data format is used, 0 otherwise). |
383 |
unsigned long SamplesTotal; ///< Reflects total number of sample points (only if known sample data format is used, 0 otherwise), do not bother to change this value, it will not be saved. |
unsigned long SamplesTotal; ///< Reflects total number of sample points (only if known sample data format is used, 0 otherwise), do not bother to change this value, it will not be saved. |
384 |
uint FrameSize; ///< Reflects the size (in bytes) of one single sample point (only if known sample data format is used, 0 otherwise). |
uint FrameSize; ///< Reflects the size (in bytes) of one single sample point (only if known sample data format is used, 0 otherwise). <b>Caution:</b> with the current version of libgig you have to upate this field by yourself whenever you change one of the following fields: Channels, BitDepth ! Ignoring this might lead to undesired behavior when i.e. calling Resize(), SetPos(), Write() or Read(). |
385 |
|
|
386 |
void* LoadSampleData(); |
void* LoadSampleData(); |
387 |
void ReleaseSampleData(); |
void ReleaseSampleData(); |
458 |
RegionList::iterator RegionsIterator; |
RegionList::iterator RegionsIterator; |
459 |
|
|
460 |
Instrument(File* pFile, RIFF::List* insList); |
Instrument(File* pFile, RIFF::List* insList); |
461 |
void LoadRegions(); |
virtual void LoadRegions(); |
462 |
virtual ~Instrument(); |
virtual ~Instrument(); |
463 |
friend class File; |
friend class File; |
464 |
}; |
}; |
488 |
typedef std::list<Instrument*> InstrumentList; |
typedef std::list<Instrument*> InstrumentList; |
489 |
|
|
490 |
RIFF::File* pRIFF; |
RIFF::File* pRIFF; |
491 |
|
std::list<RIFF::File*> ExtensionFiles; |
492 |
SampleList* pSamples; |
SampleList* pSamples; |
493 |
SampleList::iterator SamplesIterator; |
SampleList::iterator SamplesIterator; |
494 |
InstrumentList* pInstruments; |
InstrumentList* pInstruments; |
499 |
uint32_t* pWavePoolTableHi; |
uint32_t* pWavePoolTableHi; |
500 |
bool b64BitWavePoolOffsets; |
bool b64BitWavePoolOffsets; |
501 |
|
|
502 |
void LoadSamples(); |
virtual void LoadSamples(); |
503 |
void LoadInstruments(); |
virtual void LoadInstruments(); |
504 |
void __ensureMandatoryChunksExist(); |
void __ensureMandatoryChunksExist(); |
505 |
friend class Region; // Region has to look in the wave pool table to get its sample |
friend class Region; // Region has to look in the wave pool table to get its sample |
506 |
private: |
private: |