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

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

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

revision 437 by persson, Wed Mar 9 22:02:40 2005 UTC revision 916 by schoenebeck, Thu Aug 10 21:27:50 2006 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, 2004 by Christian Schoenebeck                     *   *   Copyright (C) 2003-2006 by Christian Schoenebeck                      *
6   *                               <cuse@users.sourceforge.net>              *   *                              <cuse@users.sourceforge.net>               *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program 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 27  Line 27 
27    
28  #include <iostream>  #include <iostream>
29  #include <cstdlib>  #include <cstdlib>
30    #include <string>
31    
32  #include "gig.h"  #include "gig.h"
33    
34  using namespace std;  using namespace std;
35    
36    string Revision();
37    void PrintVersion();
38    void PrintFileInformations(gig::File* gig);
39  void PrintSamples(gig::File* gig);  void PrintSamples(gig::File* gig);
40  void PrintInstruments(gig::File* gig);  void PrintInstruments(gig::File* gig);
41  void PrintRegions(gig::Instrument* instr);  void PrintRegions(gig::Instrument* instr);
# Line 44  int main(int argc, char *argv[]) Line 48  int main(int argc, char *argv[])
48          PrintUsage();          PrintUsage();
49          return EXIT_FAILURE;          return EXIT_FAILURE;
50      }      }
51        if (argv[1][0] == '-') {
52            switch (argv[1][1]) {
53                case 'v':
54                    PrintVersion();
55                    return EXIT_SUCCESS;
56            }
57        }
58      FILE* hFile = fopen(argv[1], "r");      FILE* hFile = fopen(argv[1], "r");
59      if (!hFile) {      if (!hFile) {
60          cout << "Invalid file argument!" << endl;          cout << "Invalid file argument!" << endl;
# Line 53  int main(int argc, char *argv[]) Line 64  int main(int argc, char *argv[])
64      try {      try {
65          RIFF::File* riff = new RIFF::File(argv[1]);          RIFF::File* riff = new RIFF::File(argv[1]);
66          gig::File*  gig  = new gig::File(riff);          gig::File*  gig  = new gig::File(riff);
67            PrintFileInformations(gig);
68            cout << endl;
69          PrintSamples(gig);          PrintSamples(gig);
70          cout << endl;          cout << endl;
71          PrintInstruments(gig);          PrintInstruments(gig);
# Line 71  int main(int argc, char *argv[]) Line 84  int main(int argc, char *argv[])
84      return EXIT_SUCCESS;      return EXIT_SUCCESS;
85  }  }
86    
87    void PrintFileInformations(gig::File* gig) {
88        cout << "Global File Informations:" << endl;
89        cout << "    Total instruments: " << gig->Instruments << endl;
90        if (gig->pVersion) {
91           cout << "    Version: " << gig->pVersion->major   << "."
92                               << gig->pVersion->minor   << "."
93                               << gig->pVersion->release << "."
94                               << gig->pVersion->build   << endl;
95        }
96        if (gig->pInfo) {
97            if (gig->pInfo->Name.size())
98                cout << "    Name: '" << gig->pInfo->Name << "'\n";
99            if (gig->pInfo->ArchivalLocation.size())
100                cout << "    ArchivalLocation: '" << gig->pInfo->ArchivalLocation << "'\n";
101            if (gig->pInfo->CreationDate.size())
102                cout << "    CreationDate: '" << gig->pInfo->CreationDate << "'\n";
103            if (gig->pInfo->Comments.size())
104                cout << "    Comments: '" << gig->pInfo->Comments << "'\n";
105            if (gig->pInfo->Product.size())
106                cout << "    Product: '" << gig->pInfo->Product << "'\n";
107            if (gig->pInfo->Copyright.size())
108                cout << "    Copyright: '" << gig->pInfo->Copyright << "'\n";
109            if (gig->pInfo->Artists.size())
110                cout << "    Artists: '" << gig->pInfo->Artists << "'\n";
111            if (gig->pInfo->Genre.size())
112                cout << "    Genre: '" << gig->pInfo->Genre << "'\n";
113            if (gig->pInfo->Keywords.size())
114                cout << "    Keywords: '" << gig->pInfo->Keywords << "'\n";
115            if (gig->pInfo->Engineer.size())
116                cout << "    Engineer: '" << gig->pInfo->Engineer << "'\n";
117            if (gig->pInfo->Technician.size())
118                cout << "    Technician: '" << gig->pInfo->Technician << "'\n";
119            if (gig->pInfo->Software.size())
120                cout << "    Software: '" << gig->pInfo->Software << "'\n";
121            if (gig->pInfo->Medium.size())
122                cout << "    Medium: '" << gig->pInfo->Medium << "'\n";
123            if (gig->pInfo->Source.size())
124                cout << "    Source: '" << gig->pInfo->Source << "'\n";
125            if (gig->pInfo->SourceForm.size())
126                cout << "    SourceForm: '" << gig->pInfo->SourceForm << "'\n";
127            if (gig->pInfo->Commissioned.size())
128                cout << "    Commissioned: '" << gig->pInfo->Commissioned << "'\n";
129        }
130    }
131    
132  void PrintSamples(gig::File* gig) {  void PrintSamples(gig::File* gig) {
133      int samples = 0;      int samples = 0;
134      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;
# Line 90  void PrintSamples(gig::File* gig) { Line 148  void PrintSamples(gig::File* gig) {
148                  case gig::loop_type_backward:       cout << "reverse)";  break;                  case gig::loop_type_backward:       cout << "reverse)";  break;
149              }              }
150              cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd;              cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd;
151                cout << ", LoopPlayCount=" << pSample->LoopPlayCount;
152          }          }
153          cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") << endl;          cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") << endl;
154          pSample = gig->GetNextSample();          pSample = gig->GetNextSample();
# Line 237  void PrintRegions(gig::Instrument* instr Line 296  void PrintRegions(gig::Instrument* instr
296                      cout << "EFFECT5DEPTH";                      cout << "EFFECT5DEPTH";
297                      break;                      break;
298                  default:                  default:
299                      cout << "UNKNOWN - please report this !";                      cout << "UNKNOWN (" << int(DimensionDef.dimension) << ") - please report this !";
300                      break;                      break;
301              }              }
302              cout << ", Bits=" << (uint) DimensionDef.bits << ", Zones=" << (uint) DimensionDef.zones;              cout << ", Bits=" << (uint) DimensionDef.bits << ", Zones=" << (uint) DimensionDef.zones;
# Line 246  void PrintRegions(gig::Instrument* instr Line 305  void PrintRegions(gig::Instrument* instr
305                  case gig::split_type_normal:                  case gig::split_type_normal:
306                      cout << "NORMAL" << endl;                      cout << "NORMAL" << endl;
307                      break;                      break;
                 case gig::split_type_customvelocity:  
                     cout << "CUSTOMVELOCITY" << endl;  
                     break;  
