/[svn]/libgig/trunk/src/gig.h
ViewVC logotype

Diff of /libgig/trunk/src/gig.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2699 by schoenebeck, Mon Jan 12 17:12:05 2015 UTC revision 2913 by schoenebeck, Tue May 17 15:19:33 2016 UTC
# Line 2  Line 2 
2   *                                                                         *   *                                                                         *
3   *   libgig - C++ cross-platform Gigasampler format file access library    *   *   libgig - C++ cross-platform Gigasampler format file access library    *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003-2015 by Christian Schoenebeck                      *   *   Copyright (C) 2003-2016 by Christian Schoenebeck                      *
6   *                              <cuse@users.sourceforge.net>               *   *                              <cuse@users.sourceforge.net>               *
7   *                                                                         *   *                                                                         *
8   *   This library is free software; you can redistribute it and/or modify  *   *   This library is free software; you can redistribute it and/or modify  *
# Line 70  namespace gig { Line 70  namespace gig {
70    
71      typedef std::string String;      typedef std::string String;
72      typedef RIFF::progress_t progress_t;      typedef RIFF::progress_t progress_t;
73        typedef RIFF::file_offset_t file_offset_t;
74    
75      /** Lower and upper limit of a range. */      /** Lower and upper limit of a range. */
76      struct range_t {      struct range_t {
# Line 80  namespace gig { Line 81  namespace gig {
81      /** Pointer address and size of a buffer. */      /** Pointer address and size of a buffer. */
82      struct buffer_t {      struct buffer_t {
83          void*         pStart;            ///< Points to the beginning of the buffer.          void*         pStart;            ///< Points to the beginning of the buffer.
84          unsigned long Size;              ///< Size of the actual data in the buffer in bytes.          file_offset_t Size;              ///< Size of the actual data in the buffer in bytes.
85          unsigned long NullExtensionSize; ///< The buffer might be bigger than the actual data, if that's the case that unused space at the end of the buffer is filled with NULLs and NullExtensionSize reflects that unused buffer space in bytes. Those NULL extensions are mandatory for differential algorithms that have to take the following data words into account, thus have to access past the buffer's boundary. If you don't know what I'm talking about, just forget this variable. :)          file_offset_t NullExtensionSize; ///< The buffer might be bigger than the actual data, if that's the case that unused space at the end of the buffer is filled with NULLs and NullExtensionSize reflects that unused buffer space in bytes. Those NULL extensions are mandatory for differential algorithms that have to take the following data words into account, thus have to access past the buffer's boundary. If you don't know what I'm talking about, just forget this variable. :)
86          buffer_t() {          buffer_t() {
87              pStart            = NULL;              pStart            = NULL;
88              Size              = 0;              Size              = 0;
# Line 307  namespace gig { Line 308  namespace gig {
308    
309      /** Reflects the current playback state for a sample. */      /** Reflects the current playback state for a sample. */
310      struct playback_state_t {      struct playback_state_t {
311          unsigned long position;          ///< Current position within the sample.          file_offset_t position;          ///< Current position within the sample.
312          bool          reverse;           ///< If playback direction is currently backwards (in case there is a pingpong or reverse loop defined).          bool          reverse;           ///< If playback direction is currently backwards (in case there is a pingpong or reverse loop defined).
313          unsigned long loop_cycles_left;  ///< How many times the loop has still to be passed, this value will be decremented with each loop cycle.          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.
314      };      };
315    
316      // just symbol prototyping      // just symbol prototyping
# Line 651  namespace gig { Line 652  namespace gig {
652    
653              // own methods              // own methods
654              buffer_t      LoadSampleData();              buffer_t      LoadSampleData();
655              buffer_t      LoadSampleData(unsigned long SampleCount);              buffer_t      LoadSampleData(file_offset_t SampleCount);
656              buffer_t      LoadSampleDataWithNullSamplesExtension(uint NullSamplesCount);              buffer_t      LoadSampleDataWithNullSamplesExtension(uint NullSamplesCount);
657              buffer_t      LoadSampleDataWithNullSamplesExtension(unsigned long SampleCount, uint NullSamplesCount);              buffer_t      LoadSampleDataWithNullSamplesExtension(file_offset_t SampleCount, uint NullSamplesCount);
658              buffer_t      GetCache();              buffer_t      GetCache();
659              // own static methods              // own static methods
660              static buffer_t CreateDecompressionBuffer(unsigned long MaxReadSize);              static buffer_t CreateDecompressionBuffer(file_offset_t MaxReadSize);
661              static void     DestroyDecompressionBuffer(buffer_t& DecompressionBuffer);              static void     DestroyDecompressionBuffer(buffer_t& DecompressionBuffer);
662              // overridden methods              // overridden methods
663              void          ReleaseSampleData();              void          ReleaseSampleData();
664              void          Resize(int iNewSize);              void          Resize(int iNewSize);
665              unsigned long SetPos(unsigned long SampleCount, RIFF::stream_whence_t Whence = RIFF::stream_start);              file_offset_t SetPos(file_offset_t SampleCount, RIFF::stream_whence_t Whence = RIFF::stream_start);
666              unsigned long GetPos() const;              file_offset_t GetPos() const;
667              unsigned long Read(void* pBuffer, unsigned long SampleCount, buffer_t* pExternalDecompressionBuffer = NULL);              file_offset_t Read(void* pBuffer, file_offset_t SampleCount, buffer_t* pExternalDecompressionBuffer = NULL);
668              unsigned long ReadAndLoop(void* pBuffer, unsigned long SampleCount, playback_state_t* pPlaybackState, DimensionRegion* pDimRgn, buffer_t* pExternalDecompressionBuffer = NULL);              file_offset_t ReadAndLoop(void* pBuffer, file_offset_t SampleCount, playback_state_t* pPlaybackState, DimensionRegion* pDimRgn, buffer_t* pExternalDecompressionBuffer = NULL);
669              unsigned long Write(void* pBuffer, unsigned long SampleCount);              file_offset_t Write(void* pBuffer, file_offset_t SampleCount);
670              Group*        GetGroup() const;              Group*        GetGroup() const;
671              virtual void  UpdateChunks(progress_t* pProgress);              virtual void  UpdateChunks(progress_t* pProgress);
672              void CopyAssignMeta(const Sample* orig);              void CopyAssignMeta(const Sample* orig);
# Line 674  namespace gig { Line 675  namespace gig {
675              static unsigned int  Instances;               ///< Number of instances of class Sample.              static unsigned int  Instances;               ///< Number of instances of class Sample.
676              static buffer_t      InternalDecompressionBuffer; ///< Buffer used for decompression as well as for truncation of 24 Bit -> 16 Bit samples.              static buffer_t      InternalDecompressionBuffer; ///< Buffer used for decompression as well as for truncation of 24 Bit -> 16 Bit samples.
677              Group*               pGroup;                  ///< pointer to the Group this sample belongs to (always not-NULL)              Group*               pGroup;                  ///< pointer to the Group this sample belongs to (always not-NULL)
678              unsigned long        FrameOffset;             ///< Current offset (sample points) in current sample frame (for decompression only).              file_offset_t        FrameOffset;             ///< Current offset (sample points) in current sample frame (for decompression only).
679              unsigned long*       FrameTable;              ///< For positioning within compressed samples only: stores the offset values for each frame.              file_offset_t*       FrameTable;              ///< For positioning within compressed samples only: stores the offset values for each frame.
680              unsigned long        SamplePos;               ///< For compressed samples only: stores the current position (in sample points).              file_offset_t        SamplePos;               ///< For compressed samples only: stores the current position (in sample points).
681              unsigned long        SamplesInLastFrame;      ///< For compressed samples only: length of the last sample frame.              file_offset_t        SamplesInLastFrame;      ///< For compressed samples only: length of the last sample frame.
682              unsigned long        WorstCaseFrameSize;      ///< For compressed samples only: size (in bytes) of the largest possible sample frame.              file_offset_t        WorstCaseFrameSize;      ///< For compressed samples only: size (in bytes) of the largest possible sample frame.
683              unsigned long        SamplesPerFrame;         ///< For compressed samples only: number of samples in a full sample frame.              file_offset_t        SamplesPerFrame;         ///< For compressed samples only: number of samples in a full sample frame.
684              buffer_t             RAMCache;                ///< Buffers samples (already uncompressed) in RAM.              buffer_t             RAMCache;                ///< Buffers samples (already uncompressed) in RAM.
685              unsigned long        FileNo;                  ///< File number (> 0 when sample is stored in an extension file, 0 when it's in the gig)              unsigned long        FileNo;                  ///< File number (> 0 when sample is stored in an extension file, 0 when it's in the gig)
686              RIFF::Chunk*         pCk3gix;              RIFF::Chunk*         pCk3gix;
687              RIFF::Chunk*         pCkSmpl;              RIFF::Chunk*         pCkSmpl;
688              uint32_t             crc;                     ///< CRC-32 checksum of the raw sample data              uint32_t             crc;                     ///< CRC-32 checksum of the raw sample data
689    
690              Sample(File* pFile, RIFF::List* waveList, unsigned long WavePoolOffset, unsigned long fileNo = 0);              Sample(File* pFile, RIFF::List* waveList, file_offset_t WavePoolOffset, unsigned long fileNo = 0);
691             ~Sample();             ~Sample();
692    
693              // Guess size (in bytes) of a compressed sample              // Guess size (in bytes) of a compressed sample
694              inline unsigned long GuessSize(unsigned long samples) {              inline file_offset_t GuessSize(file_offset_t samples) {
695                  // 16 bit: assume all frames are compressed - 1 byte                  // 16 bit: assume all frames are compressed - 1 byte
696                  // per sample and 5 bytes header per 2048 samples                  // per sample and 5 bytes header per 2048 samples
697    
698                  // 24 bit: assume next best compression rate - 1.5                  // 24 bit: assume next best compression rate - 1.5
699                  // bytes per sample and 13 bytes header per 256                  // bytes per sample and 13 bytes header per 256
700                  // samples                  // samples
701                  const unsigned long size =                  const file_offset_t size =
702                      BitDepth == 24 ? samples + (samples >> 1) + (samples >> 8) * 13                      BitDepth == 24 ? samples + (samples >> 1) + (samples >> 8) * 13
703                                     : samples + (samples >> 10) * 5;                                     : samples + (samples >> 10) * 5;
704                  // Double for stereo and add one worst case sample                  // Double for stereo and add one worst case sample
# Line 707  namespace gig { Line 708  namespace gig {
708    
709              // Worst case amount of sample points that can be read with the              // Worst case amount of sample points that can be read with the
710              // given decompression buffer.              // given decompression buffer.
711              inline unsigned long WorstCaseMaxSamples(buffer_t* pDecompressionBuffer) {              inline file_offset_t WorstCaseMaxSamples(buffer_t* pDecompressionBuffer) {
712                  return (unsigned long) ((float)pDecompressionBuffer->Size / (float)WorstCaseFrameSize * (float)SamplesPerFrame);                  return (file_offset_t) ((float)pDecompressionBuffer->Size / (float)WorstCaseFrameSize * (float)SamplesPerFrame);
713              }              }
714          private:          private:
715              void ScanCompressedSample();              void ScanCompressedSample();
# Line 979  namespace gig { Line 980  namespace gig {
980       * not available in the GigaStudio 4 software. It is currently only       * not available in the GigaStudio 4 software. It is currently only
981       * supported by LinuxSampler and gigedit. Scripts will not load with the       * supported by LinuxSampler and gigedit. Scripts will not load with the
982       * original GigaStudio software.       * original GigaStudio software.
983         *
984         * You find more informations about Instrument Scripts on the LinuxSampler
985         * documentation site:
986         *
987         * - <a href="http://doc.linuxsampler.org/Instrument_Scripts/">About Instrument Scripts in General</a>
988         * - <a href="http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language">Introduction to the NKSP Script Language</a>
989         * - <a href="http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language/Reference/">NKSP Reference Manual</a>
990         * - <a href="http://doc.linuxsampler.org/Gigedit/Managing_Scripts">Using Instrument Scripts with Gigedit</a>
991       */       */
992      class Script {      class Script {
993          public:          public:
# Line 989  namespace gig { Line 998  namespace gig {
998                  COMPRESSION_NONE = 0 ///< Is not compressed at all (default).                  COMPRESSION_NONE = 0 ///< Is not compressed at all (default).
999              };              };
1000              enum Language_t {              enum Language_t {
1001                  LANGUAGE_NKSP = 0 ///< NKSP stands for "Is Not KSP" (default).                  LANGUAGE_NKSP = 0 ///< NKSP stands for "Is Not KSP" (default). Refer to the <a href="http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language/Reference/">NKSP Reference Manual</a> for details about this script language.
1002              };              };
1003    
1004              String         Name;        ///< Arbitrary name of the script, which may be displayed i.e. in an instrument editor.              String         Name;        ///< Arbitrary name of the script, which may be displayed i.e. in an instrument editor.
# Line 1090  namespace gig { Line 1099  namespace gig {
1099              Region*   GetNextRegion();              Region*   GetNextRegion();
1100              Region*   AddRegion();              Region*   AddRegion();
1101              void      DeleteRegion(Region* pRegion);              void      DeleteRegion(Region* pRegion);
1102                void      MoveTo(Instrument* dst);
1103              virtual void UpdateChunks(progress_t* pProgress);              virtual void UpdateChunks(progress_t* pProgress);
1104              virtual void CopyAssign(const Instrument* orig);              virtual void CopyAssign(const Instrument* orig);
1105              // own methods              // own methods
# Line 1259  namespace gig { Line 1269  namespace gig {
1269              void SetSampleChecksum(Sample* pSample, uint32_t crc);              void SetSampleChecksum(Sample* pSample, uint32_t crc);
1270              friend class Region;              friend class Region;
1271              friend class Sample;              friend class Sample;
1272                friend class Instrument;
1273              friend class Group; // so Group can access protected member pRIFF              friend class Group; // so Group can access protected member pRIFF
1274              friend class ScriptGroup; // so ScriptGroup can access protected member pRIFF              friend class ScriptGroup; // so ScriptGroup can access protected member pRIFF
1275          private:          private:

Legend:
Removed from v.2699  
changed lines
  Added in v.2913

  ViewVC Help
Powered by ViewVC