--- libgig/trunk/src/gig.h 2005/01/23 20:47:18 347
+++ libgig/trunk/src/gig.h 2005/02/10 19:16:31 365
@@ -219,7 +219,7 @@
dimension_velocity = 0x82, ///< Key Velocity (this is the only dimension where the ranges can exactly be defined).
dimension_channelaftertouch = 0x83, ///< Channel Key Pressure
dimension_releasetrigger = 0x84, ///< Special dimension for triggering samples on releasing a key.
- dimension_keyboard = 0x85, ///< Key Position
+ dimension_keyboard = 0x85, ///< Dimension for keyswitching
dimension_modwheel = 0x01, ///< Modulation Wheel (MIDI Controller 1)
dimension_breath = 0x02, ///< Breath Controller (Coarse, MIDI Controller 2)
dimension_foot = 0x04, ///< Foot Pedal (Coarse, MIDI Controller 4)
@@ -279,8 +279,7 @@
*
* Note: The default value for crossfade points is 0,0,0,0. Layers with
* such a default value should be treated as if they would not have a
- * crossfade, that is the crossfade volume factor should always
- * be 1.0f for such layers.
+ * crossfade.
*/
struct crossfade_t {
#if WORDS_BIGENDIAN
@@ -493,10 +492,13 @@
protected:
static unsigned int Instances; ///< Number of instances of class Sample.
static unsigned long DecompressionBufferSize; ///< Current size of the decompression buffer.
- static void* pDecompressionBuffer; ///< Small buffer used for decompression only.
+ static unsigned char* pDecompressionBuffer; ///< Small buffer used for decompression only.
unsigned long FrameOffset; ///< Current offset (sample points) in current sample frame (for decompression only).
unsigned long* FrameTable; ///< For positioning within compressed samples only: stores the offset values for each frame.
unsigned long SamplePos; ///< For compressed samples only: stores the current position (in sample points).
+ unsigned long SamplesInLastFrame; ///< For compressed samples only: length of the last sample frame.
+ unsigned long WorstCaseFrameSize; ///< For compressed samples only: size (in bytes) of the largest possible sample frame.
+ unsigned long SamplesPerFrame; ///< For compressed samples only: number of samples in a full sample frame.
buffer_t RAMCache; ///< Buffers samples (already uncompressed) in RAM.
Sample(File* pFile, RIFF::List* waveList, unsigned long WavePoolOffset);
@@ -561,6 +563,22 @@
return (A > B) ? B : A;
}
inline long Abs(long val) { return (val > 0) ? val : -val; }
+
+ // Guess size (in bytes) of a compressed sample
+ inline unsigned long GuessSize(unsigned long samples) {
+ // 16 bit: assume all frames are compressed - 1 byte
+ // per sample and 5 bytes header per 2048 samples
+
+ // 24 bit: assume next best compression rate - 1.5
+ // bytes per sample and 13 bytes header per 256
+ // samples
+ const unsigned long size =
+ BitDepth == 24 ? samples + (samples >> 1) + (samples >> 8) * 13
+ : samples + (samples >> 10) * 5;
+ // Double for stereo and add one worst case sample
+ // frame
+ return (Channels == 2 ? size << 1 : size) + WorstCaseFrameSize;
+ }
private:
void ScanCompressedSample();
friend class File;
@@ -649,7 +667,7 @@
Instrument* GetFirstInstrument(); ///< Returns a pointer to the first Instrument object of the file, NULL otherwise.
Instrument* GetNextInstrument(); ///< Returns a pointer to the next Instrument object of the file, NULL otherwise.
Instrument* GetInstrument(uint index);
- ~File() {};
+ ~File();
protected:
typedef std::list SampleList;
typedef std::list InstrumentList;