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 * |
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); |
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; |
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(); |
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; |
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; |
cout << ", Bits=" << (uint) DimensionDef.bits << ", Zones=" << (uint) DimensionDef.zones; |
257 |
case gig::split_type_normal: |
case gig::split_type_normal: |
258 |
cout << "NORMAL" << endl; |
cout << "NORMAL" << endl; |
259 |
break; |
break; |
|
case gig::split_type_customvelocity: |
|
|
cout << "CUSTOMVELOCITY" << endl; |
|
|
break; |
|
260 |
case gig::split_type_bit: |
case gig::split_type_bit: |
261 |
cout << "BIT" << endl; |
cout << "BIT" << endl; |
262 |
break; |
break; |
274 |
void PrintDimensionRegions(gig::Region* rgn) { |
void PrintDimensionRegions(gig::Region* rgn) { |
275 |
int dimensionRegions = 0; |
int dimensionRegions = 0; |
276 |
gig::DimensionRegion* pDimensionRegion; |
gig::DimensionRegion* pDimensionRegion; |
277 |
while (dimensionRegions < 32) { |
while (dimensionRegions < rgn->DimensionRegions) { |
278 |
pDimensionRegion = rgn->pDimensionRegions[dimensionRegions]; |
pDimensionRegion = rgn->pDimensionRegions[dimensionRegions]; |
279 |
if (!pDimensionRegion) break; |
if (!pDimensionRegion) break; |
280 |
|
|
287 |
cout << "\"" << pSample->pInfo->Name << "\", "; |
cout << "\"" << pSample->pInfo->Name << "\", "; |
288 |
} |
} |
289 |
cout << pSample->SamplesPerSecond << "Hz, "; |
cout << pSample->SamplesPerSecond << "Hz, "; |
290 |
cout << "UnityNote=" << (int) pDimensionRegion->UnityNote << ", FineTune=" << (int) pDimensionRegion->FineTune << endl; |
cout << "UnityNote=" << (int) pDimensionRegion->UnityNote << ", FineTune=" << (int) pDimensionRegion->FineTune << ", Gain=" << (-pDimensionRegion->Gain / 655360.0) << "dB, SampleStartOffset=" << pDimensionRegion->SampleStartOffset << endl; |
291 |
} |
} |
292 |
else { |
else { |
293 |
cout << " Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl; |
cout << " Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl; |
320 |
} |
} |
321 |
} |
} |
322 |
|
|
323 |
|
string Revision() { |
324 |
|
string s = "$Revision: 1.18 $"; |
325 |
|
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
326 |
|
} |
327 |
|
|
328 |
|
void PrintVersion() { |
329 |
|
cout << "gigdump revision " << Revision() << endl; |
330 |
|
cout << "using " << gig::libraryName() << " " << gig::libraryVersion() << endl; |
331 |
|
} |
332 |
|
|
333 |
void PrintUsage() { |
void PrintUsage() { |
334 |
cout << "gigdump - parses Gigasampler files and prints out the content." << endl; |
cout << "gigdump - parses Gigasampler files and prints out the content." << endl; |
335 |
cout << endl; |
cout << endl; |
336 |
cout << "Usage: gigdump FILE" << endl; |
cout << "Usage: gigdump [-v] FILE" << endl; |
337 |
|
cout << endl; |
338 |
|
cout << " -v Print version and exit." << endl; |
339 |
|
cout << endl; |
340 |
} |
} |