gig::Sample Class Reference

Encapsulates sample waves of Gigasampler/GigaStudio files used for playback. More...

`#include <gig.h>`

Inheritance diagram for gig::Sample:

## Public Member Functions

buffer_t | LoadSampleData ()
| Loads (and uncompresses if needed) the whole sample wave into RAM.
buffer_t | LoadSampleData (file_offset_t SampleCount)
| Reads (uncompresses if needed) and caches the first SampleCount numbers of SamplePoints in RAM.
buffer_t | LoadSampleDataWithNullSamplesExtension (uint NullSamplesCount)
| Loads (and uncompresses if needed) the whole sample wave into RAM.
buffer_t | LoadSampleDataWithNullSamplesExtension (file_offset_t SampleCount, uint NullSamplesCount)
| Reads (uncompresses if needed) and caches the first SampleCount numbers of SamplePoints in RAM.
buffer_t | GetCache ()
| Returns current cached sample points.
void | ReleaseSampleData ()
| Frees the cached sample from RAM if loaded with LoadSampleData() previously.
void | Resize (file_offset_t NewSize)
| Resize sample.
file_offset_t | SetPos (file_offset_t SampleCount, RIFF::stream_whence_t Whence=RIFF::stream_start)
| Sets the position within the sample (in sample points, not in bytes).
file_offset_t | GetPos () const
| Returns the current position in the sample (in sample points).
file_offset_t | Read (void *pBuffer, file_offset_t SampleCount, buffer_t *pExternalDecompressionBuffer=NULL)
| Reads SampleCount number of sample points from the current position into the buffer pointed by pBuffer and increments the position within the sample.
file_offset_t | ReadAndLoop (void *pBuffer, file_offset_t SampleCount, playback_state_t *pPlaybackState, DimensionRegion *pDimRgn, buffer_t *pExternalDecompressionBuffer=NULL)
| Reads SampleCount number of sample points from the position stored in pPlaybackState into the buffer pointed by pBuffer and moves the position within the sample respectively, this method honors the looping informations of the sample (if any).
file_offset_t | Write (void *pBuffer, file_offset_t SampleCount)
| Write sample wave data.
Group * | GetGroup () const
| Returns pointer to the Group this Sample belongs to.
virtual void | UpdateChunks (progress_t *pProgress)
| Apply sample and its settings to the respective RIFF chunks.
void | CopyAssignMeta (const Sample *orig)
| Make a (semi) deep copy of the Sample object given by orig (without the actual waveform data) and assign it to this object.
void | CopyAssignWave (const Sample *orig)
| Should be called after CopyAssignMeta() and File::Save() sequence.
uint32_t | GetWaveDataCRC32Checksum ()
| Returns the CRC-32 checksum of the sample's raw wave form data at the time when this sample's wave form data was modified for the last time by calling Write().
bool | VerifyWaveData (uint32_t *pActually=NULL)
| Checks the integrity of this sample's raw audio wave data.
file_offset_t | GetSize () const
| Returns sample size.
file_offset_t | Read (void *pBuffer, file_offset_t SampleCount)
| Reads SampleCount number of sample points from the current position into the buffer pointed by pBuffer and increments the position within the sample.
virtual void | DeleteChunks ()
| Remove all RIFF chunks associated with this Sample object.
virtual void | CopyAssign (const Sample *orig)
| Make a deep copy of the Sample object given by orig and assign it to this object.
virtual void | CopyAssign (const Resource *orig)
| Make a deep copy of the Resource object given by orig and assign it to this object.
Resource * | GetParent ()
const Resource * | GetParent () const
void | GenerateDLSID ()
| Generates a new DLSID for the resource.

## Static Public Member Functions

static buffer_t | CreateDecompressionBuffer (file_offset_t MaxReadSize)
| Allocates a decompression buffer for streaming (compressed) samples with Sample::Read().
static void | DestroyDecompressionBuffer (buffer_t &DecompressionBuffer)
| Free decompression buffer, previously created with CreateDecompressionBuffer().
static void | GenerateDLSID (dlsid_t *pDLSID)

## Public Attributes

uint32_t | Manufacturer
| Specifies the MIDI Manufacturer's Association (MMA) Manufacturer code for the sampler intended to receive this file's waveform. If no particular manufacturer is to be specified, a value of 0 should be used.
uint32_t | Product
| Specifies the MIDI model ID defined by the manufacturer corresponding to the Manufacturer field. If no particular manufacturer's product is to be specified, a value of 0 should be used.
uint32_t | SamplePeriod
| Specifies the duration of time that passes during the playback of one sample in nanoseconds (normally equal to 1 / Samples Per Second, where Samples Per Second is the value found in the format chunk), don't bother to update this attribute, it won't be saved.
uint32_t | MIDIUnityNote
| Specifies the musical note at which the sample will be played at it's original sample rate.
uint32_t | FineTune
| Specifies the fraction of a semitone up from the specified MIDI unity note field. A value of 0x80000000 means 1/2 semitone (50 cents) and a value of 0x00000000 means no fine tuning between semitones.
smpte_format_t | SMPTEFormat
| Specifies the Society of Motion Pictures and Television E time format used in the following SMPTEOffset field. If a value of 0 is set, SMPTEOffset should also be set to 0.
uint32_t | SMPTEOffset

The SMPTE Offset value specifies the time offset to be used for the synchronization / calibration to the first sample in the waveform. This value uses a format of 0xhhmmssff where hh is a signed value that specifies the number of hours (-23 to 23), mm is an unsigned value that specifies the number of minutes (0 to 59), ss is an unsigned value that specifies the number of seconds (0 to 59) and ff is an unsigned value that specifies the number of frames (0 to -1).

