[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [10958] branches/soc-2007-hcube: Added audio sequencing skeleton.

Csaba Hruska csaba.hruska at gmail.com
Mon Jun 18 20:45:59 CEST 2007


Revision: 10958
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=10958
Author:   hcube
Date:     2007-06-18 20:45:59 +0200 (Mon, 18 Jun 2007)

Log Message:
-----------
Added audio sequencing skeleton.

Modified Paths:
--------------
    branches/soc-2007-hcube/intern/tinySND/sndfile/sndfileProvider.cpp
    branches/soc-2007-hcube/source/blender/blenkernel/BKE_sound.h
    branches/soc-2007-hcube/source/blender/blenkernel/intern/sound.c
    branches/soc-2007-hcube/source/blender/src/buttons_scene.c
    branches/soc-2007-hcube/source/blender/src/drawview.c
    branches/soc-2007-hcube/source/blender/src/editscreen.c
    branches/soc-2007-hcube/source/blender/src/editseq.c
    branches/soc-2007-hcube/source/blender/src/header_sound.c
    branches/soc-2007-hcube/source/blender/src/header_time.c
    branches/soc-2007-hcube/source/blender/src/usiblender.c
    branches/soc-2007-hcube/source/creator/creator.c

Added Paths:
-----------
    branches/soc-2007-hcube/source/blender/include/BSE_sound.h
    branches/soc-2007-hcube/source/blender/src/sound.c

Modified: branches/soc-2007-hcube/intern/tinySND/sndfile/sndfileProvider.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/sndfile/sndfileProvider.cpp	2007-06-18 18:30:15 UTC (rev 10957)
+++ branches/soc-2007-hcube/intern/tinySND/sndfile/sndfileProvider.cpp	2007-06-18 18:45:59 UTC (rev 10958)
@@ -34,7 +34,7 @@
     
     if( mIsSeekable )
     {
-	sf_seek( mSndFile, frameNum, SEEK_SET );
+		sf_seek( mSndFile, frameNum, SEEK_SET );
     }
 }
 

Modified: branches/soc-2007-hcube/source/blender/blenkernel/BKE_sound.h
===================================================================
--- branches/soc-2007-hcube/source/blender/blenkernel/BKE_sound.h	2007-06-18 18:30:15 UTC (rev 10957)
+++ branches/soc-2007-hcube/source/blender/blenkernel/BKE_sound.h	2007-06-18 18:45:59 UTC (rev 10958)
@@ -42,13 +42,6 @@
 /* bad bad global... */
 extern struct ListBase *samples;
 
-void sound_initialize(void);
-void sound_finalize(void);
-
-struct bSound* sound_new_sound(char *name);
-void sound_play_sound(struct bSound *sound);
-void sound_stop_all_sounds(void);
-
 void sound_free_all_samples(void);
 
 void sound_set_packedfile(struct bSample* sample, struct PackedFile* pf);

Modified: branches/soc-2007-hcube/source/blender/blenkernel/intern/sound.c
===================================================================
--- branches/soc-2007-hcube/source/blender/blenkernel/intern/sound.c	2007-06-18 18:30:15 UTC (rev 10957)
+++ branches/soc-2007-hcube/source/blender/blenkernel/intern/sound.c	2007-06-18 18:45:59 UTC (rev 10958)
@@ -147,58 +147,3 @@
 	return (pf);
 }
 
-bSound* sound_new_sound(char *name)
-{
-	bSound *sound = NULL;
-	SND_SoundIHandle soundHandle;
-//	char str[FILE_MAXDIR+FILE_MAXFILE];
-	
-	// allocate some memory for the sound 
-	sound = alloc_libblock(&G.main->sound, ID_SO, "sound");
-	strcpy(sound->name, name);
-		
-	soundHandle = SND_NewSound( name );
-	if (soundHandle == NULL)
-	{
-		free_libblock(&G.main->sound, sound);
-		sound = NULL;
-	} 
-	else
-	{
-		sound->volume = 1.0;
-		sound->attenuation = 1.0;
-		sound->distance = 1.0;
-		sound->min_gain = 0.0;
-		sound->max_gain = 1.0;
-		sound->snd_sound = soundHandle;
-	}
-	
-	return (sound);
-}
-
-void sound_play_sound(struct bSound *sound)
-{
-	assert( sound != NULL );
-	assert( sound->snd_sound != NULL );
-
-	SND_PlaySound( (SND_SoundIHandle)sound->snd_sound );
-}
-
-void sound_stop_all_sounds(void)
-{
-	SND_StopAllSounds();
-}
-
-void sound_initialize(void)
-{
-	SND_Initialize();
-}
-
-void sound_finalize(void)
-{
-	if( SND_IsInitialized() )
-	{
-		SND_Finalize();
-	}
-}
-

