/[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 235 by schoenebeck, Thu Sep 9 18:37:22 2004 UTC revision 2493 by schoenebeck, Wed Jan 1 17:06:51 2014 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-2009 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 PrintInstruments(gig::File* gig);  void PrintInstruments(gig::File* gig);
44  void PrintRegions(gig::Instrument* instr);  void PrintRegions(gig::Instrument* instr);
# Line 44  int main(int argc, char *argv[]) Line 51  int main(int argc, char *argv[])
51          PrintUsage();          PrintUsage();
52          return EXIT_FAILURE;          return EXIT_FAILURE;
53      }      }
54        if (argv[1][0] == '-') {
55            switch (argv[1][1]) {
56                case 'v':
57                    PrintVersion();
58                    return EXIT_SUCCESS;
59            }
60        }
61      FILE* hFile = fopen(argv[1], "r");      FILE* hFile = fopen(argv[1], "r");
62      if (!hFile) {      if (!hFile) {
63          cout << "Invalid file argument!" << endl;          cout << "Invalid file argument!" << endl;
# Line 53  int main(int argc, char *argv[]) Line 67  int main(int argc, char *argv[])
67      try {      try {
68          RIFF::File* riff = new RIFF::File(argv[1]);          RIFF::File* riff = new RIFF::File(argv[1]);
69          gig::File*  gig  = new gig::File(riff);          gig::File*  gig  = new gig::File(riff);
70            PrintFileInformations(gig);
71            cout << endl;
72            PrintGroups(gig);
73            cout << endl;
74          PrintSamples(gig);          PrintSamples(gig);
75          cout << endl;          cout << endl;
76          PrintInstruments(gig);          PrintInstruments(gig);
# Line 71  int main(int argc, char *argv[]) Line 89  int main(int argc, char *argv[])
89      return EXIT_SUCCESS;      return EXIT_SUCCESS;
90  }  }
91    
92    void PrintFileInformations(gig::File* gig) {
93        cout << "Global File Informations:" << endl;
94        cout << "    Total instruments: " << gig->Instruments << endl;
95        if (gig->pVersion) {
96           cout << "    Version: " << gig->pVersion->major   << "."
97                               << gig->pVersion->minor   << "."
98                               << gig->pVersion->release << "."
99                               << gig->pVersion->build   << endl;
100        }
101        if (gig->pInfo) {
102            if (gig->pInfo->Name.size())
103                cout << "    Name: '" << gig->pInfo->Name << "'\n";
104            if (gig->pInfo->ArchivalLocation.size())
105                cout << "    ArchivalLocation: '" << gig->pInfo->ArchivalLocation << "'\n";
106            if (gig->pInfo->CreationDate.size())
107                cout << "    CreationDate: '" << gig->pInfo->CreationDate << "'\n";
108            if (gig->pInfo->Comments.size())
109                cout << "    Comments: '" << gig->pInfo->Comments << "'\n";
110            if (gig->pInfo->Product.size())
111                cout << "    Product: '" << gig->pInfo->Product << "'\n";
112            if (gig->pInfo->Copyright.size())
113                cout << "    Copyright: '" << gig->pInfo->Copyright << "'\n";
114            if (gig->pInfo->Artists.size())
115                cout << "    Artists: '" << gig->pInfo->Artists << "'\n";
116            if (gig->pInfo->Genre.size())
117                cout << "    Genre: '" << gig->pInfo->Genre << "'\n";
118            if (gig->pInfo->Keywords.size())
119                cout << "    Keywords: '" << gig->pInfo->Keywords << "'\n";
120            if (gig->pInfo->Engineer.size())
121                cout << "    Engineer: '" << gig->pInfo->Engineer << "'\n";
122            if (gig->pInfo->Technician.size())
123                cout << "    Technician: '" << gig->pInfo->Technician << "'\n";
124            if (gig->pInfo->Software.size())
125                cout << "    Software: '" << gig->pInfo->Software << "'\n";
126            if (gig->pInfo->Medium.size())
127                cout << "    Medium: '" << gig->pInfo->Medium << "'\n";
128            if (gig->pInfo->Source.size())
129                cout << "    Source: '" << gig->pInfo->Source << "'\n";
130            if (gig->pInfo->SourceForm.size())
131                cout << "    SourceForm: '" << gig->pInfo->SourceForm << "'\n";
132            if (gig->pInfo->Commissioned.size())
133                cout << "    Commissioned: '" << gig->pInfo->Commissioned << "'\n";
134        }
135    }
136    
137    void PrintGroups(gig::File* gig) {
138        int groups = 0;
139        cout << "ALL defined Groups:" << endl;
140        for (gig::Group* pGroup = gig->GetFirstGroup(); pGroup; pGroup = gig->GetNextGroup()) {
141            groups++;
142            string name = pGroup->Name;
143            if (name == "") name = "<NO NAME>";
144            else            name = '\"' + name + '\"';
145            cout << "    Group " << groups << ")" << endl;
146            cout << "        Name: " << name << endl;
147        }
148    }
149    
150  void PrintSamples(gig::File* gig) {  void PrintSamples(gig::File* gig) {
151      int samples = 0;      int samples = 0;
152      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;
153      gig::Sample* pSample = gig->GetFirstSample();      gig::Sample* pSample = gig->GetFirstSample();
154      while (pSample) {      while (pSample) {
155          samples++;          samples++;
156            // determine sample's name
157          string name = pSample->pInfo->Name;          string name = pSample->pInfo->Name;
158          if (name == "") name = "<NO NAME>";          if (name == "") name = "<NO NAME>";
159          else            name = '\"' + name + '\"';          else            name = '\"' + name + '\"';
160            // determine group this sample belongs to
161            int iGroup = 1;
162            for (gig::Group* pGroup = gig->GetFirstGroup(); pGroup; pGroup = gig->GetNextGroup(), iGroup++) {
163                if (pGroup == pSample->GetGroup()) break;
164            }
165            // print sample info
166          cout << "    Sample " << samples << ") " << name << ", ";          cout << "    Sample " << samples << ") " << name << ", ";
167            cout << "Group " << iGroup << ", ";
168          cout << pSample->SamplesPerSecond << "Hz, " << pSample->Channels << " Channels, " << pSample->Loops << " Loops";          cout << pSample->SamplesPerSecond << "Hz, " << pSample->Channels << " Channels, " << pSample->Loops << " Loops";
169          if (pSample->Loops) {          if (pSample->Loops) {
170              cout << " (Type: ";              cout << " (Type: ";
# Line 90  void PrintSamples(gig::File* gig) { Line 174  void PrintSamples(gig::File* gig) {
174                  case gig::loop_type_backward:       cout << "reverse)";  break;                  case gig::loop_type_backward:       cout << "reverse)";  break;
175              }              }
176              cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd;              cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd;
177                cout << ", LoopPlayCount=" << pSample->LoopPlayCount;
178          }          }
179          cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") << endl;          cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") << endl;
180          pSample = gig->GetNextSample();          pSample = gig->GetNextSample();
# Line 131  void PrintRegions(gig::Instrument* instr Line 216  void PrintRegions(gig::Instrument* instr
216              cout << "<NO_VALID_SAMPLE_REFERENCE> ";              cout << "<NO_VALID_SAMPLE_REFERENCE> ";
217          }          }
218          cout << "            KeyRange=" << pRegion->KeyRange.low << "-" << pRegion->KeyRange.high << ", ";          cout << "            KeyRange=" << pRegion->KeyRange.low << "-" << pRegion->KeyRange.high << ", ";
219          cout << "VelocityRange=" << pRegion->VelocityRange.low << "-" << pRegion->VelocityRange.high << ", Layer=" << pRegion->Layer << endl;          cout << "VelocityRange=" << pRegion->VelocityRange.low << "-" << pRegion->VelocityRange.high << ", Layers=" << pRegion->Layers << endl;
220          cout << "            Loops=" << pRegion->SampleLoops << endl;          cout << "            Loops=" << pRegion->SampleLoops << endl;
221          cout << "            Dimensions=" << pRegion->Dimensions << endl;          cout << "            Dimensions=" << pRegion->Dimensions << endl;
222          for (int iDimension = 0; iDimension < pRegion->Dimensions; iDimension++) {          for (int iDimension = 0; iDimension < pRegion->Dimensions; iDimension++) {
# Line 144  void PrintRegions(gig::Instrument* instr Line 229  void PrintRegions(gig::Instrument* instr
229                  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).
230                      cout << "SAMPLECHANNEL";                      cout << "SAMPLECHANNEL";
231                      break;                      break;
232                  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).
233                      gig::crossfade_t crossfade = pRegion->pDimensionRegions[iDimension]->Crossfade;                      gig::crossfade_t crossfade = pRegion->pDimensionRegions[iDimension]->Crossfade;
234                      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 << ")";                      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 << ")";
235                      break;                      break;
236                    }
237                  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).
238                      cout << "VELOCITY";                      cout << "VELOCITY";
239                      break;                      break;
# Line 160  void PrintRegions(gig::Instrument* instr Line 246  void PrintRegions(gig::Instrument* instr
246                  case gig::dimension_keyboard: // Key Position                  case gig::dimension_keyboard: // Key Position
247                      cout << "KEYBOARD";                      cout << "KEYBOARD";
248                      break;                      break;
249                    case gig::dimension_roundrobin: // Different samples triggered each time a note is played, dimension regions selected in sequence
250                        cout << "ROUNDROBIN";
251                        break;
252                    case gig::dimension_random: // Different samples triggered each time a note is played, random order
253                        cout << "RANDOM";
254                        break;
255                    case gig::dimension_smartmidi: // For MIDI tools like legato and repetition mode
256                        cout << "SMARTMIDI";
257                        break;
258                    case gig::dimension_roundrobinkeyboard: // Different samples triggered each time a note is played, any key advances the counter
259                        cout << "ROUNDROBINKEYBOARD";
260                        break;
261                  case gig::dimension_modwheel: // Modulation Wheel (MIDI Controller 1)                  case gig::dimension_modwheel: // Modulation Wheel (MIDI Controller 1)
262                      cout << "MODWHEEL";                      cout << "MODWHEEL";
263                      break;                      break;
# Line 230  void PrintRegions(gig::Instrument* instr Line 328  void PrintRegions(gig::Instrument* instr
328                      cout << "EFFECT5DEPTH";                      cout << "EFFECT5DEPTH";
329                      break;                      break;
330                  default:                  default:
331                      cout << "UNKNOWN - please report this !";                      cout << "UNKNOWN (" << int(DimensionDef.dimension) << ") - please report this !";
332                      break;                      break;
333              }              }
334              cout << ", Bits=" << (uint) DimensionDef.bits << ", Zones=" << (uint) DimensionDef.zones << endl;              cout << ", Bits=" << (uint) DimensionDef.bits << ", Zones=" << (uint) DimensionDef.zones;
335                cout << ", SplitType=";
336                switch (DimensionDef.split_type) {
337                    case gig::split_type_normal:
338                        cout << "NORMAL" << endl;
339                        break;
340                    case gig::split_type_bit:
341                        cout << "BIT" << endl;
342                        break;
343                    default:
344                        cout << "UNKNOWN" << endl;
345                }
346          }          }
347    
348          PrintDimensionRegions(pRegion);          PrintDimensionRegions(pRegion);
# Line 245  void PrintRegions(gig::Instrument* instr Line 354  void PrintRegions(gig::Instrument* instr
354  void PrintDimensionRegions(gig::Region* rgn) {  void PrintDimensionRegions(gig::Region* rgn) {
355      int dimensionRegions = 0;      int dimensionRegions = 0;
356      gig::DimensionRegion* pDimensionRegion;      gig::DimensionRegion* pDimensionRegion;
357      while (dimensionRegions < 32) {      while (dimensionRegions < rgn->DimensionRegions) {
358          pDimensionRegion = rgn->pDimensionRegions[dimensionRegions];          pDimensionRegion = rgn->pDimensionRegions[dimensionRegions];
359          if (!pDimensionRegion) break;          if (!pDimensionRegion) break;
360    
# Line 257  void PrintDimensionRegions(gig::Region* Line 366  void PrintDimensionRegions(gig::Region*
366              if (pSample->pInfo->Name != "") {              if (pSample->pInfo->Name != "") {
367                  cout << "\"" << pSample->pInfo->Name << "\", ";                  cout << "\"" << pSample->pInfo->Name << "\", ";
368              }              }
369              cout << pSample->SamplesPerSecond << "Hz, " << endl;              cout << pSample->SamplesPerSecond << "Hz, ";
370                cout << "UnityNote=" << (int) pDimensionRegion->UnityNote << ", FineTune=" << (int) pDimensionRegion->FineTune << ", Gain=" << (-pDimensionRegion->Gain / 655360.0) << "dB, SampleStartOffset=" << pDimensionRegion->SampleStartOffset << endl;
371          }          }
372          else {          else {
373              cout << "                Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl;              cout << "                Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl;
# Line 284  void PrintDimensionRegions(gig::Region* Line 394  void PrintDimensionRegions(gig::Region*
394                  cout << "UNKNOWN - please report this !";                  cout << "UNKNOWN - please report this !";
395          }          }
396          cout << ", VelocityResponseDepth=" << (int) pDimensionRegion->VelocityResponseDepth << ", VelocityResponseCurveScaling=" << (int) pDimensionRegion->VelocityResponseCurveScaling << endl;          cout << ", VelocityResponseDepth=" << (int) pDimensionRegion->VelocityResponseDepth << ", VelocityResponseCurveScaling=" << (int) pDimensionRegion->VelocityResponseCurveScaling << endl;
397            cout << "                Pan=" << (int) pDimensionRegion->Pan << endl;
398    
399          dimensionRegions++;          dimensionRegions++;
400      }      }
401  }  }
402    
403    string Revision() {
404        string s = "$Revision$";
405        return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
406    }
407    
408    void PrintVersion() {
409        cout << "gigdump revision " << Revision() << endl;
410        cout << "using " << gig::libraryName() << " " << gig::libraryVersion() << endl;
411    }
412    
413  void PrintUsage() {  void PrintUsage() {
414      cout << "gigdump - parses Gigasampler files and prints out the content." << endl;      cout << "gigdump - parses Gigasampler files and prints out the content." << endl;
415      cout << endl;      cout << endl;
416      cout << "Usage: gigdump FILE" << endl;      cout << "Usage: gigdump [-v] FILE" << endl;
417        cout << endl;
418        cout << "   -v  Print version and exit." << endl;
419        cout << endl;
420  }  }

Legend:
Removed from v.235  
changed lines
  Added in v.2493

  ViewVC Help
Powered by ViewVC