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

Diff of /libgig/trunk/src/gigextract.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 549 by schoenebeck, Mon May 16 18:40:45 2005 UTC revision 608 by schoenebeck, Fri Jun 3 14:35:44 2005 UTC
# Line 53  Line 53 
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>
# Line 74  void ExtractSamples(gig::File* gig, char Line 80  void ExtractSamples(gig::File* gig, char
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);
# Line 161  int main(int argc, char *argv[]) { Line 167  int main(int argc, char *argv[]) {
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
# Line 253  void ExtractSamples(gig::File* gig, char Line 259  void ExtractSamples(gig::File* gig, char
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  }  }
# Line 299  int writeWav(const char* filename, void* Line 305  int writeWav(const char* filename, void*
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);
# Line 316  int writeWav(const char* filename, void* Line 322  int writeWav(const char* filename, void*
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) {
# Line 341  void closeAFlib() { Line 347  void closeAFlib() {
347  #endif // !HAVE_SNDFILE  #endif // !HAVE_SNDFILE
348    
349  string Revision() {  string Revision() {
350      string s = "$Revision: 1.6 $";      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    
# Line 352  void PrintVersion() { Line 358  void PrintVersion() {
358      char versionBuffer[128];      char versionBuffer[128];
359      sf_command(NULL, SFC_GET_LIB_VERSION, versionBuffer, 128);      sf_command(NULL, SFC_GET_LIB_VERSION, versionBuffer, 128);
360      cout << ", " << versionBuffer;      cout << ", " << versionBuffer;
361      #endif // HAVE_SNDFILE      #else // use libaudiofile
362      cout << endl;      cout << "\nbuilt against libaudiofile "
363      #if !HAVE_SNDFILE           << LIBAUDIOFILE_MAJOR_VERSION << "." << LIBAUDIOFILE_MINOR_VERSION;
     cout << "built against libaudiofile "  
          << LIBAUDIOFILE_MAJOR_VERSION << "." << LIBAUDIOFILE_MINOR_VERSION  
364      # ifdef LIBAUDIOFILE_MICRO_VERSION      # ifdef LIBAUDIOFILE_MICRO_VERSION
365           << "." << LIBAUDIOFILE_MICRO_VERSION      cout << "." << LIBAUDIOFILE_MICRO_VERSION;
366      # endif // LIBAUDIOFILE_MICRO_VERSION      # endif // LIBAUDIOFILE_MICRO_VERSION
367           << endl;      #endif // HAVE_SNDFILE
368      #endif // !HAVE_SNDFILE      cout << endl;
369  }  }
370    
371  void PrintUsage() {  void PrintUsage() {

Legend:
Removed from v.549  
changed lines
  Added in v.608

  ViewVC Help
Powered by ViewVC