2 |
* * |
* * |
3 |
* libgig - C++ cross-platform Gigasampler format file access library * |
* libgig - C++ cross-platform Gigasampler format file access library * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003-2009 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. * |
* This program is part of libgig. * |
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 |
|
|
40 |
void PrintFileInformations(gig::File* gig); |
void PrintFileInformations(gig::File* gig); |
41 |
void PrintGroups(gig::File* gig); |
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) { |
79 |
cout << endl; |
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; |
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 |
// determine sample's name |
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 |
|
|
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(); |
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; |
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++; |