/[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 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 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 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 81  void PrintSamples(gig::File* gig) { Line 139  void PrintSamples(gig::File* gig) {
139          if (name == "") name = "<NO NAME>";          if (name == "") name = "<NO NAME>";
140          else            name = '\"' + name + '\"';          else            name = '\"' + name + '\"';
141          cout << "    Sample " << samples << ") " << name << ", ";          cout << "    Sample " << samples << ") " << name << ", ";
142          cout << pSample->SamplesPerSecond << "Hz, " << pSample->Channels << " Channels, " << pSample->Loops          cout << pSample->SamplesPerSecond << "Hz, " << pSample->Channels << " Channels, " << pSample->Loops << " Loops";
143               << " Loops, LoopFraction=" << pSample->LoopFraction << ", Length=" << pSample->SamplesTotal << " Compressed=" << pSample->Compressed << endl;          if (pSample->Loops) {
144                cout << " (Type: ";
145                switch (pSample->LoopType) {
146                    case gig::loop_type_normal:         cout << "normal)";   break;
147                    case gig::loop_type_bidirectional:  cout << "pingpong)"; break;
148                    case gig::loop_type_backward:       cout << "reverse)";  break;
149                }
150                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;
154          pSample = gig->GetNextSample();          pSample = gig->GetNextSample();
155      }      }
156  }  }
# Line 122  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;
196            for (int iDimension = 0; iDimension < pRegion->Dimensions; iDimension++) {
197                cout << "            Dimension[" << iDimension << "]: Type=";
198                gig::dimension_def_t DimensionDef = pRegion->pDimensionDefinitions[iDimension];
199                switch (DimensionDef.dimension) {
200                    case gig::dimension_none:
201                        cout << "NONE";
202                        break;
203                    case gig::dimension_samplechannel: // If used sample has more than one channel (thus is not mono).
204                        cout << "SAMPLECHANNEL";
205                        break;
206                    case gig::dimension_layer: { // For layering of up to 8 instruments (and eventually crossfading of 2 or 4 layers).
207                        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;
210                    }
211                    case gig::dimension_velocity: // Key Velocity (this is the only dimension where the ranges can exactly be defined).
212                        cout << "VELOCITY";
213                        break;
214                    case gig::dimension_channelaftertouch: // Channel Key Pressure
215                        cout << "AFTERTOUCH";
216                        break;
217                    case gig::dimension_releasetrigger: // Special dimension for triggering samples on releasing a key.
218                        cout << "RELEASETRIGGER";
219                        break;
220                    case gig::dimension_keyboard: // Key Position
221                        cout << "KEYBOARD";
222                        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)
230                        cout << "MODWHEEL";
231                        break;
232                    case gig::dimension_breath: // Breath Controller (Coarse, MIDI Controller 2)
233                        cout << "BREATH";
234                        break;
235                    case gig::dimension_foot: // Foot Pedal (Coarse, MIDI Controller 4)
236                        cout << "FOOT";
237                        break;
238                    case gig::dimension_portamentotime: // Portamento Time (Coarse, MIDI Controller 5)
239                        cout << "PORTAMENTOTIME";
240                        break;
241                    case gig::dimension_effect1: // Effect Controller 1 (Coarse, MIDI Controller 12)
242                        cout << "EFFECT1";
243                        break;
244                    case gig::dimension_effect2: // Effect Controller 2 (Coarse, MIDI Controller 13)
245                        cout << "EFFECT2";
246                        break;
247                    case gig::dimension_genpurpose1: // General Purpose Controller 1 (Slider, MIDI Controller 16)
248                        cout << "GENPURPOSE1";
249                        break;
250                    case gig::dimension_genpurpose2: // General Purpose Controller 2 (Slider, MIDI Controller 17)
251                        cout << "GENPURPOSE2";
252                        break;
253                    case gig::dimension_genpurpose3: // General Purpose Controller 3 (Slider, MIDI Controller 18)
254                        cout << "GENPURPOSE3";
255                        break;
256                    case gig::dimension_genpurpose4: // General Purpose Controller 4 (Slider, MIDI Controller 19)
257                        cout << "GENPURPOSE4";
258                        break;
259                    case gig::dimension_sustainpedal: // Sustain Pedal (MIDI Controller 64)
260                        cout << "SUSTAINPEDAL";
261                        break;
262                    case gig::dimension_portamento: // Portamento (MIDI Controller 65)
263                        cout << "PORTAMENTO";
264                        break;
265                    case gig::dimension_sostenutopedal: // Sostenuto Pedal (MIDI Controller 66)
266                        cout << "SOSTENUTOPEDAL";
267                        break;
268                    case gig::dimension_softpedal: // Soft Pedal (MIDI Controller 67)
269                        cout << "SOFTPEDAL";
270                        break;
271                    case gig::dimension_genpurpose5: // General Purpose Controller 5 (Button, MIDI Controller 80)
272                        cout << "GENPURPOSE5";
273                        break;
274                    case gig::dimension_genpurpose6: // General Purpose Controller 6 (Button, MIDI Controller 81)
275                        cout << "GENPURPOSE6";
276                        break;
277                    case gig::dimension_genpurpose7: // General Purpose Controller 7 (Button, MIDI Controller 82)
278                        cout << "GENPURPOSE7";
279                        break;
280                    case gig::dimension_genpurpose8: // General Purpose Controller 8 (Button, MIDI Controller 83)
281                        cout << "GENPURPOSE8";
282                        break;
283                    case gig::dimension_effect1depth: // Effect 1 Depth (MIDI Controller 91)
284                        cout << "EFFECT1DEPTH";
285                        break;
286                    case gig::dimension_effect2depth: // Effect 2 Depth (MIDI Controller 92)
287                        cout << "EFFECT2DEPTH";
288                        break;
289                    case gig::dimension_effect3depth: // Effect 3 Depth (MIDI Controller 93)
290                        cout << "EFFECT3DEPTH";
291                        break;
292                    case gig::dimension_effect4depth: // Effect 4 Depth (MIDI Controller 94)
293                        cout << "EFFECT4DEPTH";
294                        break;
295                    case gig::dimension_effect5depth:  // Effect 5 Depth (MIDI Controller 95)
296                        cout << "EFFECT5DEPTH";
297                        break;
298                    default:
299                        cout << "UNKNOWN (" << int(DimensionDef.dimension) << ") - please report this !";
300                        break;
301                }
302                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);
317    
318          pRegion = instr->GetNextRegion();          pRegion = instr->GetNextRegion();
# Line 133  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 145  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 156  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.2  
changed lines
  Added in v.916

  ViewVC Help
Powered by ViewVC