/[svn]/libgig/trunk/src/tools/gigdump.cpp
ViewVC logotype

Annotation of /libgig/trunk/src/tools/gigdump.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 439 - (hide annotations) (download)
Wed Mar 9 23:46:19 2005 UTC (14 years, 5 months ago) by schoenebeck
Original Path: libgig/trunk/src/gigdump.cpp
File size: 16512 byte(s)
print the dimension number of unknown dimensions

1 schoenebeck 2 /***************************************************************************
2     * *
3     * libgig - C++ cross-platform Gigasampler format file loader library *
4     * *
5 schoenebeck 55 * Copyright (C) 2003, 2004 by Christian Schoenebeck *
6     * <cuse@users.sourceforge.net> *
7 schoenebeck 2 * *
8     * 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 *
10     * the Free Software Foundation; either version 2 of the License, or *
11     * (at your option) any later version. *
12     * *
13     * This program is distributed in the hope that it will be useful, *
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16     * GNU General Public License for more details. *
17     * *
18     * You should have received a copy of the GNU General Public License *
19     * along with this program; if not, write to the Free Software *
20     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21     * MA 02111-1307 USA *
22     ***************************************************************************/
23    
24     #ifdef HAVE_CONFIG_H
25 schoenebeck 24 # include <config.h>
26 schoenebeck 2 #endif
27    
28     #include <iostream>
29     #include <cstdlib>
30    
31     #include "gig.h"
32    
33     using namespace std;
34    
35     void PrintSamples(gig::File* gig);
36     void PrintInstruments(gig::File* gig);
37     void PrintRegions(gig::Instrument* instr);
38     void PrintUsage();
39     void PrintDimensionRegions(gig::Region* rgn);
40    
41     int main(int argc, char *argv[])
42     {
43     if (argc <= 1) {
44     PrintUsage();
45     return EXIT_FAILURE;
46     }
47     FILE* hFile = fopen(argv[1], "r");
48     if (!hFile) {
49     cout << "Invalid file argument!" << endl;
50     return EXIT_FAILURE;
51     }
52     fclose(hFile);
53     try {
54     RIFF::File* riff = new RIFF::File(argv[1]);
55     gig::File* gig = new gig::File(riff);
56     PrintSamples(gig);
57     cout << endl;
58     PrintInstruments(gig);
59     delete gig;
60     delete riff;
61     }
62     catch (RIFF::Exception e) {
63     e.PrintMessage();
64     return EXIT_FAILURE;
65     }
66     catch (...) {
67     cout << "Unknown exception while trying to parse file." << endl;
68     return EXIT_FAILURE;
69     }
70    
71     return EXIT_SUCCESS;
72     }
73    
74     void PrintSamples(gig::File* gig) {
75     int samples = 0;
76     cout << "ALL Available Samples (as there might be more than referenced by Instruments):" << endl;
77     gig::Sample* pSample = gig->GetFirstSample();
78     while (pSample) {
79     samples++;
80     string name = pSample->pInfo->Name;
81     if (name == "") name = "<NO NAME>";
82     else name = '\"' + name + '\"';
83     cout << " Sample " << samples << ") " << name << ", ";
84 schoenebeck 24 cout << pSample->SamplesPerSecond << "Hz, " << pSample->Channels << " Channels, " << pSample->Loops << " Loops";
85     if (pSample->Loops) {
86     cout << " (Type: ";
87     switch (pSample->LoopType) {
88     case gig::loop_type_normal: cout << "normal)"; break;
89     case gig::loop_type_bidirectional: cout << "pingpong)"; break;
90     case gig::loop_type_backward: cout << "reverse)"; break;
91     }
92     cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd;
93     }
94     cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") << endl;
95 schoenebeck 2 pSample = gig->GetNextSample();
96     }
97     }
98    
99     void PrintInstruments(gig::File* gig) {
100     int instruments = 0;
101     cout << "Available Instruments:" << endl;
102     gig::Instrument* pInstrument = gig->GetFirstInstrument();
103     while (pInstrument) {
104     instruments++;
105     string name = pInstrument->pInfo->Name;
106     if (name == "") name = "<NO NAME>";
107     else name = '\"' + name + '\"';
108     cout << " Instrument " << instruments << ") " << name << ", ";
109    
110     cout << " MIDIBank=" << pInstrument->MIDIBank << ", MIDIProgram=" << pInstrument->MIDIProgram << endl;
111     PrintRegions(pInstrument);
112    
113     pInstrument = gig->GetNextInstrument();
114     }
115     }
116    
117     void PrintRegions(gig::Instrument* instr) {
118     int iRegion = 1;
119     gig::Region* pRegion = instr->GetFirstRegion();
120     while (pRegion) {
121     cout << " Region " << iRegion++ << ") ";
122     gig::Sample* pSample = pRegion->GetSample();
123     if (pSample) {
124     cout << "Sample: ";
125     if (pSample->pInfo->Name != "") {
126     cout << "\"" << pSample->pInfo->Name << "\", ";
127     }
128     cout << pSample->SamplesPerSecond << "Hz, " << endl;
129     }
130     else {
131     cout << "<NO_VALID_SAMPLE_REFERENCE> ";
132     }
133     cout << " KeyRange=" << pRegion->KeyRange.low << "-" << pRegion->KeyRange.high << ", ";
134 schoenebeck 282 cout << "VelocityRange=" << pRegion->VelocityRange.low << "-" << pRegion->VelocityRange.high << ", Layers=" << pRegion->Layers << endl;
135 schoenebeck 2 cout << " Loops=" << pRegion->SampleLoops << endl;
136 schoenebeck 229 cout << " Dimensions=" << pRegion->Dimensions << endl;
137     for (int iDimension = 0; iDimension < pRegion->Dimensions; iDimension++) {
138     cout << " Dimension[" << iDimension << "]: Type=";
139     gig::dimension_def_t DimensionDef = pRegion->pDimensionDefinitions[iDimension];
140     switch (DimensionDef.dimension) {
141     case gig::dimension_none:
142     cout << "NONE";
143     break;
144     case gig::dimension_samplechannel: // If used sample has more than one channel (thus is not mono).
145     cout << "SAMPLECHANNEL";
146     break;
147 schoenebeck 402 case gig::dimension_layer: { // For layering of up to 8 instruments (and eventually crossfading of 2 or 4 layers).
148 schoenebeck 235 gig::crossfade_t crossfade = pRegion->pDimensionRegions[iDimension]->Crossfade;
149     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 << ")";
150 schoenebeck 229 break;
151 schoenebeck 402 }
152 schoenebeck 229 case gig::dimension_velocity: // Key Velocity (this is the only dimension where the ranges can exactly be defined).
153     cout << "VELOCITY";
154     break;
155     case gig::dimension_channelaftertouch: // Channel Key Pressure
156     cout << "AFTERTOUCH";
157     break;
158     case gig::dimension_releasetrigger: // Special dimension for triggering samples on releasing a key.
159     cout << "RELEASETRIGGER";
160     break;
161     case gig::dimension_keyboard: // Key Position
162     cout << "KEYBOARD";
163     break;
164 persson 437 case gig::dimension_roundrobin: // Different samples triggered each time a note is played, dimension regions selected in sequence
165     cout << "ROUNDROBIN";
166     break;
167     case gig::dimension_random: // Different samples triggered each time a note is played, random order
168     cout << "RANDOM";
169     break;
170 schoenebeck 229 case gig::dimension_modwheel: // Modulation Wheel (MIDI Controller 1)
171     cout << "MODWHEEL";
172     break;
173     case gig::dimension_breath: // Breath Controller (Coarse, MIDI Controller 2)
174     cout << "BREATH";
175     break;
176     case gig::dimension_foot: // Foot Pedal (Coarse, MIDI Controller 4)
177     cout << "FOOT";
178     break;
179     case gig::dimension_portamentotime: // Portamento Time (Coarse, MIDI Controller 5)
180     cout << "PORTAMENTOTIME";
181     break;
182     case gig::dimension_effect1: // Effect Controller 1 (Coarse, MIDI Controller 12)
183     cout << "EFFECT1";
184     break;
185     case gig::dimension_effect2: // Effect Controller 2 (Coarse, MIDI Controller 13)
186     cout << "EFFECT2";
187     break;
188     case gig::dimension_genpurpose1: // General Purpose Controller 1 (Slider, MIDI Controller 16)
189     cout << "GENPURPOSE1";
190     break;
191     case gig::dimension_genpurpose2: // General Purpose Controller 2 (Slider, MIDI Controller 17)
192     cout << "GENPURPOSE2";
193     break;
194     case gig::dimension_genpurpose3: // General Purpose Controller 3 (Slider, MIDI Controller 18)
195     cout << "GENPURPOSE3";
196     break;
197     case gig::dimension_genpurpose4: // General Purpose Controller 4 (Slider, MIDI Controller 19)
198     cout << "GENPURPOSE4";
199     break;
200     case gig::dimension_sustainpedal: // Sustain Pedal (MIDI Controller 64)
201     cout << "SUSTAINPEDAL";
202     break;
203     case gig::dimension_portamento: // Portamento (MIDI Controller 65)
204     cout << "PORTAMENTO";
205     break;
206     case gig::dimension_sostenutopedal: // Sostenuto Pedal (MIDI Controller 66)
207     cout << "SOSTENUTOPEDAL";
208     break;
209     case gig::dimension_softpedal: // Soft Pedal (MIDI Controller 67)
210     cout << "SOFTPEDAL";
211     break;
212     case gig::dimension_genpurpose5: // General Purpose Controller 5 (Button, MIDI Controller 80)
213     cout << "GENPURPOSE5";
214     break;
215     case gig::dimension_genpurpose6: // General Purpose Controller 6 (Button, MIDI Controller 81)
216     cout << "GENPURPOSE6";
217     break;
218     case gig::dimension_genpurpose7: // General Purpose Controller 7 (Button, MIDI Controller 82)
219     cout << "GENPURPOSE7";
220     break;
221     case gig::dimension_genpurpose8: // General Purpose Controller 8 (Button, MIDI Controller 83)
222     cout << "GENPURPOSE8";
223     break;
224     case gig::dimension_effect1depth: // Effect 1 Depth (MIDI Controller 91)
225     cout << "EFFECT1DEPTH";
226     break;
227     case gig::dimension_effect2depth: // Effect 2 Depth (MIDI Controller 92)
228     cout << "EFFECT2DEPTH";
229     break;
230     case gig::dimension_effect3depth: // Effect 3 Depth (MIDI Controller 93)
231     cout << "EFFECT3DEPTH";
232     break;
233     case gig::dimension_effect4depth: // Effect 4 Depth (MIDI Controller 94)
234     cout << "EFFECT4DEPTH";
235     break;
236     case gig::dimension_effect5depth: // Effect 5 Depth (MIDI Controller 95)
237     cout << "EFFECT5DEPTH";
238     break;
239     default:
240 schoenebeck 439 cout << "UNKNOWN (" << int(DimensionDef.dimension) << ") - please report this !";
241 schoenebeck 229 break;
242     }
243 schoenebeck 240 cout << ", Bits=" << (uint) DimensionDef.bits << ", Zones=" << (uint) DimensionDef.zones;
244     cout << ", SplitType=";
245     switch (DimensionDef.split_type) {
246     case gig::split_type_normal:
247     cout << "NORMAL" << endl;
248     break;
249     case gig::split_type_customvelocity:
250     cout << "CUSTOMVELOCITY" << endl;
251     break;
252     case gig::split_type_bit:
253     cout << "BIT" << endl;
254     break;
255     default:
256     cout << "UNKNOWN" << endl;
257     }
258 schoenebeck 229 }
259    
260 schoenebeck 2 PrintDimensionRegions(pRegion);
261    
262     pRegion = instr->GetNextRegion();
263     }
264     }
265    
266     void PrintDimensionRegions(gig::Region* rgn) {
267     int dimensionRegions = 0;
268     gig::DimensionRegion* pDimensionRegion;
269     while (dimensionRegions < 32) {
270     pDimensionRegion = rgn->pDimensionRegions[dimensionRegions];
271     if (!pDimensionRegion) break;
272    
273     cout << " Dimension Region " << dimensionRegions + 1 << ")" << endl;
274    
275     gig::Sample* pSample = pDimensionRegion->pSample;
276     if (pSample) {
277     cout << " Sample: ";
278     if (pSample->pInfo->Name != "") {
279     cout << "\"" << pSample->pInfo->Name << "\", ";
280     }
281 schoenebeck 334 cout << pSample->SamplesPerSecond << "Hz, ";
282 persson 406 cout << "UnityNote=" << (int) pDimensionRegion->UnityNote << ", FineTune=" << (int) pDimensionRegion->FineTune << ", Gain=" << (-pDimensionRegion->Gain / 655360.0) << "dB, SampleStartOffset=" << pDimensionRegion->SampleStartOffset << endl;
283 schoenebeck 2 }
284     else {
285     cout << " Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl;
286     }
287     cout << " LFO1Frequency=" << pDimensionRegion->LFO1Frequency << "Hz, LFO1InternalDepth=" << pDimensionRegion-> LFO1InternalDepth << ", LFO1ControlDepth=" << pDimensionRegion->LFO1ControlDepth << " LFO1Controller=" << pDimensionRegion->LFO1Controller << endl;
288     cout << " LFO2Frequency=" << pDimensionRegion->LFO2Frequency << "Hz, LFO2InternalDepth=" << pDimensionRegion-> LFO2InternalDepth << ", LFO2ControlDepth=" << pDimensionRegion->LFO2ControlDepth << " LFO2Controller=" << pDimensionRegion->LFO2Controller << endl;
289     cout << " LFO3Frequency=" << pDimensionRegion->LFO3Frequency << "Hz, LFO3InternalDepth=" << pDimensionRegion-> LFO3InternalDepth << ", LFO3ControlDepth=" << pDimensionRegion->LFO3ControlDepth << " LFO3Controller=" << pDimensionRegion->LFO3Controller << endl;
290     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;
291     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;
292     cout << " VCFEnabled=" << pDimensionRegion->VCFEnabled << ", VCFType=" << pDimensionRegion->VCFType << ", VCFCutoff=" << (int) pDimensionRegion->VCFCutoff << ", VCFResonance=" << (int) pDimensionRegion->VCFResonance << ", VCFCutoffController=" << pDimensionRegion->VCFCutoffController << endl;
293 schoenebeck 231 cout << " VelocityResponseCurve=";
294     switch (pDimensionRegion->VelocityResponseCurve) {
295     case gig::curve_type_nonlinear:
296     cout << "NONLINEAR";
297     break;
298     case gig::curve_type_linear:
299     cout << "LINEAR";
300     break;
301     case gig::curve_type_special:
302     cout << "SPECIAL";
303     break;
304     case gig::curve_type_unknown:
305     default:
306     cout << "UNKNOWN - please report this !";
307     }
308     cout << ", VelocityResponseDepth=" << (int) pDimensionRegion->VelocityResponseDepth << ", VelocityResponseCurveScaling=" << (int) pDimensionRegion->VelocityResponseCurveScaling << endl;
309 schoenebeck 269 cout << " Pan=" << (int) pDimensionRegion->Pan << endl;
310 schoenebeck 2
311     dimensionRegions++;
312     }
313     }
314    
315     void PrintUsage() {
316     cout << "gigdump - parses Gigasampler files and prints out the content." << endl;
317     cout << endl;
318     cout << "Usage: gigdump FILE" << endl;
319     }

  ViewVC Help
Powered by ViewVC