Blender  V2.93
sequencer/intern/sound.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  *
19  * - Blender Foundation, 2003-2009
20  * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
21  */
22 
27 #include <math.h>
28 
29 #include "DNA_scene_types.h"
30 #include "DNA_sequence_types.h"
31 #include "DNA_sound_types.h"
32 
33 #include "BLI_listbase.h"
34 
35 #include "BKE_main.h"
36 #include "BKE_scene.h"
37 #include "BKE_sound.h"
38 
39 #include "SEQ_sound.h"
40 #include "SEQ_time.h"
41 
42 #include "strip_time.h"
43 
44 /* Unlike _update_sound_ funcs, these ones take info from audaspace to update sequence length! */
45 #ifdef WITH_AUDASPACE
46 static bool sequencer_refresh_sound_length_recursive(Main *bmain, Scene *scene, ListBase *seqbase)
47 {
48  Sequence *seq;
49  bool changed = false;
50 
51  for (seq = seqbase->first; seq; seq = seq->next) {
52  if (seq->type == SEQ_TYPE_META) {
53  if (sequencer_refresh_sound_length_recursive(bmain, scene, &seq->seqbase)) {
55  changed = true;
56  }
57  }
58  else if (seq->type == SEQ_TYPE_SOUND_RAM && seq->sound) {
59  const float length = BKE_sound_get_length(bmain, seq->sound);
60  int old = seq->len;
61  float fac;
62 
63  seq->len = (int)ceil((double)length * FPS);
64  fac = (float)seq->len / (float)old;
65  old = seq->startofs;
66  seq->startofs *= fac;
67  seq->endofs *= fac;
68  seq->start += (old - seq->startofs); /* So that visual/"real" start frame does not change! */
69 
71  changed = true;
72  }
73  }
74  return changed;
75 }
76 #endif
77 
79 {
80 #ifdef WITH_AUDASPACE
81  if (scene->ed) {
82  sequencer_refresh_sound_length_recursive(bmain, scene, &scene->ed->seqbase);
83  }
84 #else
85  UNUSED_VARS(bmain, scene);
86 #endif
87 }
88 
90 {
91  Editing *ed = scene->ed;
92 
93  if (ed) {
94  Sequence *seq;
95 
96  for (seq = ed->seqbase.first; seq; seq = seq->next) {
97  if (seq->type == SEQ_TYPE_META) {
99  }
100  else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
102  }
103  }
104  }
105 }
106 
108 {
109  if (seq->type == SEQ_TYPE_SCENE) {
110  if (seq->scene && seq->scene_sound) {
111  /* We have to take into account start frame of the sequence's scene! */
112  int startofs = seq->startofs + seq->anim_startofs + seq->scene->r.sfra;
113 
115  scene, seq->scene_sound, seq->startdisp, seq->enddisp, startofs, 0.0);
116  }
117  }
118  else {
120  }
121  /* mute is set in seq_update_muting_recursive */
122 }
123 
124 static void seq_update_sound_recursive(Scene *scene, ListBase *seqbasep, bSound *sound)
125 {
126  Sequence *seq;
127 
128  for (seq = seqbasep->first; seq; seq = seq->next) {
129  if (seq->type == SEQ_TYPE_META) {
131  }
132  else if (seq->type == SEQ_TYPE_SOUND_RAM) {
133  if (seq->scene_sound && sound == seq->sound) {
135  }
136  }
137  }
138 }
139 
141 {
142  if (scene->ed) {
144  }
145 }
typedef float(TangentPoint)[2]
float BKE_sound_get_length(struct Main *bmain, struct bSound *sound)
void BKE_sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence)
void BKE_sound_move_scene_sound(struct Scene *scene, void *handle, int startframe, int endframe, int frameskip, double audio_offset)
void BKE_sound_update_scene_sound(void *handle, struct bSound *sound)
#define UNUSED_VARS(...)
#define ELEM(...)
#define FPS
@ SEQ_TYPE_SOUND_RAM
@ SEQ_TYPE_META
@ SEQ_TYPE_SCENE
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
Definition: btQuaternion.h:895
Scene scene
static void seq_update_sound_recursive(Scene *scene, ListBase *seqbasep, bSound *sound)
void SEQ_sound_update_bounds_all(Scene *scene)
void SEQ_sound_update(Scene *scene, bSound *sound)
void SEQ_sound_update_bounds(Scene *scene, Sequence *seq)
void SEQ_sound_update_length(Main *bmain, Scene *scene)
void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq)
Definition: strip_time.c:144
void SEQ_time_update_sequence(Scene *scene, Sequence *seq)
Definition: strip_time.c:197
ListBase seqbase
void * first
Definition: DNA_listBase.h:47
Definition: BKE_main.h:116
struct Editing * ed
struct RenderData r
struct Scene * scene
void * scene_sound
ListBase seqbase
struct bSound * sound
struct Sequence * next
ccl_device_inline float3 ceil(const float3 &a)