[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11710] branches/soc-2007-hcube/source/ blender/src: Renamed setframeposition function to scrub.
Csaba Hruska
csaba.hruska at gmail.com
Sun Aug 19 19:59:26 CEST 2007
Revision: 11710
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11710
Author: hcube
Date: 2007-08-19 19:59:26 +0200 (Sun, 19 Aug 2007)
Log Message:
-----------
Renamed setframeposition function to scrub. Fixed scrubbing code.
Modified Paths:
--------------
branches/soc-2007-hcube/source/blender/src/headerbuttons.c
branches/soc-2007-hcube/source/blender/src/seqaudio.c
Modified: branches/soc-2007-hcube/source/blender/src/headerbuttons.c
===================================================================
--- branches/soc-2007-hcube/source/blender/src/headerbuttons.c 2007-08-19 17:57:53 UTC (rev 11709)
+++ branches/soc-2007-hcube/source/blender/src/headerbuttons.c 2007-08-19 17:59:26 UTC (rev 11710)
@@ -415,7 +415,7 @@
// by hcube
if ( (CFRA>1) && (!mute) && (G.scene->audio.flag & AUDIO_SCRUB))
- seqaudio_setframeposition( CFRA );// scrub
+ seqaudio_scrub();
/* 3d window, preview */
BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
Modified: branches/soc-2007-hcube/source/blender/src/seqaudio.c
===================================================================
--- branches/soc-2007-hcube/source/blender/src/seqaudio.c 2007-08-19 17:57:53 UTC (rev 11709)
+++ branches/soc-2007-hcube/source/blender/src/seqaudio.c 2007-08-19 17:59:26 UTC (rev 11710)
@@ -31,21 +31,56 @@
typedef enum
{
- SEQAUDIO_STOP = 0,
- SEQAUDIO_PLAY = 1
+ SEQAUDIO_STOP = 0,
+ SEQAUDIO_PLAY = 1,
+ SEQAUDIO_SCRUB = 2
} SeqAudioState;
-SeqAudioState gSeqAudioState = SEQAUDIO_STOP;
-int gSequenceStartFrame = 0;
+SeqAudioState gSeqAudioState = SEQAUDIO_STOP;
+int gSequenceStartFrame = 0;
+int gScrubCounter = 0;
////////////////////////////////////
// sequencing code NEW
////////////////////////////////////
+
+// this will be called before mixing has been done by tinySND
+static void do_seqaudio_update_cb( int framesNum, void *userData1, void *userData2 )
+{
+ /*
+ Sequence *seq = (Sequence*)userData1;
+ float facf;
+
+ if( seq->ipo && seq->ipo->curve.first )
+ {
+ do_seq_ipo(seq);
+ facf = seq->facf0;
+ }
+ else
+ {
+ facf = 1.0;
+ }
+ */
+
+ // do scrubbing
+ gScrubCounter--;
+ if( gScrubCounter <= 0 )
+ {
+ gScrubCounter = 0;
+
+ if( gSeqAudioState == SEQAUDIO_SCRUB )
+ {
+ seqaudio_stop();
+ }
+ }
+}
+
void seqaudio_initialize(void)
{
gSeqAudioState = SEQAUDIO_STOP;
gSequenceStartFrame = 0;
+ audio_setcallback( do_seqaudio_update_cb, 0, 0 );
}
void seqaudio_finalize(void)
@@ -76,51 +111,21 @@
seqaudio_update();
}
-// this will be called before mixing has been done by tinySND
-static void do_seqaudio_update_ipo_cb( void *userData1, void *userData2 )
+static void do_seqaudio_update( Sequence *seq )
{
- Sequence *seq = (Sequence*)userData1;
- float facf;
-
- if( seq->ipo && seq->ipo->curve.first )
- {
- do_seq_ipo(seq);
- facf = seq->facf0;
- }
- else
- {
- facf = 1.0;
- }
- /*
- cvtbuf = malloc(len);
- memcpy(cvtbuf, ((Uint8*)sound->stream)+(seq->curpos & (~3)), len);
- audio_levels(cvtbuf, len, seq->level, facf, seq->pan);
- if (!mixdown) {
- SDL_MixAudio(sstream, cvtbuf, len, SDL_MIX_MAXVOLUME);
- } else {
- SDL_MixAudio((Uint8*)mixdown, cvtbuf, len, SDL_MIX_MAXVOLUME);
- }
- */
-}
-
-static void do_seqaudio_update( Sequence *seq, int doScrub )
-{
/*
if(seq->startofs && seq->startstill) seq->startstill= 0;
if(seq->endofs && seq->endstill) seq->endstill= 0;
seq->startdisp= seq->start + seq->startofs - seq->startstill;
seq->enddisp= seq->start+seq->len - seq->endofs + seq->endstill;
-
-int audio_sound_getframeposition(struct bSound *sound);
-void audio_sound_setframeposition(struct bSound *sound, int framePos);
*/
while( seq )
{
if( seq->type == SEQ_META )
{
- do_seqaudio_update( seq->seqbase.first, doScrub );
+ do_seqaudio_update( seq->seqbase.first );
}
if( (seq->type == SEQ_RAM_SOUND) || (seq->type == SEQ_HD_SOUND) )
@@ -133,6 +138,7 @@
//int curpos; // last sample position in audio_fill()
seq->curpos = (int)( (((float) ((float)startframe -(float)seq->start) / (float)G.scene->r.frs_sec) * ((float)G.scene->audio.mixrate) * 4 ));
*/
+
//only Play/Stop
if( gSeqAudioState == SEQAUDIO_STOP )
{
@@ -151,16 +157,6 @@
audio_sound_play( seq->sound );
audio_sound_setframeposition( seq->sound, (int)startPos );
}
- else
- {
- // do scrubbing here
- if( doScrub == TRUE )
- {
- float framePos = seq->startofs + CFRA - seq->startdisp;
- framePos *= ((float)seq->sound->sample->rate) / ((float)G.scene->r.frs_sec);
- audio_sound_setframeposition( seq->sound, (int)framePos );
- }
- }
}
else
{
@@ -180,13 +176,13 @@
{
Editing *ed;
- assert( gSeqAudioState == SEQAUDIO_STOP || gSeqAudioState == SEQAUDIO_PLAY );
+ assert( gSeqAudioState == SEQAUDIO_STOP || gSeqAudioState == SEQAUDIO_PLAY || gSeqAudioState == SEQAUDIO_SCRUB );
ed = G.scene->ed;
if( !audio_isinitialized() || !ed )
{
return;
}
- do_seqaudio_update( ed->seqbasep->first, FALSE );
+ do_seqaudio_update( ed->seqbasep->first );
}
int seqaudio_getframeposition(void)
@@ -204,17 +200,29 @@
return (int)pos;
}
-void seqaudio_setframeposition(int framePos)
+void seqaudio_scrub(void)
{
- Editing *ed;
-
- assert( gSeqAudioState == SEQAUDIO_STOP || gSeqAudioState == SEQAUDIO_PLAY );
- ed = G.scene->ed;
- if( !audio_isinitialized() || !ed )
+ assert( gSeqAudioState == SEQAUDIO_STOP || gSeqAudioState == SEQAUDIO_PLAY || gSeqAudioState == SEQAUDIO_SCRUB );
+
+ if( !audio_isinitialized() )
{
return;
}
- do_seqaudio_update( ed->seqbasep->first, TRUE );
+
+ // setup scrub state
+
+ // calculate how many seconds should be played
+ // !!!! NOT IMPLEMENTED YET !!!!
+ gScrubCounter = 2;
+
+ if( gSeqAudioState == SEQAUDIO_STOP )
+ {
+ gSeqAudioState = SEQAUDIO_SCRUB;
+ }
+
+ audio_clearglobalframecounter();
+ gSequenceStartFrame = CFRA;
+ seqaudio_update();
}
int seqaudio_mixdown(char *fileName, int sampleRate)
More information about the Bf-blender-cvs
mailing list