libgig
4.3.0
|
.KSF audio sample file More...
#include <Korg.h>
Public Member Functions | |
KSFSample (const String &filename) | |
int | FrameSize () const |
Returns the size of one sample point of this sample in bytes. | |
bool | IsCompressed () const |
uint8_t | CompressionID () const |
bool | Use2ndStart () const |
String | FileName () const |
buffer_t | GetCache () const |
Returns current cached sample points. More... | |
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... | |
void | ReleaseSampleData () |
Frees the cached sample from RAM if loaded with LoadSampleData() previously. More... | |
unsigned long | SetPos (unsigned long SampleCount, RIFF::stream_whence_t Whence=RIFF::stream_start) |
Sets the position within the sample (in sample points, not in bytes). More... | |
unsigned long | GetPos () const |
Returns the current position in the sample (in sample points). | |
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... | |
Public Attributes | |
String | Name |
Sample name for drums (since this name is always stored with 16 bytes, this name must never be longer than 16 characters). | |
uint8_t | DefaultBank |
0..3 | |
uint32_t | Start |
uint32_t | Start2 |
uint32_t | LoopStart |
uint32_t | LoopEnd |
uint32_t | SampleRate |
i.e. 44100 | |
uint8_t | Attributes |
Bit field of flags, better call IsCompressed(), CompressionID() and Use2ndStart() instead of accessing this variable directly. | |
int8_t | LoopTune |
-99..+99 | |
uint8_t | Channels |
Number of audio channels (seems to be always 1, thus Mono for all Korg sound files ATM). | |
uint8_t | BitDepth |
i.e. 8 or 16 | |
uint32_t | SamplePoints |
Currently the library expects all Korg samples to be Mono, thus the value here might be incorrect in case you ever find a Korg sample in Stereo. If you got a Stereo one, please report it! | |
.KSF audio sample file
Implements access to KORG audio sample files with ".KSF" file name extension. As of to date, there are only mono samples in .KSF format. If you ever encounter a stereo sample, please report it!
buffer_t Korg::KSFSample::GetCache | ( | ) | const |
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 219 of file Korg.cpp.
References gig::buffer_t::NullExtensionSize, gig::buffer_t::pStart, and gig::buffer_t::Size.
Referenced by LoadSampleDataWithNullSamplesExtension().
buffer_t Korg::KSFSample::LoadSampleData | ( | ) |
Loads the whole sample wave into RAM.
Use ReleaseSampleData() to free the memory if you don't need the cached sample data anymore.
Definition at line 139 of file Korg.cpp.
References LoadSampleDataWithNullSamplesExtension(), and SamplePoints.
buffer_t Korg::KSFSample::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.
SampleCount | - number of sample points to load into RAM |
Definition at line 153 of file Korg.cpp.
References LoadSampleDataWithNullSamplesExtension().
buffer_t Korg::KSFSample::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 |
Definition at line 174 of file Korg.cpp.
References SamplePoints.
Referenced by LoadSampleData().
buffer_t Korg::KSFSample::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. 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 |
Definition at line 197 of file Korg.cpp.
References FrameSize(), GetCache(), gig::buffer_t::NullExtensionSize, gig::buffer_t::pStart, Read(), SamplePoints, SetPos(), and gig::buffer_t::Size.
unsigned long Korg::KSFSample::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.
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 (which is not implemented for this class yet)!
pBuffer | destination buffer |
SampleCount | number of sample points to read |
Definition at line 300 of file Korg.cpp.
References FrameSize(), RIFF::List::GetSubChunk(), and RIFF::Chunk::Read().
Referenced by LoadSampleDataWithNullSamplesExtension().
void Korg::KSFSample::ReleaseSampleData | ( | ) |
Frees the cached sample from RAM if loaded with LoadSampleData() previously.
Definition at line 234 of file Korg.cpp.
References gig::buffer_t::NullExtensionSize, gig::buffer_t::pStart, and gig::buffer_t::Size.
unsigned long Korg::KSFSample::SetPos | ( | unsigned long | 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.
SampleCount | number of sample points to jump |
Whence | optional: to which relation SampleCount refers to, if omited RIFF::stream_start is assumed |
Definition at line 252 of file Korg.cpp.
References FrameSize(), GetPos(), RIFF::List::GetSubChunk(), SamplePoints, and RIFF::Chunk::SetPos().
Referenced by LoadSampleDataWithNullSamplesExtension().