Added: branches/soc-2007-hcube/source/blender/include/BSE_sound.h
===================================================================
--- branches/soc-2007-hcube/source/blender/include/BSE_sound.h	                        (rev 0)
+++ branches/soc-2007-hcube/source/blender/include/BSE_sound.h	2007-06-18 18:45:59 UTC (rev 10958)
@@ -0,0 +1,17 @@
+#ifndef BSE_SOUND_H
+#define BSE_SOUND_H
+
+#include "DNA_sound_types.h"
+
+void sound_initialize(void);
+void sound_finalize(void);
+
+struct bSound* sound_new_sound(char *name);
+void sound_play_sound(struct bSound *sound);
+void sound_stop_all_sounds(void);
+
+void sound_play_seq(void);
+void sound_stop_seq(void);
+void sound_update_seq(void);
+
+#endif

Modified: branches/soc-2007-hcube/source/blender/src/buttons_scene.c
===================================================================
--- branches/soc-2007-hcube/source/blender/src/buttons_scene.c	2007-06-18 18:30:15 UTC (rev 10957)
+++ branches/soc-2007-hcube/source/blender/src/buttons_scene.c	2007-06-18 18:45:59 UTC (rev 10958)
@@ -49,10 +49,12 @@
 #include "BKE_node.h"
 #include "BKE_library.h"
 #include "BKE_scene.h"
-#include "BKE_sound.h"
 #include "BKE_packedFile.h"
 #include "BKE_utildefines.h"
+#include "BKE_sound.h"
 
+#include "BSE_sound.h"
+
 #include "BLI_blenlib.h"
 
 #include "BSE_filesel.h"

Modified: branches/soc-2007-hcube/source/blender/src/drawview.c
===================================================================
--- branches/soc-2007-hcube/source/blender/src/drawview.c	2007-06-18 18:30:15 UTC (rev 10957)
+++ branches/soc-2007-hcube/source/blender/src/drawview.c	2007-06-18 18:45:59 UTC (rev 10958)
@@ -3136,7 +3136,7 @@
 	double time;
 
     // by hcube
-	if ((U.mixbufsize)/*&&(audiostream_pos() != CFRA)*/&&(G.scene->audio.flag & AUDIO_SYNC)) return 0;
+	//if ((U.mixbufsize)/*&&(audiostream_pos() != CFRA)*/&&(G.scene->audio.flag & AUDIO_SYNC)) return 0;
 
 	time = PIL_check_seconds_timer();
 	
@@ -3185,6 +3185,9 @@
 		sa= sa->next;	
 	}
 	
+	// update sound seqences
+	sound_update_seq();
+	
 	/* make sure that swaptime passed by */
 	tottime -= swaptime;
 	while (update_time()) PIL_sleep_ms(1);
@@ -3193,6 +3196,8 @@
 		if (tottime > 0.0) tottime = 0.0;
 		CFRA= PSFRA;
         // by hcube
+		sound_stop_seq();
+		sound_play_seq();
 		//audiostream_stop();
 		//audiostream_start( CFRA );
 	}
@@ -3200,6 +3205,7 @@
         // by hcube
 		//if (U.mixbufsize && (G.scene->audio.flag & AUDIO_SYNC)) CFRA = audiostream_pos();
 		//else CFRA++;
+		CFRA++;
 	}
 }
 
@@ -3230,6 +3236,7 @@
 	oldsa= curarea;
     // by hcube
 	//audiostream_start( CFRA );
