00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifdef HAVE_CONFIG_H
00027 # include <config.h>
00028 #endif
00029
00030 #include <iostream>
00031 #include <cstdlib>
00032 #include <string>
00033
00034 #include "gig.h"
00035
00036 using namespace std;
00037
00038 string Revision();
00039 void PrintVersion();
00040 void PrintFileInformations(gig::File* gig);
00041 void PrintGroups(gig::File* gig);
00042 void PrintSamples(gig::File* gig);
00043 void PrintInstruments(gig::File* gig);
00044 void PrintRegions(gig::Instrument* instr);
00045 void PrintUsage();
00046 void PrintDimensionRegions(gig::Region* rgn);
00047
00048 int main(int argc, char *argv[])
00049 {
00050 if (argc <= 1) {
00051 PrintUsage();
00052 return EXIT_FAILURE;
00053 }
00054 if (argv[1][0] == '-') {
00055 switch (argv[1][1]) {
00056 case 'v':
00057 PrintVersion();
00058 return EXIT_SUCCESS;
00059 }
00060 }
00061 FILE* hFile = fopen(argv[1], "r");
00062 if (!hFile) {
00063 cout << "Invalid file argument!" << endl;
00064 return EXIT_FAILURE;
00065 }
00066 fclose(hFile);
00067 try {
00068 RIFF::File* riff = new RIFF::File(argv[1]);
00069 gig::File* gig = new gig::File(riff);
00070 PrintFileInformations(gig);
00071 cout << endl;
00072 PrintGroups(gig);
00073 cout << endl;
00074 PrintSamples(gig);
00075 cout << endl;
00076 PrintInstruments(gig);
00077 delete gig;
00078 delete riff;
00079 }
00080 catch (RIFF::Exception e) {
00081 e.PrintMessage();
00082 return EXIT_FAILURE;
00083 }
00084 catch (...) {
00085 cout << "Unknown exception while trying to parse file." << endl;
00086 return EXIT_FAILURE;
00087 }
00088
00089 return EXIT_SUCCESS;
00090 }
00091
00092 void PrintFileInformations(gig::File* gig) {
00093 cout << "Global File Informations:" << endl;
00094 cout << " Total instruments: " << gig->Instruments << endl;
00095 if (gig->pVersion) {
00096 cout << " Version: " << gig->pVersion->major << "."
00097 << gig->pVersion->minor << "."
00098 << gig->pVersion->release << "."
00099 << gig->pVersion->build << endl;
00100 }
00101 if (gig->pInfo) {
00102 if (gig->pInfo->Name.size())
00103 cout << " Name: '" << gig->pInfo->Name << "'\n";
00104 if (gig->pInfo->ArchivalLocation.size())
00105 cout << " ArchivalLocation: '" << gig->pInfo->ArchivalLocation << "'\n";
00106 if (gig->pInfo->CreationDate.size())
00107 cout << " CreationDate: '" << gig->pInfo->CreationDate << "'\n";
00108 if (gig->pInfo->Comments.size())
00109 cout << " Comments: '" << gig->pInfo->Comments << "'\n";
00110 if (gig->pInfo->Product.size())
00111 cout << " Product: '" << gig->pInfo->Product << "'\n";
00112 if (gig->pInfo->Copyright.size())
00113 cout << " Copyright: '" << gig->pInfo->Copyright << "'\n";
00114 if (gig->pInfo->Artists.size())
00115 cout << " Artists: '" << gig->pInfo->Artists << "'\n";
00116 if (gig->pInfo->Genre.size())
00117 cout << " Genre: '" << gig->pInfo->Genre << "'\n";
00118 if (gig->pInfo->Keywords.size())
00119 cout << " Keywords: '" << gig->pInfo->Keywords << "'\n";
00120 if (gig->pInfo->Engineer.size())
00121 cout << " Engineer: '" << gig->pInfo->Engineer << "'\n";
00122 if (gig->pInfo->Technician.size())
00123 cout << " Technician: '" << gig->pInfo->Technician << "'\n";
00124 if (gig->pInfo->Software.size())
00125 cout << " Software: '" << gig->pInfo->Software << "'\n";
00126 if (gig->pInfo->Medium.size())
00127 cout << " Medium: '" << gig->pInfo->Medium << "'\n";
00128 if (gig->pInfo->Source.size())
00129 cout << " Source: '" << gig->pInfo->Source << "'\n";
00130 if (gig->pInfo->SourceForm.size())
00131 cout << " SourceForm: '" << gig->pInfo->SourceForm << "'\n";
00132 if (gig->pInfo->Commissioned.size())
00133 cout << " Commissioned: '" << gig->pInfo->Commissioned << "'\n";
00134 }
00135 }
00136
00137 void PrintGroups(gig::File* gig) {
00138 int groups = 0;
00139 cout << "ALL defined Groups:" << endl;
00140 for (gig::Group* pGroup = gig->GetFirstGroup(); pGroup; pGroup = gig->GetNextGroup()) {
00141 groups++;
00142 string name = pGroup->Name;
00143 if (name == "") name = "<NO NAME>";
00144 else name = '\"' + name + '\"';
00145 cout << " Group " << groups << ")" << endl;
00146 cout << " Name: " << name << endl;
00147 }
00148 }
00149
00150 void PrintSamples(gig::File* gig) {
00151 int samples = 0;
00152 cout << "ALL Available Samples (as there might be more than referenced by Instruments):" << endl;
00153 gig::Sample* pSample = gig->GetFirstSample();
00154 while (pSample) {
00155 samples++;
00156
00157 string name = pSample->pInfo->Name;
00158 if (name == "") name = "<NO NAME>";
00159 else name = '\"' + name + '\"';
00160
00161 int iGroup = 1;
00162 for (gig::Group* pGroup = gig->GetFirstGroup(); pGroup; pGroup = gig->GetNextGroup(), iGroup++) {
00163 if (pGroup == pSample->GetGroup()) break;
00164 }
00165
00166 cout << " Sample " << samples << ") " << name << ", ";
00167 cout << "Group " << iGroup << ", ";
00168 cout << pSample->SamplesPerSecond << "Hz, " << pSample->Channels << " Channels, " << pSample->Loops << " Loops";
00169 if (pSample->Loops) {
00170 cout << " (Type: ";
00171 switch (pSample->LoopType) {
00172 case gig::loop_type_normal: cout << "normal)"; break;
00173 case gig::loop_type_bidirectional: cout << "pingpong)"; break;
00174 case gig::loop_type_backward: cout << "reverse)"; break;
00175 }
00176 cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd;
00177 cout << ", LoopPlayCount=" << pSample->LoopPlayCount;
00178 }
00179 cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") << endl;
00180 pSample = gig->GetNextSample();
00181 }
00182 }
00183
00184 void PrintInstruments(gig::File* gig) {
00185 int instruments = 0;
00186 cout << "Available Instruments:" << endl;
00187 gig::Instrument* pInstrument = gig->GetFirstInstrument();
00188 while (pInstrument) {
00189 instruments++;
00190 string name = pInstrument->pInfo->Name;
00191 if (name == "") name = "<NO NAME>";
00192 else name = '\"' + name + '\"';
00193 cout << " Instrument " << instruments << ") " << name << ", ";
00194
00195 cout << " MIDIBank=" << pInstrument->MIDIBank << ", MIDIProgram=" << pInstrument->MIDIProgram << endl;
00196 PrintRegions(pInstrument);
00197
00198 pInstrument = gig->GetNextInstrument();
00199 }
00200 }
00201
00202 void PrintRegions(gig::Instrument* instr) {
00203 int iRegion = 1;
00204 gig::Region* pRegion = instr->GetFirstRegion();
00205 while (pRegion) {
00206 cout << " Region " << iRegion++ << ") ";
00207 gig::Sample* pSample = pRegion->GetSample();
00208 if (pSample) {
00209 cout << "Sample: ";
00210 if (pSample->pInfo->Name != "") {
00211 cout << "\"" << pSample->pInfo->Name << "\", ";
00212 }
00213 cout << pSample->SamplesPerSecond << "Hz, " << endl;
00214 }
00215 else {
00216 cout << "<NO_VALID_SAMPLE_REFERENCE> ";
00217 }
00218 cout << " KeyRange=" << pRegion->KeyRange.low << "-" << pRegion->KeyRange.high << ", ";
00219 cout << "VelocityRange=" << pRegion->VelocityRange.low << "-" << pRegion->VelocityRange.high << ", Layers=" << pRegion->Layers << endl;
00220 cout << " Loops=" << pRegion->SampleLoops << endl;
00221 cout << " Dimensions=" << pRegion->Dimensions << endl;
00222 for (int iDimension = 0; iDimension < pRegion->Dimensions; iDimension++) {
00223 cout << " Dimension[" << iDimension << "]: Type=";
00224 gig::dimension_def_t DimensionDef = pRegion->pDimensionDefinitions[iDimension];
00225 switch (DimensionDef.dimension) {
00226 case gig::dimension_none:
00227 cout << "NONE";
00228 break;
00229 case gig::dimension_samplechannel:
00230 cout << "SAMPLECHANNEL";
00231 break;
00232 case gig::dimension_layer: {
00233 gig::crossfade_t crossfade = pRegion->pDimensionRegions[iDimension]->Crossfade;
00234 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 << ")";
00235 break;
00236 }
00237 case gig::dimension_velocity:
00238 cout << "VELOCITY";
00239 break;
00240 case gig::dimension_channelaftertouch:
00241 cout << "AFTERTOUCH";
00242 break;
00243 case gig::dimension_releasetrigger:
00244 cout << "RELEASETRIGGER";
00245 break;
00246 case gig::dimension_keyboard:
00247 cout << "KEYBOARD";
00248 break;
00249 case gig::dimension_roundrobin:
00250 cout << "ROUNDROBIN";
00251 break;
00252 case gig::dimension_random:
00253 cout << "RANDOM";
00254 break;
00255 case gig::dimension_modwheel:
00256 cout << "MODWHEEL";
00257 break;
00258 case gig::dimension_breath:
00259 cout << "BREATH";
00260 break;
00261 case gig::dimension_foot:
00262 cout << "FOOT";
00263 break;
00264 case gig::dimension_portamentotime:
00265 cout << "PORTAMENTOTIME";
00266 break;
00267 case gig::dimension_effect1:
00268 cout << "EFFECT1";
00269 break;
00270 case gig::dimension_effect2:
00271 cout << "EFFECT2";
00272 break;
00273 case gig::dimension_genpurpose1:
00274 cout << "GENPURPOSE1";
00275 break;
00276 case gig::dimension_genpurpose2:
00277 cout << "GENPURPOSE2";
00278 break;
00279 case gig::dimension_genpurpose3:
00280 cout << "GENPURPOSE3";
00281 break;
00282 case gig::dimension_genpurpose4:
00283 cout << "GENPURPOSE4";
00284 break;
00285 case gig::dimension_sustainpedal:
00286 cout << "SUSTAINPEDAL";
00287 break;
00288 case gig::dimension_portamento:
00289 cout << "PORTAMENTO";
00290 break;
00291 case gig::dimension_sostenutopedal:
00292 cout << "SOSTENUTOPEDAL";
00293 break;
00294 case gig::dimension_softpedal:
00295 cout << "SOFTPEDAL";
00296 break;
00297 case gig::dimension_genpurpose5:
00298 cout << "GENPURPOSE5";
00299 break;
00300 case gig::dimension_genpurpose6:
00301 cout << "GENPURPOSE6";
00302 break;
00303 case gig::dimension_genpurpose7:
00304 cout << "GENPURPOSE7";
00305 break;
00306 case gig::dimension_genpurpose8:
00307 cout << "GENPURPOSE8";
00308 break;
00309 case gig::dimension_effect1depth:
00310 cout << "EFFECT1DEPTH";
00311 break;
00312 case gig::dimension_effect2depth:
00313 cout << "EFFECT2DEPTH";
00314 break;
00315 case gig::dimension_effect3depth:
00316 cout << "EFFECT3DEPTH";
00317 break;
00318 case gig::dimension_effect4depth:
00319 cout << "EFFECT4DEPTH";
00320 break;
00321 case gig::dimension_effect5depth:
00322 cout << "EFFECT5DEPTH";
00323 break;
00324 default:
00325 cout << "UNKNOWN (" << int(DimensionDef.dimension) << ") - please report this !";
00326 break;
00327 }
00328 cout << ", Bits=" << (uint) DimensionDef.bits << ", Zones=" << (uint) DimensionDef.zones;
00329 cout << ", SplitType=";
00330 switch (DimensionDef.split_type) {
00331 case gig::split_type_normal:
00332 cout << "NORMAL" << endl;
00333 break;
00334 case gig::split_type_bit:
00335 cout << "BIT" << endl;
00336 break;
00337 default:
00338 cout << "UNKNOWN" << endl;
00339 }
00340 }
00341
00342 PrintDimensionRegions(pRegion);
00343
00344 pRegion = instr->GetNextRegion();
00345 }
00346 }
00347
00348 void PrintDimensionRegions(gig::Region* rgn) {
00349 int dimensionRegions = 0;
00350 gig::DimensionRegion* pDimensionRegion;
00351 while (dimensionRegions < rgn->DimensionRegions) {
00352 pDimensionRegion = rgn->pDimensionRegions[dimensionRegions];
00353 if (!pDimensionRegion) break;
00354
00355 cout << " Dimension Region " << dimensionRegions + 1 << ")" << endl;
00356
00357 gig::Sample* pSample = pDimensionRegion->pSample;
00358 if (pSample) {
00359 cout << " Sample: ";
00360 if (pSample->pInfo->Name != "") {
00361 cout << "\"" << pSample->pInfo->Name << "\", ";
00362 }
00363 cout << pSample->SamplesPerSecond << "Hz, ";
00364 cout << "UnityNote=" << (int) pDimensionRegion->UnityNote << ", FineTune=" << (int) pDimensionRegion->FineTune << ", Gain=" << (-pDimensionRegion->Gain / 655360.0) << "dB, SampleStartOffset=" << pDimensionRegion->SampleStartOffset << endl;
00365 }
00366 else {
00367 cout << " Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl;
00368 }
00369 cout << " LFO1Frequency=" << pDimensionRegion->LFO1Frequency << "Hz, LFO1InternalDepth=" << pDimensionRegion-> LFO1InternalDepth << ", LFO1ControlDepth=" << pDimensionRegion->LFO1ControlDepth << " LFO1Controller=" << pDimensionRegion->LFO1Controller << endl;
00370 cout << " LFO2Frequency=" << pDimensionRegion->LFO2Frequency << "Hz, LFO2InternalDepth=" << pDimensionRegion-> LFO2InternalDepth << ", LFO2ControlDepth=" << pDimensionRegion->LFO2ControlDepth << " LFO2Controller=" << pDimensionRegion->LFO2Controller << endl;
00371 cout << " LFO3Frequency=" << pDimensionRegion->LFO3Frequency << "Hz, LFO3InternalDepth=" << pDimensionRegion-> LFO3InternalDepth << ", LFO3ControlDepth=" << pDimensionRegion->LFO3ControlDepth << " LFO3Controller=" << pDimensionRegion->LFO3Controller << endl;
00372 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;
00373 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;
00374 cout << " VCFEnabled=" << pDimensionRegion->VCFEnabled << ", VCFType=" << pDimensionRegion->VCFType << ", VCFCutoff=" << (int) pDimensionRegion->VCFCutoff << ", VCFResonance=" << (int) pDimensionRegion->VCFResonance << ", VCFCutoffController=" << pDimensionRegion->VCFCutoffController << endl;
00375 cout << " VelocityResponseCurve=";
00376 switch (pDimensionRegion->VelocityResponseCurve) {
00377 case gig::curve_type_nonlinear:
00378 cout << "NONLINEAR";
00379 break;
00380 case gig::curve_type_linear:
00381 cout << "LINEAR";
00382 break;
00383 case gig::curve_type_special:
00384 cout << "SPECIAL";
00385 break;
00386 case gig::curve_type_unknown:
00387 default:
00388 cout << "UNKNOWN - please report this !";
00389 }
00390 cout << ", VelocityResponseDepth=" << (int) pDimensionRegion->VelocityResponseDepth << ", VelocityResponseCurveScaling=" << (int) pDimensionRegion->VelocityResponseCurveScaling << endl;
00391 cout << " Pan=" << (int) pDimensionRegion->Pan << endl;
00392
00393 dimensionRegions++;
00394 }
00395 }
00396
00397 string Revision() {
00398 string s = "$Revision: 1.22 $";
00399 return s.substr(11, s.size() - 13);
00400 }
00401
00402 void PrintVersion() {
00403 cout << "gigdump revision " << Revision() << endl;
00404 cout << "using " << gig::libraryName() << " " << gig::libraryVersion() << endl;
00405 }
00406
00407 void PrintUsage() {
00408 cout << "gigdump - parses Gigasampler files and prints out the content." << endl;
00409 cout << endl;
00410 cout << "Usage: gigdump [-v] FILE" << endl;
00411 cout << endl;
00412 cout << " -v Print version and exit." << endl;
00413 cout << endl;
00414 }