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

libgig/trunk/src/gigdump.cpp revision 808 by schoenebeck, Tue Nov 22 09:11:17 2005 UTC libgig/trunk/src/tools/gigdump.cpp revision 2984 by schoenebeck, Tue Sep 20 15:13:58 2016 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-2005 by Christian Schoenebeck                      *   *   Copyright (C) 2003-2014 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  *
12   *   the Free Software Foundation; either version 2 of the License, or     *   *   the Free Software Foundation; either version 2 of the License, or     *
# Line 29  Line 31 
31  #include <cstdlib>  #include <cstdlib>
32  #include <string>  #include <string>
33    
34  #include "gig.h"  #include "../gig.h"
35    
36  using namespace std;  using namespace std;
37    
38  string Revision();  string Revision();
39  void PrintVersion();  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 PrintScripts(gig::File* gig);
44  void PrintInstruments(gig::File* gig);  void PrintInstruments(gig::File* gig);
45  void PrintRegions(gig::Instrument* instr);  void PrintRegions(gig::Instrument* instr);
46  void PrintUsage();  void PrintUsage();
47  void PrintDimensionRegions(gig::Region* rgn);  void PrintDimensionRegions(gig::Region* rgn);
48    
49    class PubSample : public gig::Sample {
50    public:
51        using DLS::Sample::pCkData;
52    };
53    
54  int main(int argc, char *argv[])  int main(int argc, char *argv[])
55  {  {
56      if (argc <= 1) {      if (argc <= 1) {
# Line 63  int main(int argc, char *argv[]) Line 73  int main(int argc, char *argv[])
73      try {      try {
74          RIFF::File* riff = new RIFF::File(argv[1]);          RIFF::File* riff = new RIFF::File(argv[1]);
75          gig::File*  gig  = new gig::File(riff);          gig::File*  gig  = new gig::File(riff);
76            PrintFileInformations(gig);
77            cout << endl;
78            PrintGroups(gig);
79            cout << endl;
80          PrintSamples(gig);          PrintSamples(gig);
81          cout << endl;          cout << endl;
82            PrintScripts(gig);
83            cout << endl;
84          PrintInstruments(gig);          PrintInstruments(gig);
85          delete gig;          delete gig;
86          delete riff;          delete riff;
# Line 81  int main(int argc, char *argv[]) Line 97  int main(int argc, char *argv[])
97      return EXIT_SUCCESS;      return EXIT_SUCCESS;
98  }  }
99    
100    void PrintFileInformations(gig::File* gig) {
101        cout << "Global File Informations:" << endl;
102        cout << "    Total instruments: " << gig->Instruments << endl;
103        if (gig->pVersion) {
104           cout << "    Version: " << gig->pVersion->major   << "."
105                               << gig->pVersion->minor   << "."
106                               << gig->pVersion->release << "."
107                               << gig->pVersion->build   << endl;
108        }
109        if (gig->pInfo) {
110            if (gig->pInfo->Name.size())
111                cout << "    Name: '" << gig->pInfo->Name << "'\n";
112            if (gig->pInfo->ArchivalLocation.size())
113                cout << "    ArchivalLocation: '" << gig->pInfo->ArchivalLocation << "'\n";
114            if (gig->pInfo->CreationDate.size())
115                cout << "    CreationDate: '" << gig->pInfo->CreationDate << "'\n";
116            if (gig->pInfo->Comments.size())
117                cout << "    Comments: '" << gig->pInfo->Comments << "'\n";
118            if (gig->pInfo->Product.size())
119                cout << "    Product: '" << gig->pInfo->Product << "'\n";
120            if (gig->pInfo->Copyright.size())
121                cout << "    Copyright: '" << gig->pInfo->Copyright << "'\n";
122            if (gig->pInfo->Artists.size())
123                cout << "    Artists: '" << gig->pInfo->Artists << "'\n";
124            if (gig->pInfo->Genre.size())
125                cout << "    Genre: '" << gig->pInfo->Genre << "'\n";
126            if (gig->pInfo->Keywords.size())
127                cout << "    Keywords: '" << gig->pInfo->Keywords << "'\n";
128            if (gig->pInfo->Engineer.size())
129                cout << "    Engineer: '" << gig->pInfo->Engineer << "'\n";
130            if (gig->pInfo->Technician.size())
131                cout << "    Technician: '" << gig->pInfo->Technician << "'\n";
132            if (gig->pInfo->Software.size())
133                cout << "    Software: '" << gig->pInfo->Software << "'\n";
134            if (gig->pInfo->Medium.size())
135                cout << "    Medium: '" << gig->pInfo->Medium << "'\n";
136            if (gig->pInfo->Source.size())
137                cout << "    Source: '" << gig->pInfo->Source << "'\n";
138            if (gig->pInfo->SourceForm.size())
139                cout << "    SourceForm: '" << gig->pInfo->SourceForm << "'\n";
140            if (gig->pInfo->Commissioned.size())
141                cout << "    Commissioned: '" << gig->pInfo->Commissioned << "'\n";
142        }
143    }
144    
145    void PrintGroups(gig::File* gig) {
146        int groups = 0;
147        cout << "ALL defined Groups:" << endl;
148        for (gig::Group* pGroup = gig->GetFirstGroup(); pGroup; pGroup = gig->GetNextGroup()) {
149            groups++;
150            string name = pGroup->Name;
151            if (name == "") name = "<NO NAME>";
152            else            name = '\"' + name + '\"';
153            cout << "    Group " << groups << ")" << endl;
154            cout << "        Name: " << name << endl;
155        }
156    }
157    
158  void PrintSamples(gig::File* gig) {  void PrintSamples(gig::File* gig) {
159      int samples = 0;      int samples = 0;
160      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;
161      gig::Sample* pSample = gig->GetFirstSample();      PubSample* pSample = (PubSample*) gig->GetFirstSample();
162      while (pSample) {      while (pSample) {
163          samples++;          samples++;
164            // determine sample's name
165          string name = pSample->pInfo->Name;          string name = pSample->pInfo->Name;
166          if (name == "") name = "<NO NAME>";          if (name == "") name = "<NO NAME>";
167          else            name = '\"' + name + '\"';          else            name = '\"' + name + '\"';
168            // determine group this sample belongs to
169            int iGroup = 1;
170            for (gig::Group* pGroup = gig->GetFirstGroup(); pGroup; pGroup = gig->GetNextGroup(), iGroup++) {
171                if (pGroup == pSample->GetGroup()) break;
172            }
173            // print sample info
174          cout << "    Sample " << samples << ") " << name << ", ";          cout << "    Sample " << samples << ") " << name << ", ";
175            cout << "Group " << iGroup << ", ";
176          cout << pSample->SamplesPerSecond << "Hz, " << pSample->Channels << " Channels, " << pSample->Loops << " Loops";          cout << pSample->SamplesPerSecond << "Hz, " << pSample->Channels << " Channels, " << pSample->Loops << " Loops";
177          if (pSample->Loops) {          if (pSample->Loops) {
178              cout << " (Type: ";              cout << " (Type: ";
# Line 102  void PrintSamples(gig::File* gig) { Line 184  void PrintSamples(gig::File* gig) {
184              cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd;              cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd;
185              cout << ", LoopPlayCount=" << pSample->LoopPlayCount;              cout << ", LoopPlayCount=" << pSample->LoopPlayCount;
186          }          }
187          cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") << endl;          cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false")
188          pSample = gig->GetNextSample();               << " foffset=" << pSample->pCkData->GetFilePos()
189                 << " fsz=" << pSample->pCkData->GetSize()
190                 << endl;
191    #if 0
192            {
193                const uint bufSize = 64;
194                unsigned char buf[bufSize] = {};
195                pSample->SetPos(0);
196                RIFF::file_offset_t n = pSample->pCkData->Read(&buf[0], bufSize, 1);
197                //RIFF::file_offset_t n = pSample->Read(&buf[0], bufSize / pSample->FrameSize);
198                cout << "        FrameSize=" << pSample->FrameSize << ",Data[" << n << "]" << flush;
199                for (int x = 0; x < bufSize; ++x)
200                    printf("%02x ", buf[x]);
201                printf("\n");
202                fflush(stdout);
203            }
204    #endif
205            pSample = (PubSample*) gig->GetNextSample();
206        }
207    }
208    
209    void PrintScripts(gig::File* gig) {
210        cout << "ALL Available Real-Time Instrument Scripts (as there might be more than referenced by Instruments):" << endl;
211        for (int g = 0; gig->GetScriptGroup(g); ++g) {
212            gig::ScriptGroup* pGroup = gig->GetScriptGroup(g);
213            cout << "    Group " << g+1 << ") '" << pGroup->Name << "'\n";
214            for (int s = 0; pGroup->GetScript(s); ++s) {
215                gig::Script* pScript = pGroup->GetScript(s);
216                cout << "        Script " << s+1 << ") '" << pScript->Name << "':\n";
217                cout << "[START OF SCRIPT]\n";
218                cout << pScript->GetScriptAsText();
219                cout << "[END OF SCRIPT]\n";
220            }
221      }      }
222  }  }
223    
# Line 119  void PrintInstruments(gig::File* gig) { Line 233  void PrintInstruments(gig::File* gig) {
233          cout << "    Instrument " << instruments << ") " << name << ", ";          cout << "    Instrument " << instruments << ") " << name << ", ";
234    
235          cout << " MIDIBank=" << pInstrument->MIDIBank << ", MIDIProgram=" << pInstrument->MIDIProgram << endl;          cout << " MIDIBank=" << pInstrument->MIDIBank << ", MIDIProgram=" << pInstrument->MIDIProgram << endl;
236    
237            cout << "        ScriptSlots=" << pInstrument->ScriptSlotCount() << endl;
238            for (int s = 0; s < pInstrument->ScriptSlotCount(); ++s) {
239                gig::Script* pScript = pInstrument->GetScriptOfSlot(s);
240                string name = pScript->Name;
241                cout << "        ScriptSlot[" << s << "]='" << name << "'\n";
242            }
243    
244          PrintRegions(pInstrument);          PrintRegions(pInstrument);
245    
246          pInstrument = gig->GetNextInstrument();          pInstrument = gig->GetNextInstrument();
# Line 178  void PrintRegions(gig::Instrument* instr Line 300  void PrintRegions(gig::Instrument* instr
300                  case gig::dimension_random: // Different samples triggered each time a note is played, random order                  case gig::dimension_random: // Different samples triggered each time a note is played, random order
301                      cout << "RANDOM";                      cout << "RANDOM";
302                      break;                      break;
303                    case gig::dimension_smartmidi: // For MIDI tools like legato and repetition mode
304                        cout << "SMARTMIDI";
305                        break;
306                    case gig::dimension_roundrobinkeyboard: // Different samples triggered each time a note is played, any key advances the counter
307                        cout << "ROUNDROBINKEYBOARD";
308                        break;
309                  case gig::dimension_modwheel: // Modulation Wheel (MIDI Controller 1)                  case gig::dimension_modwheel: // Modulation Wheel (MIDI Controller 1)
310                      cout << "MODWHEEL";                      cout << "MODWHEEL";
311                      break;                      break;
# Line 257  void PrintRegions(gig::Instrument* instr Line 385  void PrintRegions(gig::Instrument* instr
385                  case gig::split_type_normal:                  case gig::split_type_normal:
386                      cout << "NORMAL" << endl;                      cout << "NORMAL" << endl;
387                      break;                      break;
                 case gig::split_type_customvelocity:  
                     cout << "CUSTOMVELOCITY" << endl;  
                     break;  
388                  case gig::split_type_bit:                  case gig::split_type_bit:
389                      cout << "BIT" << endl;                      cout << "BIT" << endl;
390                      break;                      break;
# Line 274  void PrintRegions(gig::Instrument* instr Line 399  void PrintRegions(gig::Instrument* instr
399      }      }
400  }  }
401    
402    template<typename T_int>
403    static void printIntArray(T_int* array, int size) {
404        printf("{");
405        for (int i = 0; i < size; ++i)
406            printf("[%d]=%d,", i, array[i]);
407        printf("}");
408        fflush(stdout);
409    }
410    
411  void PrintDimensionRegions(gig::Region* rgn) {  void PrintDimensionRegions(gig::Region* rgn) {
412      int dimensionRegions = 0;      int dimensionRegions = 0;
413      gig::DimensionRegion* pDimensionRegion;      gig::DimensionRegion* pDimensionRegion;
# Line 317  void PrintDimensionRegions(gig::Region* Line 451  void PrintDimensionRegions(gig::Region*
451                  cout << "UNKNOWN - please report this !";                  cout << "UNKNOWN - please report this !";
452          }          }
453          cout << ", VelocityResponseDepth=" << (int) pDimensionRegion->VelocityResponseDepth << ", VelocityResponseCurveScaling=" << (int) pDimensionRegion->VelocityResponseCurveScaling << endl;          cout << ", VelocityResponseDepth=" << (int) pDimensionRegion->VelocityResponseDepth << ", VelocityResponseCurveScaling=" << (int) pDimensionRegion->VelocityResponseCurveScaling << endl;
454            cout << "                VelocityUpperLimit=" << (int) pDimensionRegion->VelocityUpperLimit << " DimensionUpperLimits[]=" << flush;
455            printIntArray(pDimensionRegion->DimensionUpperLimits, 8);
456            cout << endl;
457    #if 0 // requires access to protected member VelocityTable, so commented out for now
458            if (pDimensionRegion->VelocityTable) {
459                cout << "                VelocityTable[]=" << flush;
460                printIntArray(pDimensionRegion->VelocityTable, 127);
461                cout << endl;
462            }
463    #endif
464          cout << "                Pan=" << (int) pDimensionRegion->Pan << endl;          cout << "                Pan=" << (int) pDimensionRegion->Pan << endl;
465    
466          dimensionRegions++;          dimensionRegions++;
# Line 324  void PrintDimensionRegions(gig::Region* Line 468  void PrintDimensionRegions(gig::Region*
468  }  }
469    
470  string Revision() {  string Revision() {
471      string s = "$Revision: 1.17 $";      string s = "$Revision$";
472      return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword      return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
473  }  }
474    

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

  ViewVC Help
Powered by ViewVC