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

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

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

revision 1179 by persson, Sat May 12 11:25:04 2007 UTC revision 1192 by persson, Thu May 17 10:12:08 2007 UTC
# Line 303  namespace { Line 303  namespace {
303       *                         is located, 0 otherwise       *                         is located, 0 otherwise
304       */       */
305      Sample::Sample(File* pFile, RIFF::List* waveList, unsigned long WavePoolOffset, unsigned long fileNo) : DLS::Sample((DLS::File*) pFile, waveList, WavePoolOffset) {      Sample::Sample(File* pFile, RIFF::List* waveList, unsigned long WavePoolOffset, unsigned long fileNo) : DLS::Sample((DLS::File*) pFile, waveList, WavePoolOffset) {
306          pInfo->UseFixedLengthStrings = true;          static const DLS::Info::FixedStringLength fixedStringLengths[] = {
307                { CHUNK_ID_INAM, 64 },
308                { 0, 0 }
309            };
310            pInfo->FixedStringLengths = fixedStringLengths;
311          Instances++;          Instances++;
312          FileNo = fileNo;          FileNo = fileNo;
313    
# Line 340  namespace { Line 344  namespace {
344              SamplePeriod  = uint32_t(1000000000.0 / SamplesPerSecond + 0.5);              SamplePeriod  = uint32_t(1000000000.0 / SamplesPerSecond + 0.5);
345              MIDIUnityNote = 64;              MIDIUnityNote = 64;
346              FineTune      = 0;              FineTune      = 0;
347                SMPTEFormat   = smpte_format_no_offset;
348              SMPTEOffset   = 0;              SMPTEOffset   = 0;
349              Loops         = 0;              Loops         = 0;
350              LoopID        = 0;              LoopID        = 0;
351                LoopType      = loop_type_normal;
352              LoopStart     = 0;              LoopStart     = 0;
353              LoopEnd       = 0;              LoopEnd       = 0;
354              LoopFraction  = 0;              LoopFraction  = 0;
# Line 398  namespace { Line 404  namespace {
404    
405          // make sure 'smpl' chunk exists          // make sure 'smpl' chunk exists
406          pCkSmpl = pWaveList->GetSubChunk(CHUNK_ID_SMPL);          pCkSmpl = pWaveList->GetSubChunk(CHUNK_ID_SMPL);
407          if (!pCkSmpl) pCkSmpl = pWaveList->AddSubChunk(CHUNK_ID_SMPL, 60);          if (!pCkSmpl) {
408                pCkSmpl = pWaveList->AddSubChunk(CHUNK_ID_SMPL, 60);
409                memset(pCkSmpl->LoadChunkData(), 0, 60);
410            }
411          // update 'smpl' chunk          // update 'smpl' chunk
412          uint8_t* pData = (uint8_t*) pCkSmpl->LoadChunkData();          uint8_t* pData = (uint8_t*) pCkSmpl->LoadChunkData();
413          SamplePeriod = uint32_t(1000000000.0 / SamplesPerSecond + 0.5);          SamplePeriod = uint32_t(1000000000.0 / SamplesPerSecond + 0.5);
# Line 1503  namespace { Line 1512  namespace {
1512    
1513          // update '3ewa' chunk with DimensionRegion's current settings          // update '3ewa' chunk with DimensionRegion's current settings
1514    
1515          const uint32_t chunksize = _3ewa->GetSize();          const uint32_t chunksize = _3ewa->GetNewSize();
1516          store32(&pData[0], chunksize); // unknown, always chunk size?          store32(&pData[0], chunksize); // unknown, always chunk size?
1517    
1518          const int32_t lfo3freq = (int32_t) GIG_EXP_ENCODE(LFO3Frequency);          const int32_t lfo3freq = (int32_t) GIG_EXP_ENCODE(LFO3Frequency);
# Line 1987  namespace { Line 1996  namespace {
1996                      default:                      default:
1997                          throw gig::Exception("leverage controller number is not supported by the gig format");                          throw gig::Exception("leverage controller number is not supported by the gig format");
1998                  }                  }
1999                    break;
2000              default:              default:
2001                  throw gig::Exception("Unknown leverage controller type.");                  throw gig::Exception("Unknown leverage controller type.");
2002          }          }
# Line 2104  namespace { Line 2114  namespace {
2114  // *  // *
2115    
2116      Region::Region(Instrument* pInstrument, RIFF::List* rgnList) : DLS::Region((DLS::Instrument*) pInstrument, rgnList) {      Region::Region(Instrument* pInstrument, RIFF::List* rgnList) : DLS::Region((DLS::Instrument*) pInstrument, rgnList) {
         pInfo->UseFixedLengthStrings = true;  
   
2117          // Initialization          // Initialization
2118          Dimensions = 0;          Dimensions = 0;
2119          for (int i = 0; i < 256; i++) {          for (int i = 0; i < 256; i++) {
# Line 2168  namespace { Line 2176  namespace {
2176              GetSample(); // load global region sample reference              GetSample(); // load global region sample reference
2177          } else {          } else {
2178              DimensionRegions = 0;              DimensionRegions = 0;
2179                for (int i = 0 ; i < 8 ; i++) {
2180                    pDimensionDefinitions[i].dimension  = dimension_none;
2181                    pDimensionDefinitions[i].bits       = 0;
2182                    pDimensionDefinitions[i].zones      = 0;
2183                }
2184          }          }
2185    
2186          // make sure there is at least one dimension region          // make sure there is at least one dimension region
# Line 2213  namespace { Line 2226  namespace {
2226          if (!_3lnk) {          if (!_3lnk) {
2227              const int _3lnkChunkSize = (pFile->pVersion && pFile->pVersion->major == 3) ? 1092 : 172;              const int _3lnkChunkSize = (pFile->pVersion && pFile->pVersion->major == 3) ? 1092 : 172;
2228              _3lnk = pCkRegion->AddSubChunk(CHUNK_ID_3LNK, _3lnkChunkSize);              _3lnk = pCkRegion->AddSubChunk(CHUNK_ID_3LNK, _3lnkChunkSize);
2229                memset(_3lnk->LoadChunkData(), 0, _3lnkChunkSize);
2230    
2231                // move 3prg to last position
2232                pCkRegion->MoveSubChunk(pCkRegion->GetSubList(LIST_TYPE_3PRG), 0);
2233          }          }
2234    
2235          // update dimension definitions in '3lnk' chunk          // update dimension definitions in '3lnk' chunk
# Line 2592  namespace { Line 2609  namespace {
2609  // *  // *
2610    
2611      Instrument::Instrument(File* pFile, RIFF::List* insList, progress_t* pProgress) : DLS::Instrument((DLS::File*)pFile, insList) {      Instrument::Instrument(File* pFile, RIFF::List* insList, progress_t* pProgress) : DLS::Instrument((DLS::File*)pFile, insList) {
2612          pInfo->UseFixedLengthStrings = true;          static const DLS::Info::FixedStringLength fixedStringLengths[] = {
2613                { CHUNK_ID_INAM, 64 },
2614                { CHUNK_ID_ISFT, 12 },
2615                { 0, 0 }
2616            };
2617            pInfo->FixedStringLengths = fixedStringLengths;
2618    
2619          // Initialization          // Initialization
2620          for (int i = 0; i < 128; i++) RegionKeyTable[i] = NULL;          for (int i = 0; i < 128; i++) RegionKeyTable[i] = NULL;
2621            EffectSend = 0;
2622            Attenuation = 0;
2623            FineTune = 0;
2624            PitchbendRange = 0;
2625            PianoReleaseMode = false;
2626            DimensionKeyRange.low = 0;
2627            DimensionKeyRange.high = 0;
2628    
2629          // Loading          // Loading
2630          RIFF::List* lart = insList->GetSubList(LIST_TYPE_LART);          RIFF::List* lart = insList->GetSubList(LIST_TYPE_LART);
# Line 2783  namespace { Line 2812  namespace {
2812      void Group::UpdateChunks() {      void Group::UpdateChunks() {
2813          // make sure <3gri> and <3gnl> list chunks exist          // make sure <3gri> and <3gnl> list chunks exist
2814          RIFF::List* _3gri = pFile->pRIFF->GetSubList(LIST_TYPE_3GRI);          RIFF::List* _3gri = pFile->pRIFF->GetSubList(LIST_TYPE_3GRI);
2815          if (!_3gri) _3gri = pFile->pRIFF->AddSubList(LIST_TYPE_3GRI);          if (!_3gri) {
2816                _3gri = pFile->pRIFF->AddSubList(LIST_TYPE_3GRI);
2817                pFile->pRIFF->MoveSubChunk(_3gri, pFile->pRIFF->GetSubChunk(CHUNK_ID_PTBL));
2818            }
2819          RIFF::List* _3gnl = _3gri->GetSubList(LIST_TYPE_3GNL);          RIFF::List* _3gnl = _3gri->GetSubList(LIST_TYPE_3GNL);
2820          if (!_3gnl) _3gnl = pFile->pRIFF->AddSubList(LIST_TYPE_3GNL);          if (!_3gnl) _3gnl = _3gri->AddSubList(LIST_TYPE_3GNL);
2821          // now store the name of this group as <3gnm> chunk as subchunk of the <3gnl> list chunk          // now store the name of this group as <3gnm> chunk as subchunk of the <3gnl> list chunk
2822          ::SaveString(CHUNK_ID_3GNM, pNameChunk, _3gnl, Name, String("Unnamed Group"), true, 64);          ::SaveString(CHUNK_ID_3GNM, pNameChunk, _3gnl, Name, String("Unnamed Group"), true, 64);
2823      }      }
# Line 2861  namespace { Line 2893  namespace {
2893  // *************** File ***************  // *************** File ***************
2894  // *  // *
2895    
2896        const DLS::Info::FixedStringLength File::FixedStringLengths[] = {
2897            { CHUNK_ID_IARL, 256 },
2898            { CHUNK_ID_IART, 128 },
2899            { CHUNK_ID_ICMS, 128 },
2900            { CHUNK_ID_ICMT, 1024 },
2901            { CHUNK_ID_ICOP, 128 },
2902            { CHUNK_ID_ICRD, 128 },
2903            { CHUNK_ID_IENG, 128 },
2904            { CHUNK_ID_IGNR, 128 },
2905            { CHUNK_ID_IKEY, 128 },
2906            { CHUNK_ID_IMED, 128 },
2907            { CHUNK_ID_INAM, 128 },
2908            { CHUNK_ID_IPRD, 128 },
2909            { CHUNK_ID_ISBJ, 128 },
2910            { CHUNK_ID_ISFT, 128 },
2911            { CHUNK_ID_ISRC, 128 },
2912            { CHUNK_ID_ISRF, 128 },
2913            { CHUNK_ID_ITCH, 128 },
2914            { 0, 0 }
2915        };
2916    
2917      File::File() : DLS::File() {      File::File() : DLS::File() {
2918          pGroups = NULL;          pGroups = NULL;
2919          pInfo->UseFixedLengthStrings = true;          pInfo->FixedStringLengths = FixedStringLengths;
2920            pInfo->ArchivalLocation = String(256, ' ');
2921    
2922            // add some mandatory chunks to get the file chunks in right
2923            // order (INFO chunk will be moved to first position later)
2924            pRIFF->AddSubChunk(CHUNK_ID_VERS, 8);
2925            pRIFF->AddSubChunk(CHUNK_ID_COLH, 4);
2926      }      }
2927    
2928      File::File(RIFF::File* pRIFF) : DLS::File(pRIFF) {      File::File(RIFF::File* pRIFF) : DLS::File(pRIFF) {
2929          pGroups = NULL;          pGroups = NULL;
2930          pInfo->UseFixedLengthStrings = true;          pInfo->FixedStringLengths = FixedStringLengths;
2931      }      }
2932    
2933      File::~File() {      File::~File() {
# Line 2910  namespace { Line 2969  namespace {
2969         // create new Sample object and its respective 'wave' list chunk         // create new Sample object and its respective 'wave' list chunk
2970         RIFF::List* wave = wvpl->AddSubList(LIST_TYPE_WAVE);         RIFF::List* wave = wvpl->AddSubList(LIST_TYPE_WAVE);
2971         Sample* pSample = new Sample(this, wave, 0 /*arbitrary value, we update offsets when we save*/);         Sample* pSample = new Sample(this, wave, 0 /*arbitrary value, we update offsets when we save*/);
2972    
2973           // add mandatory chunks to get the chunks in right order
2974           wave->AddSubChunk(CHUNK_ID_FMT, 16);
2975           wave->AddSubList(LIST_TYPE_INFO);
2976    
2977         pSamples->push_back(pSample);         pSamples->push_back(pSample);
2978         return pSample;         return pSample;
2979      }      }
# Line 3052  namespace { Line 3116  namespace {
3116         __ensureMandatoryChunksExist();         __ensureMandatoryChunksExist();
3117         RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS);         RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS);
3118         RIFF::List* lstInstr = lstInstruments->AddSubList(LIST_TYPE_INS);         RIFF::List* lstInstr = lstInstruments->AddSubList(LIST_TYPE_INS);
3119    
3120           // add mandatory chunks to get the chunks in right order
3121           lstInstr->AddSubList(LIST_TYPE_INFO);
3122    
3123         Instrument* pInstrument = new Instrument(this, lstInstr);         Instrument* pInstrument = new Instrument(this, lstInstr);
3124    
3125           lstInstr->AddSubChunk(CHUNK_ID_INSH, 12);
3126    
3127           // this string is needed for the gig to be loadable in GSt:
3128           pInstrument->pInfo->Software = "Endless Wave";
3129    
3130         pInstruments->push_back(pInstrument);         pInstruments->push_back(pInstrument);
3131         return pInstrument;         return pInstrument;
3132      }      }
# Line 3220  namespace { Line 3294  namespace {
3294       * @throws Exception - on errors       * @throws Exception - on errors
3295       */       */
3296      void File::UpdateChunks() {      void File::UpdateChunks() {
3297            RIFF::Chunk* info = pRIFF->GetSubList(LIST_TYPE_INFO);
3298    
3299          // first update base class's chunks          // first update base class's chunks
3300          DLS::File::UpdateChunks();          DLS::File::UpdateChunks();
3301    
3302            if (!info) {
3303                // INFO was added by Resource::UpdateChunks - make sure it
3304                // is placed first in file
3305                info = pRIFF->GetSubList(LIST_TYPE_INFO);
3306                RIFF::Chunk* first = pRIFF->GetFirstSubChunk();
3307                if (first != info) {
3308                    pRIFF->MoveSubChunk(info, first);
3309                }
3310            }
3311    
3312          // update group's chunks          // update group's chunks
3313          if (pGroups) {          if (pGroups) {
3314              std::list<Group*>::iterator iter = pGroups->begin();              std::list<Group*>::iterator iter = pGroups->begin();

Legend:
Removed from v.1179  
changed lines
  Added in v.1192

  ViewVC Help
Powered by ViewVC