308                  case gig::split_type_bit:                  case gig::split_type_bit:
309                      cout << "BIT" << endl;                      cout << "BIT" << endl;
310                      break;                      break;
# Line 266  void PrintRegions(gig::Instrument* instr Line 322  void PrintRegions(gig::Instrument* instr
322  void PrintDimensionRegions(gig::Region* rgn) {  void PrintDimensionRegions(gig::Region* rgn) {
323      int dimensionRegions = 0;      int dimensionRegions = 0;
324      gig::DimensionRegion* pDimensionRegion;      gig::DimensionRegion* pDimensionRegion;
325      while (dimensionRegions < 32) {      while (dimensionRegions < rgn->DimensionRegions) {
326          pDimensionRegion = rgn->pDimensionRegions[dimensionRegions];          pDimensionRegion = rgn->pDimensionRegions[dimensionRegions];
327          if (!pDimensionRegion) break;          if (!pDimensionRegion) break;
328    
# Line 312  void PrintDimensionRegions(gig::Region* Line 368  void PrintDimensionRegions(gig::Region*
368      }      }
369  }  }
370    
371    string Revision() {
372        string s = "$Revision: 1.19 $";
373        return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
374    }
375    
376    void PrintVersion() {
377        cout << "gigdump revision " << Revision() << endl;
378        cout << "using " << gig::libraryName() << " " << gig::libraryVersion() << endl;
379    }
380    
381  void PrintUsage() {  void PrintUsage() {
382      cout << "gigdump - parses Gigasampler files and prints out the content." << endl;      cout << "gigdump - parses Gigasampler files and prints out the content." << endl;
383      cout << endl;      cout << endl;
384      cout << "Usage: gigdump FILE" << endl;      cout << "Usage: gigdump [-v] FILE" << endl;
385        cout << endl;
386        cout << "   -v  Print version and exit." << endl;
387        cout << endl;
388  }  }

Legend:
Removed from v.437  
changed lines
  Added in v.916

  ViewVC Help
Powered by ViewVC