== Ipo ==
authorPeter Schlaile <peter@schlaile.de>
Mon, 12 May 2008 17:16:54 +0000 (17:16 +0000)
committerPeter Schlaile <peter@schlaile.de>
Mon, 12 May 2008 17:16:54 +0000 (17:16 +0000)
This fixes [#11118] Record Mouse in IPO Curve Editor 2.46rc3
and adds thereby a new feature: correct audio sync to IPO mouse recording :)

source/blender/include/BSE_drawview.h
source/blender/src/drawview.c
source/blender/src/editipo.c

index be1f5581be7bd00b10a91b2595d0ef51213057b7..83031ff3bad8158d16ddb174fb09cd8c93ff7527 100644 (file)
@@ -59,7 +59,7 @@ void drawview3d_render(struct View3D *v3d, int winx, int winy, float winmat[][4]
 void draw_depth(struct ScrArea *sa, void *spacedata);
 void view3d_update_depths(struct View3D *v3d);
 
-int update_time(void);
+int update_time(int cfra);
 void calc_viewborder(struct View3D *v3d, struct rctf *viewborder_r);
 void view3d_set_1_to_1_viewborder(struct View3D *v3d);
 
index 15b7f3dbe675d2ccb42e7460f99b700661af3923..52e0d3d6f05c794e652ed157c301fe29caacd496 100644 (file)
@@ -3398,12 +3398,12 @@ static float redrawtimes_fps[REDRAW_FRAME_AVERAGE];
 static short redrawtime_index;
 
 
-int update_time(void)
+int update_time(int cfra)
 {
        static double ltime;
        double time;
 
-       if ((audiostream_pos() != CFRA)
+       if ((audiostream_pos() != cfra)
            && (G.scene->audio.flag & AUDIO_SYNC)) {
                return 0;
        }
@@ -3641,7 +3641,7 @@ void inner_play_anim_loop(int init, int mode)
 
        /* make sure that swaptime passed by */
        tottime -= swaptime;
-       while (update_time()) {
+       while (update_time(CFRA)) {
                PIL_sleep_ms(1);
        }
        
@@ -3700,7 +3700,7 @@ int play_anim(int mode)
 
        inner_play_prefetch_startup(mode);
 
-       update_time();
+       update_time(CFRA);
        
        inner_play_anim_loop(1, mode);  /* 1==init */
 
index a8b2ff761e50a52d90e5cd5ff6a160ce3bd54cc9..c5dd41e16d55fd519ed9aad28bbcccbe1edc21cd 100644 (file)
 #include "BSE_headerbuttons.h"
 #include "BSE_node.h"
 #include "BSE_sequence.h"
+#include "BSE_seqaudio.h"
 #include "BSE_time.h"
 
 #include "blendef.h"
@@ -5643,7 +5644,7 @@ void ipo_record(void)
        if(poin) ei1->icu->curval= read_ipo_poin(poin, type);
        or1= ei1->icu->curval;
        ei1->icu->flag |= IPO_LOCK;
-       
+
        if(ei2) {
                if(ei2->icu==NULL)
                        ei2->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei2->adrcode);
@@ -5671,8 +5672,9 @@ void ipo_record(void)
                }               
                sa= sa->next;   
        }
+
        if(sa) areawinset(sa->win);
-       
+
        /* can we? */
        while(get_mbut()&L_MOUSE) BIF_wait_for_statechange();
        data1= MEM_callocN(sizeof(float)*(EFRA-SFRA+1), "data1");
@@ -5681,14 +5683,18 @@ void ipo_record(void)
        getmouseco_areawin(mvalo);
        xn= mvalo[0]; yn= mvalo[1];
        waitcursor(1);
-       
+
        tottime= 0.0;
        swaptime= 1.0/FPS;
 
        cfrao= CFRA;
        cfra=efra= SFRA;
        sfra= EFRA;
-       
+
+       if (G.scene->audio.flag & AUDIO_SYNC) {
+               audiostream_start(cfra);
+       }
+
        while(afbreek==0) {
                
                getmouseco_areawin(mval);
@@ -5698,7 +5704,7 @@ void ipo_record(void)
                        else firsttime= 0;
 
                        set_timecursor(cfra);
-                       
+       
                        /* do ipo: first all, then the specific ones */
                        if(anim==2) {
                                do_ob_ipo(ob);
@@ -5729,7 +5735,7 @@ void ipo_record(void)
 
                        /* minimal wait swaptime */
                        tottime -= swaptime;
-                       while (update_time()) PIL_sleep_ms(1);
+                       while (update_time(cfra)) PIL_sleep_ms(1);
 
                        screen_swapbuffers();
                        
@@ -5739,8 +5745,18 @@ void ipo_record(void)
                        mvalo[1]= mval[1];
                        
                        if(anim || (G.qual & LR_CTRLKEY)) {
-                               cfra++;
-                               if(cfra>EFRA) cfra= SFRA;
+                               if (G.scene->audio.flag & AUDIO_SYNC) {
+                                       cfra = audiostream_pos();
+                               } else {
+                                       cfra++;
+                               }
+                               if(cfra>EFRA) {
+                                       cfra= SFRA;
+                                       if (G.scene->audio.flag & AUDIO_SYNC) {
+                                               audiostream_stop();
+                                               audiostream_start( cfra );
+                                       }
+                               }
                        }
                }
                
@@ -5793,6 +5809,9 @@ void ipo_record(void)
        editipo_changed(G.sipo, 0);
        do_ipo(G.sipo->ipo);
        waitcursor(0);
+       if (G.scene->audio.flag & AUDIO_SYNC) {
+               audiostream_stop();
+       }
 
        allqueue(REDRAWVIEW3D, 0);
        if(sa) scrarea_queue_headredraw(sa);    /* headerprint */