--- libgig/trunk/src/gigdump.cpp 2005/11/22 09:11:17 808 +++ libgig/trunk/src/tools/gigdump.cpp 2016/05/21 08:54:32 2923 @@ -1,10 +1,12 @@ /*************************************************************************** * * - * libgig - C++ cross-platform Gigasampler format file loader library * + * libgig - C++ cross-platform Gigasampler format file access library * * * - * Copyright (C) 2003-2005 by Christian Schoenebeck * + * Copyright (C) 2003-2014 by Christian Schoenebeck * * * * * + * This program is part of libgig. * + * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * @@ -29,13 +31,16 @@ #include #include -#include "gig.h" +#include "../gig.h" using namespace std; string Revision(); void PrintVersion(); +void PrintFileInformations(gig::File* gig); +void PrintGroups(gig::File* gig); void PrintSamples(gig::File* gig); +void PrintScripts(gig::File* gig); void PrintInstruments(gig::File* gig); void PrintRegions(gig::Instrument* instr); void PrintUsage(); @@ -63,8 +68,14 @@ try { RIFF::File* riff = new RIFF::File(argv[1]); gig::File* gig = new gig::File(riff); + PrintFileInformations(gig); + cout << endl; + PrintGroups(gig); + cout << endl; PrintSamples(gig); cout << endl; + PrintScripts(gig); + cout << endl; PrintInstruments(gig); delete gig; delete riff; @@ -81,16 +92,82 @@ return EXIT_SUCCESS; } +void PrintFileInformations(gig::File* gig) { + cout << "Global File Informations:" << endl; + cout << " Total instruments: " << gig->Instruments << endl; + if (gig->pVersion) { + cout << " Version: " << gig->pVersion->major << "." + << gig->pVersion->minor << "." + << gig->pVersion->release << "." + << gig->pVersion->build << endl; + } + if (gig->pInfo) { + if (gig->pInfo->Name.size()) + cout << " Name: '" << gig->pInfo->Name << "'\n"; + if (gig->pInfo->ArchivalLocation.size()) + cout << " ArchivalLocation: '" << gig->pInfo->ArchivalLocation << "'\n"; + if (gig->pInfo->CreationDate.size()) + cout << " CreationDate: '" << gig->pInfo->CreationDate << "'\n"; + if (gig->pInfo->Comments.size()) + cout << " Comments: '" << gig->pInfo->Comments << "'\n"; + if (gig->pInfo->Product.size()) + cout << " Product: '" << gig->pInfo->Product << "'\n"; + if (gig->pInfo->Copyright.size()) + cout << " Copyright: '" << gig->pInfo->Copyright << "'\n"; + if (gig->pInfo->Artists.size()) + cout << " Artists: '" << gig->pInfo->Artists << "'\n"; + if (gig->pInfo->Genre.size()) + cout << " Genre: '" << gig->pInfo->Genre << "'\n"; + if (gig->pInfo->Keywords.size()) + cout << " Keywords: '" << gig->pInfo->Keywords << "'\n"; + if (gig->pInfo->Engineer.size()) + cout << " Engineer: '" << gig->pInfo->Engineer << "'\n"; + if (gig->pInfo->Technician.size()) + cout << " Technician: '" << gig->pInfo->Technician << "'\n"; + if (gig->pInfo->Software.size()) + cout << " Software: '" << gig->pInfo->Software << "'\n"; + if (gig->pInfo->Medium.size()) + cout << " Medium: '" << gig->pInfo->Medium << "'\n"; + if (gig->pInfo->Source.size()) + cout << " Source: '" << gig->pInfo->Source << "'\n"; + if (gig->pInfo->SourceForm.size()) + cout << " SourceForm: '" << gig->pInfo->SourceForm << "'\n"; + if (gig->pInfo->Commissioned.size()) + cout << " Commissioned: '" << gig->pInfo->Commissioned << "'\n"; + } +} + +void PrintGroups(gig::File* gig) { + int groups = 0; + cout << "ALL defined Groups:" << endl; + for (gig::Group* pGroup = gig->GetFirstGroup(); pGroup; pGroup = gig->GetNextGroup()) { + groups++; + string name = pGroup->Name; + if (name == "") name = ""; + else name = '\"' + name + '\"'; + cout << " Group " << groups << ")" << endl; + cout << " Name: " << name << endl; + } +} + void PrintSamples(gig::File* gig) { int samples = 0; cout << "ALL Available Samples (as there might be more than referenced by Instruments):" << endl; gig::Sample* pSample = gig->GetFirstSample(); while (pSample) { samples++; + // determine sample's name string name = pSample->pInfo->Name; if (name == "") name = ""; else name = '\"' + name + '\"'; + // determine group this sample belongs to + int iGroup = 1; + for (gig::Group* pGroup = gig->GetFirstGroup(); pGroup; pGroup = gig->GetNextGroup(), iGroup++) { + if (pGroup == pSample->GetGroup()) break; + } + // print sample info cout << " Sample " << samples << ") " << name << ", "; + cout << "Group " << iGroup << ", "; cout << pSample->SamplesPerSecond << "Hz, " << pSample->Channels << " Channels, " << pSample->Loops << " Loops"; if (pSample->Loops) { cout << " (Type: "; @@ -107,6 +184,21 @@ } } +void PrintScripts(gig::File* gig) { + cout << "ALL Available Real-Time Instrument Scripts (as there might be more than referenced by Instruments):" << endl; + for (int g = 0; gig->GetScriptGroup(g); ++g) { + gig::ScriptGroup* pGroup = gig->GetScriptGroup(g); + cout << " Group " << g+1 << ") '" << pGroup->Name << "'\n"; + for (int s = 0; pGroup->GetScript(s); ++s) { + gig::Script* pScript = pGroup->GetScript(s); + cout << " Script " << s+1 << ") '" << pScript->Name << "':\n"; + cout << "[START OF SCRIPT]\n"; + cout << pScript->GetScriptAsText(); + cout << "[END OF SCRIPT]\n"; + } + } +} + void PrintInstruments(gig::File* gig) { int instruments = 0; cout << "Available Instruments:" << endl; @@ -119,6 +211,14 @@ cout << " Instrument " << instruments << ") " << name << ", "; cout << " MIDIBank=" << pInstrument->MIDIBank << ", MIDIProgram=" << pInstrument->MIDIProgram << endl; + + cout << " ScriptSlots=" << pInstrument->ScriptSlotCount() << endl; + for (int s = 0; s < pInstrument->ScriptSlotCount(); ++s) { + gig::Script* pScript = pInstrument->GetScriptOfSlot(s); + string name = pScript->Name; + cout << " ScriptSlot[" << s << "]='" << name << "'\n"; + } + PrintRegions(pInstrument); pInstrument = gig->GetNextInstrument(); @@ -178,6 +278,12 @@ case gig::dimension_random: // Different samples triggered each time a note is played, random order cout << "RANDOM"; break; + case gig::dimension_smartmidi: // For MIDI tools like legato and repetition mode + cout << "SMARTMIDI"; + break; + case gig::dimension_roundrobinkeyboard: // Different samples triggered each time a note is played, any key advances the counter + cout << "ROUNDROBINKEYBOARD"; + break; case gig::dimension_modwheel: // Modulation Wheel (MIDI Controller 1) cout << "MODWHEEL"; break; @@ -257,9 +363,6 @@ case gig::split_type_normal: cout << "NORMAL" << endl; break; - case gig::split_type_customvelocity: - cout << "CUSTOMVELOCITY" << endl; - break; case gig::split_type_bit: cout << "BIT" << endl; break; @@ -274,6 +377,15 @@ } } +template +static void printIntArray(T_int* array, int size) { + printf("{"); + for (int i = 0; i < size; ++i) + printf("[%d]=%d,", i, array[i]); + printf("}"); + fflush(stdout); +} + void PrintDimensionRegions(gig::Region* rgn) { int dimensionRegions = 0; gig::DimensionRegion* pDimensionRegion; @@ -317,6 +429,16 @@ cout << "UNKNOWN - please report this !"; } cout << ", VelocityResponseDepth=" << (int) pDimensionRegion->VelocityResponseDepth << ", VelocityResponseCurveScaling=" << (int) pDimensionRegion->VelocityResponseCurveScaling << endl; + cout << " VelocityUpperLimit=" << (int) pDimensionRegion->VelocityUpperLimit << " DimensionUpperLimits[]=" << flush; + printIntArray(pDimensionRegion->DimensionUpperLimits, 8); + cout << endl; +#if 0 // requires access to protected member VelocityTable, so commented out for now + if (pDimensionRegion->VelocityTable) { + cout << " VelocityTable[]=" << flush; + printIntArray(pDimensionRegion->VelocityTable, 127); + cout << endl; + } +#endif cout << " Pan=" << (int) pDimensionRegion->Pan << endl; dimensionRegions++; @@ -324,7 +446,7 @@ } string Revision() { - string s = "$Revision: 1.17 $"; + string s = "$Revision$"; return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword }