[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22156] branches/soundsystem/source/ blender: Loading pre 2.5 files now works flawlessly.

Jörg Müller nexyon at gmail.com
Sun Aug 2 22:34:12 CEST 2009


Revision: 22156
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22156
Author:   nexyon
Date:     2009-08-02 22:34:12 +0200 (Sun, 02 Aug 2009)

Log Message:
-----------
Loading pre 2.5 files now works flawlessly.

Modified Paths:
--------------
    branches/soundsystem/source/blender/blenkernel/BKE_sound.h
    branches/soundsystem/source/blender/blenkernel/intern/sound.c
    branches/soundsystem/source/blender/blenloader/intern/readfile.c
    branches/soundsystem/source/blender/editors/space_sequencer/sequencer_add.c
    branches/soundsystem/source/blender/makesdna/DNA_sequence_types.h
    branches/soundsystem/source/blender/makesdna/DNA_sound_types.h

Modified: branches/soundsystem/source/blender/blenkernel/BKE_sound.h
===================================================================
--- branches/soundsystem/source/blender/blenkernel/BKE_sound.h	2009-08-02 19:40:25 UTC (rev 22155)
+++ branches/soundsystem/source/blender/blenkernel/BKE_sound.h	2009-08-02 20:34:12 UTC (rev 22156)
@@ -36,6 +36,7 @@
 // AUD_XXX struct bSample;
 struct bContext;
 struct ListBase;
+struct Main;
 
 /* bad bad global... */
 // AUD_XXX
@@ -58,7 +59,7 @@
 
 void sound_exit();
 
-struct bSound* sound_new_file(struct bContext *C, char* filename);
+struct bSound* sound_new_file(struct Main *main, char* filename);
 
 // AUD_XXX unused currently
 #if 0

Modified: branches/soundsystem/source/blender/blenkernel/intern/sound.c
===================================================================
--- branches/soundsystem/source/blender/blenkernel/intern/sound.c	2009-08-02 19:40:25 UTC (rev 22155)
+++ branches/soundsystem/source/blender/blenkernel/intern/sound.c	2009-08-02 20:34:12 UTC (rev 22156)
@@ -199,7 +199,7 @@
 	AUD_exit();
 }
 
