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

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

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

revision 2 by schoenebeck, Sat Oct 25 20:15:04 2003 UTC revision 384 by schoenebeck, Thu Feb 17 02:22:26 2005 UTC
# Line 2  Line 2 
2   *                                                                         *   *                                                                         *
3   *   libgig - C++ cross-platform Gigasampler format file loader library    *   *   libgig - C++ cross-platform Gigasampler format file loader library    *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003 by Christian Schoenebeck                           *   *   Copyright (C) 2003-2005 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  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 59  namespace DLS { Line 59  namespace DLS {
59          pConnections = new Connection[Connections];          pConnections = new Connection[Connections];
60          Connection::conn_block_t connblock;          Connection::conn_block_t connblock;
61          for (uint32_t i = 0; i <= Connections; i++) {          for (uint32_t i = 0; i <= Connections; i++) {
62              artList->Read(&connblock, 1, sizeof(Connection::conn_block_t));              artList->Read(&connblock.source, 1, 2);
63                artList->Read(&connblock.control, 1, 2);
64                artList->Read(&connblock.destination, 1, 2);
65                artList->Read(&connblock.transform, 1, 2);
66                artList->Read(&connblock.scale, 1, 4);
67              pConnections[i].Init(&connblock);              pConnections[i].Init(&connblock);
68          }          }
69      }      }
# Line 163  namespace DLS { Line 167  namespace DLS {
167          RIFF::Chunk* ckDLSID = lstResource->GetSubChunk(CHUNK_ID_DLID);          RIFF::Chunk* ckDLSID = lstResource->GetSubChunk(CHUNK_ID_DLID);
168          if (ckDLSID) {          if (ckDLSID) {
169              pDLSID = new dlsid_t;              pDLSID = new dlsid_t;
170              ckDLSID->Read(pDLSID, 1, sizeof(dlsid_t));              ckDLSID->Read(&pDLSID->ulData1, 1, 4);
171                ckDLSID->Read(&pDLSID->usData2, 1, 2);
172                ckDLSID->Read(&pDLSID->usData3, 1, 2);
173                ckDLSID->Read(pDLSID->abData, 8, 1);
174          }          }
175          else pDLSID = NULL;          else pDLSID = NULL;
176      }      }
# Line 192  namespace DLS { Line 199  namespace DLS {
199          pSampleLoops            = (SampleLoops) ? new sample_loop_t[SampleLoops] : NULL;          pSampleLoops            = (SampleLoops) ? new sample_loop_t[SampleLoops] : NULL;
200          wsmp->SetPos(headersize);          wsmp->SetPos(headersize);
201          for (uint32_t i = 0; i < SampleLoops; i++) {          for (uint32_t i = 0; i < SampleLoops; i++) {
202              wsmp->Read(pSampleLoops + i, 1, sizeof(sample_loop_t));              wsmp->Read(pSampleLoops + i, 4, 4);
203              if (pSampleLoops[i].Size > sizeof(sample_loop_t)) { // if loop struct was extended              if (pSampleLoops[i].Size > sizeof(sample_loop_t)) { // if loop struct was extended
204                  wsmp->SetPos(pSampleLoops[i].Size - sizeof(sample_loop_t), RIFF::stream_curpos);                  wsmp->SetPos(pSampleLoops[i].Size - sizeof(sample_loop_t), RIFF::stream_curpos);
205              }              }
# Line 271  namespace DLS { Line 278  namespace DLS {
278       */       */
279      unsigned long Sample::Read(void* pBuffer, unsigned long SampleCount) {      unsigned long Sample::Read(void* pBuffer, unsigned long SampleCount) {
280          if (FormatTag != WAVE_FORMAT_PCM) return 0; // failed: wave data not PCM format          if (FormatTag != WAVE_FORMAT_PCM) return 0; // failed: wave data not PCM format
281          return pCkData->Read(pBuffer, SampleCount, FrameSize);          return pCkData->Read(pBuffer, SampleCount, FrameSize); // FIXME: channel inversion due to endian correction?
282      }      }
283    
284    
# Line 283  namespace DLS { Line 290  namespace DLS {
290          pCkRegion = rgnList;          pCkRegion = rgnList;
291    
292          RIFF::Chunk* rgnh = rgnList->GetSubChunk(CHUNK_ID_RGNH);          RIFF::Chunk* rgnh = rgnList->GetSubChunk(CHUNK_ID_RGNH);
293          rgnh->Read(&KeyRange, 1, sizeof(range_t));          rgnh->Read(&KeyRange, 2, 2);
294          rgnh->Read(&VelocityRange, 1, sizeof(range_t));          rgnh->Read(&VelocityRange, 2, 2);
295          uint16_t optionflags = rgnh->ReadUint16();          uint16_t optionflags = rgnh->ReadUint16();
296          SelfNonExclusive = optionflags & F_RGN_OPTION_SELFNONEXCLUSIVE;          SelfNonExclusive = optionflags & F_RGN_OPTION_SELFNONEXCLUSIVE;
297          KeyGroup = rgnh->ReadUint16();          KeyGroup = rgnh->ReadUint16();
# Line 332  namespace DLS { Line 339  namespace DLS {
339          if (!insh) throw DLS::Exception("Mandatory chunks in <lins> list chunk not found.");          if (!insh) throw DLS::Exception("Mandatory chunks in <lins> list chunk not found.");
340          Regions = insh->ReadUint32();          Regions = insh->ReadUint32();
341          midi_locale_t locale;          midi_locale_t locale;
342          insh->Read(&locale, 1, sizeof(midi_locale_t));          insh->Read(&locale, 2, 4);
343          MIDIProgram    = locale.instrument;          MIDIProgram    = locale.instrument;
344          IsDrum         = locale.bank & DRUM_TYPE_MASK;          IsDrum         = locale.bank & DRUM_TYPE_MASK;
345          MIDIBankCoarse = (uint8_t) MIDI_BANK_COARSE(locale.bank);          MIDIBankCoarse = (uint8_t) MIDI_BANK_COARSE(locale.bank);
# Line 393  namespace DLS { Line 400  namespace DLS {
400          RIFF::Chunk* ckVersion = pRIFF->GetSubChunk(CHUNK_ID_VERS);          RIFF::Chunk* ckVersion = pRIFF->GetSubChunk(CHUNK_ID_VERS);
401          if (ckVersion) {          if (ckVersion) {
402              pVersion = new version_t;              pVersion = new version_t;
403              ckVersion->Read(pVersion, 1, sizeof(version_t));              ckVersion->Read(pVersion, 4, 2);
404          }          }
405          else pVersion = NULL;          else pVersion = NULL;
406    
# Line 407  namespace DLS { Line 414  namespace DLS {
414          WavePoolCount  = ptbl->ReadUint32();          WavePoolCount  = ptbl->ReadUint32();
415          pWavePoolTable = new uint32_t[WavePoolCount];          pWavePoolTable = new uint32_t[WavePoolCount];
416          ptbl->SetPos(headersize);          ptbl->SetPos(headersize);
417          ptbl->Read(pWavePoolTable, WavePoolCount, sizeof(uint32_t));  
418            // Check for 64 bit offsets (used in gig v3 files)
419            if (ptbl->GetSize() - headersize == WavePoolCount * 8) {
420                for (int i = 0 ; i < WavePoolCount ; i++) {
421                    // Just ignore the upper bits for now
422                    uint32_t upper = ptbl->ReadUint32();
423                    pWavePoolTable[i] = ptbl->ReadUint32();
424                    if (upper || (pWavePoolTable[i] & 0x80000000))
425                        throw DLS::Exception("Files larger than 2 GB not yet supported");
426                }
427            }
428            else ptbl->Read(pWavePoolTable, WavePoolCount, sizeof(uint32_t));
429    
430          pSamples     = NULL;          pSamples     = NULL;
431          pInstruments = NULL;          pInstruments = NULL;

Legend:
Removed from v.2  
changed lines
  Added in v.384

  ViewVC Help
Powered by ViewVC