27 |
#include "RIFF.h" |
#include "RIFF.h" |
28 |
|
|
29 |
#if WORDS_BIGENDIAN |
#if WORDS_BIGENDIAN |
30 |
# define RIFF_TYPE_DLS 0x646C7320 |
# define RIFF_TYPE_DLS 0x444C5320 |
31 |
# define LIST_TYPE_INFO 0x494E464F |
# define LIST_TYPE_INFO 0x494E464F |
32 |
# define LIST_TYPE_WVPL 0x7776706C |
# define LIST_TYPE_WVPL 0x7776706C |
33 |
# define LIST_TYPE_DWPL 0x6477706C ///< Seen on some files instead of a wvpl list chunk. |
# define LIST_TYPE_DWPL 0x6477706C ///< Seen on some files instead of a wvpl list chunk. |
69 |
# define CHUNK_ID_ARTL 0x6172746C |
# define CHUNK_ID_ARTL 0x6172746C |
70 |
# define CHUNK_ID_ART2 0x61727432 |
# define CHUNK_ID_ART2 0x61727432 |
71 |
#else // little endian |
#else // little endian |
72 |
# define RIFF_TYPE_DLS 0x20736C64 |
# define RIFF_TYPE_DLS 0x20534C44 |
73 |
# define LIST_TYPE_INFO 0x4F464E49 |
# define LIST_TYPE_INFO 0x4F464E49 |
74 |
# define LIST_TYPE_WVPL 0x6C707677 |
# define LIST_TYPE_WVPL 0x6C707677 |
75 |
# define LIST_TYPE_DWPL 0x6C707764 ///< Seen on some files instead of a wvpl list chunk. |
# define LIST_TYPE_DWPL 0x6C707764 ///< Seen on some files instead of a wvpl list chunk. |
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 |
|
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. |
319 |
|
|
320 |
Info(RIFF::List* list); |
Info(RIFF::List* list); |
321 |
|
virtual ~Info(); |
322 |
virtual void UpdateChunks(); |
virtual void UpdateChunks(); |
323 |
private: |
private: |
324 |
RIFF::List* pResourceListChunk; |
RIFF::List* pResourceListChunk; |
325 |
|
|
326 |
void LoadString(uint32_t ChunkID, RIFF::List* lstINFO, String& s); |
void LoadString(uint32_t ChunkID, RIFF::List* lstINFO, String& s); |
327 |
void SaveString(uint32_t ChunkID, RIFF::List* lstINFO, const String& s, const String& sDefault); |
void SaveString(uint32_t ChunkID, RIFF::List* lstINFO, const String& s, const String& sDefault, int size); |
328 |
}; |
}; |
329 |
|
|
330 |
/** 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. */ |
366 |
/** @brief Encapsulates sample waves used for playback. |
/** @brief Encapsulates sample waves used for playback. |
367 |
* |
* |
368 |
* In case you created a new sample with File::AddSample(), you should |
* In case you created a new sample with File::AddSample(), you should |
369 |
* first call Resize() with the desired sample size. This will create |
* first update all attributes with the desired meta informations |
370 |
|
* (amount of channels, bit depth, sample rate, etc.), then call |
371 |
|
* Resize() with the desired sample size. The latter will create |
372 |
* the mandatory RIFF chunk which will hold the sample wave data. |
* the mandatory RIFF chunk which will hold the sample wave data. |
373 |
*/ |
*/ |
374 |
class Sample : public Resource { |
class Sample : public Resource { |
375 |
public: |
public: |
376 |
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()). |
377 |
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). |
378 |
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). |
379 |
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). |
380 |
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. |
381 |
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). |
382 |
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. |
383 |
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(). |
384 |
|
|
385 |
void* LoadSampleData(); |
void* LoadSampleData(); |
386 |
void ReleaseSampleData(); |
void ReleaseSampleData(); |
457 |
RegionList::iterator RegionsIterator; |
RegionList::iterator RegionsIterator; |
458 |
|
|
459 |
Instrument(File* pFile, RIFF::List* insList); |
Instrument(File* pFile, RIFF::List* insList); |
460 |
void LoadRegions(); |
virtual void LoadRegions(); |
461 |
virtual ~Instrument(); |
virtual ~Instrument(); |
462 |
friend class File; |
friend class File; |
463 |
}; |
}; |
487 |
typedef std::list<Instrument*> InstrumentList; |
typedef std::list<Instrument*> InstrumentList; |
488 |
|
|
489 |
RIFF::File* pRIFF; |
RIFF::File* pRIFF; |
490 |
|
std::list<RIFF::File*> ExtensionFiles; |
491 |
SampleList* pSamples; |
SampleList* pSamples; |
492 |
SampleList::iterator SamplesIterator; |
SampleList::iterator SamplesIterator; |
493 |
InstrumentList* pInstruments; |
InstrumentList* pInstruments; |
498 |
uint32_t* pWavePoolTableHi; |
uint32_t* pWavePoolTableHi; |
499 |
bool b64BitWavePoolOffsets; |
bool b64BitWavePoolOffsets; |
500 |
|
|
501 |
void LoadSamples(); |
virtual void LoadSamples(); |
502 |
void LoadInstruments(); |
virtual void LoadInstruments(); |
503 |
void __ensureMandatoryChunksExist(); |
void __ensureMandatoryChunksExist(); |
504 |
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 |
505 |
private: |
private: |