-struct bSound* sound_new_file(struct bContext *C, char* filename)
+struct bSound* sound_new_file(struct Main *main, char* filename)
 {
 	bSound* sound = NULL;
 
@@ -213,7 +213,7 @@
 	while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\')
 		len--;
 
-	sound = alloc_libblock(&CTX_data_main(C)->sound, ID_SO, filename+len);
+	sound = alloc_libblock(&main->sound, ID_SO, filename+len);
 	strcpy(sound->name, filename);
 	sound->type = SOUND_TYPE_FILE;
 
@@ -221,7 +221,7 @@
 
 	if(!sound->snd_sound)
 	{
-		free_libblock(&CTX_data_main(C)->sound, sound);
+		free_libblock(&main->sound, sound);
 		sound = NULL;
 	}
 

Modified: branches/soundsystem/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soundsystem/source/blender/blenloader/intern/readfile.c	2009-08-02 19:40:25 UTC (rev 22155)
+++ branches/soundsystem/source/blender/blenloader/intern/readfile.c	2009-08-02 20:34:12 UTC (rev 22156)
@@ -4042,7 +4042,10 @@
 				if(seq->scene) seq->scene= newlibadr(fd, sce->id.lib, seq->scene);
 				// AUD_XXX
 				if(seq->sound) {
-					seq->sound= newlibadr(fd, sce->id.lib, seq->sound);
+					if(seq->type == SEQ_HD_SOUND)
+						seq->type = SEQ_SOUND;
+					else
+						seq->sound= newlibadr(fd, sce->id.lib, seq->sound);
 					if (seq->sound) {
 						seq->sound->id.us++;
 						seq->sound_handle= sound_new_handle(sce, seq->sound, seq->startdisp, seq->enddisp, seq->startofs);
@@ -5033,6 +5036,9 @@
 			sound->id.flag -= LIB_NEEDLINK;
 			sound->ipo= newlibadr_us(fd, sound->id.lib, sound->ipo); // XXX depreceated - old animation system
 			sound->stream = 0;
+
+			// AUD_XXX
+			sound_load(sound);
 		}
 		sound= sound->id.next;
 	}
@@ -9173,6 +9179,8 @@
 
 // AUD_XXX
 		bSound *sound;
+		Sequence *seq;
+		bActuator *act;
 
 		for(sound = main->sound.first; sound; sound = sound->id.next)
 		{
@@ -9180,10 +9188,57 @@
 			{
 				sound->packedfile = sound->newpackedfile;
 				sound->newpackedfile = NULL;
-				sound->type = SOUND_TYPE_FILE;
 			}
 		}
 
+		for(ob = main->object.first; ob; ob= ob->id.next) {
+			for(act= ob->actuators.first; act; act= act->next) {
+				if (act->type == ACT_SOUND) {
+					bSoundActuator *sAct = (bSoundActuator*) act->data;
+/* that would only work if do_versions was called after the linking
+					if(sAct->sound)
+					{
+						sAct->flag = sAct->sound->flags | SOUND_FLAGS_3D ? ACT_SND_3D_SOUND : 0;
+						sAct->pitch = sAct->sound->pitch;
+						sAct->volume = sAct->sound->volume;
+						sAct->sound3D.reference_distance = sAct->sound->distance;
+						sAct->sound3D.max_gain = sAct->sound->max_gain;
+						sAct->sound3D.min_gain = sAct->sound->min_gain;
+						sAct->sound3D.rolloff_factor = sAct->sound->attenuation;
+					}
+					else*/
+					{
+						sAct->sound3D.reference_distance = 1.0f;
+						sAct->flag = ACT_SND_3D_SOUND;
+						sAct->volume = 1.0f;
+						sAct->sound3D.max_gain = 1.0f;
+						sAct->sound3D.rolloff_factor = 1.0f;
+					}
+					sAct->sound3D.cone_inner_angle = 360.0f;
+					sAct->sound3D.cone_outer_angle = 360.0f;
+					sAct->sound3D.max_distance = FLT_MAX;
+				}
+			}
+		}
+
+		for(scene = main->scene.first; scene; scene = scene->id.next)
+		{
+			if(scene->ed && scene->ed->seqbasep)
+			{
+				for(seq = scene->ed->seqbasep->first; seq; seq = seq->next)
+				{
+					if(seq->type == SEQ_HD_SOUND)
+					{
+						char str[FILE_MAX];
+						BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name);
+						BLI_convertstringcode(str, G.sce);
+						BLI_convertstringframe(str, scene->r.cfra);
+						seq->sound = sound_new_file(main, str);
+					}
+				}
+			}
+		}
+
 		for(screen= main->screen.first; screen; screen= screen->id.next) {
 			do_versions_windowmanager_2_50(screen);
 			do_versions_gpencil_2_50(main, screen);
@@ -9278,15 +9333,7 @@
 		Scene *sce;
 		ToolSettings *ts;
 		int i, a;
-// AUD_XXX
-		bSound *sound;
 
-		for(sound = main->sound.first; sound; sound = sound->id.next)
-		{
-			sound->snd_sound = NULL;
-			sound_load(sound);
-		}
-
 		for(ob = main->object.first; ob; ob = ob->id.next) {
 
 			if(ob->type == OB_MESH) {

Modified: branches/soundsystem/source/blender/editors/space_sequencer/sequencer_add.c
===================================================================
--- branches/soundsystem/source/blender/editors/space_sequencer/sequencer_add.c	2009-08-02 19:40:25 UTC (rev 22155)
+++ branches/soundsystem/source/blender/editors/space_sequencer/sequencer_add.c	2009-08-02 20:34:12 UTC (rev 22156)
@@ -241,7 +241,7 @@
 
 	AUD_SoundInfo info;
 
-	sound = sound_new_file(C, filename);
+	sound = sound_new_file(CTX_data_main(C), filename);
 
 	if (sound==NULL || sound->snd_sound == NULL) {
 		if(op)

Modified: branches/soundsystem/source/blender/makesdna/DNA_sequence_types.h
===================================================================
--- branches/soundsystem/source/blender/makesdna/DNA_sequence_types.h	2009-08-02 19:40:25 UTC (rev 22155)
+++ branches/soundsystem/source/blender/makesdna/DNA_sequence_types.h	2009-08-02 20:34:12 UTC (rev 22156)
@@ -283,7 +283,7 @@
 #define SEQ_RAM_SOUND		4
 #define SEQ_HD_SOUND            5
 // AUD_XXX #define SEQ_MOVIE_AND_HD_SOUND  6 /* helper for add_sequence */
-#define SEQ_SOUND		6
+#define SEQ_SOUND		4
 
 #define SEQ_EFFECT		8
 #define SEQ_CROSS		8

Modified: branches/soundsystem/source/blender/makesdna/DNA_sound_types.h
===================================================================
--- branches/soundsystem/source/blender/makesdna/DNA_sound_types.h	2009-08-02 19:40:25 UTC (rev 22155)
+++ branches/soundsystem/source/blender/makesdna/DNA_sound_types.h	2009-08-02 20:34:12 UTC (rev 22156)
@@ -141,8 +141,8 @@
 } bSound;
 
 typedef enum eSound_Type {
-	SOUND_TYPE_INVALID = 0,
-	SOUND_TYPE_FILE,
+	SOUND_TYPE_INVALID = -1,
+	SOUND_TYPE_FILE = 0,
 	SOUND_TYPE_BUFFER,
 	SOUND_TYPE_LIMITER
 } eSound_Type;





More information about the Bf-blender-cvs mailing list