uint32_t | Loops
| Caution: Use the respective field in the DimensionRegion instead of this one! (Intended purpose: Number of defined sample loops. So far only seen single loops in gig files - please report if you encounter more!)
uint32_t | LoopID
| Specifies the unique ID that corresponds to one of the defined cue points in the cue point list (only if Loops > 0), as the Gigasampler format only allows one loop definition at the moment, this attribute isn't really useful for anything.
loop_type_t | LoopType
| Caution: Use the respective field in the DimensionRegion instead of this one! (Intended purpose: The type field defines how the waveform samples will be looped.)
uint32_t | LoopStart
| Caution: Use the respective field in the DimensionRegion instead of this one! (Intended purpose: The start value specifies the offset [in sample points] in the waveform data of the first sample to be played in the loop [only if Loops > 0].)
uint32_t | LoopEnd
| Caution: Use the respective field in the DimensionRegion instead of this one! (Intended purpose: The end value specifies the offset [in sample points] in the waveform data which represents the end of the loop [only if Loops > 0].)
uint32_t | LoopSize
| Caution: Use the respective fields in the DimensionRegion instead of this one! (Intended purpose: Length of the looping area [in sample points] which is equivalent to
uint32_t | LoopFraction
| The fractional value specifies a fraction of a sample at which to loop. This allows a loop to be fine tuned at a resolution greater than one sample. A value of 0 means no fraction, a value of 0x80000000 means 1/2 of a sample length. 0xFFFFFFFF is the smallest fraction of a sample that can be represented.
uint32_t | LoopPlayCount
| Number of times the loop should be played (a value of 0 = infinite).
bool | Compressed
| If the sample wave is compressed (probably just interesting for instrument and sample editors, as this library already handles the decompression in it's sample access methods anyway).
uint32_t | TruncatedBits
| For 24-bit compressed samples only: number of bits truncated during compression (0, 4 or 6).
bool | Dithered
| For 24-bit compressed samples only: if dithering was used during compression with bit reduction.
uint16_t | FormatTag
| Format ID of the waveform data (should be DLS_WAVE_FORMAT_PCM for DLS1 compliant files, this is also the default value if Sample was created with Instrument::AddSample()).
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).
uint32_t | SamplesPerSecond
| Sampling rate at which each channel should be played (defaults to 44100 if Sample was created with Instrument::AddSample() previously).
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).
uint16_t | BlockAlign
| The block alignment (in bytes) of the waveform data. Playback software needs to process a multiple of BlockAlign bytes of data at a time, so the value of BlockAlign can be used for buffer alignment.
uint16_t | BitDepth
| Size of each sample per channel (only if known sample data format is used, 0 otherwise).
file_offset_t | 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.
uint | FrameSize
| Reflects the size (in bytes) of one single sample point (only if known sample data format is used, 0 otherwise). Caution: 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().
Info * | pInfo
| Points (in any case) to an Info object, providing additional, optional infos and comments.
dlsid_t * | pDLSID
| Points to a dlsid_t structure if the file provided a DLS ID else is NULL.

## Protected Member Functions

| Sample (File *pFile, RIFF::List *waveList, file_offset_t WavePoolOffset, unsigned long fileNo=0, int index=-1)
| Constructor.
| ~Sample ()
| Destructor.
uint32_t | CalculateWaveDataChecksum ()
file_offset_t | GuessSize (file_offset_t samples)
file_offset_t | WorstCaseMaxSamples (buffer_t *pDecompressionBuffer)
void | CopyAssignCore (const Sample *orig)
| Make a deep copy of the Sample object given by orig (without the actual sample waveform data however) and assign it to this object.

## Protected Attributes

