/[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 2 by schoenebeck, Sat Oct 25 20:15:04 2003 UTC revision 931 by schoenebeck, Sun Oct 29 17:58:14 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 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 22  Line 22 
22   ***************************************************************************/   ***************************************************************************/
23    
24  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
25  #include <config.h>  # include <config.h>
26  #endif  #endif
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 PrintGroups(gig::File* gig);
40  void PrintSamples(gig::File* gig);  void PrintSamples(gig::File* gig);
41  void PrintInstruments(gig::File* gig);  void PrintInstruments(gig::File* gig);
42  void PrintRegions(gig::Instrument* instr);  void PrintRegions(gig::Instrument* instr);
# Line 44  int main(int argc, char *argv[]) Line 49  int main(int argc, char *argv[])
49          PrintUsage();          PrintUsage();
50          return EXIT_FAILURE;          return EXIT_FAILURE;
51      }      }
52        if (argv[1][0] == '-') {
53            switch (argv[1][1]) {
54                case 'v':
55                    PrintVersion();
56                    return EXIT_SUCCESS;
57            }
58        }
59      FILE* hFile = fopen(argv[1], "r");      FILE* hFile = fopen(argv[1], "r");
60      if (!hFile) {      if (!hFile) {
61          cout << "Invalid file argument!" << endl;          cout << "Invalid file argument!" << endl;
# Line 53  int main(int argc, char *argv[]) Line 65  int main(int argc, char *argv[])
65      try {      try {
66          RIFF::File* riff = new RIFF::File(argv[1]);          RIFF::File* riff = new RIFF::File(argv[1]);
67          gig::File*  gig  = new gig::File(riff);          gig::File*  gig  = new gig::File(riff);
68            PrintFileInformations(gig);
69            cout << endl;
70            PrintGroups(gig);
71            cout << endl;
72          PrintSamples(gig);          PrintSamples(gig);
73          cout << endl;          cout << endl;
74          PrintInstruments(gig);          PrintInstruments(gig);
# Line 71  int main(int argc, char *argv[]) Line 87  int main(int argc, char *argv[])
87      return EXIT_SUCCESS;      return EXIT_SUCCESS;
88  }  }
89    
90    void PrintFileInformations(gig::File* gig) {
91        cout << "Global File Informations:" << endl;
92        cout << "    Total instruments: " << gig->Instruments << endl;
93        if (gig->pVersion) {
94           cout << "    Version: " << gig->pVersion->major   << "."
95                               << gig->pVersion->minor   << "."
96                               << gig->pVersion->release << "."
97                               << gig->pVersion->build   << endl;
98        }
99        if (gig->pInfo) {
100            if (gig->pInfo->Name.size())
101                cout << "    Name: '" << gig->pInfo->Name << "'\n";
102            if (gig->pInfo->ArchivalLocation.size())
103                cout << "    ArchivalLocation: '" << gig->pInfo->ArchivalLocation << "'\n";
104            if (gig->pInfo->CreationDate.size())
105                cout << "    CreationDate: '" << gig->pInfo->CreationDate << "'\n";
106            if (gig->pInfo->Comments.size())
107                cout << "    Comments: '" << gig->pInfo->Comments << "'\n";
108            if (gig->pInfo->Product.size())
109                cout << "    Product: '" << gig->pInfo->Product << "'\n";
110            if (gig->pInfo->Copyright.size())
111                cout << "    Copyright: '" << gig->pInfo->Copyright << "'\n";
112            if (gig->pInfo->Artists.size())
113                cout << "    Artists: '" << gig->pInfo->Artists << "'\n";
114            if (gig->pInfo->Genre.size())
115                cout << "    Genre: '" << gig->pInfo->Genre << "'\n";
116            if (gig->pInfo->Keywords.size())
117                cout << "    Keywords: '" << gig->pInfo->Keywords << "'\n";
118            if (gig->pInfo->Engineer.size())
119                cout << "    Engineer: '" << gig->pInfo->Engineer << "'\n";
120            if (gig->pInfo->Technician.size())
121                cout << "    Technician: '" << gig->pInfo->Technician << "'\n";
122            if (gig->pInfo->Software.size())
123                cout << "    Software: '" << gig->pInfo->Software << "'\n";
124            if (gig->pInfo->Medium.size())
125                cout << "    Medium: '" << gig->pInfo->Medium << "'\n";
126            if (gig->pInfo->Source.size())
127                cout << "    Source: '" << gig->pInfo->Source << "'\n";
128            if (gig->pInfo->SourceForm.size())
129                cout << "    SourceForm: '" << gig->pInfo->SourceForm << "'\n";
130            if (gig->pInfo->Commissioned.size())
131                cout << "    Commissioned: '" << gig->pInfo->Commissioned << "'\n";
132        }
133    }
134    
135    void PrintGroups(gig::File* gig) {
136        int groups = 0;
137        cout << "ALL defined Groups:" << endl;
138        for (gig::Group* pGroup = gig->GetFirstGroup(); pGroup; pGroup = gig->GetNextGroup()) {
139            groups++;
140            string name = pGroup->Name;
141            if (name == "") name = "<NO NAME>";
142            else            name = '\"' + name + '\"';
143            cout << "    Group " << groups << ")" << endl;
144            cout << "        Name: " << name << endl;
145        }
146    }
147    
148  void PrintSamples(gig::File* gig) {  void PrintSamples(gig::File* gig) {
149      int samples = 0;      int samples = 0;
150      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;
151      gig::Sample* pSample = gig->GetFirstSample();      gig::Sample* pSample = gig->GetFirstSample();
152      while (pSample) {      while (pSample) {
153          samples++;          samples++;
154            // determine sample's name
155          string name = pSample->pInfo->Name;          string name = pSample->pInfo->Name;
156          if (name == "") name = "<NO NAME>";          if (name == "") name = "<NO NAME>";
157          else            name = '\"' + name + '\"';          else            name = '\"' + name + '\"';
158            // determine group this sample belongs to
159            int iGroup = 1;
160            for (gig::Group* pGroup = gig->GetFirstGroup(); pGroup; pGroup = gig->GetNextGroup(), iGroup++) {
161                if (pGroup == pSample->GetGroup()) break;
162            }
163            // print sample info
164          cout << "    Sample " << samples << ") " << name << ", ";          cout << "    Sample " << samples << ") " << name << ", ";
165          cout << pSample->SamplesPerSecond << "Hz, " << pSample->Channels << " Channels, " << pSample->Loops          cout << "Group " << iGroup << ", ";
166               << " Loops, LoopFraction=" << pSample->LoopFraction << ", Length=" << pSample->SamplesTotal << " Compressed=" << pSample->Compressed << endl;          cout << pSample->SamplesPerSecond << "Hz, " << pSample->Channels << " Channels, " << pSample->Loops << " Loops";
167            if (pSample->Loops) {
168                cout << " (Type: ";
169                switch (pSample->LoopType) {
170                    case gig::loop_type_normal:         cout << "normal)";   break;
171                    case gig::loop_type_bidirectional:  cout << "pingpong)"; break;
172                    case gig::loop_type_backward:       cout << "reverse)";  break;
173                }
174                cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd;
175                cout << ", LoopPlayCount=" << pSample->LoopPlayCount;
176            }
177            cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") << endl;
178          pSample = gig->GetNextSample();          pSample = gig->GetNextSample();
179      }      }
180  }  }
# Line 122  void PrintRegions(gig::Instrument* instr Line 214  void PrintRegions(gig::Instrument* instr
214              cout << "<NO_VALID_SAMPLE_REFERENCE> ";              cout << "<NO_VALID_SAMPLE_REFERENCE> ";
215          }          }
216          cout << "            KeyRange=" << pRegion->KeyRange.low << "-" << pRegion->KeyRange.high << ", ";          cout << "            KeyRange=" << pRegion->KeyRange.low << "-" << pRegion->KeyRange.high << ", ";
217          cout << "VelocityRange=" << pRegion->VelocityRange.low << "-" << pRegion->VelocityRange.high << ", Layer=" << pRegion->Layer << endl;          cout << "VelocityRange=" << pRegion->VelocityRange.low << "-" << pRegion->VelocityRange.high << ", Layers=" << pRegion->Layers << endl;
218          cout << "            Loops=" << pRegion->SampleLoops << endl;          cout << "            Loops=" << pRegion->SampleLoops << endl;
219            cout << "            Dimensions=" << pRegion->Dimensions << endl;
220            for (int iDimension = 0; iDimension < pRegion->Dimensions; iDimension++) {
221                cout << "            Dimension[" << iDimension << "]: Type=";
222                gig::dimension_def_t DimensionDef = pRegion->pDimensionDefinitions[iDimension];
223                switch (DimensionDef.dimension) {
224                    case gig::dimension_none:
225                        cout << "NONE";
226                        break;
227                    case gig::dimension_samplechannel: // If used sample has more than one channel (thus is not mono).
228                        cout << "SAMPLECHANNEL";
229                        break;
230                    case gig::dimension_layer: { // For layering of up to 8 instruments (and eventually crossfading of 2 or 4 layers).
231                        gig::crossfade_t crossfade = pRegion->pDimensionRegions[iDimension]->Crossfade;
232                        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 << ")";
233                        break;
234                    }
235                    case gig::dimension_velocity: // Key Velocity (this is the only dimension where the ranges can exactly be defined).
236                        cout << "VELOCITY";
237                        break;
238                    case gig::dimension_channelaftertouch: // Channel Key Pressure
239                        cout << "AFTERTOUCH";
240                        break;
241                    case gig::dimension_releasetrigger: // Special dimension for triggering samples on releasing a key.
242                        cout << "RELEASETRIGGER";
243                        break;
244                    case gig::dimension_keyboard: // Key Position
245                        cout << "KEYBOARD";
246                        break;
247                    case gig::dimension_roundrobin: // Different samples triggered each time a note is played, dimension regions selected in sequence
248                        cout << "ROUNDROBIN";
249                        break;
250                    case gig::dimension_random: // Different samples triggered each time a note is played, random order
251                        cout << "RANDOM";
252                        break;
253                    case gig::dimension_modwheel: // Modulation Wheel (MIDI Controller 1)
254                        cout << "MODWHEEL";
255                        break;
256                    case gig::dimension_breath: // Breath Controller (Coarse, MIDI Controller 2)
257                        cout << "BREATH";
258                        break;
259                    case gig::dimension_foot: // Foot Pedal (Coarse, MIDI Controller 4)
260                        cout << "FOOT";
261                        break;
262                    case gig::dimension_portamentotime: // Portamento Time (Coarse, MIDI Controller 5)
263                        cout << "PORTAMENTOTIME";
264                        break;
265                    case gig::dimension_effect1: // Effect Controller 1 (Coarse, MIDI Controller 12)
266                        cout << "EFFECT1";
267                        break;
268                    case gig::dimension_effect2: // Effect Controller 2 (Coarse, MIDI Controller 13)
269                        cout << "EFFECT2";
270                        break;
271                    case gig::dimension_genpurpose1: // General Purpose Controller 1 (Slider, MIDI Controller 16)
272                        cout << "GENPURPOSE1";
273                        break;
274                    case gig::dimension_genpurpose2: // General Purpose Controller 2 (Slider, MIDI Controller 17)
275                        cout << "GENPURPOSE2";
276                        break;
277                    case gig::dimension_genpurpose3: // General Purpose Controller 3 (Slider, MIDI Controller 18)
278                        cout << "GENPURPOSE3";
279                        break;
280                    case gig::dimension_genpurpose4: // General Purpose Controller 4 (Slider, MIDI Controller 19)
281                        cout << "GENPURPOSE4";
282                        break;
283                    case gig::dimension_sustainpedal: // Sustain Pedal (MIDI Controller 64)
284                        cout << "SUSTAINPEDAL";
285                        break;
286                    case gig::dimension_portamento: // Portamento (MIDI Controller 65)
287                        cout << "PORTAMENTO";
288                        break;
289                    case gig::dimension_sostenutopedal: // Sostenuto Pedal (MIDI Controller 66)
290                        cout << "SOSTENUTOPEDAL";
291                        break;
292                    case gig::dimension_softpedal: // Soft Pedal (MIDI Controller 67)
293                        cout << "SOFTPEDAL";
294                        break;
295                    case gig::dimension_genpurpose5: // General Purpose Controller 5 (Button, MIDI Controller 80)
296                        cout << "GENPURPOSE5";
297                        break;
298                    case gig::dimension_genpurpose6: // General Purpose Controller 6 (Button, MIDI Controller 81)
299                        cout << "GENPURPOSE6";
300                        break;
301                    case gig::dimension_genpurpose7: // General Purpose Controller 7 (Button, MIDI Controller 82)
302                        cout << "GENPURPOSE7";
303                        break;
304                    case gig::dimension_genpurpose8: // General Purpose Controller 8 (Button, MIDI Controller 83)
305                        cout << "GENPURPOSE8";
306                        break;
307                    case gig::dimension_effect1depth: // Effect 1 Depth (MIDI Controller 91)
308                        cout << "EFFECT1DEPTH";
309                        break;
310                    case gig::dimension_effect2depth: // Effect 2 Depth (MIDI Controller 92)
311                        cout << "EFFECT2DEPTH";
312                        break;
313                    case gig::dimension_effect3depth: // Effect 3 Depth (MIDI Controller 93)
314                        cout << "EFFECT3DEPTH";
315                        break;
316                    case gig::dimension_effect4depth: // Effect 4 Depth (MIDI Controller 94)
317                        cout << "EFFECT4DEPTH";
318                        break;
319                    case gig::dimension_effect5depth:  // Effect 5 Depth (MIDI Controller 95)
320                        cout << "EFFECT5DEPTH";
321                        break;
322                    default:
323                        cout << "UNKNOWN (" << int(DimensionDef.dimension) << ") - please report this !";
324                        break;
325                }
326                cout << ", Bits=" << (uint) DimensionDef.bits << ", Zones=" << (uint) DimensionDef.zones;
327                cout << ", SplitType=";
328                switch (DimensionDef.split_type) {
329                    case gig::split_type_normal:
330                        cout << "NORMAL" << endl;
331                        break;
332                    case gig::split_type_bit:
333                        cout << "BIT" << endl;
334                        break;
335                    default:
336                        cout << "UNKNOWN" << endl;
337                }
338            }
339    
340          PrintDimensionRegions(pRegion);          PrintDimensionRegions(pRegion);
341    
342          pRegion = instr->GetNextRegion();          pRegion = instr->GetNextRegion();
# Line 133  void PrintRegions(gig::Instrument* instr Line 346  void PrintRegions(gig::Instrument* instr
346  void PrintDimensionRegions(gig::Region* rgn) {  void PrintDimensionRegions(gig::Region* rgn) {
347      int dimensionRegions = 0;      int dimensionRegions = 0;
348      gig::DimensionRegion* pDimensionRegion;      gig::DimensionRegion* pDimensionRegion;
349      while (dimensionRegions < 32) {      while (dimensionRegions < rgn->DimensionRegions) {
350          pDimensionRegion = rgn->pDimensionRegions[dimensionRegions];          pDimensionRegion = rgn->pDimensionRegions[dimensionRegions];
351          if (!pDimensionRegion) break;          if (!pDimensionRegion) break;
352    
# Line 145  void PrintDimensionRegions(gig::Region* Line 358  void PrintDimensionRegions(gig::Region*
358              if (pSample->pInfo->Name != "") {              if (pSample->pInfo->Name != "") {
359                  cout << "\"" << pSample->pInfo->Name << "\", ";                  cout << "\"" << pSample->pInfo->Name << "\", ";
360              }              }
361              cout << pSample->SamplesPerSecond << "Hz, " << endl;              cout << pSample->SamplesPerSecond << "Hz, ";
362                cout << "UnityNote=" << (int) pDimensionRegion->UnityNote << ", FineTune=" << (int) pDimensionRegion->FineTune << ", Gain=" << (-pDimensionRegion->Gain / 655360.0) << "dB, SampleStartOffset=" << pDimensionRegion->SampleStartOffset << endl;
363          }          }
364          else {          else {
365              cout << "                Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl;              cout << "                Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl;
# Line 156  void PrintDimensionRegions(gig::Region* Line 370  void PrintDimensionRegions(gig::Region*
370          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;
371          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;
372          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;
373            cout << "                VelocityResponseCurve=";
374            switch (pDimensionRegion->VelocityResponseCurve) {
375                case gig::curve_type_nonlinear:
376                    cout << "NONLINEAR";
377                    break;
378                case gig::curve_type_linear:
379                    cout << "LINEAR";
380                    break;
381                case gig::curve_type_special:
382                    cout << "SPECIAL";
383                    break;
384                case gig::curve_type_unknown:
385                default:
386                    cout << "UNKNOWN - please report this !";
387            }
388            cout << ", VelocityResponseDepth=" << (int) pDimensionRegion->VelocityResponseDepth << ", VelocityResponseCurveScaling=" << (int) pDimensionRegion->VelocityResponseCurveScaling << endl;
389            cout << "                Pan=" << (int) pDimensionRegion->Pan << endl;
390    
391          dimensionRegions++;          dimensionRegions++;
392      }      }
393  }  }
394    
395    string Revision() {
396        string s = "$Revision: 1.21 $";
397        return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
398    }
399    
400    void PrintVersion() {
401        cout << "gigdump revision " << Revision() << endl;
402        cout << "using " << gig::libraryName() << " " << gig::libraryVersion() << endl;
403    }
404    
405  void PrintUsage() {  void PrintUsage() {
406      cout << "gigdump - parses Gigasampler files and prints out the content." << endl;      cout << "gigdump - parses Gigasampler files and prints out the content." << endl;
407      cout << endl;      cout << endl;
408      cout << "Usage: gigdump FILE" << endl;      cout << "Usage: gigdump [-v] FILE" << endl;
409        cout << endl;
410        cout << "   -v  Print version and exit." << endl;
411        cout << endl;
412  }  }

Legend:
Removed from v.2  
changed lines
  Added in v.931

  ViewVC Help
Powered by ViewVC