+	sound_play_seq();
 	
 	if (curarea && curarea->spacetype == SPACE_SEQ) {
 		SpaceSeq *sseq = curarea->spacedata.first;
@@ -3278,6 +3285,7 @@
 	else CFRA= cfraont;
 	// by hcube
 	//audiostream_stop();
+	sound_stop_seq();
 
 	if(oldsa!=curarea) areawinset(oldsa->win);
 	

Modified: branches/soc-2007-hcube/source/blender/src/editscreen.c
===================================================================
--- branches/soc-2007-hcube/source/blender/src/editscreen.c	2007-06-18 18:30:15 UTC (rev 10957)
+++ branches/soc-2007-hcube/source/blender/src/editscreen.c	2007-06-18 18:45:59 UTC (rev 10958)
@@ -1082,6 +1082,8 @@
             // by hcube
 			//audiostream_stop();
 			//audiostream_start( CFRA );
+			sound_stop_seq();
+			sound_play_seq();
 		}
 		else {
             // by hcube

Modified: branches/soc-2007-hcube/source/blender/src/editseq.c
===================================================================
--- branches/soc-2007-hcube/source/blender/src/editseq.c	2007-06-18 18:30:15 UTC (rev 10957)
+++ branches/soc-2007-hcube/source/blender/src/editseq.c	2007-06-18 18:45:59 UTC (rev 10958)
@@ -71,7 +71,7 @@
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_scene.h"
-#include "BKE_sound.h"
+#include "BSE_sound.h"
 
 #include "BIF_space.h"
 #include "BIF_interface.h"
@@ -720,7 +720,8 @@
     // by hcube
 	//audio_makestream(sound);
 
-	totframe= (int) ( ((float)(sound->streamlen-1)/( (float)G.scene->audio.mixrate*4.0 ))* (float)G.scene->r.frs_sec);
+	//totframe= (int) ( ((float)(sound->streamlen-1)/( (float)G.scene->audio.mixrate*4.0 ))* (float)G.scene->r.frs_sec);
+	totframe= sound->streamlen;
 
 	/* make seq */
 	seq= alloc_sequence(((Editing *)G.scene->ed)->seqbasep, cfra, machine);

Modified: branches/soc-2007-hcube/source/blender/src/header_sound.c
===================================================================
--- branches/soc-2007-hcube/source/blender/src/header_sound.c	2007-06-18 18:30:15 UTC (rev 10957)
+++ branches/soc-2007-hcube/source/blender/src/header_sound.c	2007-06-18 18:45:59 UTC (rev 10958)
@@ -65,7 +65,7 @@
 #include "BIF_butspace.h"
 
 #include "BKE_global.h"
-#include "BKE_sound.h"
+#include "BSE_sound.h"
 #include "BKE_main.h"
 
 #include "BSE_drawipo.h"

Modified: branches/soc-2007-hcube/source/blender/src/header_time.c
===================================================================
--- branches/soc-2007-hcube/source/blender/src/header_time.c	2007-06-18 18:30:15 UTC (rev 10957)
+++ branches/soc-2007-hcube/source/blender/src/header_time.c	2007-06-18 18:45:59 UTC (rev 10958)
@@ -81,14 +81,16 @@
 	case B_TL_PLAY:
 		add_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM, stime->redraws);
 		if(stime->redraws & TIME_WITH_SEQ_AUDIO)
-            ;// by hcube
+			sound_play_seq();
+            // by hcube
 			//audiostream_start( CFRA );
 
 		break;
 	case B_TL_STOP:
 		rem_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM);
 		if(stime->redraws & TIME_WITH_SEQ_AUDIO)
-            ;//by hcube
+			sound_stop_seq();
+            //by hcube
 			//audiostream_stop();
 		allqueue(REDRAWALL, 0);
 		

Added: branches/soc-2007-hcube/source/blender/src/sound.c
===================================================================
--- branches/soc-2007-hcube/source/blender/src/sound.c	                        (rev 0)
+++ branches/soc-2007-hcube/source/blender/src/sound.c	2007-06-18 18:45:59 UTC (rev 10958)
@@ -0,0 +1,214 @@
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+
+#include "DNA_scene_types.h"
+#include "DNA_sound_types.h"
+#include "DNA_packedFile_types.h"
+
+#include "BKE_utildefines.h"
+#include "BKE_global.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_sound.h"
+#include "BKE_packedFile.h"
+
+#include "BSE_sound.h"
+
+#include "SND_C-api.h"
+
+bSound* sound_new_sound(char *name)
+{
+	bSound *sound = NULL;
+	SND_SoundIHandle soundHandle;
+//	char str[FILE_MAXDIR+FILE_MAXFILE];
+	
+	// allocate some memory for the sound 
+	sound = alloc_libblock(&G.main->sound, ID_SO, "sound");
+	strcpy(sound->name, name);
+		
+	soundHandle = SND_NewSound( name );
+	if (soundHandle == NULL)
+	{
+		free_libblock(&G.main->sound, sound);
+		sound = NULL;
+	} 
+	else
+	{
+		sound->volume = 1.0;
+		sound->attenuation = 1.0;
+		sound->distance = 1.0;
+		sound->min_gain = 0.0;
+		sound->max_gain = 1.0;
+		sound->snd_sound = soundHandle;
+	}
+	
+	return (sound);
+}
+
+void sound_play_sound(struct bSound *sound)
+{
+	assert( sound != NULL );
+	assert( sound->snd_sound != NULL );
+
+	SND_PlaySound( (SND_SoundIHandle)sound->snd_sound );
+}
+
+void sound_stop_all_sounds(void)
+{
+	SND_StopAllSounds();
+}
+
+void sound_initialize(void)
+{
+	SND_Initialize();
+}
+
+void sound_finalize(void)
+{
+	if( SND_IsInitialized() )
+	{
+		SND_Finalize();
+	}
+}
+
+////////////////////////////////////
+// sequencing code NEW
+////////////////////////////////////
+
+void sound_play_seq(void)
+{
+}
+
+void sound_stop_seq(void)
+{
+}
+
+void sound_update_seq(void)
+{
+}
+
+////////////////////////////////////
+// sequencing code OLD
+////////////////////////////////////
+/*
+static int audiostream_play_seq(Sequence * seq, Uint32 startframe)
+{
+	char name[FILE_MAXDIR+FILE_MAXFILE];
+	int have_sound = 0;
+
+	while(seq) {
+		if (seq->type == SEQ_META) {
+			if (audiostream_play_seq(

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list