git » fp-git.git » commit 869a963

tested and bugfixed the new wav reading module

author ecalot
2006-02-23 04:34:53 UTC
committer ecalot
2006-02-23 04:34:53 UTC
parent 9ded0f4bf793a7bc27e9cfcc37cb9f3947bb6893

tested and bugfixed the new wav reading module

PR/src/lib/actions/import.c +1 -1
PR/src/lib/formats/wav.c +3 -3
PR/src/lib/object/object.c +1 -0
PR/src/lib/object/sound/sound_common.c +2 -2

diff --git a/PR/src/lib/actions/import.c b/PR/src/lib/actions/import.c
index 6e92052..575b96a 100644
--- a/PR/src/lib/actions/import.c
+++ b/PR/src/lib/actions/import.c
@@ -157,7 +157,7 @@ int import_partial(const char* vFiledat, const char* vDirExt, tResourceList* r,
 			/* get save file name (if unknown document is in the XML) */
 			getFileName(vFileext,vDirExt,&res,vFiledat,vDatFileName,optionflag,backupExtension,NULL);
 
-			o=readObject(vFileext,&newRes,&result);
+			o=readObject(repairFolders(vFileext),&newRes,&result);
 /*			if (!fatal(ok)) */
 			setObject(o,&result);
 			
diff --git a/PR/src/lib/formats/wav.c b/PR/src/lib/formats/wav.c
index e42f913..df9b2a3 100644
--- a/PR/src/lib/formats/wav.c
+++ b/PR/src/lib/formats/wav.c
@@ -101,9 +101,9 @@ int readWav(const char* file, tBinary* snd, int *pchannels, long *psamplerate, l
 	/* Validate input vars */	
   ok=ok&& (AudioFormat   == 1 ); /* PCM */
   ok=ok&& (BlockAlign    == NumChannels * BitsPerSample/8 );
-	ok=ok&& (ByteRate      == SampleRate * NumChannels * BitsPerSample/8 );
-	ok=ok&& (ChunkSize     == 4 + (8 + SubChunk1Size) + (8 + SubChunk2Size) );
-  ok=ok&& (SubChunk1Size == 16 ); /* PCM chunk */
+	ok=ok&& ((int)ByteRate      == (int)(SampleRate * NumChannels * BitsPerSample/8) ); /* why int? because I can't compare it with long, never tried in 32 bits */
+	ok=ok&& ((int)ChunkSize     == (int)(4 + (8 + SubChunk1Size) + (8 + SubChunk2Size)) );
+  ok=ok&& ((int)SubChunk1Size == (int)16 ); /* PCM chunk */
 /*	ok=ok&& (SubChunk2Size == NumSamples * NumChannels * BitsPerSample/8 );*/
 	
 	/* Read data*/
diff --git a/PR/src/lib/object/object.c b/PR/src/lib/object/object.c
index bc1f2f0..2188450 100644
--- a/PR/src/lib/object/object.c
+++ b/PR/src/lib/object/object.c
@@ -146,6 +146,7 @@ tObject readObject(const char* file,tResource* res,int *result) {
 			break;
 		case eResTypeWave:
 			o.obj=objWaveRead(file,result);
+printf("wav: result=%d\n",*result);
 			break;
 		case eResTypeMidi:
 			/*o.obj=objMidiRead(file,res.content,result);*/
diff --git a/PR/src/lib/object/sound/sound_common.c b/PR/src/lib/object/sound/sound_common.c
index 6ac6ae0..da27043 100644
--- a/PR/src/lib/object/sound/sound_common.c
+++ b/PR/src/lib/object/sound/sound_common.c
@@ -74,9 +74,9 @@ void* objWaveRead(const char* file, int *result) {
 	*result=readWav(file,o,&channels,&samplerate,&bps);
 
 	if (*result==PR_RESULT_SUCCESS) {
-		if (bps!=8) *result=PR_RESULT_WAV_UNSUPPORTED_BITRATE;
+		if (bps!=8)            *result=PR_RESULT_WAV_UNSUPPORTED_BITRATE;
 		if (samplerate!=11025) *result=PR_RESULT_WAV_UNSUPPORTED_SAMPLERATE;
-		if (samplerate!=1) *result=PR_RESULT_WAV_UNSUPPORTED_STEREO;
+		if (channels!=1)     *result=PR_RESULT_WAV_UNSUPPORTED_STEREO;
 	}
 	if (*result!=PR_RESULT_SUCCESS) {
 		free(o->data);