libgig
3.3.0.svn21
|
#include <SF.h>
Classes | |
struct | buffer_t |
Pointer address and size of a buffer. More... | |
class | PlaybackState |
Reflects the current playback state for a sample. More... | |
Public Types | |
enum | Link { MONO_SAMPLE = 1, RIGHT_SAMPLE = 2, LEFT_SAMPLE = 4, LINKED_SAMPLE = 8, ROM_MONO_SAMPLE = 0x8001, ROM_RIGHT_SAMPLE = 0x8002, ROM_LEFT_SAMPLE = 0x8004, ROM_LINKED_SAMPLE = 0x8008 } |
Public Member Functions | |
Sample (RIFF::Chunk *ck, RIFF::Chunk *pCkSmpl, RIFF::Chunk *pCkSm24) | |
String | GetName () |
int | GetChannelCount () |
long | GetTotalFrameCount () |
int | GetFrameSize () |
bool | HasLoops () |
bool | IsUnpitched () |
buffer_t | LoadSampleData () |
Loads the whole sample wave into RAM. More... | |
buffer_t | LoadSampleData (unsigned long SampleCount) |
Reads and caches the first SampleCount numbers of SamplePoints in RAM. More... | |
buffer_t | LoadSampleDataWithNullSamplesExtension (uint NullSamplesCount) |
Loads the whole sample wave into RAM. More... | |
buffer_t | LoadSampleDataWithNullSamplesExtension (unsigned long SampleCount, uint NullSamplesCount) |
Reads and caches the first SampleCount numbers of SamplePoints in RAM. More... | |
buffer_t | GetCache () |
Returns current cached sample points. More... | |
void | ReleaseSampleData () |
Frees the cached sample from RAM if loaded with LoadSampleData() previously. More... | |
unsigned long | SetPos (unsigned long SampleCount) |
Sets the position within the sample (in sample points, not in bytes). More... | |
unsigned long | GetPos () |
Returns the current position in the sample (in sample points). More... | |
unsigned long | Read (void *pBuffer, unsigned long SampleCount) |
Reads SampleCount number of sample points from the current position into the buffer pointed by pBuffer and increments the position within the sample. More... | |
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 pointed by pBuffer and moves the position within the sample respectively, this method honors the looping informations of the sample (if any). More... | |
Public Attributes | |
String | Name |
buffer_t | RAMCache |
Buffers samples (already uncompressed) in RAM. More... | |
RIFF::Chunk * | pCkSmpl |
RIFF::Chunk * | pCkSm24 |
int | ChannelCount |
uint32_t | Start |
uint32_t | End |
uint32_t | StartLoop |
uint32_t | EndLoop |
uint32_t | SampleRate |
uint8_t | OriginalPitch |
uint8_t | PitchCorrection |
uint16_t | SampleLink |
uint16_t | SampleType |
enum sf2::Sample::Link |
sf2::Sample::Sample | ( | RIFF::Chunk * | ck, |
RIFF::Chunk * | pCkSmpl, | ||
RIFF::Chunk * | pCkSm24 | ||
) |
Definition at line 150 of file SF.cpp.
References RIFF::Chunk::GetSize(), LEFT_SAMPLE, LINKED_SAMPLE, sf2::LoadString(), MONO_SAMPLE, RIFF::Chunk::ReadInt16(), RIFF::Chunk::ReadInt32(), RIFF::Chunk::ReadInt8(), RIGHT_SAMPLE, ROM_LEFT_SAMPLE, ROM_LINKED_SAMPLE, ROM_MONO_SAMPLE, and ROM_RIGHT_SAMPLE.
Sample::buffer_t sf2::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.
Definition at line 1363 of file SF.cpp.
References sf2::Sample::buffer_t::NullExtensionSize, sf2::Sample::buffer_t::pStart, and sf2::Sample::buffer_t::Size.
int sf2::Sample::GetFrameSize | ( | ) |
unsigned long sf2::Sample::GetPos | ( | ) |
Sample::buffer_t sf2::Sample::LoadSampleData | ( | ) |
Loads the whole sample wave into RAM.
Use ReleaseSampleData() to free the memory if you don't need the cached sample data anymore.
Sample::buffer_t sf2::Sample::LoadSampleData | ( | unsigned long | SampleCount | ) |
Reads 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. 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:
SampleCount | - number of sample points to load into RAM |
Sample::buffer_t sf2::Sample::LoadSampleDataWithNullSamplesExtension | ( | uint | NullSamplesCount | ) |
Loads 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.
NullSamplesCount | - number of silence samples the buffer should be extended past it's data end |
Sample::buffer_t sf2::Sample::LoadSampleDataWithNullSamplesExtension | ( | unsigned long | SampleCount, |
uint | NullSamplesCount | ||
) |
Reads 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. 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:
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.
SampleCount | - number of sample points to load into RAM |
NullSamplesCount | - number of silence samples the buffer should be extended past it's data end |
unsigned long sf2::Sample::Read | ( | void * | pBuffer, |
unsigned long | SampleCount | ||
) |
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.
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.
pBuffer | destination buffer |
SampleCount | number of sample points to read |
unsigned long sf2::Sample::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 pointed by pBuffer and moves the position within the sample respectively, this method honors the looping informations of the sample (if any).
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:
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.
pBuffer | destination buffer |
FrameCount | number of sample points to read |
pPlaybackState | will be used to store and reload the playback state for the next ReadAndLoop() call |
Definition at line 233 of file SF.cpp.
References sf2::Region::HasLoop, sf2::Region::LoopEnd, sf2::Region::LoopStart, and sf2::Sample::PlaybackState::position.
void sf2::Sample::ReleaseSampleData | ( | ) |
Frees the cached sample from RAM if loaded with LoadSampleData() previously.
unsigned long sf2::Sample::SetPos | ( | unsigned long | SampleCount | ) |
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.
SampleCount | number of sample points to jump |
Definition at line 1394 of file SF.cpp.
References RIFF::stream_start.
String sf2::Sample::Name |
Definition at line 296 of file SF.h.
Referenced by sf2::File::DeleteSample().
RIFF::Chunk* sf2::Sample::pCkSm24 |
RIFF::Chunk* sf2::Sample::pCkSmpl |
buffer_t sf2::Sample::RAMCache |