--- simsam/lib/sample.h 2004-02-17 17:53:36.000000000 +0100 +++ simsam-mp3-ogg/lib/sample.h 2004-09-19 07:35:37.000000000 +0200 @@ -66,6 +66,9 @@ class Sample : public Subject { char name[256]; int loadFile(const char *filename); + int loadWavFile(const char *filename); + int loadOggFile(const char *filename); + int loadMP3File(const char *filename); void unload(); float getMonoFrame(int pos); --- simsam/lib/sample.cpp 2004-04-18 16:23:01.000000000 +0200 +++ simsam-mp3-ogg/lib/sample.cpp 2004-09-19 08:01:36.000000000 +0200 @@ -17,8 +17,95 @@ #include "midi.h" #include "output.h" + + int Sample::loadFile(const char *filename) { + char* p; + + if ((p = strcasestr(filename, ".ogg"))) { + + if (!strcasecmp(p, ".ogg")) return(loadOggFile(filename)); + + } + + if ((p = strcasestr(filename, ".mp3"))) { + + if (!strcasecmp(p, ".mp3")) return(loadMP3File(filename)); + + } + + return(loadWavFile(filename)); +} + + +int Sample::loadOggFile(const char* filename) { + + char tmpFilename[128]; + char decCommand[1024]; + char delCommand[1024]; + + snprintf(tmpFilename, 128, "/tmp/simsam-%d-temp.wav", getpid()); + snprintf(decCommand, 1024, "ogg123 -d wav -f %s %s", tmpFilename, filename); + snprintf(delCommand, 1024, "rm -f %s", tmpFilename); + + int res; + + res = system(decCommand); + + if (res != 0) { + + system(delCommand); + return(-1); + } + + res = loadWavFile(tmpFilename); + + // overwrite the temporary filename + + strncpy(path, filename, 1024); + system(delCommand); + + return(res); +} + + +int Sample::loadMP3File(const char* filename) { + + char tmpFilename[128]; + char decCommand[1024]; + char delCommand[1024]; + + snprintf(tmpFilename, 128, "/tmp/simsam-%d-temp.wav", getpid()); + snprintf(decCommand, 1024, "mpg123 -w %s %s", tmpFilename, filename); + snprintf(delCommand, 1024, "rm -f %s", tmpFilename); + + int res; + + res = system(decCommand); + + if (res != 0) { + + system(delCommand); + return(-1); + } + + res = loadWavFile(tmpFilename); + + // overwrite the temporary filename + + strncpy(path, filename, 1024); + system(delCommand); + + return(res); +} + + + + +int Sample::loadWavFile(const char *filename) { + + SNDFILE *sf; SF_INFO sfi; --- simsam/gui/simsamgui.cpp 2004-03-30 09:50:35.000000000 +0200 +++ simsam-mp3-ogg/gui/simsamgui.cpp 2004-09-19 07:38:24.000000000 +0200 @@ -299,7 +299,7 @@ void SimsamGui::loadSample() { if (!sample) {error_message("NULL"); return; } QString s (QFileDialog::getOpenFileName(Settings::samplePath, - "Sample files (*.wav *.aiff *.aifc *.snd *.au *.voc)", + "Sample files (*.wav *.aiff *.aifc *.snd *.au *.voc *.ogg *.mp3)", this )); if (s.isEmpty()) return; --- simsam/configure.in 2004-02-21 19:30:59.000000000 +0100 +++ simsam-mp3-ogg/configure.in 2004-09-19 08:29:06.000000000 +0200 @@ -1,5 +1,5 @@ AC_INIT(configure.in) -AM_INIT_AUTOMAKE(simsam,0.1.8-CVS) +AM_INIT_AUTOMAKE(simsam,0.1.8-CVS-mp3-ogg) AC_PROG_CXX AC_PROG_INSTALL