Group * | pGroup
| pointer to the Group this sample belongs to (always not-NULL)
file_offset_t | FrameOffset
| Current offset (sample points) in current sample frame (for decompression only).
file_offset_t * | FrameTable
| For positioning within compressed samples only: stores the offset values for each frame.
file_offset_t | SamplePos
| For compressed samples only: stores the current position (in sample points).
file_offset_t | SamplesInLastFrame
| For compressed samples only: length of the last sample frame.
file_offset_t | WorstCaseFrameSize
| For compressed samples only: size (in bytes) of the largest possible sample frame.
file_offset_t | SamplesPerFrame
| For compressed samples only: number of samples in a full sample frame.
buffer_t | RAMCache
| Buffers samples (already uncompressed) in RAM.
unsigned long | FileNo
| File number (> 0 when sample is stored in an extension file, 0 when it's in the gig).
RIFF::Chunk * | pCk3gix
RIFF::Chunk * | pCkSmpl
uint32_t | crc
| Reflects CRC-32 checksum of the raw sample data at the last time when the sample's raw wave form data has been modified consciously by the user by calling Write().
RIFF::List * | pWaveList
RIFF::Chunk * | pCkData
RIFF::Chunk * | pCkFormat
file_offset_t | ullWavePoolOffset
Resource * | pParent
RIFF::List * | pResourceList

## Static Protected Attributes

static size_t | Instances = 0
| Number of instances of class Sample.
static buffer_t | InternalDecompressionBuffer
| Buffer used for decompression of samples, and only if no external decompression buffer was supplied.

## Detailed Description

Encapsulates sample waves of Gigasampler/GigaStudio files used for playback.

This class provides access to the actual audio sample data of a Gigasampler/GigaStudio file. Along to the actual sample data, it also provides access to the sample's meta informations like bit depth, sample rate, encoding type, but also loop informations. The latter may be used by instruments for resembling sounds with arbitary note lengths.

In case you created a new sample with File::AddSample(), you should first update all attributes with the desired meta informations (amount of channels, bit depth, sample rate, etc.), then call Resize() with the desired sample size, followed by File::Save(), this will create the mandatory RIFF chunk which will hold the sample wave data and / or resize the file so you will be able to Write() the sample data directly to disk.

Caution: for gig synthesis, most looping relevant information are retrieved from the respective DimensionRegon instead from the Sample itself. This was made for allowing different loop definitions for the same sample under different conditions.

Since the gig format was designed as extension to the DLS file format, this class is derived from the DLS::Sample class. So also refer to DLS::Sample for additional informations, class attributes and methods.

Definition at line 814 of file gig.h.

## Constructor & Destructor Documentation

## Sample()

gig::Sample::Sample | ( | File * | pFile,
|  | RIFF::List * | waveList,
|  | file_offset_t | WavePoolOffset,
|  | unsigned long | fileNo = 0,
|  | int | index = -1 )

protected

Constructor.

Load an existing sample or create a new one. A 'wave' list chunk must be given to this constructor. In case the given 'wave' list chunk contains a 'fmt', 'data' (and optionally a '3gix', 'smpl') chunk, the format and sample data will be loaded from there, otherwise default values will be used and those chunks will be created when File::Save() will be called later on.

Parameters

  pFile | - pointer to gig::File where this sample is located (or will be located)
  waveList | - pointer to 'wave' list chunk which is (or will be) associated with this sample
  WavePoolOffset | - offset of this sample data from wave pool ('wvpl') list chunk
  fileNo | - number of an extension file where this sample is located, 0 otherwise
  index | - wave pool index of sample (may be -1 on new sample)

Definition at line 390 of file gig.cpp.

References DLS::Sample::BitDepth, DLS::Sample::Channels, Compressed, crc, Dithered, FileNo, FineTune, FrameOffset, FrameTable, gig::File::GetGroup(), RIFF::List::GetSubChunk(), Instances, InternalDecompressionBuffer, gig::loop_type_normal, LoopEnd, LoopFraction, LoopID, LoopPlayCount, Loops, LoopSize, LoopStart, LoopType, Manufacturer, MIDIUnityNote, pGroup, DLS::Resource::pInfo, Product, RAMCache, RIFF::Chunk::ReadInt32(), Sample(), SamplePeriod, SamplePos, DLS::Sample::SamplesPerSecond, RIFF::Chunk::SetPos(), gig::smpte_format_no_offset, SMPTEFormat, SMPTEOffset, and TruncatedBits.

Referenced by CopyAssignMeta(), CopyAssignWave(), and Sample().

## ~Sample()

gig::Sample::~Sample | ( |  | ) |

protected virtual

Destructor.

Frees all memory occupied by this sample.

Reimplemented from DLS::Sample.

Definition at line 1477 of file gig.cpp.

References FrameTable, Instances, InternalDecompressionBuffer, and RAMCache.

## Member Function Documentation

## CalculateWaveDataChecksum()

uint32_t gig::Sample::CalculateWaveDataChecksum | ( |  | ) |

protected

Definition at line 1459 of file gig.cpp.

## CopyAssign() [1/2]

void Resource::CopyAssign | ( | const Resource * | orig | ) |

virtual inherited

Make a deep copy of the Resource object given by orig and assign it to this object.

Parameters

  orig | - original Resource object to be copied from

Definition at line 654 of file DLS.cpp.

References pInfo, and Resource().

Referenced by DLS::Region::CopyAssign(), and DLS::Sample::CopyAssignCore().

## CopyAssign() [2/2]

void DLS::Sample::CopyAssign | ( | const Sample * | orig | ) |

virtual inherited

Make a deep copy of the Sample object given by orig and assign it to this object.

Parameters

  orig | - original Sample object to be copied from

Definition at line 934 of file DLS.cpp.

References CopyAssignCore(), FrameSize, RIFF::Chunk::GetPos(), GetSize(), LoadSampleData(), Read(), Resize(), Sample(), SetPos(), and RIFF::Chunk::SetPos().

## CopyAssignCore()

void DLS::Sample::CopyAssignCore | ( | const Sample * | orig | ) |

protected inherited

Make a deep copy of the Sample object given by orig (without the actual sample waveform data however) and assign it to this object.

This is a special internal variant of CopyAssign() which only copies the most mandatory member variables. It will be called by gig::Sample descendent instead of CopyAssign() since gig::Sample has its own implementation to access and copy the actual sample waveform data.

Parameters

  orig | - original Sample object to be copied from

Definition at line 914 of file DLS.cpp.

References AverageBytesPerSecond, BitDepth, BlockAlign, Channels, DLS::Resource::CopyAssign(), FormatTag, FrameSize, Sample(), SamplesPerSecond, and SamplesTotal.

Referenced by CopyAssign(), and gig::Sample::CopyAssignMeta().

## CopyAssignMeta()

void gig::Sample::CopyAssignMeta | ( | const Sample * | orig | ) |

Make a (semi) deep copy of the Sample object given by orig (without the actual waveform data) and assign it to this object.

Discussion: copying .gig samples is a bit tricky. It requires three steps:

1. Copy sample's meta informations (done by CopyAssignMeta()) including its new sample waveform data size.
2. Saving the file (done by File::Save()) so that it gains correct size and layout for writing the actual wave form data directly to disc in next step.
3. Copy the waveform data with disk streaming (done by CopyAssignWave()).

Parameters

  orig | - original Sample object to be copied from

Definition at line 510 of file gig.cpp.

References DLS::Sample::CopyAssignCore(), FineTune, DLS::Sample::GetSize(), LoopEnd, LoopFraction, LoopID, LoopPlayCount, Loops, LoopSize, LoopStart, LoopType, Manufacturer, MIDIUnityNote, Product, Resize(), Sample(), SamplePeriod, SMPTEFormat, and SMPTEOffset.

Referenced by gig::File::AddContentOf().

## CopyAssignWave()

void gig::Sample::CopyAssignWave | ( | const Sample * | orig | ) |

Should be called after CopyAssignMeta() and File::Save() sequence.

Read more about it in the discussion of CopyAssignMeta(). This method copies the actual waveform data by disk streaming.

CAUTION: this method is currently not thread safe! During this operation the sample must not be used for other purposes by other threads!

Parameters

  orig | - original Sample object to be copied from

Definition at line 546 of file gig.cpp.

References DLS::Sample::FrameSize, GetPos(), Read(), Sample(), SetPos(), and Write().

## CreateDecompressionBuffer()

buffer_t gig::Sample::CreateDecompressionBuffer | ( | file_offset_t | MaxReadSize | ) |

static

Allocates a decompression buffer for streaming (compressed) samples with Sample::Read().

If you are using more than one streaming thread in your application you HAVE to create a decompression buffer for EACH of your streaming threads and provide it with the Sample::Read() call in order to avoid race conditions and crashes.

You should free the memory occupied by the allocated buffer(s) once you don't need one of your streaming threads anymore by calling DestroyDecompressionBuffer().

Parameters

  MaxReadSize | - the maximum size (in sample points) you ever expect to read with one Read() call

Returns
  allocated decompression buffer

See also
  DestroyDecompressionBuffer()

Definition at line 1373 of file gig.cpp.

References gig::buffer_t::NullExtensionSize, gig::buffer_t::pStart, and gig::buffer_t::Size.

## DeleteChunks()

void DLS::Sample::DeleteChunks | ( |  | ) |

virtual inherited

Remove all RIFF chunks associated with this Sample object.

See Storage::DeleteChunks() for details.

Reimplemented from DLS::Resource.

Definition at line 891 of file DLS.cpp.

References DLS::Resource::DeleteChunks(), RIFF::List::DeleteSubChunk(), and RIFF::Chunk::GetParent().

Referenced by DLS::File::DeleteSample(), and gig::File::DeleteSample().

## DestroyDecompressionBuffer()

void gig::Sample::DestroyDecompressionBuffer | ( | buffer_t & | DecompressionBuffer | ) |

static

Free decompression buffer, previously created with CreateDecompressionBuffer().

Parameters

  DecompressionBuffer | - previously allocated decompression buffer to free

Definition at line 1390 of file gig.cpp.

References gig::buffer_t::NullExtensionSize, gig::buffer_t::pStart, and gig::buffer_t::Size.

## GenerateDLSID() [1/2]

void Resource::GenerateDLSID | ( |  | ) |

inherited

Generates a new DLSID for the resource.

Definition at line 604 of file DLS.cpp.

References GenerateDLSID(), and pDLSID.

Referenced by gig::File::AddInstrument(), GenerateDLSID(), gig::Script::GenerateUuid(), and DLS::File::UpdateChunks().

## GenerateDLSID() [2/2]

void Resource::GenerateDLSID | ( | dlsid_t * | pDLSID | ) |

static inherited

Definition at line 611 of file DLS.cpp.

## GetCache()

buffer_t gig::Sample::GetCache | ( |  | ) |

Returns current cached sample points.

A buffer_t structure will be returned which contains address pointer to the begin of the cache and the size of the cached sample data in bytes. Use LoadSampleData() to cache a specific amount of sample points in RAM.

Returns
  buffer_t structure with current cached sample points

See also
  LoadSampleData();

Definition at line 814 of file gig.cpp.

References gig::buffer_t::NullExtensionSize, gig::buffer_t::pStart, RAMCache, and gig::buffer_t::Size.

Referenced by LoadSampleDataWithNullSamplesExtension().

## GetGroup()

Group * gig::Sample::GetGroup | ( |  | ) | const

Returns pointer to the Group this Sample belongs to.

In the .gig format a sample always belongs to one group. If it wasn't explicitly assigned to a certain group, it will be automatically assigned to a default group.

Returns
  Sample's Group (never NULL)

Definition at line 1407 of file gig.cpp.

References pGroup.

Referenced by gig::File::AddContentOf().

## GetParent() [1/2]

Resource * DLS::Resource::GetParent | ( |  | ) |

inline inherited

Definition at line 409 of file DLS.h.

## GetParent() [2/2]

const Resource * DLS::Resource::GetParent | ( |  | ) | const

inline inherited

Definition at line 410 of file DLS.h.

## GetPos()

file_offset_t gig::Sample::GetPos | ( |  | ) | const

Returns the current position in the sample (in sample points).

Definition at line 926 of file gig.cpp.

References Compressed, DLS::Sample::FrameSize, and SamplePos.

Referenced by CopyAssignWave(), and ReadAndLoop().

## GetSize()

file_offset_t DLS::Sample::GetSize | ( |  | ) | const

inherited

Returns sample size.

Returns the sample wave form's data size (in sample points). This is actually the current, physical size (converted to sample points) of the RIFF chunk which encapsulates the sample's wave data. The returned value is dependant to the current FrameSize value.

Returns
  number of sample points or 0 if FormatTag != DLS_WAVE_FORMAT_PCM

See also
  FrameSize, FormatTag

Definition at line 1003 of file DLS.cpp.

References FormatTag, and FrameSize.

Referenced by CopyAssign(), gig::Sample::CopyAssignMeta(), Write(), and gig::Sample::Write().

## GetWaveDataCRC32Checksum()

uint32_t gig::Sample::GetWaveDataCRC32Checksum | ( |  | ) |

Returns the CRC-32 checksum of the sample's raw wave form data at the time when this sample's wave form data was modified for the last time by calling Write().

This checksum only covers the raw wave form data, not any meta informations like i.e. bit depth or loop points. Since this method just returns the checksum stored for this sample i.e. when the gig file was loaded, this method returns immediately. So it does no recalcuation of the checksum with the currently available sample wave form data.

See also
  VerifyWaveData()

Definition at line 1423 of file gig.cpp.

References crc.

## GuessSize()

file_offset_t gig::Sample::GuessSize | ( | file_offset_t | samples | ) |

inline protected

Definition at line 879 of file gig.h.

## LoadSampleData() [1/2]

buffer_t gig::Sample::LoadSampleData | ( |  | ) |

Loads (and uncompresses if needed) the whole sample wave into RAM.

Use ReleaseSampleData() to free the memory if you don't need the cached sample data anymore.

Returns
  buffer_t structure with start address and size of the buffer in bytes

See also
  ReleaseSampleData(), Read(), SetPos()

Definition at line 706 of file gig.cpp.

References LoadSampleDataWithNullSamplesExtension(), and DLS::Sample::SamplesTotal.

## LoadSampleData() [2/2]

buffer_t gig::Sample::LoadSampleData | ( | file_offset_t | SampleCount | ) |

Reads (uncompresses if needed) and caches the first SampleCount numbers of SamplePoints in RAM.

Use ReleaseSampleData() to free the memory space if you don't need the cached samples anymore. There is no guarantee that exactly SampleCount samples will be cached; this is not an error. The size will be eventually truncated e.g. to the beginning of a frame of a compressed sample. This is done for efficiency reasons while streaming the wave by your sampler engine later. Read the Size member of the buffer_t structure that will be returned to determine the actual cached samples, but note that the size is given in bytes! You get the number of actually cached samples by dividing it by the frame size of the sample:

buffer_t buf = pSample->LoadSampleData(acquired_samples);
long cachedsamples = buf.Size / pSample->FrameSize;
gig::buffer_t
Pointer address and size of a buffer.
Definition gig.h:114
gig::buffer_t::Size
file_offset_t Size
Size of the actual data in the buffer in bytes.
Definition gig.h:116

Parameters

  SampleCount | - number of sample points to load into RAM

Returns
  buffer_t structure with start address and size of the cached sample data in bytes

See also
  ReleaseSampleData(), Read(), SetPos()

Definition at line 732 of file gig.cpp.

References LoadSampleDataWithNullSamplesExtension().

## LoadSampleDataWithNullSamplesExtension() [1/2]

buffer_t gig::Sample::LoadSampleDataWithNullSamplesExtension | ( | file_offset_t | SampleCount,
|  | uint | NullSamplesCount )

Reads (uncompresses if needed) and caches the first SampleCount numbers of SamplePoints in RAM.

Use ReleaseSampleData() to free the memory space if you don't need the cached samples anymore. There is no guarantee that exactly SampleCount samples will be cached; this is not an error. The size will be eventually truncated e.g. to the beginning of a frame of a compressed sample. This is done for efficiency reasons while streaming the wave by your sampler engine later. Read the Size member of the buffer_t structure that will be returned to determine the actual cached samples, but note that the size is given in bytes! You get the number of actually cached samples by dividing it by the frame size of the sample:

buffer_t buf = pSample->LoadSampleDataWithNullSamplesExtension(acquired_samples, null_samples);
long cachedsamples = buf.Size / pSample->FrameSize;

The method will add NullSamplesCount silence samples past the official buffer end (this won't affect the 'Size' member of the buffer_t structure, that means 'Size' always reflects the size of the actual sample data, the buffer might be bigger though). Silence samples past the official buffer are needed for differential algorithms that always have to take subsequent samples into account (resampling/interpolation would be an important example) and avoids memory access faults in such cases.

Parameters

  SampleCount | - number of sample points to load into RAM
  NullSamplesCount | - number of silence samples the buffer should be extended past it's data end

Returns
  buffer_t structure with start address and size of the cached sample data in bytes

See also
  ReleaseSampleData(), Read(), SetPos()

Definition at line 791 of file gig.cpp.

References DLS::Sample::FrameSize, GetCache(), RAMCache, Read(), DLS::Sample::SamplesTotal, and SetPos().

## LoadSampleDataWithNullSamplesExtension() [2/2]

buffer_t gig::Sample::LoadSampleDataWithNullSamplesExtension | ( | uint | NullSamplesCount | ) |

Loads (and uncompresses if needed) the whole sample wave into RAM.

Use ReleaseSampleData() to free the memory if you don't need the cached sample data anymore. The method will add NullSamplesCount silence samples past the official buffer end (this won't affect the 'Size' member of the buffer_t structure, that means 'Size' always reflects the size of the actual sample data, the buffer might be bigger though). Silence samples past the official buffer are needed for differential algorithms that always have to take subsequent samples into account (resampling/interpolation would be an important example) and avoids memory access faults in such cases.

Parameters

  NullSamplesCount | - number of silence samples the buffer should be extended past it's data end

Returns
  buffer_t structure with start address and size of the buffer in bytes

See also
  ReleaseSampleData(), Read(), SetPos()

Definition at line 755 of file gig.cpp.

References LoadSampleDataWithNullSamplesExtension(), and DLS::Sample::SamplesTotal.

Referenced by LoadSampleData(), LoadSampleData(), and LoadSampleDataWithNullSamplesExtension().

## Read() [1/2]

file_offset_t DLS::Sample::Read | ( | void * | pBuffer,
|  | file_offset_t | SampleCount )

inherited

Reads SampleCount number of sample points from the current position into the buffer pointed by pBuffer and increments the position within the sample.

Use this method and SetPos() if you don't want to load the sample into RAM, thus for disk streaming.

Parameters

  pBuffer | destination buffer
  SampleCount | number of sample points to read

Definition at line 1081 of file DLS.cpp.

References FormatTag, and FrameSize.

Referenced by CopyAssign().

## Read() [2/2]

file_offset_t gig::Sample::Read | ( | void * | pBuffer,
|  | file_offset_t | SampleCount,
|  | buffer_t * | pExternalDecompressionBuffer = NULL )

Reads SampleCount number of sample points from the current position into the buffer pointed by pBuffer and increments the position within the sample.

The sample wave stream will be decompressed on the fly if using a compressed sample. Use this method and SetPos() if you don't want to load the sample into RAM, thus for disk streaming.

Caution: If you are using more than one streaming thread, you have to use an external decompression buffer for EACH streaming thread to avoid race conditions and crashes!

For 16 bit samples, the data in the buffer will be int16_t (using native endianness). For 24 bit, the buffer will contain three bytes per sample, little-endian.

Parameters

  pBuffer | destination buffer
  SampleCount | number of sample points to read
  pExternalDecompressionBuffer | (optional) external buffer to use for decompression

Returns
  number of successfully read sample points

See also
  SetPos(), CreateDecompressionBuffer()

Definition at line 1140 of file gig.cpp.

References DLS::Sample::BitDepth, DLS::Sample::Channels, Compressed, FrameOffset, DLS::Sample::FrameSize, InternalDecompressionBuffer, gig::buffer_t::pStart, SamplePos, SamplesInLastFrame, SamplesPerFrame, DLS::Sample::SamplesTotal, gig::buffer_t::Size, and TruncatedBits.

Referenced by CopyAssignWave(), LoadSampleDataWithNullSamplesExtension(), and ReadAndLoop().

## ReadAndLoop()

file_offset_t gig::Sample::ReadAndLoop | ( | void * | pBuffer,
|  | file_offset_t | SampleCount,
|  | playback_state_t * | pPlaybackState,
|  | DimensionRegion * | pDimRgn,
|  | buffer_t * | pExternalDecompressionBuffer = NULL )

Reads SampleCount number of sample points from the position stored in pPlaybackState into the buffer pointed by pBuffer and moves the position within the sample respectively, this method honors the looping informations of the sample (if any).

The sample wave stream will be decompressed on the fly if using a compressed sample. Use this method if you don't want to load the sample into RAM, thus for disk streaming. All this methods needs to know to proceed with streaming for the next time you call this method is stored in pPlaybackState. You have to allocate and initialize the playback_state_t structure by yourself before you use it to stream a sample:

gig::playback_state_t playbackstate;
playbackstate.position = 0;
playbackstate.reverse = false;
playbackstate.loop_cycles_left = pSample->LoopPlayCount;
gig::playback_state_t
Reflects the current playback state for a sample.
Definition gig.h:422
gig::playback_state_t::reverse
bool reverse
If playback direction is currently backwards (in case there is a pingpong or reverse loop defined).
Definition gig.h:424
gig::playback_state_t::loop_cycles_left
file_offset_t loop_cycles_left
How many times the loop has still to be passed, this value will be decremented with each loop cycle.
Definition gig.h:425
gig::playback_state_t::position
file_offset_t position
Current position within the sample.
Definition gig.h:423

You don't have to take care of things like if there is actually a loop defined or if the current read position is located within a loop area. The method already handles such cases by itself.

Caution: If you are using more than one streaming thread, you have to use an external decompression buffer for EACH streaming thread to avoid race conditions and crashes!

Parameters

  pBuffer | destination buffer
  SampleCount | number of sample points to read
  pPlaybackState | will be used to store and reload the playback state for the next ReadAndLoop() call
  pDimRgn | dimension region with looping information
  pExternalDecompressionBuffer | (optional) external buffer to use for decompression

Returns
  number of successfully read sample points

See also
  CreateDecompressionBuffer()

Definition at line 965 of file gig.cpp.

References DLS::Sample::FrameSize, GetPos(), gig::playback_state_t::loop_cycles_left, gig::loop_type_backward, gig::loop_type_bidirectional, gig::loop_type_normal, DLS::sample_loop_t::LoopLength, LoopPlayCount, DLS::sample_loop_t::LoopStart, DLS::sample_loop_t::LoopType, gig::playback_state_t::position, gig::DimensionRegion::pSampleLoops, Read(), gig::playback_state_t::reverse, gig::DimensionRegion::SampleLoops, and SetPos().

## ReleaseSampleData()

void gig::Sample::ReleaseSampleData | ( |  | ) |

Frees the cached sample from RAM if loaded with LoadSampleData() previously.

See also
  LoadSampleData();

Definition at line 829 of file gig.cpp.

References RAMCache.

## Resize()

void gig::Sample::Resize | ( | file_offset_t | NewSize | ) |

Resize sample.

Resizes the sample's wave form data, that is the actual size of sample wave data possible to be written for this sample. This call will return immediately and just schedule the resize operation. You should call File::Save() to actually perform the resize operation(s) "physically" to the file. As this can take a while on large files, it is recommended to call Resize() first on all samples which have to be resized and finally to call File::Save() to perform all those resize operations in one rush.

The actual size (in bytes) is dependant to the current FrameSize value. You may want to set FrameSize before calling Resize().

Caution: You cannot directly write (i.e. with Write()) to enlarged samples before calling File::Save() as this might exceed the current sample's boundary!

Also note: only DLS_WAVE_FORMAT_PCM is currently supported, that is FormatTag must be DLS_WAVE_FORMAT_PCM. Trying to resize samples with other formats will fail!

Parameters

  NewSize | - new sample wave data size in sample points (must be greater than zero)

Exceptions

  DLS::Excecption | if FormatTag != DLS_WAVE_FORMAT_PCM
  DLS::Exception | if NewSize is less than 1 or unrealistic large
  gig::Exception | if existing sample is compressed

See also
  DLS::Sample::GetSize(), DLS::Sample::FrameSize, DLS::Sample::FormatTag, File::Save()

Definition at line 866 of file gig.cpp.

References Compressed, and DLS::Sample::Resize().

Referenced by CopyAssignMeta().

## SetPos()

file_offset_t gig::Sample::SetPos | ( | file_offset_t | SampleCount,
|  | RIFF::stream_whence_t | Whence = RIFF::stream_start )

Sets the position within the sample (in sample points, not in bytes).

Use this method and Read() if you don't want to load the sample into RAM, thus for disk streaming.

Although the original Gigasampler engine doesn't allow positioning within compressed samples, I decided to implement it. Even though the Gigasampler format doesn't allow to define loops for compressed samples at the moment, positioning within compressed samples might be interesting for some sampler engines though. The only drawback about my decision is that it takes longer to load compressed gig Files on startup, because it's neccessary to scan the samples for some mandatory informations. But I think as it doesn't affect the runtime efficiency, nobody will have a problem with that.

Parameters

  SampleCount | number of sample points to jump
  Whence | optional: to which relation SampleCount refers to, if omited RIFF::stream_start is assumed

Returns
  the new sample position

See also
  Read()

Definition at line 892 of file gig.cpp.

References Compressed, FrameOffset, DLS::Sample::FrameSize, FrameTable, SamplePos, and DLS::Sample::SamplesTotal.

Referenced by CopyAssignWave(), LoadSampleDataWithNullSamplesExtension(), and ReadAndLoop().

## UpdateChunks()

void gig::Sample::UpdateChunks | ( | progress_t * | pProgress | ) |

virtual

Apply sample and its settings to the respective RIFF chunks.

You have to call File::Save() to make changes persistent.

Usually there is absolutely no need to call this method explicitly. It will be called automatically when File::Save() was called.

Parameters

  pProgress | - callback function for progress notification

Exceptions

  DLS::Exception | if FormatTag != DLS_WAVE_FORMAT_PCM or no sample data was provided yet
  gig::Exception | if there is any invalid sample setting

Reimplemented from DLS::Sample.

Definition at line 574 of file gig.cpp.

References Compressed, FineTune, LoopEnd, LoopFraction, LoopID, LoopPlayCount, Loops, LoopStart, LoopType, Manufacturer, MIDIUnityNote, pGroup, Product, SamplePeriod, DLS::Sample::SamplesPerSecond, SMPTEFormat, SMPTEOffset, and DLS::Sample::UpdateChunks().

## VerifyWaveData()

bool gig::Sample::VerifyWaveData | ( | uint32_t * | pActually = NULL | ) |

Checks the integrity of this sample's raw audio wave data.

Whenever a Sample's raw wave data is intentionally modified (i.e. by calling Write() and supplying the new raw audio wave form data) a CRC32 checksum is calculated and stored/updated for this sample, along to the sample's meta informations.

Now by calling this method the current raw audio wave data is checked against the already stored CRC32 check sum in order to check whether the sample data had been damaged unintentionally for some reason. Since by calling this method always the entire raw audio wave data has to be read, verifying all samples this way may take a long time accordingly. And that's also the reason why the sample integrity is not checked by default whenever a gig file is loaded. So this method must be called explicitly to fulfill this task.

Parameters

  pActually | - (optional) if provided, will be set to the actually calculated checksum of the current raw wave form data, you can get the expected checksum instead by calling GetWaveDataCRC32Checksum()

Returns
  true if sample is OK or false if the sample is damaged

Exceptions

  Exception | if no checksum had been stored to disk for this sample yet, or on I/O issues

See also
  GetWaveDataCRC32Checksum()

Definition at line 1452 of file gig.cpp.

References crc.

## WorstCaseMaxSamples()

file_offset_t gig::Sample::WorstCaseMaxSamples | ( | buffer_t * | pDecompressionBuffer | ) |

inline protected

Definition at line 896 of file gig.h.

## Write()

file_offset_t gig::Sample::Write | ( | void * | pBuffer,
|  | file_offset_t | SampleCount )

Write sample wave data.

Writes SampleCount number of sample points from the buffer pointed by pBuffer and increments the position within the sample. Use this method to directly write the sample data to disk, i.e. if you don't want or cannot load the whole sample data into RAM.

You have to Resize() the sample to the desired size and call File::Save() before using Write().

Note: there is currently no support for writing compressed samples.

For 16 bit samples, the data in the source buffer should be int16_t (using native endianness). For 24 bit, the buffer should contain three bytes per sample, little-endian.

Parameters

  pBuffer | - source buffer
  SampleCount | - number of sample points to write

Exceptions

  DLS::Exception | if current sample size is too small
  gig::Exception | if sample is compressed

See also
  DLS::LoadSampleData()

Definition at line 1329 of file gig.cpp.

References DLS::Sample::BitDepth, DLS::Sample::Channels, Compressed, crc, DLS::Sample::FrameSize, DLS::Sample::GetSize(), and gig::File::SetSampleChecksum().

Referenced by CopyAssignWave().

## Member Data Documentation

## AverageBytesPerSecond

uint32_t DLS::Sample::AverageBytesPerSecond

inherited

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).

