53 |
# define HAVE_SNDFILE 1 |
# define HAVE_SNDFILE 1 |
54 |
#endif // WIN32 |
#endif // WIN32 |
55 |
|
|
56 |
|
// abort compilation here if neither libsndfile nor libaudiofile are available |
57 |
|
#if !HAVE_SNDFILE && !HAVE_AUDIOFILE |
58 |
|
# error "Neither libsndfile nor libaudiofile seem to be available!" |
59 |
|
# error "(HAVE_SNDFILE and HAVE_AUDIOFILE are both false)" |
60 |
|
#endif |
61 |
|
|
62 |
// we prefer libsndfile before libaudiofile |
// we prefer libsndfile before libaudiofile |
63 |
#if HAVE_SNDFILE |
#if HAVE_SNDFILE |
64 |
# include <sndfile.h> |
# include <sndfile.h> |
80 |
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); |
81 |
string ToString(int i); |
string ToString(int i); |
82 |
|
|
83 |
#ifndef HAVE_SNDFILE |
#if !HAVE_SNDFILE // use libaudiofile |
84 |
void* hAFlib; // handle to libaudiofile |
void* hAFlib; // handle to libaudiofile |
85 |
void openAFlib(void); |
void openAFlib(void); |
86 |
void closeAFlib(void); |
void closeAFlib(void); |
167 |
} |
} |
168 |
|
|
169 |
void ExtractSamples(gig::File* gig, char* destdir, OrderMap* ordered) { |
void ExtractSamples(gig::File* gig, char* destdir, OrderMap* ordered) { |
170 |
#ifndef HAVE_SNDFILE |
#if !HAVE_SNDFILE // use libaudiofile |
171 |
hAFlib = NULL; |
hAFlib = NULL; |
172 |
openAFlib(); |
openAFlib(); |
173 |
#endif // !HAVE_SNDFILE |
#endif // !HAVE_SNDFILE |
259 |
pSample = gig->GetNextSample(); |
pSample = gig->GetNextSample(); |
260 |
} |
} |
261 |
if (pWave) delete[] (uint8_t*) pWave; |
if (pWave) delete[] (uint8_t*) pWave; |
262 |
#ifndef HAVE_SNDFILE |
#if !HAVE_SNDFILE // use libaudiofile |
263 |
closeAFlib(); |
closeAFlib(); |
264 |
#endif // !HAVE_SNDFILE |
#endif // !HAVE_SNDFILE |
265 |
} |
} |
305 |
return -1; |
return -1; |
306 |
} |
} |
307 |
sf_close(hfile); |
sf_close(hfile); |
308 |
#else |
#else // use libaudiofile |
309 |
AFfilesetup setup = _afNewFileSetup(); |
AFfilesetup setup = _afNewFileSetup(); |
310 |
_afInitFileFormat(setup, AF_FILE_WAVE); |
_afInitFileFormat(setup, AF_FILE_WAVE); |
311 |
_afInitChannels(setup, AF_DEFAULT_TRACK, channels); |
_afInitChannels(setup, AF_DEFAULT_TRACK, channels); |
322 |
return 0; // success |
return 0; // success |
323 |
} |
} |
324 |
|
|
325 |
#ifndef HAVE_SNDFILE |
#if !HAVE_SNDFILE // use libaudiofile |
326 |
void openAFlib() { |
void openAFlib() { |
327 |
hAFlib = dlopen("libaudiofile.so", RTLD_NOW); |
hAFlib = dlopen("libaudiofile.so", RTLD_NOW); |
328 |
if (!hAFlib) { |
if (!hAFlib) { |
347 |
#endif // !HAVE_SNDFILE |
#endif // !HAVE_SNDFILE |
348 |
|
|
349 |
string Revision() { |
string Revision() { |
350 |
string s = "$Revision: 1.5 $"; |
string s = "$Revision: 1.7 $"; |
351 |
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
352 |
} |
} |
353 |
|
|
354 |
void PrintVersion() { |
void PrintVersion() { |
355 |
cout << "gigextract revision " << Revision() << endl; |
cout << "gigextract revision " << Revision() << endl; |
356 |
cout << "using " << gig::libraryName() << " " << gig::libraryVersion() << endl; |
cout << "using " << gig::libraryName() << " " << gig::libraryVersion(); |
357 |
|
#if HAVE_SNDFILE |
358 |
|
char versionBuffer[128]; |
359 |
|
sf_command(NULL, SFC_GET_LIB_VERSION, versionBuffer, 128); |
360 |
|
cout << ", " << versionBuffer; |
361 |
|
#else // use libaudiofile |
362 |
|
cout << "\nbuilt against libaudiofile " |
363 |
|
<< LIBAUDIOFILE_MAJOR_VERSION << "." << LIBAUDIOFILE_MINOR_VERSION; |
364 |
|
# ifdef LIBAUDIOFILE_MICRO_VERSION |
365 |
|
cout << "." << LIBAUDIOFILE_MICRO_VERSION; |
366 |
|
# endif // LIBAUDIOFILE_MICRO_VERSION |
367 |
|
#endif // HAVE_SNDFILE |
368 |
|
cout << endl; |
369 |
} |
} |
370 |
|
|
371 |
void PrintUsage() { |
void PrintUsage() { |