2 |
* * |
* * |
3 |
* libgig - C++ cross-platform Gigasampler format file loader library * |
* libgig - C++ cross-platform Gigasampler format file loader library * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Christian Schoenebeck * |
* Copyright (C) 2003-2005 by Christian Schoenebeck * |
6 |
* <cuse@users.sourceforge.net> * |
* <cuse@users.sourceforge.net> * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* 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 * |
* it under the terms of the GNU General Public License as published by * |
40 |
#include <iostream> |
#include <iostream> |
41 |
#include <cstdlib> |
#include <cstdlib> |
42 |
#include <string.h> |
#include <string.h> |
43 |
|
#include <string> |
44 |
#include <stdlib.h> |
#include <stdlib.h> |
45 |
#include <sys/types.h> |
#include <sys/types.h> |
46 |
#include <sys/stat.h> |
#include <sys/stat.h> |
67 |
typedef map<unsigned int, bool> OrderMap; |
typedef map<unsigned int, bool> OrderMap; |
68 |
OrderMap* pOrderedSamples = NULL; |
OrderMap* pOrderedSamples = NULL; |
69 |
|
|
70 |
|
string Revision(); |
71 |
|
void PrintVersion(); |
72 |
void PrintUsage(); |
void PrintUsage(); |
73 |
void ExtractSamples(gig::File* gig, char* destdir, OrderMap* ordered); |
void ExtractSamples(gig::File* gig, char* destdir, OrderMap* ordered); |
74 |
int writeWav(const char* filename, void* samples, long samplecount, int channels, int bitdepth, long rate); |
int writeWav(const char* filename, void* samples, long samplecount, int channels, int bitdepth, long rate); |
91 |
#endif // !HAVE_SNDFILE |
#endif // !HAVE_SNDFILE |
92 |
|
|
93 |
int main(int argc, char *argv[]) { |
int main(int argc, char *argv[]) { |
94 |
|
if (argc >= 2) { |
95 |
|
if (argv[1][0] == '-') { |
96 |
|
switch (argv[1][1]) { |
97 |
|
case 'v': |
98 |
|
PrintVersion(); |
99 |
|
return EXIT_SUCCESS; |
100 |
|
} |
101 |
|
} |
102 |
|
} |
103 |
if (argc < 3) { |
if (argc < 3) { |
104 |
PrintUsage(); |
PrintUsage(); |
105 |
return EXIT_FAILURE; |
return EXIT_FAILURE; |
340 |
} |
} |
341 |
#endif // !HAVE_SNDFILE |
#endif // !HAVE_SNDFILE |
342 |
|
|
343 |
|
string Revision() { |
344 |
|
string s = "$Revision: 1.5 $"; |
345 |
|
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
346 |
|
} |
347 |
|
|
348 |
|
void PrintVersion() { |
349 |
|
cout << "gigextract revision " << Revision() << endl; |
350 |
|
cout << "using " << gig::libraryName() << " " << gig::libraryVersion() << endl; |
351 |
|
} |
352 |
|
|
353 |
void PrintUsage() { |
void PrintUsage() { |
354 |
cout << "gigextract - extracts samples from a Gigasampler file." << endl; |
cout << "gigextract - extracts samples from a Gigasampler file." << endl; |
355 |
cout << endl; |
cout << endl; |
356 |
cout << "Usage: gigextract GIGFILE DESTDIR [SAMPLENR] [ [SAMPLENR] ...]" << endl; |
cout << "Usage: gigextract [-v] GIGFILE DESTDIR [SAMPLENR] [ [SAMPLENR] ...]" << endl; |
357 |
cout << endl; |
cout << endl; |
358 |
cout << " GIGFILE Input Gigasampler (.gig) file." << endl; |
cout << " GIGFILE Input Gigasampler (.gig) file." << endl; |
359 |
cout << endl; |
cout << endl; |
363 |
cout << " If no sample indices are given, all samples will be extracted" << endl; |
cout << " If no sample indices are given, all samples will be extracted" << endl; |
364 |
cout << " (use gigdump to look for available samples)." << endl; |
cout << " (use gigdump to look for available samples)." << endl; |
365 |
cout << endl; |
cout << endl; |
366 |
|
cout << " -v Print version and exit." << endl; |
367 |
|
cout << endl; |
368 |
} |
} |
369 |
|
|
370 |
string ToString(int i) { |
string ToString(int i) { |