/[svn]/libgig/trunk/src/tools/gigdump.cpp
ViewVC logotype

Diff of /libgig/trunk/src/tools/gigdump.cpp

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

libgig/trunk/src/gigdump.cpp revision 55 by schoenebeck, Tue Apr 27 09:06:07 2004 UTC libgig/trunk/src/tools/gigdump.cpp revision 2985 by schoenebeck, Tue Sep 20 22:13:37 2016 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   libgig - C++ cross-platform Gigasampler format file loader library    *   *   libgig - C++ cross-platform Gigasampler format file access library    *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Christian Schoenebeck                     *   *   Copyright (C) 2003-2016 by Christian Schoenebeck                      *
6   *                               <cuse@users.sourceforge.net>              *   *                              <cuse@users.sourceforge.net>               *
7     *                                                                         *
8     *   This program is part of libgig.                                       *
9   *                                                                         *   *                                                                         *
10   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
11   *   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 27  Line 29 
29    
30  #include <iostream>  #include <iostream>
31  #include <cstdlib>  #include <cstdlib>
32    #include <string>
33    
34  #include "gig.h"  #include "../gig.h"
35    
36  using namespace std;  using namespace std;
37    
38    string Revision();
39    void PrintVersion();
40    void PrintFileInformations(gig::File* gig);
41    void PrintGroups(gig::File* gig);
42  void PrintSamples(gig::File* gig);  void PrintSamples(gig::File* gig);
43    void PrintScripts(gig::File* gig);
44  void PrintInstruments(gig::File* gig);  void PrintInstruments(gig::File* gig);
45  void PrintRegions(gig::Instrument* instr);  void PrintRegions(gig::Instrument* instr);
46  void PrintUsage();  void PrintUsage();
47  void PrintDimensionRegions(gig::Region* rgn);  void PrintDimensionRegions(gig::Region* rgn);
48    bool VerifyFile(gig::File* gig);
49    void RebuildChecksumTable(gig::File* gig);
50    
51    class PubSample : public gig::Sample {
52    public:
53        using DLS::Sample::pCkData;
54    };
55    
56    class PubFile : public gig::File {
57    public:
58        using gig::File::VerifySampleChecksumTable;
59        using gig::File::RebuildSampleChecksumTable;
60    };
61    
62    
63  int main(int argc, char *argv[])  int main(int argc, char *argv[])
64  {  {
65        bool bVerify = false;
66        bool bRebuildChecksums = false;
67    
68      if (argc <= 1) {      if (argc <= 1) {
69          PrintUsage();          PrintUsage();
70          return EXIT_FAILURE;          return EXIT_FAILURE;
71      }      }
72      FILE* hFile = fopen(argv[1], "r");  
73        int iArg;
74        for (iArg = 1; iArg < argc; ++iArg) {
75            const string opt = argv[iArg];
76            if (opt == "--") { // common for all command line tools: separator between initial option arguments and i.e. subsequent file arguments
77                iArg++;
78                break;
79            }
80            if (opt.substr(0, 1) != "-") break;
81    
82            if (opt == "-v") {
83                PrintVersion();
84                return EXIT_SUCCESS;
85            } else if (opt == "--verify") {
86                bVerify = true;
87            } else if (opt == "--rebuild-checksums") {
88                bRebuildChecksums = true;
89            } else {
90                cerr << "Unknown option '" << opt << "'" << endl;
91                cerr << endl;
92                PrintUsage();
93                return EXIT_FAILURE;
94            }
95        }
96        if (iArg >= argc) {
97            cout << "No file name provided!" << endl;
98            return EXIT_FAILURE;
99        }
100        const char* filename = argv[iArg];
101    
102        FILE* hFile = fopen(filename, "r");
103      if (!hFile) {      if (!hFile) {
104          cout << "Invalid file argument!" << endl;          cout << "Invalid file argument!" << endl;
105          return EXIT_FAILURE;          return EXIT_FAILURE;
106      }      }
107      fclose(hFile);      fclose(hFile);
108      try {      try {
109          RIFF::File* riff = new RIFF::File(argv[1]);          RIFF::File* riff = new RIFF::File(filename);
110          gig::File*  gig  = new gig::File(riff);          gig::File*  gig  = new gig::File(riff);
111          PrintSamples(gig);  
112          cout << endl;          if (bRebuildChecksums) {
113          PrintInstruments(gig);              RebuildChecksumTable(gig);
114            } else if (bVerify) {
115                bool OK = VerifyFile(gig);
116                if (OK) cout << "All checks passed successfully! :-)\n";
117                return (OK) ? EXIT_SUCCESS : EXIT_FAILURE;
118            } else {
119                PrintFileInformations(gig);
120                cout << endl;
121                PrintGroups(gig);
122                cout << endl;
123                PrintSamples(gig);
124                cout << endl;
125                PrintScripts(gig);
126                cout << endl;
127                PrintInstruments(gig);
128            }
129          delete gig;          delete gig;
130          delete riff;          delete riff;
131      }      }
# Line 71  int main(int argc, char *argv[]) Line 141  int main(int argc, char *argv[])
141      return EXIT_SUCCESS;      return EXIT_SUCCESS;
142  }  }
143    
144    void PrintFileInformations(gig::File* gig) {
145        cout << "Global File Informations:" << endl;
146        cout << "    Total instruments: " << gig->Instruments << endl;
147        if (gig->pVersion) {
148           cout << "    Version: " << gig->pVersion->major   << "."
149                               << gig->pVersion->minor   << "."
150                               << gig->pVersion->release << "."
151                               << gig->pVersion->build   << endl;
152        }
153        if (gig->pInfo) {
154            if (gig->pInfo->Name.size())
155                cout << "    Name: '" << gig->pInfo->Name << "'\n";
156            if (gig->pInfo->ArchivalLocation.size())
157                cout << "    ArchivalLocation: '" << gig->pInfo->ArchivalLocation << "'\n";
158            if (gig->pInfo->CreationDate.size())
159                cout << "    CreationDate: '" << gig->pInfo->CreationDate << "'\n";
160            if (gig->pInfo->Comments.size())
161                cout << "    Comments: '" << gig->pInfo->Comments << "'\n";
162            if (gig->pInfo->Product.size())
163                cout << "    Product: '" << gig->pInfo->Product << "'\n";
164            if (gig->pInfo->Copyright.size())
165                cout << "    Copyright: '" << gig->pInfo->Copyright << "'\n";
166            if (gig->pInfo->Artists.size())
167                cout << "    Artists: '" << gig->pInfo->Artists << "'\n";
168            if (gig->pInfo->Genre.size())
169                cout << "    Genre: '" << gig->pInfo->Genre << "'\n";
170            if (gig->pInfo->Keywords.size())
171                cout << "    Keywords: '" << gig->pInfo->Keywords << "'\n";
172            if (gig->pInfo->Engineer.size())
173                cout << "    Engineer: '" << gig->pInfo->Engineer << "'\n";
174            if (gig->pInfo->Technician.size())
175                cout << "    Technician: '" << gig->pInfo->Technician << "'\n";
176            if (gig->pInfo->Software.size())
177                cout << "    Software: '" << gig->pInfo->Software << "'\n";
178            if (gig->pInfo->Medium.size())
179                cout << "    Medium: '" << gig->pInfo->Medium << "'\n";
180            if (gig->pInfo->Source.size())
181                cout << "    Source: '" << gig->pInfo->Source << "'\n";
182            if (gig->pInfo->SourceForm.size())
183                cout << "    SourceForm: '" << gig->pInfo->SourceForm << "'\n";
184            if (gig->pInfo->Commissioned.size())
185                cout << "    Commissioned: '" << gig->pInfo->Commissioned << "'\n";
186        }
187    }
188    
189    void PrintGroups(gig::File* gig) {
190        int groups = 0;
191        cout << "ALL defined Groups:" << endl;
192        for (gig::Group* pGroup = gig->GetFirstGroup(); pGroup; pGroup = gig->GetNextGroup()) {
193            groups++;
194            string name = pGroup->Name;
195            if (name == "") name = "<NO NAME>";
196            else            name = '\"' + name + '\"';
197            cout << "    Group " << groups << ")" << endl;
198            cout << "        Name: " << name << endl;
199        }
200    }
201    
202  void PrintSamples(gig::File* gig) {  void PrintSamples(gig::File* gig) {
203      int samples = 0;      int samples = 0;
204      cout << "ALL Available Samples (as there might be more than referenced by Instruments):" << endl;      cout << "ALL Available Samples (as there might be more than referenced by Instruments):" << endl;
205      gig::Sample* pSample = gig->GetFirstSample();      PubSample* pSample = (PubSample*) gig->GetFirstSample();
206      while (pSample) {      while (pSample) {
207          samples++;          samples++;
208            // determine sample's name
209          string name = pSample->pInfo->Name;          string name = pSample->pInfo->Name;
210          if (name == "") name = "<NO NAME>";          if (name == "") name = "<NO NAME>";
211          else            name = '\"' + name + '\"';          else            name = '\"' + name + '\"';
212            // determine group this sample belongs to
213            int iGroup = 1;
214            for (gig::Group* pGroup = gig->GetFirstGroup(); pGroup; pGroup = gig->GetNextGroup(), iGroup++) {
215                if (pGroup == pSample->GetGroup()) break;
216            }
217            // print sample info
218          cout << "    Sample " << samples << ") " << name << ", ";          cout << "    Sample " << samples << ") " << name << ", ";
219            cout << "Group " << iGroup << ", ";
220          cout << pSample->SamplesPerSecond << "Hz, " << pSample->Channels << " Channels, " << pSample->Loops << " Loops";          cout << pSample->SamplesPerSecond << "Hz, " << pSample->Channels << " Channels, " << pSample->Loops << " Loops";
221          if (pSample->Loops) {          if (pSample->Loops) {
222              cout << " (Type: ";              cout << " (Type: ";
# Line 90  void PrintSamples(gig::File* gig) { Line 226  void PrintSamples(gig::File* gig) {
226                  case gig::loop_type_backward:       cout << "reverse)";  break;                  case gig::loop_type_backward:       cout << "reverse)";  break;
227              }              }
228              cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd;              cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd;
229                cout << ", LoopPlayCount=" << pSample->LoopPlayCount;
230            }
231            cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false")
232                 << " foffset=" << pSample->pCkData->GetFilePos()
233                 << " fsz=" << pSample->pCkData->GetSize()
234                 << endl;
235    #if 0
236            {
237                const uint bufSize = 64;
238                unsigned char buf[bufSize] = {};
239                pSample->SetPos(0);
240                RIFF::file_offset_t n = pSample->pCkData->Read(&buf[0], bufSize, 1);
241                //RIFF::file_offset_t n = pSample->Read(&buf[0], bufSize / pSample->FrameSize);
242                cout << "        FrameSize=" << pSample->FrameSize << ",Data[" << n << "]" << flush;
243                for (int x = 0; x < bufSize; ++x)
244                    printf("%02x ", buf[x]);
245                printf("\n");
246                fflush(stdout);
247            }
248    #endif
249            pSample = (PubSample*) gig->GetNextSample();
250        }
251    }
252    
253    void PrintScripts(gig::File* gig) {
254        cout << "ALL Available Real-Time Instrument Scripts (as there might be more than referenced by Instruments):" << endl;
255        for (int g = 0; gig->GetScriptGroup(g); ++g) {
256            gig::ScriptGroup* pGroup = gig->GetScriptGroup(g);
257            cout << "    Group " << g+1 << ") '" << pGroup->Name << "'\n";
258            for (int s = 0; pGroup->GetScript(s); ++s) {
259                gig::Script* pScript = pGroup->GetScript(s);
260                cout << "        Script " << s+1 << ") '" << pScript->Name << "':\n";
261                cout << "[START OF SCRIPT]\n";
262                cout << pScript->GetScriptAsText();
263                cout << "[END OF SCRIPT]\n";
264          }          }
         cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") << endl;  
         pSample = gig->GetNextSample();  
265      }      }
266  }  }
267    
# Line 108  void PrintInstruments(gig::File* gig) { Line 277  void PrintInstruments(gig::File* gig) {
277          cout << "    Instrument " << instruments << ") " << name << ", ";          cout << "    Instrument " << instruments << ") " << name << ", ";
278    
279          cout << " MIDIBank=" << pInstrument->MIDIBank << ", MIDIProgram=" << pInstrument->MIDIProgram << endl;          cout << " MIDIBank=" << pInstrument->MIDIBank << ", MIDIProgram=" << pInstrument->MIDIProgram << endl;
280    
281            cout << "        ScriptSlots=" << pInstrument->ScriptSlotCount() << endl;
282            for (int s = 0; s < pInstrument->ScriptSlotCount(); ++s) {
283                gig::Script* pScript = pInstrument->GetScriptOfSlot(s);
284                string name = pScript->Name;
285                cout << "        ScriptSlot[" << s << "]='" << name << "'\n";
286            }
287    
288          PrintRegions(pInstrument);          PrintRegions(pInstrument);
289    
290          pInstrument = gig->GetNextInstrument();          pInstrument = gig->GetNextInstrument();
# Line 131  void PrintRegions(gig::Instrument* instr Line 308  void PrintRegions(gig::Instrument* instr
308              cout << "<NO_VALID_SAMPLE_REFERENCE> ";              cout << "<NO_VALID_SAMPLE_REFERENCE> ";
309          }          }
310          cout << "            KeyRange=" << pRegion->KeyRange.low << "-" << pRegion->KeyRange.high << ", ";          cout << "            KeyRange=" << pRegion->KeyRange.low << "-" << pRegion->KeyRange.high << ", ";
311          cout << "VelocityRange=" << pRegion->VelocityRange.low << "-" << pRegion->VelocityRange.high << ", Layer=" << pRegion->Layer << endl;          cout << "VelocityRange=" << pRegion->VelocityRange.low << "-" << pRegion->VelocityRange.high << ", Layers=" << pRegion->Layers << endl;
312          cout << "            Loops=" << pRegion->SampleLoops << endl;          cout << "            Loops=" << pRegion->SampleLoops << endl;
313            cout << "            Dimensions=" << pRegion->Dimensions << endl;
314            for (int iDimension = 0; iDimension < pRegion->Dimensions; iDimension++) {
315                cout << "            Dimension[" << iDimension << "]: Type=";
316                gig::dimension_def_t DimensionDef = pRegion->pDimensionDefinitions[iDimension];
317                switch (DimensionDef.dimension) {
318                    case gig::dimension_none:
319                        cout << "NONE";
320                        break;
321                    case gig::dimension_samplechannel: // If used sample has more than one channel (thus is not mono).
322                        cout << "SAMPLECHANNEL";
323                        break;
324                    case gig::dimension_layer: { // For layering of up to 8 instruments (and eventually crossfading of 2 or 4 layers).
325                        gig::crossfade_t crossfade = pRegion->pDimensionRegions[iDimension]->Crossfade;
326                        cout << "LAYER (Crossfade in_start=" << (int) crossfade.in_start << ",in_end=" << (int) crossfade.in_end << ",out_start=" << (int) crossfade.out_start << ",out_end=" << (int) crossfade.out_end << ")";
327                        break;
328                    }
329                    case gig::dimension_velocity: // Key Velocity (this is the only dimension where the ranges can exactly be defined).
330                        cout << "VELOCITY";
331                        break;
332                    case gig::dimension_channelaftertouch: // Channel Key Pressure
333                        cout << "AFTERTOUCH";
334                        break;
335                    case gig::dimension_releasetrigger: // Special dimension for triggering samples on releasing a key.
336                        cout << "RELEASETRIGGER";
337                        break;
338                    case gig::dimension_keyboard: // Key Position
339                        cout << "KEYBOARD";
340                        break;
341                    case gig::dimension_roundrobin: // Different samples triggered each time a note is played, dimension regions selected in sequence
342                        cout << "ROUNDROBIN";
343                        break;
344                    case gig::dimension_random: // Different samples triggered each time a note is played, random order
345                        cout << "RANDOM";
346                        break;
347                    case gig::dimension_smartmidi: // For MIDI tools like legato and repetition mode
348                        cout << "SMARTMIDI";
349                        break;
350                    case gig::dimension_roundrobinkeyboard: // Different samples triggered each time a note is played, any key advances the counter
351                        cout << "ROUNDROBINKEYBOARD";
352                        break;
353                    case gig::dimension_modwheel: // Modulation Wheel (MIDI Controller 1)
354                        cout << "MODWHEEL";
355                        break;
356                    case gig::dimension_breath: // Breath Controller (Coarse, MIDI Controller 2)
357                        cout << "BREATH";
358                        break;
359                    case gig::dimension_foot: // Foot Pedal (Coarse, MIDI Controller 4)
360                        cout << "FOOT";
361                        break;
362                    case gig::dimension_portamentotime: // Portamento Time (Coarse, MIDI Controller 5)
363                        cout << "PORTAMENTOTIME";
364                        break;
365                    case gig::dimension_effect1: // Effect Controller 1 (Coarse, MIDI Controller 12)
366                        cout << "EFFECT1";
367                        break;
368                    case gig::dimension_effect2: // Effect Controller 2 (Coarse, MIDI Controller 13)
369                        cout << "EFFECT2";
370                        break;
371                    case gig::dimension_genpurpose1: // General Purpose Controller 1 (Slider, MIDI Controller 16)
372                        cout << "GENPURPOSE1";
373                        break;
374                    case gig::dimension_genpurpose2: // General Purpose Controller 2 (Slider, MIDI Controller 17)
375                        cout << "GENPURPOSE2";
376                        break;
377                    case gig::dimension_genpurpose3: // General Purpose Controller 3 (Slider, MIDI Controller 18)
378                        cout << "GENPURPOSE3";
379                        break;
380                    case gig::dimension_genpurpose4: // General Purpose Controller 4 (Slider, MIDI Controller 19)
381                        cout << "GENPURPOSE4";
382                        break;
383                    case gig::dimension_sustainpedal: // Sustain Pedal (MIDI Controller 64)
384                        cout << "SUSTAINPEDAL";
385                        break;
386                    case gig::dimension_portamento: // Portamento (MIDI Controller 65)
387                        cout << "PORTAMENTO";
388                        break;
389                    case gig::dimension_sostenutopedal: // Sostenuto Pedal (MIDI Controller 66)
390                        cout << "SOSTENUTOPEDAL";
391                        break;
392                    case gig::dimension_softpedal: // Soft Pedal (MIDI Controller 67)
393                        cout << "SOFTPEDAL";
394                        break;
395                    case gig::dimension_genpurpose5: // General Purpose Controller 5 (Button, MIDI Controller 80)
396                        cout << "GENPURPOSE5";
397                        break;
398                    case gig::dimension_genpurpose6: // General Purpose Controller 6 (Button, MIDI Controller 81)
399                        cout << "GENPURPOSE6";
400                        break;
401                    case gig::dimension_genpurpose7: // General Purpose Controller 7 (Button, MIDI Controller 82)
402                        cout << "GENPURPOSE7";
403                        break;
404                    case gig::dimension_genpurpose8: // General Purpose Controller 8 (Button, MIDI Controller 83)
405                        cout << "GENPURPOSE8";
406                        break;
407                    case gig::dimension_effect1depth: // Effect 1 Depth (MIDI Controller 91)
408                        cout << "EFFECT1DEPTH";
409                        break;
410                    case gig::dimension_effect2depth: // Effect 2 Depth (MIDI Controller 92)
411                        cout << "EFFECT2DEPTH";
412                        break;
413                    case gig::dimension_effect3depth: // Effect 3 Depth (MIDI Controller 93)
414                        cout << "EFFECT3DEPTH";
415                        break;
416                    case gig::dimension_effect4depth: // Effect 4 Depth (MIDI Controller 94)
417                        cout << "EFFECT4DEPTH";
418                        break;
419                    case gig::dimension_effect5depth:  // Effect 5 Depth (MIDI Controller 95)
420                        cout << "EFFECT5DEPTH";
421                        break;
422                    default:
423                        cout << "UNKNOWN (" << int(DimensionDef.dimension) << ") - please report this !";
424                        break;
425                }
426                cout << ", Bits=" << (uint) DimensionDef.bits << ", Zones=" << (uint) DimensionDef.zones;
427                cout << ", SplitType=";
428                switch (DimensionDef.split_type) {
429                    case gig::split_type_normal:
430                        cout << "NORMAL" << endl;
431                        break;
432                    case gig::split_type_bit:
433                        cout << "BIT" << endl;
434                        break;
435                    default:
436                        cout << "UNKNOWN" << endl;
437                }
438            }
439    
440          PrintDimensionRegions(pRegion);          PrintDimensionRegions(pRegion);
441    
442          pRegion = instr->GetNextRegion();          pRegion = instr->GetNextRegion();
443      }      }
444  }  }
445    
446    template<typename T_int>
447    static void printIntArray(T_int* array, int size) {
448        printf("{");
449        for (int i = 0; i < size; ++i)
450            printf("[%d]=%d,", i, array[i]);
451        printf("}");
452        fflush(stdout);
453    }
454    
455  void PrintDimensionRegions(gig::Region* rgn) {  void PrintDimensionRegions(gig::Region* rgn) {
456      int dimensionRegions = 0;      int dimensionRegions = 0;
457      gig::DimensionRegion* pDimensionRegion;      gig::DimensionRegion* pDimensionRegion;
458      while (dimensionRegions < 32) {      while (dimensionRegions < rgn->DimensionRegions) {
459          pDimensionRegion = rgn->pDimensionRegions[dimensionRegions];          pDimensionRegion = rgn->pDimensionRegions[dimensionRegions];
460          if (!pDimensionRegion) break;          if (!pDimensionRegion) break;
461    
# Line 154  void PrintDimensionRegions(gig::Region* Line 467  void PrintDimensionRegions(gig::Region*
467              if (pSample->pInfo->Name != "") {              if (pSample->pInfo->Name != "") {
468                  cout << "\"" << pSample->pInfo->Name << "\", ";                  cout << "\"" << pSample->pInfo->Name << "\", ";
469              }              }
470              cout << pSample->SamplesPerSecond << "Hz, " << endl;              cout << pSample->SamplesPerSecond << "Hz, ";
471                cout << "UnityNote=" << (int) pDimensionRegion->UnityNote << ", FineTune=" << (int) pDimensionRegion->FineTune << ", Gain=" << (-pDimensionRegion->Gain / 655360.0) << "dB, SampleStartOffset=" << pDimensionRegion->SampleStartOffset << endl;
472          }          }
473          else {          else {
474              cout << "                Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl;              cout << "                Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl;
# Line 165  void PrintDimensionRegions(gig::Region* Line 479  void PrintDimensionRegions(gig::Region*
479          cout << "                EG1PreAttack=" << pDimensionRegion->EG1PreAttack << "permille, EG1Attack=" << pDimensionRegion->EG1Attack << "s, EG1Decay1=" << pDimensionRegion->EG1Decay1 << "s,  EG1Sustain=" << pDimensionRegion->EG1Sustain << "permille, EG1Release=" << pDimensionRegion->EG1Release << "s, EG1Decay2=" << pDimensionRegion->EG1Decay2 << "s, EG1Hold=" << pDimensionRegion->EG1Hold << endl;          cout << "                EG1PreAttack=" << pDimensionRegion->EG1PreAttack << "permille, EG1Attack=" << pDimensionRegion->EG1Attack << "s, EG1Decay1=" << pDimensionRegion->EG1Decay1 << "s,  EG1Sustain=" << pDimensionRegion->EG1Sustain << "permille, EG1Release=" << pDimensionRegion->EG1Release << "s, EG1Decay2=" << pDimensionRegion->EG1Decay2 << "s, EG1Hold=" << pDimensionRegion->EG1Hold << endl;
480          cout << "                EG2PreAttack=" << pDimensionRegion->EG2PreAttack << "permille, EG2Attack=" << pDimensionRegion->EG2Attack << "s, EG2Decay1=" << pDimensionRegion->EG2Decay1 << "s,  EG2Sustain=" << pDimensionRegion->EG2Sustain << "permille, EG2Release=" << pDimensionRegion->EG2Release << "s, EG2Decay2=" << pDimensionRegion->EG2Decay2 << "s" << endl;          cout << "                EG2PreAttack=" << pDimensionRegion->EG2PreAttack << "permille, EG2Attack=" << pDimensionRegion->EG2Attack << "s, EG2Decay1=" << pDimensionRegion->EG2Decay1 << "s,  EG2Sustain=" << pDimensionRegion->EG2Sustain << "permille, EG2Release=" << pDimensionRegion->EG2Release << "s, EG2Decay2=" << pDimensionRegion->EG2Decay2 << "s" << endl;
481          cout << "                VCFEnabled=" << pDimensionRegion->VCFEnabled << ", VCFType=" << pDimensionRegion->VCFType << ", VCFCutoff=" << (int) pDimensionRegion->VCFCutoff << ",  VCFResonance=" << (int) pDimensionRegion->VCFResonance << ", VCFCutoffController=" << pDimensionRegion->VCFCutoffController << endl;          cout << "                VCFEnabled=" << pDimensionRegion->VCFEnabled << ", VCFType=" << pDimensionRegion->VCFType << ", VCFCutoff=" << (int) pDimensionRegion->VCFCutoff << ",  VCFResonance=" << (int) pDimensionRegion->VCFResonance << ", VCFCutoffController=" << pDimensionRegion->VCFCutoffController << endl;
482            cout << "                VelocityResponseCurve=";
483            switch (pDimensionRegion->VelocityResponseCurve) {
484                case gig::curve_type_nonlinear:
485                    cout << "NONLINEAR";
486                    break;
487                case gig::curve_type_linear:
488                    cout << "LINEAR";
489                    break;
490                case gig::curve_type_special:
491                    cout << "SPECIAL";
492                    break;
493                case gig::curve_type_unknown:
494                default:
495                    cout << "UNKNOWN - please report this !";
496            }
497            cout << ", VelocityResponseDepth=" << (int) pDimensionRegion->VelocityResponseDepth << ", VelocityResponseCurveScaling=" << (int) pDimensionRegion->VelocityResponseCurveScaling << endl;
498            cout << "                VelocityUpperLimit=" << (int) pDimensionRegion->VelocityUpperLimit << " DimensionUpperLimits[]=" << flush;
499            printIntArray(pDimensionRegion->DimensionUpperLimits, 8);
500            cout << endl;
501    #if 0 // requires access to protected member VelocityTable, so commented out for now
502            if (pDimensionRegion->VelocityTable) {
503                cout << "                VelocityTable[]=" << flush;
504                printIntArray(pDimensionRegion->VelocityTable, 127);
505                cout << endl;
506            }
507    #endif
508            cout << "                Pan=" << (int) pDimensionRegion->Pan << endl;
509    
510          dimensionRegions++;          dimensionRegions++;
511      }      }
512  }  }
513    
514    bool VerifyFile(gig::File* _gig) {
515        PubFile* gig = (PubFile*) _gig;
516    
517        cout << "Verifying sample checksum table ... " << flush;
518        if (!gig->VerifySampleChecksumTable()) {
519            cout << "DAMAGED\n";
520            cout << "You may use --rebuild-checksums to repair the sample checksum table.\n";
521            return false;
522        }
523        cout << "OK\n" << flush;
524    
525        cout << "Verifying samples ... " << flush;
526        std::map<int,gig::Sample*> failedSamples;
527        int iTotal = 0;
528        for (gig::Sample* pSample = gig->GetFirstSample(); pSample; pSample = gig->GetNextSample(), ++iTotal) {
529            if (!pSample->VerifyWaveData())
530                failedSamples[iTotal] = pSample;
531        }
532        if (failedSamples.empty()) {
533            cout << "ALL OK\n";
534            return true;
535        } else {
536            cout << failedSamples.size() << " of " << iTotal << " Samples DAMAGED:\n";
537            for (std::map<int,gig::Sample*>::iterator it = failedSamples.begin(); it != failedSamples.end(); ++it) {
538                const int i = it->first;
539                gig::Sample* pSample = it->second;
540    
541                string name = pSample->pInfo->Name;
542                if (name == "") name = "<NO NAME>";
543                else            name = '\"' + name + '\"';
544    
545                cout << "Damaged Sample " << (i+1) << ") " << name << endl;
546            }
547            return false;
548        }
549    }
550    
551    void RebuildChecksumTable(gig::File* _gig) {
552        PubFile* gig = (PubFile*) _gig;
553    
554        cout << "Recalculating checksums of all samples ... " << flush;
555        bool bSaveRequired = gig->RebuildSampleChecksumTable();
556        cout << "OK\n";
557        if (bSaveRequired) {
558            cout << "WARNING: File structure change required, rebuilding entire file now ..." << endl;
559            gig->Save();
560            cout << "DONE\n";
561            cout << "NOTE: Since the entire file was rebuilt, you may need to manually check all samples in this particular case now!\n";
562        }
563    }
564    
565    string Revision() {
566        string s = "$Revision$";
567        return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
568    }
569    
570    void PrintVersion() {
571        cout << "gigdump revision " << Revision() << endl;
572        cout << "using " << gig::libraryName() << " " << gig::libraryVersion() << endl;
573    }
574    
575  void PrintUsage() {  void PrintUsage() {
576      cout << "gigdump - parses Gigasampler files and prints out the content." << endl;      cout << "gigdump - parses Gigasampler files and prints out the content." << endl;
577      cout << endl;      cout << endl;
578      cout << "Usage: gigdump FILE" << endl;      cout << "Usage: gigdump [-v | --verify | --rebuild-checksums] FILE" << endl;
579        cout << endl;
580        cout << "   --rebuild-checksums  Rebuild checksum table for all samples." << endl;
581        cout << endl;
582        cout << "   -v                   Print version and exit." << endl;
583        cout << endl;
584        cout << "   --verify             Checks raw wave data integrity of all samples." << endl;
585        cout << endl;
586  }  }

Legend:
Removed from v.55  
changed lines
  Added in v.2985

  ViewVC Help
Powered by ViewVC