/[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

revision 229 by schoenebeck, Sat Aug 28 16:10:25 2004 UTC revision 808 by schoenebeck, Tue Nov 22 09:11:17 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, 2004 by Christian Schoenebeck                     *   *   Copyright (C) 2003-2005 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 PrintSamples(gig::File* gig);  void PrintSamples(gig::File* gig);
39  void PrintInstruments(gig::File* gig);  void PrintInstruments(gig::File* gig);
40  void PrintRegions(gig::Instrument* instr);  void PrintRegions(gig::Instrument* instr);
# Line 44  int main(int argc, char *argv[]) Line 47  int main(int argc, char *argv[])
47          PrintUsage();          PrintUsage();
48          return EXIT_FAILURE;          return EXIT_FAILURE;
49      }      }
50        if (argv[1][0] == '-') {
51            switch (argv[1][1]) {
52                case 'v':
53                    PrintVersion();
54                    return EXIT_SUCCESS;
55            }
56        }
57      FILE* hFile = fopen(argv[1], "r");      FILE* hFile = fopen(argv[1], "r");
58      if (!hFile) {      if (!hFile) {
59          cout << "Invalid file argument!" << endl;          cout << "Invalid file argument!" << endl;
# Line 90  void PrintSamples(gig::File* gig) { Line 100  void PrintSamples(gig::File* gig) {
100                  case gig::loop_type_backward:       cout << "reverse)";  break;                  case gig::loop_type_backward:       cout << "reverse)";  break;
101              }              }
102              cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd;              cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd;
103                cout << ", LoopPlayCount=" << pSample->LoopPlayCount;
104          }          }
105          cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") << endl;          cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") << endl;
106          pSample = gig->GetNextSample();          pSample = gig->GetNextSample();
# Line 131  void PrintRegions(gig::Instrument* instr Line 142  void PrintRegions(gig::Instrument* instr
142              cout << "<NO_VALID_SAMPLE_REFERENCE> ";              cout << "<NO_VALID_SAMPLE_REFERENCE> ";
143          }          }
144          cout << "            KeyRange=" << pRegion->KeyRange.low << "-" << pRegion->KeyRange.high << ", ";          cout << "            KeyRange=" << pRegion->KeyRange.low << "-" << pRegion->KeyRange.high << ", ";
145          cout << "VelocityRange=" << pRegion->VelocityRange.low << "-" << pRegion->VelocityRange.high << ", Layer=" << pRegion->Layer << endl;          cout << "VelocityRange=" << pRegion->VelocityRange.low << "-" << pRegion->VelocityRange.high << ", Layers=" << pRegion->Layers << endl;
146          cout << "            Loops=" << pRegion->SampleLoops << endl;          cout << "            Loops=" << pRegion->SampleLoops << endl;
147          cout << "            Dimensions=" << pRegion->Dimensions << endl;          cout << "            Dimensions=" << pRegion->Dimensions << endl;
148          for (int iDimension = 0; iDimension < pRegion->Dimensions; iDimension++) {          for (int iDimension = 0; iDimension < pRegion->Dimensions; iDimension++) {
# Line 144  void PrintRegions(gig::Instrument* instr Line 155  void PrintRegions(gig::Instrument* instr
155                  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).
156                      cout << "SAMPLECHANNEL";                      cout << "SAMPLECHANNEL";
157                      break;                      break;
158                  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).
159                      cout << "LAYER";                      gig::crossfade_t crossfade = pRegion->pDimensionRegions[iDimension]->Crossfade;
160                        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 << ")";
161                      break;                      break;
162                    }
163                  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).
164                      cout << "VELOCITY";                      cout << "VELOCITY";
165                      break;                      break;
# Line 159  void PrintRegions(gig::Instrument* instr Line 172  void PrintRegions(gig::Instrument* instr
172                  case gig::dimension_keyboard: // Key Position                  case gig::dimension_keyboard: // Key Position
173                      cout << "KEYBOARD";                      cout << "KEYBOARD";
174                      break;                      break;
175                    case gig::dimension_roundrobin: // Different samples triggered each time a note is played, dimension regions selected in sequence
176                        cout << "ROUNDROBIN";
177                        break;
178                    case gig::dimension_random: // Different samples triggered each time a note is played, random order
179                        cout << "RANDOM";
180                        break;
181                  case gig::dimension_modwheel: // Modulation Wheel (MIDI Controller 1)                  case gig::dimension_modwheel: // Modulation Wheel (MIDI Controller 1)
182                      cout << "MODWHEEL";                      cout << "MODWHEEL";
183                      break;                      break;
# Line 229  void PrintRegions(gig::Instrument* instr Line 248  void PrintRegions(gig::Instrument* instr
248                      cout << "EFFECT5DEPTH";                      cout << "EFFECT5DEPTH";
249                      break;                      break;
250                  default:                  default:
251                      cout << "UNKNOWN - please report this !";                      cout << "UNKNOWN (" << int(DimensionDef.dimension) << ") - please report this !";
252                      break;                      break;
253              }              }
254              cout << ", Bits=" << (uint) DimensionDef.bits << ", Zones=" << (uint) DimensionDef.zones << endl;              cout << ", Bits=" << (uint) DimensionDef.bits << ", Zones=" << (uint) DimensionDef.zones;
255                cout << ", SplitType=";
256                switch (DimensionDef.split_type) {
257                    case gig::split_type_normal:
258                        cout << "NORMAL" << endl;
259                        break;
260                    case gig::split_type_customvelocity:
261                        cout << "CUSTOMVELOCITY" << endl;
262                        break;
263                    case gig::split_type_bit:
264                        cout << "BIT" << endl;
265                        break;
266                    default:
267                        cout << "UNKNOWN" << endl;
268                }
269          }          }
270    
271          PrintDimensionRegions(pRegion);          PrintDimensionRegions(pRegion);
# Line 244  void PrintRegions(gig::Instrument* instr Line 277  void PrintRegions(gig::Instrument* instr
277  void PrintDimensionRegions(gig::Region* rgn) {  void PrintDimensionRegions(gig::Region* rgn) {
278      int dimensionRegions = 0;      int dimensionRegions = 0;
279      gig::DimensionRegion* pDimensionRegion;      gig::DimensionRegion* pDimensionRegion;
280      while (dimensionRegions < 32) {      while (dimensionRegions < rgn->DimensionRegions) {
281          pDimensionRegion = rgn->pDimensionRegions[dimensionRegions];          pDimensionRegion = rgn->pDimensionRegions[dimensionRegions];
282          if (!pDimensionRegion) break;          if (!pDimensionRegion) break;
283    
# Line 256  void PrintDimensionRegions(gig::Region* Line 289  void PrintDimensionRegions(gig::Region*
289              if (pSample->pInfo->Name != "") {              if (pSample->pInfo->Name != "") {
290                  cout << "\"" << pSample->pInfo->Name << "\", ";                  cout << "\"" << pSample->pInfo->Name << "\", ";
291              }              }
292              cout << pSample->SamplesPerSecond << "Hz, " << endl;              cout << pSample->SamplesPerSecond << "Hz, ";
293                cout << "UnityNote=" << (int) pDimensionRegion->UnityNote << ", FineTune=" << (int) pDimensionRegion->FineTune << ", Gain=" << (-pDimensionRegion->Gain / 655360.0) << "dB, SampleStartOffset=" << pDimensionRegion->SampleStartOffset << endl;
294          }          }
295          else {          else {
296              cout << "                Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl;              cout << "                Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl;
# Line 267  void PrintDimensionRegions(gig::Region* Line 301  void PrintDimensionRegions(gig::Region*
301          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;
302          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;
303          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;
304            cout << "                VelocityResponseCurve=";
305            switch (pDimensionRegion->VelocityResponseCurve) {
306                case gig::curve_type_nonlinear:
307                    cout << "NONLINEAR";
308                    break;
309                case gig::curve_type_linear:
310                    cout << "LINEAR";
311                    break;
312                case gig::curve_type_special:
313                    cout << "SPECIAL";
314                    break;
315                case gig::curve_type_unknown:
316                default:
317                    cout << "UNKNOWN - please report this !";
318            }
319            cout << ", VelocityResponseDepth=" << (int) pDimensionRegion->VelocityResponseDepth << ", VelocityResponseCurveScaling=" << (int) pDimensionRegion->VelocityResponseCurveScaling << endl;
320            cout << "                Pan=" << (int) pDimensionRegion->Pan << endl;
321    
322          dimensionRegions++;          dimensionRegions++;
323      }      }
324  }  }
325    
326    string Revision() {
327        string s = "$Revision: 1.17 $";
328        return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
329    }
330    
331    void PrintVersion() {
332        cout << "gigdump revision " << Revision() << endl;
333        cout << "using " << gig::libraryName() << " " << gig::libraryVersion() << endl;
334    }
335    
336  void PrintUsage() {  void PrintUsage() {
337      cout << "gigdump - parses Gigasampler files and prints out the content." << endl;      cout << "gigdump - parses Gigasampler files and prints out the content." << endl;
338      cout << endl;      cout << endl;
339      cout << "Usage: gigdump FILE" << endl;      cout << "Usage: gigdump [-v] FILE" << endl;
340        cout << endl;
341        cout << "   -v  Print version and exit." << endl;
342        cout << endl;
343  }  }

Legend:
Removed from v.229  
changed lines
  Added in v.808

  ViewVC Help
Powered by ViewVC