diff options
author | Ton Roosendaal <ton@blender.org> | 2006-06-14 16:42:23 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-06-14 16:42:23 +0400 |
commit | b81e5bac741fca9e6938d4608d343a08c5e9d6cc (patch) | |
tree | 3ee9e28193b1458ffe24e696cf0eadde892abdaa /source | |
parent | 8988a0de38dcf545447649ac778b145b2fb5e14a (diff) |
Bugfix #4135
Mixdown option (blending sequence audio strips) didn't write proper WAV.
- file length in header chunk was too short (potential crasher)
- endian switch code used swab(), which wasn't defined to work when src and
target is identical
- cleaned up some code too... like removing timecursor() for core loop.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_utildefines.h | 5 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 6 | ||||
-rw-r--r-- | source/blender/src/buttons_scene.c | 2 | ||||
-rw-r--r-- | source/blender/src/editsound.c | 21 | ||||
-rw-r--r-- | source/blender/src/seqaudio.c | 45 |
5 files changed, 38 insertions, 41 deletions
diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 4c143e3293a..f5fe91920b7 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -163,6 +163,11 @@ s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \ s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; } +#define SWITCH_SHORT(a) { \ + char s_i, *p_i; \ + p_i= (char *)&(a); \ + s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; } + /* Bit operations */ #define BTST(a,b) ( ( (a) & 1<<(b) )!=0 ) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c9a90d0dc02..d63374d472d 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -215,12 +215,6 @@ READ s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \ s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \ s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; } -// only used here in readfile.c -#define SWITCH_SHORT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; } - /***/ diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index c2f5f84199b..9beeb64c4ea 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -344,7 +344,7 @@ static void sound_panel_sequencer(void) uiDefButBitS(block, TOG, AUDIO_MUTE, 0, "Mute", xco,yco,235,24, &G.scene->audio.flag, 0, 0, 0, 0, "Mute audio from sequencer"); yco -= 35; - uiDefBut(block, BUT, B_SOUND_MIXDOWN, "MIXDOWN", xco,yco,235,24, 0, 0, 0, 0, 0, "Create WAV file from sequenced audio"); + uiDefBut(block, BUT, B_SOUND_MIXDOWN, "MIXDOWN", xco,yco,235,24, 0, 0, 0, 0, 0, "Create WAV file from sequenced audio (output goes to render output dir)"); } diff --git a/source/blender/src/editsound.c b/source/blender/src/editsound.c index 30b38d2c2d7..7e685465e4b 100644 --- a/source/blender/src/editsound.c +++ b/source/blender/src/editsound.c @@ -314,12 +314,7 @@ void sound_read_wav_data(bSound* sound, PackedFile* pf) readPackedFile(pf, &shortbuf, 2); if(G.order==B_ENDIAN) { - /* was SWITCH_SHORT before */ - char s_i, *p_i; - p_i= (char *)&(shortbuf); - s_i= p_i[0]; - p_i[0]= p_i[1]; - p_i[1]= s_i; + SWITCH_SHORT(shortbuf); } /* read the number of channels */ @@ -327,12 +322,7 @@ void sound_read_wav_data(bSound* sound, PackedFile* pf) if(G.order==B_ENDIAN) { - /* was SWITCH_SHORT before */ - char s_i, *p_i; - p_i= (char *)&(shortbuf); - s_i= p_i[0]; - p_i[0]= p_i[1]; - p_i[1]= s_i; + SWITCH_SHORT(shortbuf); } /* check the number of channels */ @@ -367,12 +357,7 @@ void sound_read_wav_data(bSound* sound, PackedFile* pf) readPackedFile(pf, &shortbuf, 2); if(G.order==B_ENDIAN) { - /* was SWITCH_SHORT before */ - char s_i, *p_i; - p_i= (char *)&(shortbuf); - s_i= p_i[0]; - p_i[0]= p_i[1]; - p_i[1]= s_i; + SWITCH_SHORT(shortbuf); } bits = shortbuf; diff --git a/source/blender/src/seqaudio.c b/source/blender/src/seqaudio.c index afa0c8d6dd1..be70124fd7f 100644 --- a/source/blender/src/seqaudio.c +++ b/source/blender/src/seqaudio.c @@ -131,9 +131,9 @@ static void do_sound_ipos(Sequence * seq) void audio_mixdown() { - int file, c, totlen, totframe, i, oldcfra, cfra2=0; + int file, c, totlen, totframe, i, oldcfra; char *buf; - Editing *ed; + Editing *ed= G.scene->ed; buf = MEM_mallocN(65536, "audio_mixdown"); makewavstring(buf); @@ -145,12 +145,20 @@ void audio_mixdown() error("Can't open output file"); return; } + + waitcursor(1); + + printf("Saving: %s ", buf); strcpy(buf, "RIFFlengWAVEfmt fmln01ccRATEbsecBP16dataDLEN"); totframe = (EFRA - SFRA + 1); totlen = (int) ( ((float)totframe / (float)G.scene->r.frs_sec) * (float)G.scene->audio.mixrate * 4.0); - printf("totlen %x\n", totlen); + printf(" totlen %d\n", totlen+36+8); + + totlen+= 36; /* len is filesize-8 in WAV spec, total header is 44 bytes */ memcpy(buf+4, &totlen, 4); + totlen-= 36; + buf[16] = 0x10; buf[17] = buf[18] = buf[19] = 0; buf[20] = 1; buf[21] = 0; buf[22] = 2; buf[23]= 0; memcpy(buf+24, &G.scene->audio.mixrate, 4); @@ -165,7 +173,7 @@ void audio_mixdown() /* length */ SWITCH_INT(buf[4]); - + /* audio rate */ SWITCH_INT(buf[24]); @@ -180,29 +188,34 @@ void audio_mixdown() oldcfra = CFRA; audiostream_play(SFRA, 0, 1); - for (CFRA = SFRA, i = 0; (CFRA<=EFRA); - CFRA=(int) ( ((float)(audio_pos-64) - /( G.scene->audio.mixrate*4 )) - *(float)G.scene->r.frs_sec )) { - if (cfra2 != CFRA) { - cfra2 = CFRA; - set_timecursor(CFRA); - } + + i= 0; + while ( totlen > 0 ) { + totlen -= 64; + memset(buf+i, 0, 64); - ed= G.scene->ed; + if (ed) { + /* retrieve current frame for ipos */ + CFRA=(int) ( ((float)(audio_pos-64)/( G.scene->audio.mixrate*4 ))*(float)G.scene->r.frs_sec ); + do_sound_ipos(ed->seqbasep->first); - } + } + audio_fill(buf+i, NULL, 64); if (G.order == B_ENDIAN) { - swab(buf+i, buf+i, 64); + char tbuf[64]; + memcpy(tbuf, buf+i, 64); + swab(tbuf, buf+i, 64); } if (i == (65536-64)) { i=0; write(file, buf, 65536); - } else i+=64; + } + else i+=64; } write(file, buf, i); + waitcursor(0); CFRA = oldcfra; close(file); |