git » fp-git.git » commit 87e9c62

starting pcs and mid import hook

author ecalot
2006-02-24 08:37:57 UTC
committer ecalot
2006-02-24 08:37:57 UTC
parent c67e5b2a47e2c0035141958a2e842867d2e69e91

starting pcs and mid import hook

PR/src/include/sound.h +9 -6
PR/src/lib/object/sound/sound_common.c +23 -0

diff --git a/PR/src/include/sound.h b/PR/src/include/sound.h
index e271b42..291e9ee 100644
--- a/PR/src/include/sound.h
+++ b/PR/src/include/sound.h
@@ -39,23 +39,26 @@ sound.h: Princed Resources :
 #include "mid.h"
 #include "wav.h"
 
-int objSoundWrite(void* o, const char* file, int write(const char* file,tBinary* data,int optionflag, const char* backupExtension), int optionflag, const char* backupExtension);
-void* objSoundCreate(tBinary c, int *error);
+/*int objSoundWrite(void* o, const char* file, int write(const char* file,tBinary* data,int optionflag, const char* backupExtension), int optionflag, const char* backupExtension);*/
 
+void* objSoundCreate(tBinary c, int *error);
 
-#define objWaveWrite(a,b,c,d) objSoundWrite(a,b,writeWav,c,d)
-#define objMidiWrite(a,b,c,d) objSoundWrite(a,b,writeMid,c,d)
-#define objPcspeakerWrite(a,b,c,d) objBinaryWrite(a,b,c,d)
+int objWaveWrite(void* o, const char* file, int optionflag, const char* backupExtension);
 
 #define objWaveCreate(a,b) objSoundCreate(a,b)
 #define objMidiCreate(a,b) objSoundCreate(a,b)
 #define objPcspeakerCreate(a,b) objSoundCreate(a,b)
 
 /*#define objWaveRead(a,b,c,d,e) objSoundRead(a,readWav,b,c,d,e)*/
-void* objSoundRead(const char* file, int read(const char* file, tBinary* c, int *pchannels, long *psamplerate, long *pbps), int *result);
+/*void* objSoundRead(const char* file, int read(const char* file, tBinary* c, int *pchannels, long *psamplerate, long *pbps), int *result);*/
 
 void* objWaveRead(const char* file, int *result);
 
 int objWaveSet(void* o,tResource* res);
+int objPcspeakerSet(void* o,tResource* res);
+int objMidiSet(void* o,tResource* res);
+
+#define objMidiWrite(a,b,c,d) objBinaryWrite(a,b,c,d)
+#define objPcspeakerWrite(a,b,c,d) objBinaryWrite(a,b,c,d)
 
 #endif
diff --git a/PR/src/lib/object/sound/sound_common.c b/PR/src/lib/object/sound/sound_common.c
index 9ed1f2c..2707d4f 100644
--- a/PR/src/lib/object/sound/sound_common.c
+++ b/PR/src/lib/object/sound/sound_common.c
@@ -61,6 +61,10 @@ int objSoundWrite(void* o, const char* file, int write(const char* file,tBinary*
 	return write(file,(tBinary*)o,optionflag,backupExtension);
 }
 
+int objWaveWrite(void* o, const char* file, int optionflag, const char* backupExtension) {
+	return writeWav(file,(tBinary*)o,optionflag,backupExtension);
+}
+
 /*void* objSoundRead(const char* file, int read(const char* file, tBinary* c, int *pchannels, long *psamplerate, long *pbps), int *result, int *pchannels, long *psamplerate, long *pbps) {
 	tBinary* o=(tBinary*)malloc(sizeof(tBinary));
 	*result=read(file,o);
@@ -100,4 +104,23 @@ int objWaveSet(void* o,tResource* res) {
 	return PR_RESULT_SUCCESS;
 }
 
+int objMidiSet(void* o,tResource* res) {
+	tBinary* midi=o;
+	res->content.size=midi->size+1;
+	res->content.data=malloc(midi->size+1);
+	res->content.data[0]=0x01; /* TODO: use MIDI_MAGIC */
+	memcpy(res->content.data+1,midi->data,midi->size);
+	mWriteFileInDatFile(res);
+	return PR_RESULT_SUCCESS;
+}
+
+int objPcspeakerSet(void* o,tResource* res) {
+	tBinary* pcspeaker=o;
+	res->content.size=pcspeaker->size+1;
+	res->content.data=malloc(pcspeaker->size+1);
+	res->content.data[0]=0x01; /* TODO: use PCSPEAKER_MAGIC */
+	memcpy(res->content.data+1,pcspeaker->data,pcspeaker->size);
+	mWriteFileInDatFile(res);
+	return PR_RESULT_SUCCESS;
+}