/[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 229 by schoenebeck, Sat Aug 28 16:10:25 2004 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 131  void PrintRegions(gig::Instrument* instr Line 190  void PrintRegions(gig::Instrument* instr
190              cout << "<NO_VALID_SAMPLE_REFERENCE> ";              cout << "<NO_VALID_SAMPLE_REFERENCE> ";
191          }          }
192          cout << "            KeyRange=" << pRegion->KeyRange.low << "-" << pRegion->KeyRange.high << ", ";          cout << "            KeyRange=" << pRegion->KeyRange.low << "-" << pRegion->KeyRange.high << ", ";
193          cout << "VelocityRange=" << pRegion->VelocityRange.low << "-" << pRegion->VelocityRange.high << ", Layer=" << pRegion->Layer << endl;          cout << "VelocityRange=" << pRegion->VelocityRange.low << "-" << pRegion->VelocityRange.high << ", Layers=" << pRegion->Layers << endl;
194          cout << "            Loops=" << pRegion->SampleLoops << endl;          cout << "            Loops=" << pRegion->SampleLoops << endl;
195          cout << "            Dimensions=" << pRegion->Dimensions << endl;          cout << "            Dimensions=" << pRegion->Dimensions << endl;
196          for (int iDimension = 0; iDimension < pRegion->Dimensions; iDimension++) {          for (int iDimension = 0; iDimension < pRegion->Dimensions; iDimension++) {
# Line 144  void PrintRegions(gig::Instrument* instr Line 203  void PrintRegions(gig::Instrument* instr
203                  case gig::dimension_samplechannel: // If used sample has more than one channel (thus is not mono).                  case gig::dimension_samplechannel: // If used sample has more than one channel (thus is not mono).
204                      cout << "SAMPLECHANNEL";                      cout << "SAMPLECHANNEL";
205                      break;                      break;
206                  case gig::dimension_layer: // For layering of up to 8 instruments (and eventually crossfading of 2 or 4 layers).                  case gig::dimension_layer: { // For layering of up to 8 instruments (and eventually crossfading of 2 or 4 layers).
207                      cout << "LAYER";                      gig::crossfade_t crossfade = pRegion->pDimensionRegions[iDimension]->Crossfade;
208                        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 << ")";
209                      break;                      break;
210                    }
211                  case gig::dimension_velocity: // Key Velocity (this is the only dimension where the ranges can exactly be defined).                  case gig::dimension_velocity: // Key Velocity (this is the only dimension where the ranges can exactly be defined).
212                      cout << "VELOCITY";                      cout << "VELOCITY";
213                      break;                      break;
# Line 159  void PrintRegions(gig::Instrument* instr Line 220  void PrintRegions(gig::Instrument* instr
220                  case gig::dimension_keyboard: // Key Position                  case gig::dimension_keyboard: // Key Position
221                      cout << "KEYBOARD";                      cout << "KEYBOARD";
222                      break;                      break;
223                    case gig::dimension_roundrobin: // Different samples triggered each time a note is played, dimension regions selected in sequence
224                        cout << "ROUNDROBIN";
225                        break;
226                    case gig::dimension_random: // Different samples triggered each time a note is played, random order
227                        cout << "RANDOM";
228                        break;
229                  case gig::dimension_modwheel: // Modulation Wheel (MIDI Controller 1)                  case gig::dimension_modwheel: // Modulation Wheel (MIDI Controller 1)
230                      cout << "MODWHEEL";                      cout << "MODWHEEL";
231                      break;                      break;
# Line 229  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 << endl;              cout << ", Bits=" << (uint) DimensionDef.bits << ", Zones=" << (uint) DimensionDef.zones;
303                cout << ", SplitType=";
304                switch (DimensionDef.split_type) {
305                    case gig::split_type_normal:
306                        cout << "NORMAL" << endl;
307                        break;
308                    case gig::split_type_bit:
309                        cout << "BIT" << endl;
310                        break;
311                    default:
312                        cout << "UNKNOWN" << endl;
313                }
314          }          }
315    
316          PrintDimensionRegions(pRegion);          PrintDimensionRegions(pRegion);
# Line 244  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 256  void PrintDimensionRegions(gig::Region* Line 334  void PrintDimensionRegions(gig::Region*
334              if (pSample->pInfo->Name != "") {              if (pSample->pInfo->Name != "") {
335                  cout << "\"" << pSample->pInfo->Name << "\", ";                  cout << "\"" << pSample->pInfo->Name << "\", ";
336              }              }
337              cout << pSample->SamplesPerSecond << "Hz, " << endl;              cout << pSample->SamplesPerSecond << "Hz, ";
338                cout << "UnityNote=" << (int) pDimensionRegion->UnityNote << ", FineTune=" << (int) pDimensionRegion->FineTune << ", Gain=" << (-pDimensionRegion->Gain / 655360.0) << "dB, SampleStartOffset=" << pDimensionRegion->SampleStartOffset << endl;
339          }          }
340          else {          else {
341              cout << "                Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl;              cout << "                Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl;
# Line 267  void PrintDimensionRegions(gig::Region* Line 346  void PrintDimensionRegions(gig::Region*
346          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;
347          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;
348          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;
349            cout << "                VelocityResponseCurve=";
350            switch (pDimensionRegion->VelocityResponseCurve) {
351                case gig::curve_type_nonlinear:
352                    cout << "NONLINEAR";
353                    break;
354                case gig::curve_type_linear:
355                    cout << "LINEAR";
356                    break;
357                case gig::curve_type_special:
358                    cout << "SPECIAL";
359                    break;
360                case gig::curve_type_unknown:
361                default:
362                    cout << "UNKNOWN - please report this !";
363            }
364            cout << ", VelocityResponseDepth=" << (int) pDimensionRegion->VelocityResponseDepth << ", VelocityResponseCurveScaling=" << (int) pDimensionRegion->VelocityResponseCurveScaling << endl;
365            cout << "                Pan=" << (int) pDimensionRegion->Pan << endl;
366    
367          dimensionRegions++;          dimensionRegions++;
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.229  
changed lines
  Added in v.916

  ViewVC Help
Powered by ViewVC