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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations) (download)
Sat Oct 25 20:15:04 2003 UTC (20 years, 5 months ago) by schoenebeck
File size: 8103 byte(s)
Initial revision

1 schoenebeck 2 /***************************************************************************
2     * *
3     * libgig - C++ cross-platform Gigasampler format file loader library *
4     * *
5     * Copyright (C) 2003 by Christian Schoenebeck *
6     * <cuse@users.sourceforge.net> *
7     * *
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     #include <config.h>
26     #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     cout << pSample->SamplesPerSecond << "Hz, " << pSample->Channels << " Channels, " << pSample->Loops
85     << " Loops, LoopFraction=" << pSample->LoopFraction << ", Length=" << pSample->SamplesTotal << " Compressed=" << pSample->Compressed << endl;
86     pSample = gig->GetNextSample();
87     }
88     }
89    
90     void PrintInstruments(gig::File* gig) {
91     int instruments = 0;
92     cout << "Available Instruments:" << endl;
93     gig::Instrument* pInstrument = gig->GetFirstInstrument();
94     while (pInstrument) {
95     instruments++;
96     string name = pInstrument->pInfo->Name;
97     if (name == "") name = "<NO NAME>";
98     else name = '\"' + name + '\"';
99     cout << " Instrument " << instruments << ") " << name << ", ";
100    
101     cout << " MIDIBank=" << pInstrument->MIDIBank << ", MIDIProgram=" << pInstrument->MIDIProgram << endl;
102     PrintRegions(pInstrument);
103    
104     pInstrument = gig->GetNextInstrument();
105     }
106     }
107    
108     void PrintRegions(gig::Instrument* instr) {
109     int iRegion = 1;
110     gig::Region* pRegion = instr->GetFirstRegion();
111     while (pRegion) {
112     cout << " Region " << iRegion++ << ") ";
113     gig::Sample* pSample = pRegion->GetSample();
114     if (pSample) {
115     cout << "Sample: ";
116     if (pSample->pInfo->Name != "") {
117     cout << "\"" << pSample->pInfo->Name << "\", ";
118     }
119     cout << pSample->SamplesPerSecond << "Hz, " << endl;
120     }
121     else {
122     cout << "<NO_VALID_SAMPLE_REFERENCE> ";
123     }
124     cout << " KeyRange=" << pRegion->KeyRange.low << "-" << pRegion->KeyRange.high << ", ";
125     cout << "VelocityRange=" << pRegion->VelocityRange.low << "-" << pRegion->VelocityRange.high << ", Layer=" << pRegion->Layer << endl;
126     cout << " Loops=" << pRegion->SampleLoops << endl;
127     PrintDimensionRegions(pRegion);
128    
129     pRegion = instr->GetNextRegion();
130     }
131     }
132    
133     void PrintDimensionRegions(gig::Region* rgn) {
134     int dimensionRegions = 0;
135     gig::DimensionRegion* pDimensionRegion;
136     while (dimensionRegions < 32) {
137     pDimensionRegion = rgn->pDimensionRegions[dimensionRegions];
138     if (!pDimensionRegion) break;
139    
140     cout << " Dimension Region " << dimensionRegions + 1 << ")" << endl;
141    
142     gig::Sample* pSample = pDimensionRegion->pSample;
143     if (pSample) {
144     cout << " Sample: ";
145     if (pSample->pInfo->Name != "") {
146     cout << "\"" << pSample->pInfo->Name << "\", ";
147     }
148     cout << pSample->SamplesPerSecond << "Hz, " << endl;
149     }
150     else {
151     cout << " Sample: <NO_VALID_SAMPLE_REFERENCE> " << endl;
152     }
153     cout << " LFO1Frequency=" << pDimensionRegion->LFO1Frequency << "Hz, LFO1InternalDepth=" << pDimensionRegion-> LFO1InternalDepth << ", LFO1ControlDepth=" << pDimensionRegion->LFO1ControlDepth << " LFO1Controller=" << pDimensionRegion->LFO1Controller << endl;
154     cout << " LFO2Frequency=" << pDimensionRegion->LFO2Frequency << "Hz, LFO2InternalDepth=" << pDimensionRegion-> LFO2InternalDepth << ", LFO2ControlDepth=" << pDimensionRegion->LFO2ControlDepth << " LFO2Controller=" << pDimensionRegion->LFO2Controller << endl;
155     cout << " LFO3Frequency=" << pDimensionRegion->LFO3Frequency << "Hz, LFO3InternalDepth=" << pDimensionRegion-> LFO3InternalDepth << ", LFO3ControlDepth=" << pDimensionRegion->LFO3ControlDepth << " LFO3Controller=" << pDimensionRegion->LFO3Controller << endl;
156     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;
157     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;
158     cout << " VCFEnabled=" << pDimensionRegion->VCFEnabled << ", VCFType=" << pDimensionRegion->VCFType << ", VCFCutoff=" << (int) pDimensionRegion->VCFCutoff << ", VCFResonance=" << (int) pDimensionRegion->VCFResonance << ", VCFCutoffController=" << pDimensionRegion->VCFCutoffController << endl;
159    
160     dimensionRegions++;
161     }
162     }
163    
164     void PrintUsage() {
165     cout << "gigdump - parses Gigasampler files and prints out the content." << endl;
166     cout << endl;
167     cout << "Usage: gigdump FILE" << endl;
168     }

  ViewVC Help
Powered by ViewVC