Definition at line 462 of file DLS.h.

Referenced by CopyAssignCore(), Sample(), and UpdateChunks().

## BitDepth

uint16_t DLS::Sample::BitDepth

inherited

Size of each sample per channel (only if known sample data format is used, 0 otherwise).

Definition at line 464 of file DLS.h.

Referenced by CopyAssignCore(), gig::Sample::Read(), Sample(), gig::Sample::Sample(), UpdateChunks(), and gig::Sample::Write().

## BlockAlign

uint16_t DLS::Sample::BlockAlign

inherited

The block alignment (in bytes) of the waveform data. Playback software needs to process a multiple of BlockAlign bytes of data at a time, so the value of BlockAlign can be used for buffer alignment.

Definition at line 463 of file DLS.h.

Referenced by CopyAssignCore(), Sample(), and UpdateChunks().

## Channels

uint16_t DLS::Sample::Channels

inherited

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).

Definition at line 460 of file DLS.h.

Referenced by CopyAssignCore(), gig::Sample::Read(), Sample(), gig::Sample::Sample(), UpdateChunks(), gig::File::UpdateChunks(), and gig::Sample::Write().

## Compressed

bool gig::Sample::Compressed

If the sample wave is compressed (probably just interesting for instrument and sample editors, as this library already handles the decompression in it's sample access methods anyway).

Definition at line 831 of file gig.h.

Referenced by GetPos(), Read(), Resize(), Sample(), SetPos(), UpdateChunks(), and Write().

## crc

uint32_t gig::Sample::crc

protected

Reflects CRC-32 checksum of the raw sample data at the last time when the sample's raw wave form data has been modified consciously by the user by calling Write().

Definition at line 872 of file gig.h.

Referenced by GetWaveDataCRC32Checksum(), gig::File::RebuildSampleChecksumTable(), Sample(), gig::File::UpdateChunks(), VerifyWaveData(), and Write().

## Dithered

bool gig::Sample::Dithered

For 24-bit compressed samples only: if dithering was used during compression with bit reduction.

Definition at line 833 of file gig.h.

Referenced by Sample().

## FileNo

unsigned long gig::Sample::FileNo

protected

File number (> 0 when sample is stored in an extension file, 0 when it's in the gig).

Definition at line 869 of file gig.h.

Referenced by Sample().

## FineTune

uint32_t gig::Sample::FineTune

Specifies the fraction of a semitone up from the specified MIDI unity note field. A value of 0x80000000 means 1/2 semitone (50 cents) and a value of 0x00000000 means no fine tuning between semitones.

Definition at line 820 of file gig.h.

Referenced by CopyAssignMeta(), Sample(), and UpdateChunks().

## FormatTag

uint16_t DLS::Sample::FormatTag

inherited

Format ID of the waveform data (should be DLS_WAVE_FORMAT_PCM for DLS1 compliant files, this is also the default value if Sample was created with Instrument::AddSample()).

Definition at line 459 of file DLS.h.

Referenced by CopyAssignCore(), GetSize(), Read(), Resize(), Sample(), SetPos(), UpdateChunks(), and Write().

## FrameOffset

file_offset_t gig::Sample::FrameOffset

protected

Current offset (sample points) in current sample frame (for decompression only).

Definition at line 862 of file gig.h.

Referenced by Read(), Sample(), and SetPos().

## FrameSize

uint DLS::Sample::FrameSize

inherited

Reflects the size (in bytes) of one single sample point (only if known sample data format is used, 0 otherwise). Caution: 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().

Definition at line 466 of file DLS.h.

Referenced by CopyAssign(), CopyAssignCore(), gig::Sample::CopyAssignWave(), gig::Sample::GetPos(), GetSize(), gig::Sample::LoadSampleDataWithNullSamplesExtension(), Read(), gig::Sample::Read(), gig::Sample::ReadAndLoop(), Resize(), Sample(), SetPos(), gig::Sample::SetPos(), Write(), and gig::Sample::Write().

## FrameTable

file_offset_t* gig::Sample::FrameTable

protected

For positioning within compressed samples only: stores the offset values for each frame.

Definition at line 863 of file gig.h.

Referenced by Sample(), SetPos(), and ~Sample().

## Instances

size_t gig::Sample::Instances = 0

static protected

Number of instances of class Sample.

Definition at line 859 of file gig.h.

Referenced by Sample(), and ~Sample().

## InternalDecompressionBuffer

buffer_t gig::Sample::InternalDecompressionBuffer

static protected

Buffer used for decompression of samples, and only if no external decompression buffer was supplied.

Definition at line 860 of file gig.h.

Referenced by Read(), Sample(), and ~Sample().

## LoopEnd

uint32_t gig::Sample::LoopEnd

Caution: Use the respective field in the DimensionRegion instead of this one! (Intended purpose: The end value specifies the offset [in sample points] in the waveform data which represents the end of the loop [only if Loops > 0].)

Definition at line 827 of file gig.h.

Referenced by CopyAssignMeta(), Sample(), and UpdateChunks().

## LoopFraction

uint32_t gig::Sample::LoopFraction

The fractional value specifies a fraction of a sample at which to loop. This allows a loop to be fine tuned at a resolution greater than one sample. A value of 0 means no fraction, a value of 0x80000000 means 1/2 of a sample length. 0xFFFFFFFF is the smallest fraction of a sample that can be represented.

Definition at line 829 of file gig.h.

Referenced by CopyAssignMeta(), Sample(), and UpdateChunks().

## LoopID

uint32_t gig::Sample::LoopID

Specifies the unique ID that corresponds to one of the defined cue points in the cue point list (only if Loops > 0), as the Gigasampler format only allows one loop definition at the moment, this attribute isn't really useful for anything.

Definition at line 824 of file gig.h.

Referenced by CopyAssignMeta(), Sample(), and UpdateChunks().

## LoopPlayCount

uint32_t gig::Sample::LoopPlayCount

Number of times the loop should be played (a value of 0 = infinite).

Definition at line 830 of file gig.h.

Referenced by CopyAssignMeta(), ReadAndLoop(), Sample(), and UpdateChunks().

## Loops

uint32_t gig::Sample::Loops

Caution: Use the respective field in the DimensionRegion instead of this one! (Intended purpose: Number of defined sample loops. So far only seen single loops in gig files - please report if you encounter more!)

Definition at line 823 of file gig.h.

Referenced by CopyAssignMeta(), Sample(), and UpdateChunks().

## LoopSize

uint32_t gig::Sample::LoopSize

Caution: Use the respective fields in the DimensionRegion instead of this one! (Intended purpose: Length of the looping area [in sample points] which is equivalent to

LoopEnd - LoopStart
gig::Sample::LoopStart
uint32_t LoopStart
Caution: Use the respective field in the DimensionRegion instead of this one! (Intended purpose: The ...
Definition gig.h:826
gig::Sample::LoopEnd
uint32_t LoopEnd
Caution: Use the respective field in the DimensionRegion instead of this one! (Intended purpose: The ...
Definition gig.h:827

.)

Definition at line 828 of file gig.h.

Referenced by CopyAssignMeta(), and Sample().

## LoopStart

uint32_t gig::Sample::LoopStart

Caution: Use the respective field in the DimensionRegion instead of this one! (Intended purpose: The start value specifies the offset [in sample points] in the waveform data of the first sample to be played in the loop [only if Loops > 0].)

Definition at line 826 of file gig.h.

Referenced by CopyAssignMeta(), Sample(), and UpdateChunks().

## LoopType

loop_type_t gig::Sample::LoopType

Caution: Use the respective field in the DimensionRegion instead of this one! (Intended purpose: The type field defines how the waveform samples will be looped.)

Definition at line 825 of file gig.h.

Referenced by CopyAssignMeta(), Sample(), and UpdateChunks().

## Manufacturer

uint32_t gig::Sample::Manufacturer

Specifies the MIDI Manufacturer's Association (MMA) Manufacturer code for the sampler intended to receive this file's waveform. If no particular manufacturer is to be specified, a value of 0 should be used.

Definition at line 816 of file gig.h.

Referenced by CopyAssignMeta(), Sample(), and UpdateChunks().

## MIDIUnityNote

uint32_t gig::Sample::MIDIUnityNote

Specifies the musical note at which the sample will be played at it's original sample rate.

Definition at line 819 of file gig.h.

Referenced by CopyAssignMeta(), Sample(), and UpdateChunks().

## pCk3gix

RIFF::Chunk* gig::Sample::pCk3gix

protected

Definition at line 870 of file gig.h.

## pCkData

RIFF::Chunk* DLS::Sample::pCkData

protected inherited

Definition at line 481 of file DLS.h.

## pCkFormat

RIFF::Chunk* DLS::Sample::pCkFormat

protected inherited

Definition at line 482 of file DLS.h.

## pCkSmpl

RIFF::Chunk* gig::Sample::pCkSmpl

protected

Definition at line 871 of file gig.h.

## pDLSID

dlsid_t* DLS::Resource::pDLSID

inherited

Points to a dlsid_t structure if the file provided a DLS ID else is NULL.

Definition at line 407 of file DLS.h.

Referenced by GenerateDLSID(), and Resource().

## pGroup

Group* gig::Sample::pGroup

protected

pointer to the Group this sample belongs to (always not-NULL)

Definition at line 861 of file gig.h.

Referenced by gig::Group::AddSample(), GetGroup(), Sample(), and UpdateChunks().

## pInfo

Info* DLS::Resource::pInfo

inherited

Points (in any case) to an Info object, providing additional, optional infos and comments.

Definition at line 406 of file DLS.h.

Referenced by CopyAssign(), Resource(), gig::Sample::Sample(), and UpdateChunks().

## pParent

Resource* DLS::Resource::pParent

protected inherited

Definition at line 417 of file DLS.h.

## pResourceList

RIFF::List* DLS::Resource::pResourceList

protected inherited

Definition at line 418 of file DLS.h.

## Product

uint32_t gig::Sample::Product

Specifies the MIDI model ID defined by the manufacturer corresponding to the Manufacturer field. If no particular manufacturer's product is to be specified, a value of 0 should be used.

Definition at line 817 of file gig.h.

Referenced by CopyAssignMeta(), Sample(), and UpdateChunks().

## pWaveList

RIFF::List* DLS::Sample::pWaveList

protected inherited

Definition at line 480 of file DLS.h.

## RAMCache

buffer_t gig::Sample::RAMCache

protected

Buffers samples (already uncompressed) in RAM.

Definition at line 868 of file gig.h.

Referenced by GetCache(), LoadSampleDataWithNullSamplesExtension(), ReleaseSampleData(), Sample(), and ~Sample().

## SamplePeriod

uint32_t gig::Sample::SamplePeriod

Specifies the duration of time that passes during the playback of one sample in nanoseconds (normally equal to 1 / Samples Per Second, where Samples Per Second is the value found in the format chunk), don't bother to update this attribute, it won't be saved.

Definition at line 818 of file gig.h.

Referenced by CopyAssignMeta(), Sample(), and UpdateChunks().

## SamplePos

file_offset_t gig::Sample::SamplePos

protected

For compressed samples only: stores the current position (in sample points).

Definition at line 864 of file gig.h.

Referenced by GetPos(), Read(), Sample(), and SetPos().

## SamplesInLastFrame

file_offset_t gig::Sample::SamplesInLastFrame

protected

For compressed samples only: length of the last sample frame.

Definition at line 865 of file gig.h.

Referenced by Read().

## SamplesPerFrame

file_offset_t gig::Sample::SamplesPerFrame

protected

For compressed samples only: number of samples in a full sample frame.

Definition at line 867 of file gig.h.

Referenced by Read().

## SamplesPerSecond

uint32_t DLS::Sample::SamplesPerSecond

inherited

Sampling rate at which each channel should be played (defaults to 44100 if Sample was created with Instrument::AddSample() previously).

Definition at line 461 of file DLS.h.

Referenced by CopyAssignCore(), Sample(), gig::Sample::Sample(), UpdateChunks(), and gig::Sample::UpdateChunks().

## SamplesTotal

file_offset_t DLS::Sample::SamplesTotal

inherited

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.

Definition at line 465 of file DLS.h.

Referenced by CopyAssignCore(), gig::Sample::LoadSampleData(), gig::Sample::LoadSampleDataWithNullSamplesExtension(), gig::Sample::LoadSampleDataWithNullSamplesExtension(), gig::Sample::Read(), Sample(), and gig::Sample::SetPos().

## SMPTEFormat

smpte_format_t gig::Sample::SMPTEFormat

Specifies the Society of Motion Pictures and Television E time format used in the following SMPTEOffset field. If a value of 0 is set, SMPTEOffset should also be set to 0.

Definition at line 821 of file gig.h.

Referenced by CopyAssignMeta(), Sample(), and UpdateChunks().

## SMPTEOffset

uint32_t gig::Sample::SMPTEOffset

The SMPTE Offset value specifies the time offset to be used for the synchronization / calibration to the first sample in the waveform. This value uses a format of 0xhhmmssff where hh is a signed value that specifies the number of hours (-23 to 23), mm is an unsigned value that specifies the number of minutes (0 to 59), ss is an unsigned value that specifies the number of seconds (0 to 59) and ff is an unsigned value that specifies the number of frames (0 to -1).

Definition at line 822 of file gig.h.

Referenced by CopyAssignMeta(), Sample(), and UpdateChunks().

## TruncatedBits

uint32_t gig::Sample::TruncatedBits

For 24-bit compressed samples only: number of bits truncated during compression (0, 4 or 6).

Definition at line 832 of file gig.h.

Referenced by Read(), and Sample().

## ullWavePoolOffset

file_offset_t DLS::Sample::ullWavePoolOffset

protected inherited

Definition at line 483 of file DLS.h.

## WorstCaseFrameSize

file_offset_t gig::Sample::WorstCaseFrameSize

protected

For compressed samples only: size (in bytes) of the largest possible sample frame.

Definition at line 866 of file gig.h.

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

- gig.h
- gig.cpp