From 6c5c58e05799f2b593cd81fcff57e6ef72ad57fb Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sun, 9 Aug 2009 21:16:39 +0000 Subject: 2.5: Sound branch merge! See mailing list for additional information. --- source/blender/blenkernel/BKE_packedFile.h | 3 +- source/blender/blenkernel/BKE_sequence.h | 7 +- source/blender/blenkernel/BKE_sound.h | 49 +- source/blender/blenkernel/BKE_writeavi.h | 5 +- source/blender/blenkernel/BKE_writeffmpeg.h | 3 +- source/blender/blenkernel/BKE_writeframeserver.h | 3 +- source/blender/blenkernel/CMakeLists.txt | 1 + source/blender/blenkernel/SConscript | 1 + source/blender/blenkernel/intern/blender.c | 5 - source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/packedFile.c | 55 +-- source/blender/blenkernel/intern/sca.c | 12 +- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenkernel/intern/sequence.c | 66 +-- source/blender/blenkernel/intern/sound.c | 515 +++++++++++++++++---- source/blender/blenkernel/intern/writeavi.c | 2 +- source/blender/blenkernel/intern/writeffmpeg.c | 29 +- .../blender/blenkernel/intern/writeframeserver.c | 2 +- source/blender/blenlib/intern/bpath.c | 2 +- source/blender/blenloader/intern/readfile.c | 90 +++- source/blender/blenloader/intern/writefile.c | 28 +- source/blender/editors/CMakeLists.txt | 1 + source/blender/editors/animation/anim_ops.c | 5 + source/blender/editors/screen/screen_ops.c | 6 +- source/blender/editors/screen/screendump.c | 2 +- source/blender/editors/space_file/filelist.c | 22 +- source/blender/editors/space_logic/logic_window.c | 17 +- source/blender/editors/space_outliner/outliner.c | 4 +- source/blender/editors/space_sequencer/SConscript | 1 + .../editors/space_sequencer/sequencer_add.c | 140 +++--- .../editors/space_sequencer/sequencer_draw.c | 15 +- .../editors/space_sequencer/sequencer_edit.c | 53 ++- .../editors/space_sequencer/sequencer_select.c | 4 +- source/blender/makesdna/DNA_actuator_types.h | 8 + source/blender/makesdna/DNA_scene_types.h | 1 + source/blender/makesdna/DNA_sequence_types.h | 4 +- source/blender/makesdna/DNA_sound_types.h | 75 ++- source/blender/makesdna/DNA_userdef_types.h | 5 + source/blender/makesrna/intern/rna_sequence.c | 24 +- source/blender/makesrna/intern/rna_sound.c | 65 --- source/blender/makesrna/intern/rna_userdef.c | 72 +++ source/blender/render/intern/source/pipeline.c | 2 +- source/blender/windowmanager/intern/wm_init_exit.c | 8 +- 43 files changed, 992 insertions(+), 424 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_packedFile.h b/source/blender/blenkernel/BKE_packedFile.h index efd930d375a..b6513bede99 100644 --- a/source/blender/blenkernel/BKE_packedFile.h +++ b/source/blender/blenkernel/BKE_packedFile.h @@ -34,7 +34,6 @@ #define RET_OK 0 #define RET_ERROR 1 -struct bSample; struct bSound; struct Image; struct Main; @@ -51,7 +50,7 @@ void packAll(struct Main *bmain, struct ReportList *reports); /* unpack */ char *unpackFile(struct ReportList *reports, char *abs_name, char *local_name, struct PackedFile *pf, int how); int unpackVFont(struct ReportList *reports, struct VFont *vfont, int how); -int unpackSample(struct ReportList *reports, struct bSample *sample, int how); +int unpackSound(struct ReportList *reports, struct bSound *sound, int how); int unpackImage(struct ReportList *reports, struct Image *ima, int how); void unpackAll(struct Main *bmain, struct ReportList *reports, int how); diff --git a/source/blender/blenkernel/BKE_sequence.h b/source/blender/blenkernel/BKE_sequence.h index 7162fa7b9dd..35cff5c9422 100644 --- a/source/blender/blenkernel/BKE_sequence.h +++ b/source/blender/blenkernel/BKE_sequence.h @@ -37,6 +37,7 @@ struct Strip; struct StripElem; struct ImBuf; struct Scene; +struct bContext; #define MAXSEQ 32 @@ -44,7 +45,6 @@ struct Scene; #define BUILD_SEQAR_COUNT_CURRENT 1 #define BUILD_SEQAR_COUNT_CHILDREN 2 - /* sequence iterator */ typedef struct SeqIterator { @@ -137,9 +137,9 @@ struct SeqEffectHandle { /* sequence.c */ // extern -void seq_free_sequence(struct Editing *ed, struct Sequence *seq); +void seq_free_sequence(struct Scene *scene, struct Sequence *seq); void seq_free_strip(struct Strip *strip); -void seq_free_editing(struct Editing *ed); +void seq_free_editing(struct Scene *scene); struct Editing *seq_give_editing(struct Scene *scene, int alloc); char *give_seqname(struct Sequence *seq); struct ImBuf *give_ibuf_seq(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size); @@ -183,3 +183,4 @@ int seq_test_overlap(struct ListBase * seqbasep, struct Sequence *test); int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test); void free_imbuf_seq(struct ListBase * seqbasep, int check_mem_usage); +void seq_update_sound(struct Sequence *seq); diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index f3bed467c3a..ef66b29f112 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -1,7 +1,7 @@ /** * sound.h (mar-2001 nzc) - * - * $Id$ + * + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -33,20 +33,47 @@ struct PackedFile; struct bSound; -struct bSample; +struct bContext; struct ListBase; +struct Main; + +void sound_init(); -/* bad bad global... */ -extern struct ListBase *samples; +void sound_reinit(struct bContext *C); -void sound_free_all_samples(void); +void sound_exit(); -/* void *sound_get_listener(void); implemented in src!also declared there now */ +struct bSound* sound_new_file(struct Main *main, char* filename); -void sound_set_packedfile(struct bSample* sample, struct PackedFile* pf); -struct PackedFile* sound_find_packedfile(struct bSound* sound); -void sound_free_sample(struct bSample* sample); -void sound_free_sound(struct bSound* sound); +// XXX unused currently +#if 0 +struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source); +struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, float start, float end); #endif +void sound_delete(struct bContext *C, struct bSound* sound); + +void sound_cache(struct bSound* sound, int ignore); + +void sound_load(struct bSound* sound); + +void sound_free(struct bSound* sound); + +void sound_unlink(struct bContext *C, struct bSound* sound); + +struct SoundHandle* sound_new_handle(struct Scene *scene, struct bSound* sound, int startframe, int endframe, int frameskip); + +void sound_delete_handle(struct Scene *scene, struct SoundHandle *handle); + +void sound_update_playing(struct bContext *C); + +void sound_scrub(struct bContext *C); + +#ifdef AUD_CAPI +AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int end); +#endif + +void sound_stop_all(struct bContext *C); + +#endif diff --git a/source/blender/blenkernel/BKE_writeavi.h b/source/blender/blenkernel/BKE_writeavi.h index cae1f25d0d8..4ef63b069c2 100644 --- a/source/blender/blenkernel/BKE_writeavi.h +++ b/source/blender/blenkernel/BKE_writeavi.h @@ -37,13 +37,14 @@ extern "C" { /* generic blender movie support, could move to own module */ struct RenderData; -void start_avi(struct RenderData *rd, int rectx, int recty); +struct Scene; +void start_avi(struct Scene *scene, struct RenderData *rd, int rectx, int recty); void end_avi(void); void append_avi(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); void makeavistring (struct RenderData *rd, char *string); typedef struct bMovieHandle { - void (*start_movie)(struct RenderData *rd, int rectx, int recty); + void (*start_movie)(struct Scene *scene, struct RenderData *rd, int rectx, int recty); void (*append_movie)(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); void (*end_movie)(void); int (*get_next_frame)(struct RenderData *rd); /* optional */ diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h index be136bd9d6d..07e0e01ef7e 100644 --- a/source/blender/blenkernel/BKE_writeffmpeg.h +++ b/source/blender/blenkernel/BKE_writeffmpeg.h @@ -57,8 +57,9 @@ extern "C" { struct IDProperty; struct RenderData; +struct Scene; -extern void start_ffmpeg(struct RenderData *rd, int rectx, int recty); +extern void start_ffmpeg(struct Scene *scene, struct RenderData *rd, int rectx, int recty); extern void end_ffmpeg(void); extern void append_ffmpeg(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); diff --git a/source/blender/blenkernel/BKE_writeframeserver.h b/source/blender/blenkernel/BKE_writeframeserver.h index e870cbb865d..6a38abe977f 100644 --- a/source/blender/blenkernel/BKE_writeframeserver.h +++ b/source/blender/blenkernel/BKE_writeframeserver.h @@ -33,8 +33,9 @@ extern "C" { #endif struct RenderData; +struct Scene; -extern void start_frameserver(struct RenderData *rd, int rectx, int recty); +extern void start_frameserver(struct Scene *scene, struct RenderData *rd, int rectx, int recty); extern void end_frameserver(void); extern void append_frameserver(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); extern int frameserver_loop(struct RenderData *rd); diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index a2a7457545d..db9bbfcc5e7 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -34,6 +34,7 @@ SET(INC ../../../extern/bullet2/src ../nodes ../../../extern/glew/include ../gpu ../makesrna ../../../intern/smoke/extern ../../../intern/bsp/extern + ../../../intern/audaspace ${ZLIB_INC} ) diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index 5b1c7b163ba..ce0ee5cf3c8 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -11,6 +11,7 @@ incs += ' #/extern/bullet2/src' incs += ' #/intern/opennl/extern #/intern/bsp/extern' incs += ' ../gpu #/extern/glew/include' incs += ' #/intern/smoke/extern' +incs += ' #/intern/audaspace' incs += ' ' + env['BF_OPENGL_INC'] incs += ' ' + env['BF_ZLIB_INC'] diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 2728aa30e6e..2e4e5596450 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -176,8 +176,6 @@ void pushpop_test() void free_blender(void) { /* samples are in a global list..., also sets G.main->sound->sample NULL */ - sound_free_all_samples(); - free_main(G.main); G.main= NULL; @@ -330,9 +328,6 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) MEM_freeN(bfd->user); } - /* samples is a global list... */ - sound_free_all_samples(); - /* case G_FILE_NO_UI or no screens in file */ if(mode) { /* leave entire context further unaltered? */ diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index ff065fd4bf6..3c8bf9200f8 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -567,7 +567,7 @@ void free_libblock(ListBase *lb, void *idv) //XXX free_script((Script *)id); break; case ID_SO: - sound_free_sound((bSound *)id); + sound_free((bSound*)id); break; case ID_GR: free_group((Group *)id); diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 590189fbd5d..8c77ed92aa1 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -123,7 +123,7 @@ int countPackedFiles(Main *bmain) { Image *ima; VFont *vf; - bSample *sample; + bSound *sound; int count = 0; // let's check if there are packed files... @@ -135,10 +135,9 @@ int countPackedFiles(Main *bmain) if(vf->packedfile) count++; - if(samples) - for(sample=samples->first; sample; sample=sample->id.next) - if(sample->packedfile) - count++; + for(sound=bmain->sound.first; sound; sound=sound->id.next) + if(sound->packedfile) + count++; return count; } @@ -208,8 +207,8 @@ void packAll(Main *bmain, ReportList *reports) { Image *ima; VFont *vf; - bSample *sample; - + bSound *sound; + for(ima=bmain->image.first; ima; ima=ima->id.next) if(ima->packedfile == NULL) ima->packedfile = newPackedFile(reports, ima->name); @@ -218,10 +217,9 @@ void packAll(Main *bmain, ReportList *reports) if(vf->packedfile == NULL) vf->packedfile = newPackedFile(reports, vf->name); - if(samples) - for(sample=samples->first; sample; sample=sample->id.next) - if(sample->packedfile == NULL) - sound_set_packedfile(sample, newPackedFile(reports, sample->name)); + for(sound=bmain->sound.first; sound; sound=sound->id.next) + if(sound->packedfile == NULL) + sound->packedfile = newPackedFile(reports, sound->name); } @@ -456,28 +454,26 @@ int unpackVFont(ReportList *reports, VFont *vfont, int how) return (ret_value); } -int unpackSample(ReportList *reports, bSample *sample, int how) +int unpackSound(ReportList *reports, bSound *sound, int how) { char localname[FILE_MAXDIR + FILE_MAX], fi[FILE_MAX]; char *newname; int ret_value = RET_ERROR; - PackedFile *pf; - - if (sample != NULL) { - strcpy(localname, sample->name); + + if (sound != NULL) { + strcpy(localname, sound->name); BLI_splitdirstring(localname, fi); - sprintf(localname, "//samples/%s", fi); - - newname = unpackFile(reports, sample->name, localname, sample->packedfile, how); + sprintf(localname, "//sounds/%s", fi); + + newname = unpackFile(reports, sound->name, localname, sound->packedfile, how); if (newname != NULL) { - strcpy(sample->name, newname); + strcpy(sound->name, newname); MEM_freeN(newname); - pf = sample->packedfile; - // because samples and sounds can point to the - // same packedfile we have to check them all - sound_set_packedfile(sample, NULL); - freePackedFile(pf); + freePackedFile(sound->packedfile); + sound->packedfile = 0; + + sound_load(sound); ret_value = RET_OK; } @@ -515,7 +511,7 @@ void unpackAll(Main *bmain, ReportList *reports, int how) { Image *ima; VFont *vf; - bSample *sample; + bSound *sound; for(ima=bmain->image.first; ima; ima=ima->id.next) if(ima->packedfile) @@ -525,9 +521,8 @@ void unpackAll(Main *bmain, ReportList *reports, int how) if(vf->packedfile) unpackVFont(reports, vf, how); - if(samples) - for(sample=samples->first; sample; sample=sample->id.next) - if(sample->packedfile) - unpackSample(reports, sample, how); + for(sound=bmain->sound.first; sound; sound=sound->id.next) + if(sound->packedfile) + unpackSound(reports, sound, how); } diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 74d2347ec39..9a66603fef0 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -35,6 +35,8 @@ #include #include +#include + #include "MEM_guardedalloc.h" #include "DNA_text_types.h" @@ -410,6 +412,7 @@ void init_actuator(bActuator *act) { /* also use when actuator changes type */ bObjectActuator *oa; + bSoundActuator *sa; if(act->data) MEM_freeN(act->data); act->data= 0; @@ -422,7 +425,14 @@ void init_actuator(bActuator *act) break; #endif case ACT_SOUND: - act->data= MEM_callocN(sizeof(bSoundActuator), "soundact"); + sa = act->data= MEM_callocN(sizeof(bSoundActuator), "soundact"); + sa->volume = 1.0f; + sa->sound3D.rolloff_factor = 1.0f; + sa->sound3D.reference_distance = 1.0f; + sa->sound3D.max_gain = 1.0f; + sa->sound3D.cone_inner_angle = 360.0f; + sa->sound3D.cone_outer_angle = 360.0f; + sa->sound3D.max_distance = FLT_MAX; break; case ACT_CD: act->data= MEM_callocN(sizeof(bCDActuator), "cdact"); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index a44118d186b..0a93874f24e 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -140,7 +140,7 @@ void free_scene(Scene *sce) /* do not free objects! */ BLI_freelistN(&sce->base); - seq_free_editing(sce->ed); + seq_free_editing(sce); BKE_free_animdata((ID *)sce); BKE_keyingsets_free(&sce->keyingsets); diff --git a/source/blender/blenkernel/intern/sequence.c b/source/blender/blenkernel/intern/sequence.c index 3b675a87e59..159a60ad3af 100644 --- a/source/blender/blenkernel/intern/sequence.c +++ b/source/blender/blenkernel/intern/sequence.c @@ -52,6 +52,10 @@ #include "BLI_threads.h" #include +#include "BKE_context.h" +#include "BKE_sound.h" +#include "AUD_C-API.h" + #ifdef WIN32 #define snprintf _snprintf #endif @@ -178,12 +182,16 @@ void seq_free_strip(Strip *strip) MEM_freeN(strip); } -void seq_free_sequence(Editing *ed, Sequence *seq) +void seq_free_sequence(Scene *scene, Sequence *seq) { + Editing *ed = scene->ed; + if(seq->strip) seq_free_strip(seq->strip); if(seq->anim) IMB_free_anim(seq->anim); - //XXX if(seq->hdaudio) sound_close_hdaudio(seq->hdaudio); + + if(seq->sound_handle) + sound_delete_handle(scene, seq->sound_handle); if (seq->type & SEQ_EFFECT) { struct SeqEffectHandle sh = get_sequence_effect(seq); @@ -208,8 +216,9 @@ Editing *seq_give_editing(Scene *scene, int alloc) return scene->ed; } -void seq_free_editing(Editing *ed) +void seq_free_editing(Scene *scene) { + Editing *ed = scene->ed; MetaStack *ms; Sequence *seq; @@ -217,7 +226,7 @@ void seq_free_editing(Editing *ed) return; SEQ_BEGIN(ed, seq) { - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); } SEQ_END @@ -444,6 +453,8 @@ void calc_sequence_disp(Sequence *seq) else if(seq->enddisp-seq->startdisp > 250) { seq->handsize= (float)((seq->enddisp-seq->startdisp)/25); } + + seq_update_sound(seq); } void calc_sequence(Sequence *seq) @@ -515,8 +526,8 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) char str[FILE_MAXDIR+FILE_MAXFILE]; if (!(seq->type == SEQ_MOVIE || seq->type == SEQ_IMAGE || - seq->type == SEQ_HD_SOUND || seq->type == SEQ_RAM_SOUND || - seq->type == SEQ_SCENE || seq->type == SEQ_META)) { + seq->type == SEQ_SOUND || + seq->type == SEQ_SCENE || seq->type == SEQ_META)) { return; } @@ -558,23 +569,8 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) seq->len = 0; } seq->strip->len = seq->len; - } else if (seq->type == SEQ_HD_SOUND) { -// XXX if(seq->hdaudio) sound_close_hdaudio(seq->hdaudio); -// seq->hdaudio = sound_open_hdaudio(str); - - if (!seq->hdaudio) { - return; - } - -// XXX seq->len = sound_hdaudio_get_duration(seq->hdaudio, FPS) - seq->anim_startofs - seq->anim_endofs; - if (seq->len < 0) { - seq->len = 0; - } - seq->strip->len = seq->len; - } else if (seq->type == SEQ_RAM_SOUND) { - seq->len = (int) ( ((float)(seq->sound->streamlen-1)/ - ((float)scene->audio.mixrate*4.0 )) - * FPS); + } else if (seq->type == SEQ_SOUND) { + seq->len = AUD_getInfo(seq->sound->snd_sound).length * FPS; seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; if (seq->len < 0) { @@ -693,8 +689,7 @@ char *give_seqname_by_type(int type) case SEQ_IMAGE: return "Image"; case SEQ_SCENE: return "Scene"; case SEQ_MOVIE: return "Movie"; - case SEQ_RAM_SOUND: return "Audio (RAM)"; - case SEQ_HD_SOUND: return "Audio (HD)"; + case SEQ_SOUND: return "Audio"; case SEQ_CROSS: return "Cross"; case SEQ_GAMCROSS: return "Gamma Cross"; case SEQ_ADD: return "Add"; @@ -1071,10 +1066,9 @@ int evaluate_seq_frame(Scene *scene, int cfra) static int video_seq_is_rendered(Sequence * seq) { - return (seq - && !(seq->flag & SEQ_MUTE) - && seq->type != SEQ_RAM_SOUND - && seq->type != SEQ_HD_SOUND); + return (seq + && !(seq->flag & SEQ_MUTE) + && seq->type != SEQ_SOUND); } static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Sequence ** seq_arr_out) @@ -3309,7 +3303,7 @@ void seq_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag) } /* sounds cannot be extended past their endpoints */ - if (seq->type == SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND) { + if (seq->type == SEQ_SOUND) { seq->startstill= 0; seq->endstill= 0; } @@ -3406,3 +3400,15 @@ int shuffle_seq(ListBase * seqbasep, Sequence *test) return 1; } } + +void seq_update_sound(struct Sequence *seq) +{ + if(seq->type == SEQ_SOUND) + { + seq->sound_handle->startframe = seq->startdisp; + seq->sound_handle->endframe = seq->enddisp; + seq->sound_handle->frameskip = seq->startofs + seq->anim_startofs; + seq->sound_handle->mute = seq->flag & SEQ_MUTE ? 1 : 0; + seq->sound_handle->changed = -1; + } +} diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 2c5b49246fb..347837d1dd0 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -1,6 +1,6 @@ /** * sound.c (mar-2001 nzc) - * + * * $Id$ */ @@ -14,125 +14,468 @@ #include "DNA_scene_types.h" #include "DNA_sound_types.h" #include "DNA_packedFile_types.h" +#include "DNA_screen_types.h" +#include "DNA_userdef_types.h" + +#include "AUD_C-API.h" #include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_main.h" #include "BKE_sound.h" +#include "BKE_context.h" +#include "BKE_library.h" #include "BKE_packedFile.h" #ifdef HAVE_CONFIG_H #include #endif -ListBase _samples = {0,0}, *samples = &_samples; +void sound_init() +{ + AUD_Specs specs; + specs.channels = AUD_CHANNELS_STEREO; + specs.format = AUD_FORMAT_S16; + specs.rate = AUD_RATE_44100; + + if(!AUD_init(AUD_SDL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE)) + if(!AUD_init(AUD_OPENAL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE*4)) + AUD_init(AUD_NULL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE); +} -void sound_free_sound(bSound *sound) +void sound_reinit(struct bContext *C) { - /* when sounds have been loaded, but not played, the packedfile was not copied - to sample block and not freed otherwise */ - if(sound->sample==NULL) { - if (sound->newpackedfile) { - freePackedFile(sound->newpackedfile); - sound->newpackedfile = NULL; - } + AUD_Specs specs; + int device, buffersize; + + device = U.audiodevice; + buffersize = U.mixbufsize; + specs.channels = U.audiochannels; + specs.format = U.audioformat; + specs.rate = U.audiorate; + + if(buffersize < 128) + buffersize = AUD_DEFAULT_BUFFER_SIZE; + + if(specs.rate < AUD_RATE_8000) + specs.rate = AUD_RATE_44100; + + if(specs.format <= AUD_FORMAT_INVALID) + specs.format = AUD_FORMAT_S16; + + if(specs.channels <= AUD_CHANNELS_INVALID) + specs.channels = AUD_CHANNELS_STEREO; + + if(!AUD_init(device, specs, buffersize)) + AUD_init(AUD_NULL_DEVICE, specs, buffersize); +} + +void sound_exit() +{ + AUD_exit(); +} + +struct bSound* sound_new_file(struct Main *main, char* filename) +{ + bSound* sound = NULL; + + char str[FILE_MAX]; + int len; + + strcpy(str, filename); + BLI_convertstringcode(str, G.sce); + + len = strlen(filename); + while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\') + len--; + + sound = alloc_libblock(&main->sound, ID_SO, filename+len); + strcpy(sound->name, filename); + sound->type = SOUND_TYPE_FILE; + + sound_load(sound); + + if(!sound->snd_sound) + { + free_libblock(&main->sound, sound); + sound = NULL; + } + + return sound; +} + +// XXX unused currently +#if 0 +struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source) +{ + bSound* sound = NULL; + + char name[25]; + strcpy(name, "buf_"); + strcpy(name + 4, source->id.name); + + sound = alloc_libblock(&CTX_data_main(C)->sound, ID_SO, name); + + sound->child_sound = source; + sound->type = SOUND_TYPE_BUFFER; + + sound_load(sound); + + if(!sound->snd_sound) + { + free_libblock(&CTX_data_main(C)->sound, sound); + sound = NULL; + } + + return sound; +} + +struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, float start, float end) +{ + bSound* sound = NULL; + + char name[25]; + strcpy(name, "lim_"); + strcpy(name + 4, source->id.name); + + sound = alloc_libblock(&CTX_data_main(C)->sound, ID_SO, name); + + sound->child_sound = source; + sound->start = start; + sound->end = end; + sound->type = SOUND_TYPE_LIMITER; + + sound_load(sound); + + if(!sound->snd_sound) + { + free_libblock(&CTX_data_main(C)->sound, sound); + sound = NULL; + } + + return sound; +} +#endif + +void sound_delete(struct bContext *C, struct bSound* sound) +{ + if(sound) + { + sound_free(sound); + + sound_unlink(C, sound); + + free_libblock(&CTX_data_main(C)->sound, sound); } - if (sound->stream) free(sound->stream); } -void sound_free_sample(bSample *sample) +void sound_cache(struct bSound* sound, int ignore) +{ + if(sound->cache && !ignore) + AUD_unload(sound->cache); + + sound->cache = AUD_bufferSound(sound->snd_sound); +} + +void sound_load(struct bSound* sound) { - if (sample) { - if (sample->data != &sample->fakedata[0] && sample->data != NULL) { - MEM_freeN(sample->data); - sample->data = &sample->fakedata[0]; + if(sound) + { + if(sound->snd_sound) + { + AUD_unload(sound->snd_sound); + sound->snd_sound = NULL; } - - if (sample->packedfile) { - freePackedFile(sample->packedfile); //FIXME: crashes sometimes - sample->packedfile = NULL; + + switch(sound->type) + { + case SOUND_TYPE_FILE: + { + char fullpath[FILE_MAX]; + char *path; + + /* load sound */ + PackedFile* pf = sound->packedfile; + + /* dont modify soundact->sound->name, only change a copy */ + BLI_strncpy(fullpath, sound->name, sizeof(fullpath)); + + if(sound->id.lib) + path = sound->id.lib->filename; + else + path = G.sce; + + BLI_convertstringcode(fullpath, path); + + /* but we need a packed file then */ + if (pf) + sound->snd_sound = AUD_loadBuffer((unsigned char*) pf->data, pf->size); + /* or else load it from disk */ + else + sound->snd_sound = AUD_load(fullpath); + break; } - - if (sample->alindex != SAMPLE_INVALID) { -// AUD_free_sample(sample->snd_sample); - sample->alindex = SAMPLE_INVALID; + case SOUND_TYPE_BUFFER: + if(sound->child_sound && sound->child_sound->snd_sound) + sound->snd_sound = AUD_bufferSound(sound->child_sound->snd_sound); + break; + case SOUND_TYPE_LIMITER: + if(sound->child_sound && sound->child_sound->snd_sound) + sound->snd_sound = AUD_limitSound(sound->child_sound, sound->start, sound->end); + break; } - sample->type = SAMPLE_INVALID; + if(sound->cache) + { + + } } } -/* this is called after file reading or undos */ -void sound_free_all_samples(void) +void sound_free(struct bSound* sound) { - bSample *sample; - bSound *sound; - - /* ensure no sample pointers exist, and check packedfile */ - for(sound= G.main->sound.first; sound; sound= sound->id.next) { - if(sound->sample && sound->sample->packedfile==sound->newpackedfile) - sound->newpackedfile= NULL; - sound->sample= NULL; + if (sound->packedfile) + { + freePackedFile(sound->packedfile); + sound->packedfile = NULL; } - - /* now free samples */ - for(sample= samples->first; sample; sample= sample->id.next) - sound_free_sample(sample); - BLI_freelistN(samples); - -} - -void sound_set_packedfile(bSample *sample, PackedFile *pf) -{ - bSound *sound; - - if (sample) { - sample->packedfile = pf; - sound = G.main->sound.first; - while (sound) { - if (sound->sample == sample) { - sound->newpackedfile = pf; - if (pf == NULL) { - strcpy(sound->name, sample->name); + + if(sound->snd_sound) + { + AUD_unload(sound->snd_sound); + sound->snd_sound = NULL; + } +} + +void sound_unlink(struct bContext *C, struct bSound* sound) +{ + bSound *snd; + Scene *scene; + SoundHandle *handle; + + for(snd = CTX_data_main(C)->sound.first; snd; snd = snd->id.next) + { + if(snd->child_sound == sound) + { + snd->child_sound = NULL; + if(snd->snd_sound) + { + AUD_unload(sound->snd_sound); + snd->snd_sound = NULL; + } + + sound_unlink(C, snd); + } + } + + for(scene = CTX_data_main(C)->scene.first; scene; scene = scene->id.next) + { + for(handle = scene->sound_handles.first; handle; handle = handle->next) + { + if(handle->source == sound) + { + handle->source = NULL; + if(handle->handle) + AUD_stop(handle->handle); + } + } + } +} + +struct SoundHandle* sound_new_handle(struct Scene *scene, struct bSound* sound, int startframe, int endframe, int frameskip) +{ + ListBase* handles = &scene->sound_handles; + + SoundHandle* handle = MEM_callocN(sizeof(SoundHandle), "sound_handle"); + handle->source = sound; + handle->startframe = startframe; + handle->endframe = endframe; + handle->frameskip = frameskip; + handle->state = AUD_STATUS_INVALID; + handle->volume = 1.0f; + + BLI_addtail(handles, handle); + + return handle; +} + +void sound_delete_handle(struct Scene *scene, struct SoundHandle *handle) +{ + if(handle == NULL) + return; + + if(handle->handle) + AUD_stop(handle->handle); + + BLI_freelinkN(&scene->sound_handles, handle); +} + +void sound_stop_all(struct bContext *C) +{ + SoundHandle *handle; + + for(handle = CTX_data_scene(C)->sound_handles.first; handle; handle = handle->next) + { + if(handle->state == AUD_STATUS_PLAYING) + { + AUD_pause(handle->handle); + handle->state = AUD_STATUS_PAUSED; + } + } +} + +#define SOUND_PLAYBACK_LAMBDA 1.0 + +void sound_update_playing(struct bContext *C) +{ + SoundHandle *handle; + Scene* scene = CTX_data_scene(C); + int cfra = CFRA; + float fps = FPS; + int action; + + AUD_lock(); + + for(handle = scene->sound_handles.first; handle; handle = handle->next) + { + if(cfra < handle->startframe || cfra >= handle->endframe || handle->mute) + { + if(handle->state == AUD_STATUS_PLAYING) + { + AUD_pause(handle->handle); + handle->state = AUD_STATUS_PAUSED; + } + } + else + { + action = 0; + + if(handle->changed != handle->source->changed) + { + handle->changed = handle->source->changed; + action = 3; + if(handle->state != AUD_STATUS_INVALID) + { + AUD_stop(handle->handle); + handle->state = AUD_STATUS_INVALID; + } + } + else + { + if(handle->state != AUD_STATUS_PLAYING) + action = 3; + else + { + handle->state = AUD_getStatus(handle->handle); + if(handle->state != AUD_STATUS_PLAYING) + action = 3; + else + { + float diff = AUD_getPosition(handle->handle) - (cfra - handle->startframe) / fps; +// AUD_XXX float diff = AUD_getPosition(handle->handle) * fps - cfra + handle->startframe + if(diff < 0.0) + diff = -diff; + if(diff > SOUND_PLAYBACK_LAMBDA) +// AUD_XXX if(diff > 5.0f) + { + action = 2; + } + } + } + } + + if(action & 1) + { + if(handle->state == AUD_STATUS_INVALID) + { + if(handle->source && handle->source->snd_sound) + { + AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->snd_sound, handle->frameskip / fps, (handle->frameskip + handle->endframe - handle->startframe)/fps); + handle->handle = AUD_play(limiter, 1); + AUD_unload(limiter); + if(handle->handle) + handle->state = AUD_STATUS_PLAYING; + if(cfra == handle->startframe) + action &= ~2; + } } + else + if(AUD_resume(handle->handle)) + handle->state = AUD_STATUS_PLAYING; + else + handle->state = AUD_STATUS_INVALID; } - sound = sound->id.next; + + if(action & 2) + AUD_seek(handle->handle, (cfra - handle->startframe) / fps); } } + + AUD_unlock(); } -PackedFile* sound_find_packedfile(bSound *sound) -{ - bSound *search; - PackedFile *pf = NULL; - char soundname[FILE_MAXDIR + FILE_MAXFILE], searchname[FILE_MAXDIR + FILE_MAXFILE]; - - // convert sound->name to abolute filename - strcpy(soundname, sound->name); - BLI_convertstringcode(soundname, G.sce); - - search = G.main->sound.first; - while (search) { - if (search->sample && search->sample->packedfile) { - strcpy(searchname, search->sample->name); - BLI_convertstringcode(searchname, G.sce); - - if (BLI_streq(searchname, soundname)) { - pf = search->sample->packedfile; - break; +void sound_scrub(struct bContext *C) +{ + SoundHandle *handle; + Scene* scene = CTX_data_scene(C); + int cfra = CFRA; + float fps = FPS; + + if(scene->audio.flag & AUDIO_SCRUB && !CTX_wm_screen(C)->animtimer) + { + AUD_lock(); + + for(handle = scene->sound_handles.first; handle; handle = handle->next) + { + if(cfra >= handle->startframe && cfra < handle->endframe && !handle->mute) + { + if(handle->source && handle->source->snd_sound) + { + int frameskip = handle->frameskip + cfra - handle->startframe; + AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->snd_sound, frameskip / fps, (frameskip + 1)/fps); + AUD_play(limiter, 0); + AUD_unload(limiter); + } } - } - - if (search->newpackedfile) { - strcpy(searchname, search->name); - BLI_convertstringcode(searchname, G.sce); - if (BLI_streq(searchname, soundname)) { - pf = search->newpackedfile; - break; + } + + AUD_unlock(); + } +} + +AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int end) +{ + AUD_Device* mixdown = AUD_openReadDevice(specs); + SoundHandle *handle; + float fps = FPS; + AUD_Sound *limiter, *delayer; + int frameskip, s, e; + + end++; + + for(handle = scene->sound_handles.first; handle; handle = handle->next) + { + if(start < handle->endframe && end > handle->startframe && !handle->mute && handle->source && handle->source->snd_sound) + { + frameskip = handle->frameskip; + s = handle->startframe - start; + e = handle->frameskip + AUD_MIN(handle->endframe, end) - handle->startframe; + + if(s < 0) + { + frameskip -= s; + s = 0; } + + limiter = AUD_limitSound(handle->source->snd_sound, frameskip / fps, e / fps); + delayer = AUD_delaySound(limiter, s / fps); + + AUD_playDevice(mixdown, delayer); + + AUD_unload(delayer); + AUD_unload(limiter); } - search = search->id.next; } - - return (pf); + + return mixdown; } diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index cfbe3f629d6..7c58a4f9499 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -127,7 +127,7 @@ void makeavistring (RenderData *rd, char *string) } } -void start_avi(RenderData *rd, int rectx, int recty) +void start_avi(struct Scene *scene, RenderData *rd, int rectx, int recty) { int x, y; char name[256]; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 5e3c8024524..e7164dc4794 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -65,6 +65,10 @@ #include "DNA_scene_types.h" +#include "AUD_C-API.h" +#include "BKE_sound.h" +#include "BKE_main.h" + #ifdef HAVE_CONFIG_H #include #endif @@ -96,6 +100,8 @@ static int audio_input_frame_size = 0; static uint8_t* audio_output_buffer = 0; static int audio_outbuf_size = 0; +static AUD_Device* audio_mixdown_device = 0; + #define FFMPEG_AUTOSPLIT_SIZE 2000000000 /* Delete a picture buffer */ @@ -127,9 +133,8 @@ static int write_audio_frame(void) c = get_codec_from_stream(audio_stream); - //XXX audiostream_fill(audio_input_buffer, - // audio_input_frame_size - // * sizeof(short) * c->channels); + if(audio_mixdown_device) + AUD_readDevice(audio_mixdown_device, audio_input_buffer, audio_input_frame_size); av_init_packet(&pkt); @@ -827,11 +832,21 @@ static void makeffmpegstring(RenderData* rd, char* string) { } -void start_ffmpeg(RenderData *rd, int rectx, int recty) +void start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty) { ffmpeg_autosplit_count = 0; start_ffmpeg_impl(rd, rectx, recty); + + if(ffmpeg_multiplex_audio && audio_stream) + { + AVCodecContext* c = get_codec_from_stream(audio_stream); + AUD_Specs specs; + specs.channels = c->channels; + specs.format = AUD_FORMAT_S16; + specs.rate = rd->audio.mixrate; + audio_mixdown_device = sound_mixdown(scene, specs, rd->sfra, rd->efra); + } } void end_ffmpeg(void); @@ -884,6 +899,12 @@ void end_ffmpeg(void) if (audio_stream && video_stream) { write_audio_frames(); } + + if(audio_mixdown_device) + { + AUD_closeReadDevice(audio_mixdown_device); + audio_mixdown_device = 0; + } if (outfile) { av_write_trailer(outfile); diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index 2d3a2e6b883..0780cd0dc48 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -101,7 +101,7 @@ static int closesocket(int fd) } #endif -void start_frameserver(RenderData *rd, int rectx, int recty) +void start_frameserver(struct Scene *scene, RenderData *rd, int rectx, int recty) { struct sockaddr_in addr; int arg = 1; diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index 85a95fa6e66..6c89afe7173 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -51,7 +51,7 @@ /* for sequence */ //XXX #include "BSE_sequence.h" //XXX define below from BSE_sequence.h - otherwise potentially odd behaviour -#define SEQ_HAS_PATH(seq) (seq->type==SEQ_MOVIE || seq->type==SEQ_HD_SOUND || seq->type==SEQ_RAM_SOUND || seq->type==SEQ_IMAGE) +#define SEQ_HAS_PATH(seq) (seq->type==SEQ_MOVIE || seq->type==SEQ_IMAGE) /* path/file handeling stuff */ #ifndef WIN32 diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index d87cd052454..7f414f8c0f6 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -149,6 +149,8 @@ #include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND #include "BKE_idprop.h" +#include "BKE_sound.h" + //XXX #include "BIF_butspace.h" // badlevel, for do_versions, patching event codes //XXX #include "BIF_filelist.h" // badlevel too, where to move this? - elubie //XXX #include "BIF_previewrender.h" // bedlelvel, for struct RenderInfo @@ -4052,14 +4054,16 @@ static void lib_link_scene(FileData *fd, Main *main) if(seq->ipo) seq->ipo= newlibadr_us(fd, sce->id.lib, seq->ipo); if(seq->scene) seq->scene= newlibadr(fd, sce->id.lib, seq->scene); 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->flags |= SOUND_FLAGS_SEQUENCE; + seq->sound_handle= sound_new_handle(sce, seq->sound, seq->startdisp, seq->enddisp, seq->startofs); } } seq->anim= 0; - seq->hdaudio = 0; } SEQ_END @@ -4103,7 +4107,9 @@ static void direct_link_scene(FileData *fd, Scene *sce) sce->theDag = NULL; sce->dagisvalid = 0; sce->obedit= NULL; - + + memset(&sce->sound_handles, 0, sizeof(sce->sound_handles)); + /* set users to one by default, not in lib-link, this will increase it for compo nodes */ sce->id.us= 1; @@ -5041,6 +5047,8 @@ static void lib_link_sound(FileData *fd, Main *main) sound->id.flag -= LIB_NEEDLINK; sound->ipo= newlibadr_us(fd, sound->id.lib, sound->ipo); // XXX depreceated - old animation system sound->stream = 0; + + sound_load(sound); } sound= sound->id.next; } @@ -9186,7 +9194,67 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Object *ob; PTCacheID *pid; ListBase pidlist; - + + bSound *sound; + Sequence *seq; + bActuator *act; + + for(sound = main->sound.first; sound; sound = sound->id.next) + { + if(sound->newpackedfile) + { + sound->packedfile = sound->newpackedfile; + sound->newpackedfile = NULL; + } + } + + 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; + if(sAct->sound) + { + sound = newlibadr(fd, lib, sAct->sound); + sAct->flag = sound->flags | SOUND_FLAGS_3D ? ACT_SND_3D_SOUND : 0; + sAct->pitch = sound->pitch; + sAct->volume = sound->volume; + sAct->sound3D.reference_distance = sound->distance; + sAct->sound3D.max_gain = sound->max_gain; + sAct->sound3D.min_gain = sound->min_gain; + sAct->sound3D.rolloff_factor = sound->attenuation; + } + else + { + sAct->sound3D.reference_distance = 1.0f; + 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); @@ -9504,7 +9572,17 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) // XXX bfd->user->uifonts.first= bfd->user->uifonts.last= NULL; bfd->user->uistyles.first= bfd->user->uistyles.last= NULL; - + + // AUD_XXX + if(bfd->user->audiochannels == 0) + bfd->user->audiochannels = 2; + if(bfd->user->audiodevice == 0) + bfd->user->audiodevice = 1; + if(bfd->user->audioformat == 0) + bfd->user->audioformat = 0x12; + if(bfd->user->audiorate == 0) + bfd->user->audiorate = 44100; + bhead = blo_nextbhead(fd, bhead); /* read all attached data */ diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 05ea60b50df..868dafdb98a 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2137,45 +2137,21 @@ static void write_texts(WriteData *wd, ListBase *idbase) static void write_sounds(WriteData *wd, ListBase *idbase) { bSound *sound; - bSample *sample; PackedFile * pf; - // set all samples to unsaved status - - sample = samples->first; // samples is a global defined in sound.c - while (sample) { - sample->flags |= SAMPLE_NEEDS_SAVE; - sample = sample->id.next; - } - sound= idbase->first; while(sound) { if(sound->id.us>0 || wd->current) { - // do we need to save the packedfile as well ? - sample = sound->sample; - if (sample) { - if (sample->flags & SAMPLE_NEEDS_SAVE) { - sound->newpackedfile = sample->packedfile; - sample->flags &= ~SAMPLE_NEEDS_SAVE; - } else { - sound->newpackedfile = NULL; - } - } - /* write LibData */ writestruct(wd, ID_SO, "bSound", 1, sound); if (sound->id.properties) IDP_WriteProperty(sound->id.properties, wd); - if (sound->newpackedfile) { - pf = sound->newpackedfile; + if (sound->packedfile) { + pf = sound->packedfile; writestruct(wd, DATA, "PackedFile", 1, pf); writedata(wd, DATA, pf->size, pf->data); } - - if (sample) { - sound->newpackedfile = sample->packedfile; - } } sound= sound->id.next; } diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index 28cfcb3ff6e..fdee568c350 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -36,6 +36,7 @@ SET(INC ../windowmanager ../../kernel/gen_system ../../../intern/SoundSystem ../readstreamglue ../quicktime ../../../intern/elbeem/extern ../../../intern/ghost ../../../intern/opennl/extern ../../../extern/glew/include ../../../intern/smoke/extern + ../../../intern/audaspace ../nodes ../gpu ../blenfont diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 9c039693b72..ffa44e60d00 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -56,6 +56,8 @@ #include "ED_markers.h" #include "ED_screen.h" +#include "BKE_sound.h" + /* ********************** frame change operator ***************************/ /* Set any flags that are necessary to indicate modal time-changing operation */ @@ -91,6 +93,8 @@ static void change_frame_apply(bContext *C, wmOperator *op) if (cfra < MINAFRAME) cfra= MINAFRAME; CFRA= cfra; + sound_scrub(C); + WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); } @@ -121,6 +125,7 @@ static int change_frame_exec(bContext *C, wmOperator *op) change_frame_apply(C, op); change_frame_exit(C, op); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index f04e4c5b347..f882a25c363 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -56,6 +56,7 @@ #include "BKE_report.h" #include "BKE_screen.h" #include "BKE_utildefines.h" +#include "BKE_sound.h" #include "WM_api.h" #include "WM_types.h" @@ -2277,7 +2278,9 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) /* since we follow drawflags, we can't send notifier but tag regions ourselves */ ED_update_for_newframe(C, 1); - + + sound_update_playing(C); + for(sa= screen->areabase.first; sa; sa= sa->next) { ARegion *ar; for(ar= sa->regionbase.first; ar; ar= ar->next) { @@ -2322,6 +2325,7 @@ static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event) if(screen->animtimer) { ED_screen_animation_timer(C, 0, 0); + sound_stop_all(C); } else { ScrArea *sa= CTX_wm_area(C); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 2ae2712d02d..5ae1bdf84aa 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -228,7 +228,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update) rd.frs_sec_base= 1.0f; if(BKE_imtype_is_movie(rd.imtype)) - mh->start_movie(&rd, sj->dumpsx, sj->dumpsy); + mh->start_movie(sj->scene, &rd, sj->dumpsx, sj->dumpsy); else mh= NULL; diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 7ebc8c4338f..538c1e4fce7 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -840,7 +840,16 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime) || BLI_testextensie(file->relname, ".mv")) { file->flags |= MOVIEFILE; } - else if(BLI_testextensie(file->relname, ".wav")) { + else if(BLI_testextensie(file->relname, ".wav") + || BLI_testextensie(file->relname, ".ogg") + || BLI_testextensie(file->relname, ".oga") + || BLI_testextensie(file->relname, ".mp3") + || BLI_testextensie(file->relname, ".mp2") + || BLI_testextensie(file->relname, ".ac3") + || BLI_testextensie(file->relname, ".aac") + || BLI_testextensie(file->relname, ".flac") + || BLI_testextensie(file->relname, ".wma") + || BLI_testextensie(file->relname, ".eac3")) { file->flags |= SOUNDFILE; } } else { // no quicktime @@ -875,7 +884,16 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime) || BLI_testextensie(file->relname, ".mv")) { file->flags |= MOVIEFILE; } - else if(BLI_testextensie(file->relname, ".wav")) { + else if(BLI_testextensie(file->relname, ".wav") + || BLI_testextensie(file->relname, ".ogg") + || BLI_testextensie(file->relname, ".oga") + || BLI_testextensie(file->relname, ".mp3") + || BLI_testextensie(file->relname, ".mp2") + || BLI_testextensie(file->relname, ".ac3") + || BLI_testextensie(file->relname, ".aac") + || BLI_testextensie(file->relname, ".flac") + || BLI_testextensie(file->relname, ".wma") + || BLI_testextensie(file->relname, ".eac3")) { file->flags |= SOUNDFILE; } } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 274f5f47e43..96f491c9a8a 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -1984,11 +1984,14 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh } case ACT_SOUND: { - ysize = 70; - sa = act->data; sa->sndnr = 0; + if(sa->flag & ACT_SND_3D_SOUND) + ysize = 114; + else + ysize = 92; + wval = (width-20)/2; glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); @@ -2003,8 +2006,14 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh char dummy_str[] = "Sound mode %t|Play Stop %x0|Play End %x1|Loop Stop %x2|Loop End %x3|Loop Ping Pong Stop %x5|Loop Ping Pong %x4"; uiDefBut(block, TEX, B_IDNAME, "SO:",xco+30,yco-22,width-40,19, sa->sound->id.name+2, 0.0, 21.0, 0, 0, ""); uiDefButS(block, MENU, 1, dummy_str,xco+10,yco-44,width-20, 19, &sa->type, 0.0, 0.0, 0, 0, ""); - uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-66,wval, 19, &sa->sound->volume, 0.0, 1.0, 0, 0, "Sets the volume of this sound"); - uiDefButF(block, NUM, 0, "Pitch:",xco+wval+10,yco-66,wval, 19, &sa->sound->pitch,-12.0, 12.0, 0, 0, "Sets the pitch of this sound"); + uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-66,wval, 19, &sa->volume, 0.0, 1.0, 0, 0, "Sets the volume of this sound"); + uiDefButF(block, NUM, 0, "Pitch:",xco+wval+10,yco-66,wval, 19, &sa->pitch,-12.0, 12.0, 0, 0, "Sets the pitch of this sound"); + uiDefButS(block, TOG | BIT, 0, "3D Sound", xco+10, yco-88, width-20, 19, &sa->flag, 0.0, 1.0, 0.0, 0.0, "Plays the sound positioned in 3D space."); + if(sa->flag & ACT_SND_3D_SOUND) + { + uiDefButF(block, NUM, 0, "Rolloff: ", xco+10, yco-110, wval, 19, &sa->sound3D.rolloff_factor, 0.0, 5.0, 0.0, 0.0, "The rolloff factor defines the influence factor on volume depending on distance."); + uiDefButF(block, NUM, 0, "Reference distance: ", xco+wval+10, yco-110, wval, 19, &sa->sound3D.reference_distance, 0.0, 1000.0, 0.0, 0.0, "The reference distance is the distance where the sound has a gain of 1.0."); + } } MEM_freeN(str); } diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 84dea679767..51cc8507ff8 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -4178,13 +4178,13 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen case TSE_POSEGRP_BASE: UI_icon_draw(x, y, ICON_VERTEXSEL); break; case TSE_SEQUENCE: - if((te->idcode==SEQ_MOVIE) || (te->idcode==SEQ_MOVIE_AND_HD_SOUND)) + if(te->idcode==SEQ_MOVIE) UI_icon_draw(x, y, ICON_SEQUENCE); else if(te->idcode==SEQ_META) UI_icon_draw(x, y, ICON_DOT); else if(te->idcode==SEQ_SCENE) UI_icon_draw(x, y, ICON_SCENE); - else if((te->idcode==SEQ_RAM_SOUND) || (te->idcode==SEQ_HD_SOUND)) + else if(te->idcode==SEQ_SOUND) UI_icon_draw(x, y, ICON_SOUND); else if(te->idcode==SEQ_IMAGE) UI_icon_draw(x, y, ICON_IMAGE_COL); diff --git a/source/blender/editors/space_sequencer/SConscript b/source/blender/editors/space_sequencer/SConscript index ab51068a529..9e7ea185c25 100644 --- a/source/blender/editors/space_sequencer/SConscript +++ b/source/blender/editors/space_sequencer/SConscript @@ -6,5 +6,6 @@ sources = env.Glob('*.c') incs = '../include ../../blenlib ../../blenkernel ../../blenfont ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../makesrna' +incs += ' #/intern/audaspace' env.BlenderLib ( 'bf_editors_space_sequencer', sources, Split(incs), [], libtype=['core'], priority=[100] ) diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 99a13c8d9e0..5d58ea431a9 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -89,6 +89,9 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "BKE_sound.h" +#include "AUD_C-API.h" + /* own include */ #include "sequencer_intern.h" @@ -224,24 +227,80 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME-2, "Scene Name", "Scene name to add as a strip"); } +static Sequence* sequencer_add_sound_strip(bContext *C, wmOperator *op, int start_frame, int channel, char* filename) +{ + Scene *scene= CTX_data_scene(C); + Editing *ed= seq_give_editing(scene, TRUE); + + bSound *sound; + + Sequence *seq; /* generic strip vars */ + Strip *strip; + StripElem *se; + + AUD_SoundInfo info; + + sound = sound_new_file(CTX_data_main(C), filename); + + if (sound==NULL || sound->snd_sound == NULL) { + if(op) + BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); + return NULL; + } + + info = AUD_getInfo(sound->snd_sound); + + if (info.specs.format == AUD_FORMAT_INVALID) { + sound_delete(C, sound); + if(op) + BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); + return NULL; + } + + seq = alloc_sequence(ed->seqbasep, start_frame, channel); + + seq->type= SEQ_SOUND; + seq->sound= sound; + + /* basic defaults */ + seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); + strip->len = seq->len = (int) (info.length * FPS); + strip->us= 1; + + strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); + + BLI_split_dirfile_basic(filename, strip->dir, se->name); + + seq->sound_handle = sound_new_handle(scene, sound, start_frame, start_frame + strip->len, 0); + + calc_sequence_disp(seq); + sort_seq(scene); + + /* last active name */ + strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1); + + return seq; +} + /* add movie operator */ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, TRUE); - + struct anim *an; char filename[FILE_MAX]; - Sequence *seq; /* generic strip vars */ + Sequence *seq, *soundseq; /* generic strip vars */ Strip *strip; StripElem *se; - - int start_frame, channel; /* operator props */ - + + int start_frame, channel, sound; /* operator props */ + start_frame= RNA_int_get(op->ptr, "start_frame"); channel= RNA_int_get(op->ptr, "channel"); - + sound = RNA_boolean_get(op->ptr, "sound"); + RNA_string_get(op->ptr, "filename", filename); an = openanim(filename, IB_rect); @@ -271,10 +330,19 @@ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) calc_sequence_disp(seq); sort_seq(scene); + if(sound) + { + soundseq = sequencer_add_sound_strip(C, NULL, start_frame, channel+1, filename); + if(soundseq != NULL) + RNA_string_get(op->ptr, "name", soundseq->name); + } + if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); set_last_seq(scene, seq); seq->flag |= SELECT; + if(soundseq) + soundseq->flag |= SELECT; } ED_area_tag_redraw(CTX_wm_area(C)); @@ -310,24 +378,15 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); - RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load hd sound with the movie"); // XXX need to impliment this + RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load sound with the movie"); } - /* add sound operator */ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Editing *ed= seq_give_editing(scene, TRUE); - - bSound *sound; - char filename[FILE_MAX]; - + Scene *scene= CTX_data_scene(C); Sequence *seq; /* generic strip vars */ - Strip *strip; - StripElem *se; - int start_frame, channel; /* operator props */ start_frame= RNA_int_get(op->ptr, "start_frame"); @@ -335,47 +394,16 @@ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filename", filename); - /* XXX if(sfile->flag & FILE_STRINGCODE) { - BLI_makestringcode(G.sce, str); - }*/ - -// XXX sound= sound_new_sound(filename); - sound= NULL; - - if (sound==NULL || sound->sample->type == SAMPLE_INVALID) { - BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); - return OPERATOR_CANCELLED; - } + seq = sequencer_add_sound_strip(C, op, start_frame, channel, filename); - if (sound==NULL || sound->sample->bits != 16) { - BKE_report(op->reports, RPT_ERROR, "Only 16 bit audio is supported"); + if(seq == NULL) return OPERATOR_CANCELLED; - } - - sound->flags |= SOUND_FLAGS_SEQUENCE; -// XXX audio_makestream(sound); - - seq = alloc_sequence(ed->seqbasep, start_frame, channel); - - seq->type= SEQ_RAM_SOUND; - seq->sound= sound; - - /* basic defaults */ - seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); - strip->len = seq->len = (int) ( ((float)(sound->streamlen-1) / ( (float)scene->r.audio.mixrate*4.0 ))* FPS); - strip->us= 1; - - strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - - BLI_split_dirfile_basic(filename, strip->dir, se->name); RNA_string_get(op->ptr, "name", seq->name); - - calc_sequence_disp(seq); - sort_seq(scene); - - /* last active name */ - strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1); + + if (RNA_boolean_get(op->ptr, "cache")) { + sound_cache(seq->sound, 0); + } if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); @@ -416,7 +444,7 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); - RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Load the sound as streaming audio"); // XXX need to impliment this + RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory."); } /* add image operator */ @@ -585,7 +613,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) if(seq->plugin==NULL) { BLI_remlink(ed->seqbasep, seq); - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); BKE_reportf(op->reports, RPT_ERROR, "Sequencer plugin \"%s\" could not load.", filename); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 3b90039335e..3d0d908d3f6 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -173,8 +173,7 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, char *col) case SEQ_PLUGIN: UI_GetThemeColor3ubv(TH_SEQ_PLUGIN, col); break; - case SEQ_HD_SOUND: - case SEQ_RAM_SOUND: + case SEQ_SOUND: UI_GetThemeColor3ubv(TH_SEQ_AUDIO, col); blendcol[0] = blendcol[1] = blendcol[2] = 128; if(seq->flag & SEQ_MUTE) UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20); @@ -546,11 +545,8 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float else sprintf(str, "%d | %s", seq->len, give_seqname(seq)); } - else if (seq->type == SEQ_RAM_SOUND) { - sprintf(str, "%d | %s", seq->len, seq->strip->stripdata->name); - } - else if (seq->type == SEQ_HD_SOUND) { - sprintf(str, "%d | %s", seq->len, seq->strip->stripdata->name); + else if (seq->type == SEQ_SOUND) { + sprintf(str, "%d | %s", seq->len, seq->sound->name); } else if (seq->type == SEQ_MOVIE) { sprintf(str, "%d | %s%s", seq->len, seq->strip->dir, seq->strip->stripdata->name); @@ -664,8 +660,9 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence * draw_shadedstrip(seq, background_col, x1, y1, x2, y2); /* draw additional info and controls */ - if (seq->type == SEQ_RAM_SOUND) - drawseqwave(scene, v2d, seq, x1, y1, x2, y2, ar->winx); +// XXX +/* if (seq->type == SEQ_SOUND) + drawseqwave(scene, v2d, seq, x1, y1, x2, y2, ar->winx);*/ if (!is_single_image) draw_seq_extensions(scene, sseq, seq); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 036c0769c1e..1555784f470 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -65,6 +65,7 @@ #include "BKE_scene.h" #include "BKE_utildefines.h" #include "BKE_report.h" +#include "BKE_sound.h" #include "WM_api.h" #include "WM_types.h" @@ -166,7 +167,7 @@ Sequence *get_foreground_frame_seq(Scene *scene, int frame) if(seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame) continue; /* only use elements you can see - not */ - if (ELEM6(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE, SEQ_MOVIE_AND_HD_SOUND, SEQ_COLOR)) { + if (ELEM5(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE, SEQ_COLOR)) { if (seq->machine > best_machine) { best_seq = seq; best_machine = seq->machine; @@ -563,7 +564,7 @@ static void reload_sound_strip(Scene *scene, char *name) calc_sequence(seqact); seq->strip= 0; - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); BLI_remlink(ed->seqbasep, seq); seq= ed->seqbasep->first; @@ -603,7 +604,7 @@ static void reload_image_strip(Scene *scene, char *name) calc_sequence(seqact); seq->strip= 0; - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); BLI_remlink(ed->seqbasep, seq); update_changed_seq_and_deps(scene, seqact, 1, 1); @@ -722,7 +723,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen for(seq=ed->seqbasep->first; seq; seq=seq->next) { if(seq->flag & SELECT) { - if (seq->type == SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND) { + if (seq->type == SEQ_SOUND) { *error_str= "Can't apply effects to audio sequence strips"; return 0; } @@ -849,7 +850,6 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq) static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short deleteall) { - Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq, *seqn; Sequence *last_seq = get_last_seq(scene); @@ -857,20 +857,20 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de while(seq) { seqn= seq->next; if((seq->flag & flag) || deleteall) { - if(seq->type==SEQ_RAM_SOUND && seq->sound) + if(seq->type==SEQ_SOUND && seq->sound) seq->sound->id.us--; BLI_remlink(lb, seq); if(seq==last_seq) set_last_seq(scene, NULL); if(seq->type==SEQ_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1); if(seq->ipo) seq->ipo->id.us--; - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); } seq= seqn; } } -static Sequence *dupli_seq(Sequence *seq) +static Sequence *dupli_seq(struct Scene *scene, Sequence *seq) { Sequence *seqn = MEM_dupallocN(seq); // XXX animato: ID *id; @@ -936,14 +936,13 @@ static Sequence *dupli_seq(Sequence *seq) seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); seqn->anim= 0; - } else if(seq->type == SEQ_RAM_SOUND) { - seqn->strip->stripdata = + } else if(seq->type == SEQ_SOUND) { + seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); + if(seq->sound_handle) + seqn->sound_handle = sound_new_handle(scene, seqn->sound, seq->sound_handle->startframe, seq->sound_handle->endframe, seq->sound_handle->frameskip); + seqn->sound->id.us++; - } else if(seq->type == SEQ_HD_SOUND) { - seqn->strip->stripdata = - MEM_dupallocN(seq->strip->stripdata); - seqn->hdaudio = 0; } else if(seq->type == SEQ_IMAGE) { seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); @@ -970,13 +969,13 @@ static Sequence *dupli_seq(Sequence *seq) return seqn; } -static Sequence * deep_dupli_seq(Sequence * seq) +static Sequence * deep_dupli_seq(struct Scene *scene, Sequence * seq) { - Sequence * seqn = dupli_seq(seq); + Sequence * seqn = dupli_seq(scene, seq); if (seq->type == SEQ_META) { Sequence * s; for(s= seq->seqbase.first; s; s = s->next) { - Sequence * n = deep_dupli_seq(s); + Sequence * n = deep_dupli_seq(scene, s); if (n) { BLI_addtail(&seqn->seqbase, n); } @@ -995,7 +994,7 @@ static void recurs_dupli_seq(Scene *scene, ListBase *old, ListBase *new) for(seq= old->first; seq; seq= seq->next) { seq->tmp= NULL; if(seq->flag & SELECT) { - seqn = dupli_seq(seq); + seqn = dupli_seq(scene, seq); if (seqn) { /*should never fail */ seq->flag &= SEQ_DESEL; seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL+SEQ_LOCK); @@ -1061,10 +1060,10 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) reload_sequence_new_file(scene, seq); calc_sequence(seq); - + if (!skip_dup) { /* Duplicate AFTER the first change */ - seqn = deep_dupli_seq(seq); + seqn = deep_dupli_seq(scene, seq); } if (seqn) { @@ -1150,10 +1149,10 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence * seq, int cutframe) } calc_sequence(seq); - + if (!skip_dup) { /* Duplicate AFTER the first change */ - seqn = deep_dupli_seq(seq); + seqn = deep_dupli_seq(scene, seq); } if (seqn) { @@ -1493,11 +1492,13 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op) if(selected){ /* mute unselected */ if (seq->flag & SELECT) { seq->flag |= SEQ_MUTE; + seq_update_sound(seq); } } else { if ((seq->flag & SELECT)==0) { seq->flag |= SEQ_MUTE; + seq_update_sound(seq); } } } @@ -1544,11 +1545,13 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) if(selected){ /* unmute unselected */ if (seq->flag & SELECT) { seq->flag &= ~SEQ_MUTE; + seq_update_sound(seq); } } else { if ((seq->flag & SELECT)==0) { seq->flag &= ~SEQ_MUTE; + seq_update_sound(seq); } } } @@ -2007,7 +2010,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) start_ofs += step; } - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); seq = seq->next; } else { seq = seq->next; @@ -2130,7 +2133,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) while(seq) { if(seq->flag & SELECT) { tot++; - if (seq->type == SEQ_RAM_SOUND) { + if (seq->type == SEQ_SOUND) { BKE_report(op->reports, RPT_ERROR, "Can't make Meta Strip from audio"); return OPERATOR_CANCELLED;; } @@ -2242,7 +2245,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *op) last_seq->seqbase.last= 0; BLI_remlink(ed->seqbasep, last_seq); - seq_free_sequence(ed, last_seq); + seq_free_sequence(scene, last_seq); /* emtpy meta strip, delete all effects depending on it */ for(seq=ed->seqbasep->first; seq; seq=seq->next) diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 335652235c6..dda5837e5f5 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -153,7 +153,7 @@ void select_single_seq(Scene *scene, Sequence *seq, int deselect_all) /* BRING B if(seq->strip) strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR-1); } - else if((seq->type==SEQ_HD_SOUND) || (seq->type==SEQ_RAM_SOUND)) { + else if(seq->type==SEQ_SOUND) { if(seq->strip) strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR-1); } @@ -336,7 +336,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR-1); } } else - if (seq->type == SEQ_HD_SOUND || seq->type == SEQ_RAM_SOUND) { + if (seq->type == SEQ_SOUND) { if(seq->strip) { strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR-1); } diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h index c3f668ff622..bbfd9cadf67 100644 --- a/source/blender/makesdna/DNA_actuator_types.h +++ b/source/blender/makesdna/DNA_actuator_types.h @@ -37,6 +37,9 @@ struct Scene; struct Group; struct Text; +// for Sound3D +#include "DNA_sound_types.h" + /* ****************** ACTUATORS ********************* */ /* unused now, moved to editobjectactuator in 2.02. Still needed for dna */ @@ -62,7 +65,9 @@ typedef struct bSoundActuator { short flag, sndnr; int sta, end; short pad1[2]; + float volume, pitch; struct bSound *sound; + struct Sound3D sound3D; short type, makecopy; short copymade, pad2[1]; } bSoundActuator; @@ -432,6 +437,9 @@ typedef struct FreeCamera { #define ACT_RANDOM_FLOAT_NORMAL 8 #define ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL 9 +/* SoundActuator->flag */ +#define ACT_SND_3D_SOUND 1 + /* SoundActuator->type */ #define ACT_SND_PLAY_STOP_SOUND 0 #define ACT_SND_PLAY_END_SOUND 1 diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 752f756401c..36cd0c6ffdf 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -662,6 +662,7 @@ typedef struct Scene { ListBase markers; ListBase transform_spaces; + ListBase sound_handles; /* none of the dependancy graph vars is mean to be saved */ struct DagForest *theDag; diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 422e1b07ed7..6d455d20f59 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -160,7 +160,7 @@ typedef struct Sequence { ListBase seqbase; /* list of strips for metastrips */ struct bSound *sound; /* the linked "bSound" object */ - struct hdaudio *hdaudio; /* external hdaudio object */ + struct SoundHandle *sound_handle; float level, pan; /* level in dB (0=full), pan -1..1 */ int scenenr; /* for scene selection */ float strobe; @@ -281,7 +281,7 @@ typedef struct SpeedControlVars { #define SEQ_MOVIE 3 #define SEQ_RAM_SOUND 4 #define SEQ_HD_SOUND 5 -#define SEQ_MOVIE_AND_HD_SOUND 6 /* helper for add_sequence */ +#define SEQ_SOUND 4 #define SEQ_EFFECT 8 #define SEQ_CROSS 8 diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h index 5dedd20e1e4..841aae099cc 100644 --- a/source/blender/makesdna/DNA_sound_types.h +++ b/source/blender/makesdna/DNA_sound_types.h @@ -64,18 +64,43 @@ typedef struct bSample { short us; } bSample; - +// runtime only - no saving +typedef struct SoundHandle { + struct SoundHandle *next, *prev; + struct bSound *source; + void *handle; + int state; + int startframe; + int endframe; + int frameskip; + int mute; + int changed; + float volume; + float pad; +} SoundHandle; + +typedef struct Sound3D +{ + float min_gain; + float max_gain; + float reference_distance; + float max_distance; + float rolloff_factor; + float cone_inner_angle; + float cone_outer_angle; + float cone_outer_gain; +} Sound3D; typedef struct bSound { ID id; char name[160]; - struct bSample *sample; - void *stream; + struct bSample *sample; // AUD_XXX deprecated + void *stream; // AUD_XXX deprecated struct PackedFile *packedfile; - struct PackedFile *newpackedfile; - void *snd_sound; - struct Ipo *ipo; - float volume, panning; + struct PackedFile *newpackedfile; // AUD_XXX deprecated + void *snd_sound; // AUD_XXX used for AUD_Sound now + struct Ipo *ipo; // AUD_XXX deprecated + float volume, panning; // AUD_XXX deprecated /** * Sets the rollofffactor. The rollofffactor is a per-Source parameter * the application can use to increase or decrease the range of a source @@ -84,27 +109,43 @@ typedef struct bSound { * value of 0, which indicates that the application does not wish any * distance attenuation on the respective Source. */ - float attenuation; - float pitch; + float attenuation; // AUD_XXX deprecated + float pitch; // AUD_XXX deprecated /** * min_gain indicates the minimal gain which is always guaranteed for this sound */ - float min_gain; + float min_gain; // AUD_XXX deprecated /** * max_gain indicates the maximal gain which is always guaranteed for this sound */ - float max_gain; + float max_gain; // AUD_XXX deprecated /** * Sets the referencedistance at which the listener will experience gain. */ - float distance; - int flags; - int streamlen; - char channels; - char highprio; - char pad[10]; + float distance; // AUD_XXX deprecated + int flags; // AUD_XXX deprecated + int streamlen; // AUD_XXX deprecated + char channels; // AUD_XXX deprecated + char highprio; // AUD_XXX deprecated + char pad[10]; // AUD_XXX deprecated + + // AUD_XXX NEW + int type; + int changed; + struct bSound *child_sound; + void *cache; + + // SOUND_TYPE_LIMITER + float start, end; } bSound; +typedef enum eSound_Type { + SOUND_TYPE_INVALID = -1, + SOUND_TYPE_FILE = 0, + SOUND_TYPE_BUFFER, + SOUND_TYPE_LIMITER +} eSound_Type; + typedef struct bSoundListener { ID id; /** diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index f61b4b2904d..4a317dfb369 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -293,6 +293,11 @@ typedef struct UserDef { short userpref, viewzoom; int mixbufsize; + int audiodevice; + int audiorate; + int audioformat; + int audiochannels; + int scrollback; /* console scrollback limit */ int dpi; /* range 48-128? */ short encoding; diff --git a/source/blender/makesrna/intern/rna_sequence.c b/source/blender/makesrna/intern/rna_sequence.c index 8ca023dc57c..fec91c64e4d 100644 --- a/source/blender/makesrna/intern/rna_sequence.c +++ b/source/blender/makesrna/intern/rna_sequence.c @@ -192,10 +192,8 @@ static StructRNA* rna_Sequence_refine(struct PointerRNA *ptr) case SEQ_SCENE: return &RNA_SceneSequence; case SEQ_MOVIE: - case SEQ_MOVIE_AND_HD_SOUND: return &RNA_MovieSequence; - case SEQ_RAM_SOUND: - case SEQ_HD_SOUND: + case SEQ_SOUND: return &RNA_SoundSequence; case SEQ_CROSS: case SEQ_ADD: @@ -362,9 +360,7 @@ static void rna_def_sequence(BlenderRNA *brna) {SEQ_META, "META", 0, "Meta", ""}, {SEQ_SCENE, "SCENE", 0, "Scene", ""}, {SEQ_MOVIE, "MOVIE", 0, "Movie", ""}, - {SEQ_RAM_SOUND, "RAM_SOUND", 0, "Ram Sound", ""}, - {SEQ_HD_SOUND, "HD_SOUND", 0, "HD Sound", ""}, - {SEQ_MOVIE_AND_HD_SOUND, "MOVIE_AND_HD_SOUND", 0, "Movie and HD Sound", ""}, + {SEQ_SOUND, "_SOUND", 0, "Sound", ""}, {SEQ_EFFECT, "REPLACE", 0, "Replace", ""}, {SEQ_CROSS, "CROSS", 0, "Cross", ""}, {SEQ_ADD, "ADD", 0, "Add", ""}, @@ -616,21 +612,6 @@ static void rna_def_filter_video(StructRNA *srna) RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); } -static void rna_def_filter_sound(StructRNA *srna) -{ - PropertyRNA *prop; - - prop= RNA_def_property(srna, "sound_gain", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "level"); - RNA_def_property_range(prop, -96.0f, 6.0f); - RNA_def_property_ui_text(prop, "Sound Gain", "Sound level in dB (0 = full volume)."); - - prop= RNA_def_property(srna, "sound_pan", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "pan"); - RNA_def_property_range(prop, -1.0f, 1.0f); - RNA_def_property_ui_text(prop, "Sound Pan", "Stereo sound balance."); -} - static void rna_def_proxy(StructRNA *srna) { PropertyRNA *prop; @@ -772,7 +753,6 @@ static void rna_def_sound(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "strip->dir"); RNA_def_property_ui_text(prop, "Directory", ""); - rna_def_filter_sound(srna); rna_def_input(srna); } diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c index 363a5595b43..9ca2a74bedd 100644 --- a/source/blender/makesrna/intern/rna_sound.c +++ b/source/blender/makesrna/intern/rna_sound.c @@ -149,71 +149,6 @@ static void rna_def_sound(BlenderRNA *brna) prop= RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "packedfile"); RNA_def_property_ui_text(prop, "Packed File", ""); - - /* game engine settings */ - prop= RNA_def_property(srna, "volume", PROP_FLOAT, PROP_UNSIGNED); - RNA_def_property_float_sdna(prop, NULL, "volume"); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 4); - RNA_def_property_ui_text(prop, "Volume", "Game engine only: volume for this sound."); - - prop= RNA_def_property(srna, "pitch", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "pitch"); - RNA_def_property_ui_range(prop, -12.0, 12.0, 10, 4); - RNA_def_property_ui_text(prop, "Pitch", "Game engine only: set the pitch of this sound."); - - prop= RNA_def_property(srna, "loop", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_LOOP); - RNA_def_property_ui_text(prop, "Sound Loop", "Game engine only: toggle between looping on/off."); - - prop= RNA_def_property(srna, "ping_pong", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_BIDIRECTIONAL_LOOP); - RNA_def_property_ui_text(prop, "Ping Pong", "Game engine only: Toggle between A->B and A->B->A looping."); - - prop= RNA_def_property(srna, "sound_3d", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_3D); - RNA_def_property_ui_text(prop, "3D Sound", "Game engine only: turns 3D sound on."); - - prop= RNA_def_property(srna, "attenuation", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "attenuation"); - RNA_def_property_range(prop, 0.0, 5.0); - RNA_def_property_ui_text(prop, "Attenuation", "Game engine only: sets the surround scaling factor for 3D sound."); - - /* gain */ - prop= RNA_def_property(srna, "min_gain", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "min_gain"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Min Gain", "Minimal gain which is always guaranteed for this sound."); - - prop= RNA_def_property(srna, "max_gain", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "max_gain"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Max Gain", "Maximal gain which is always guaranteed for this sound."); - - prop= RNA_def_property(srna, "reference_distance", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "distance"); - RNA_def_property_ui_text(prop, "Reference Distance", "Reference distance at which the listener will experience gain."); - RNA_def_property_ui_range(prop, 0.0, 1000.0, 10, 4); /* NOT used anywhere */ - - /* unused - prop= RNA_def_property(srna, "panning", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "panning"); - RNA_def_property_ui_range(prop, -1.0, 1.0, 10, 4); - RNA_def_property_ui_text(prop, "Panning", "Pan the sound from left to right"); */ - - /* unused - prop= RNA_def_property(srna, "fixed_volume", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_FIXED_VOLUME); - RNA_def_property_ui_text(prop, "Fixed Volume", "Constraint sound to fixed volume."); */ - - /* unused - prop= RNA_def_property(srna, "fixed_panning", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_FIXED_PANNING); - RNA_def_property_ui_text(prop, "Fixed Panning", "Constraint sound to fixed panning."); */ - - /* unused - prop= RNA_def_property(srna, "priority", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_PRIORITY); - RNA_def_property_ui_text(prop, "Priority", "Make sound higher priority."); */ } void RNA_def_sound(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index f1fd11a0094..8dcca446507 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -37,6 +37,8 @@ #include "BKE_utildefines.h" +#include "BKE_sound.h" + #ifdef RNA_RUNTIME static void rna_userdef_lmb_select_set(struct PointerRNA *ptr,int value) @@ -116,6 +118,11 @@ static PointerRNA rna_UserDef_system_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_UserPreferencesSystem, ptr->data); } +static void rna_UserDef_audio_update(bContext *C, PointerRNA *ptr) +{ + sound_reinit(C); +} + #else static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) @@ -1977,6 +1984,46 @@ static void rna_def_userdef_system(BlenderRNA *brna) {512, "AUDIO_SAMPLES_512", 0, "512", "Set audio mixing buffer size to 512 samples"}, {1024, "AUDIO_SAMPLES_1024", 0, "1024", "Set audio mixing buffer size to 1024 samples"}, {2048, "AUDIO_SAMPLES_2048", 0, "2048", "Set audio mixing buffer size to 2048 samples"}, + {4096, "AUDIO_SAMPLES_4096", 0, "4096", "Set audio mixing buffer size to 4096 samples"}, + {8192, "AUDIO_SAMPLES_8192", 0, "8192", "Set audio mixing buffer size to 8192 samples"}, + {16384, "AUDIO_SAMPLES_16384", 0, "16384", "Set audio mixing buffer size to 16384 samples"}, + {32768, "AUDIO_SAMPLES_32768", 0, "32768", "Set audio mixing buffer size to 32768 samples"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem audio_device_items[] = { + {0, "AUDIO_DEVICE_NULL", 0, "No Audio", "Null device - there will be no audio output."}, + {1, "AUDIO_DEVICE_SDL", 0, "SDL", "SDL device - simple direct media layer, recommended for sequencer usage."}, + {2, "AUDIO_DEVICE_OPENAL", 0, "OpenAL", "OpenAL device - supports 3D audio, recommended for game engine usage."}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem audio_rate_items[] = { +// {8000, "AUDIO_RATE_8000", 0, "8 kHz", "Set audio sampling rate to 8000 samples per second."}, +// {11025, "AUDIO_RATE_11025", 0, "11.025 kHz", "Set audio sampling rate to 11025 samples per second."}, +// {16000, "AUDIO_RATE_16000", 0, "16 kHz", "Set audio sampling rate to 16000 samples per second."}, +// {22050, "AUDIO_RATE_22050", 0, "22.05 kHz", "Set audio sampling rate to 22050 samples per second."}, +// {32000, "AUDIO_RATE_32000", 0, "32 kHz", "Set audio sampling rate to 32000 samples per second."}, + {44100, "AUDIO_RATE_44100", 0, "44.1 kHz", "Set audio sampling rate to 44100 samples per second."}, + {48000, "AUDIO_RATE_48000", 0, "48 kHz", "Set audio sampling rate to 48000 samples per second."}, +// {88200, "AUDIO_RATE_88200", 0, "88.2 kHz", "Set audio sampling rate to 88200 samples per second."}, + {96000, "AUDIO_RATE_96000", 0, "96 kHz", "Set audio sampling rate to 96000 samples per second."}, + {192000, "AUDIO_RATE_192000", 0, "192 kHz", "Set audio sampling rate to 192000 samples per second."}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem audio_format_items[] = { + {0x01, "AUDIO_FORMAT_U8", 0, "8-bit Unsigned", "Set audio sample format to 8 bit unsigned integer."}, + {0x12, "AUDIO_FORMAT_S16", 0, "16-bit Signed", "Set audio sample format to 16 bit signed integer."}, + {0x13, "AUDIO_FORMAT_S24", 0, "24-bit Signed", "Set audio sample format to 24 bit signed integer."}, + {0x14, "AUDIO_FORMAT_S32", 0, "32-bit Signed", "Set audio sample format to 32 bit signed integer."}, + {0x24, "AUDIO_FORMAT_FLOAT", 0, "32-bit Float", "Set audio sample format to 32 bit float."}, + {0x28, "AUDIO_FORMAT_DOUBLE", 0, "64-bit Float", "Set audio sample format to 64 bit float."}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem audio_channel_items[] = { + {1, "AUDIO_CHANNELS_MONO", 0, "Mono", "Set audio channels to mono."}, + {2, "AUDIO_CHANNELS_STEREO", 0, "Stereo", "Set audio channels to stereo."}, + {4, "AUDIO_CHANNELS_SURROUND4", 0, "4 Channels", "Set audio channels to 4 channels."}, + {6, "AUDIO_CHANNELS_SURROUND51", 0, "5.1 Surround", "Set audio channels to 5.1 surround sound."}, + {8, "AUDIO_CHANNELS_SURROUND71", 0, "7.1 Surround", "Set audio channels to 7.1 surround sound."}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem draw_method_items[] = { @@ -2078,6 +2125,31 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "mixbufsize"); RNA_def_property_enum_items(prop, audio_mixing_samples_items); RNA_def_property_ui_text(prop, "Audio Mixing Buffer", "Sets the number of samples used by the audio mixing buffer."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); + + prop= RNA_def_property(srna, "audio_device", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "audiodevice"); + RNA_def_property_enum_items(prop, audio_device_items); + RNA_def_property_ui_text(prop, "Audio Device", "Sets the audio output device."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); + + prop= RNA_def_property(srna, "audio_sample_rate", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "audiorate"); + RNA_def_property_enum_items(prop, audio_rate_items); + RNA_def_property_ui_text(prop, "Audio Sample Rate", "Sets the audio sample rate."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); + + prop= RNA_def_property(srna, "audio_sample_format", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "audioformat"); + RNA_def_property_enum_items(prop, audio_format_items); + RNA_def_property_ui_text(prop, "Audio Sample Format", "Sets the audio sample format."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); + + prop= RNA_def_property(srna, "audio_channels", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "audiochannels"); + RNA_def_property_enum_items(prop, audio_channel_items); + RNA_def_property_ui_text(prop, "Audio Channels", "Sets the audio channel count."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); #if 0 prop= RNA_def_property(srna, "verse_master", PROP_STRING, PROP_NONE); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 14df6b8ec9f..4744288f3a9 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2692,7 +2692,7 @@ void RE_BlenderAnim(Render *re, Scene *scene, int sfra, int efra, int tfra) re->result_ok= 0; if(BKE_imtype_is_movie(scene->r.imtype)) - mh->start_movie(&re->r, re->rectx, re->recty); + mh->start_movie(scene, &re->r, re->rectx, re->recty); if (mh->get_next_frame) { while (!(G.afbreek == 1)) { diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 7179efb186d..e4e585a33b6 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -90,7 +90,7 @@ #include "GPU_extensions.h" #include "GPU_draw.h" - +#include "BKE_sound.h" /* XXX */ static void sound_init_listener(void) @@ -156,6 +156,8 @@ void WM_init(bContext *C) read_Blog(); BLI_strncpy(G.lib, G.sce, FILE_MAX); + + sound_init(); } /* free strings of open recent files */ @@ -184,7 +186,9 @@ extern void free_posebuf(); void WM_exit(bContext *C) { wmWindow *win; - + + sound_exit(); + /* first wrap up running stuff, we assume only the active WM is running */ /* modal handlers are on window level freed, others too? */ /* note; same code copied in wm_files.c */ -- cgit v1.2.3