[Bf-blender-cvs] [6ecdd045c71] temp-vse-retiming-tool: Implement constant range pitch definition and audaspace seek fix
Richard Antalik
noreply at git.blender.org
Mon Nov 14 16:58:20 CET 2022
Commit: 6ecdd045c71915fbb89da4d11bbe1455d854f3c5
Author: Richard Antalik
Date: Thu Oct 20 22:14:53 2022 +0200
Branches: temp-vse-retiming-tool
https://developer.blender.org/rB6ecdd045c71915fbb89da4d11bbe1455d854f3c5
Implement constant range pitch definition and audaspace seek fix
===================================================================
M extern/audaspace/bindings/C/AUD_Sequence.cpp
M extern/audaspace/bindings/C/AUD_Sequence.h
M extern/audaspace/include/sequence/AnimateableProperty.h
M extern/audaspace/include/sequence/SequenceEntry.h
M extern/audaspace/src/sequence/AnimateableProperty.cpp
M extern/audaspace/src/sequence/SequenceData.cpp
M extern/audaspace/src/sequence/SequenceEntry.cpp
M extern/audaspace/src/sequence/SequenceHandle.cpp
M source/blender/blenkernel/BKE_sound.h
M source/blender/blenkernel/intern/sound.c
M source/blender/sequencer/intern/sequencer.c
M source/blender/sequencer/intern/strip_retiming.cc
===================================================================
diff --git a/extern/audaspace/bindings/C/AUD_Sequence.cpp b/extern/audaspace/bindings/C/AUD_Sequence.cpp
index e3f88629657..93e4558c7b7 100644
--- a/extern/audaspace/bindings/C/AUD_Sequence.cpp
+++ b/extern/audaspace/bindings/C/AUD_Sequence.cpp
@@ -165,6 +165,12 @@ AUD_API void AUD_SequenceEntry_move(AUD_SequenceEntry* entry, double begin, doub
(*entry)->move(begin, end, skip);
}
+AUD_API void AUD_SequenceEntry_setAnimationData_constant_range(AUD_SequenceEntry* entry, AUD_AnimateablePropertyType type, int frame_start, int frame_end, float* data)
+{
+ AnimateableProperty* prop = (*entry)->getAnimProperty(static_cast<AnimateablePropertyType>(type));
+ prop->write_range(data, frame_start, frame_end);
+}
+
AUD_API void AUD_SequenceEntry_setAnimationData(AUD_SequenceEntry* entry, AUD_AnimateablePropertyType type, int frame, float* data, char animated)
{
AnimateableProperty* prop = (*entry)->getAnimProperty(static_cast<AnimateablePropertyType>(type));
diff --git a/extern/audaspace/bindings/C/AUD_Sequence.h b/extern/audaspace/bindings/C/AUD_Sequence.h
index bdf1a61a2de..ee97c6081f3 100644
--- a/extern/audaspace/bindings/C/AUD_Sequence.h
+++ b/extern/audaspace/bindings/C/AUD_Sequence.h
@@ -169,6 +169,16 @@ extern AUD_API void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float valu
*/
extern AUD_API void AUD_SequenceEntry_move(AUD_SequenceEntry* entry, double begin, double end, double skip);
+/**
+ * Writes animation data to a sequenced entry.
+ * \param entry The sequenced entry.
+ * \param type The type of animation data.
+ * \param frame The frame this data is for.
+ * \param data The data to write.
+ * \param animated Whether the attribute is animated.
+ */
+AUD_API void AUD_SequenceEntry_setAnimationData_constant_range(AUD_SequenceEntry* entry, AUD_AnimateablePropertyType type, int frame_start, int frame_end, float* data);
+
/**
* Writes animation data to a sequenced entry.
* \param entry The sequenced entry.
diff --git a/extern/audaspace/include/sequence/AnimateableProperty.h b/extern/audaspace/include/sequence/AnimateableProperty.h
index 2c3fcf23f8b..76cb5ecd3f9 100644
--- a/extern/audaspace/include/sequence/AnimateableProperty.h
+++ b/extern/audaspace/include/sequence/AnimateableProperty.h
@@ -112,6 +112,14 @@ public:
*/
void write(const float* data, int position, int count);
+ /**
+ * Fills the properties frame range with constant value and marks it animated.
+ * \param data The new value.
+ * \param position The start position in the animation in frames.
+ * \param position The end position in the animation in frames.
+ */
+ void write_range(const float* data, int position_start, int position_end);
+
/**
* Reads the properties value.
* \param position The position in the animation in frames.
diff --git a/extern/audaspace/include/sequence/SequenceEntry.h b/extern/audaspace/include/sequence/SequenceEntry.h
index b8e9f116ee4..2495d08137c 100644
--- a/extern/audaspace/include/sequence/SequenceEntry.h
+++ b/extern/audaspace/include/sequence/SequenceEntry.h
@@ -63,6 +63,9 @@ private:
/// How many seconds are skipped at the beginning.
double m_skip;
+ /// The FPS of the scene.
+ float m_fps;
+
/// Whether the entry is muted.
bool m_muted;
@@ -124,7 +127,7 @@ public:
* \param skip How much seconds should be skipped at the beginning.
* \param id The ID of the entry.
*/
- SequenceEntry(std::shared_ptr<ISound> sound, double begin, double end, double skip, int id);
+ SequenceEntry(std::shared_ptr<ISound> sound, double begin, double end, double skip, float fps, int id);
virtual ~SequenceEntry();
/**
diff --git a/extern/audaspace/src/sequence/AnimateableProperty.cpp b/extern/audaspace/src/sequence/AnimateableProperty.cpp
index 306ba8e07f5..7969947c8bf 100644
--- a/extern/audaspace/src/sequence/AnimateableProperty.cpp
+++ b/extern/audaspace/src/sequence/AnimateableProperty.cpp
@@ -65,6 +65,16 @@ void AnimateableProperty::write(const float* data)
std::memcpy(getBuffer(), data, m_count * sizeof(float));
}
+void AnimateableProperty::write_range(const float* data, int position_start, int position_end){
+ assureSize(position_end * m_count * sizeof(float), true);
+ float* buf = getBuffer();
+
+ for (int i = position_start; i < position_end; i++){
+ std::memcpy(buf + i * m_count, data, m_count * sizeof(float));
+ }
+ m_isAnimated = true;
+}
+
void AnimateableProperty::write(const float* data, int position, int count)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
diff --git a/extern/audaspace/src/sequence/SequenceData.cpp b/extern/audaspace/src/sequence/SequenceData.cpp
index 288f0bd225d..d569df40878 100644
--- a/extern/audaspace/src/sequence/SequenceData.cpp
+++ b/extern/audaspace/src/sequence/SequenceData.cpp
@@ -153,7 +153,7 @@ std::shared_ptr<SequenceEntry> SequenceData::add(std::shared_ptr<ISound> sound,
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
- std::shared_ptr<SequenceEntry> entry = std::shared_ptr<SequenceEntry>(new SequenceEntry(sound, begin, end, skip, m_id++));
+ std::shared_ptr<SequenceEntry> entry = std::shared_ptr<SequenceEntry>(new SequenceEntry(sound, begin, end, skip, m_fps, m_id++));
m_entries.push_back(entry);
m_entry_status++;
diff --git a/extern/audaspace/src/sequence/SequenceEntry.cpp b/extern/audaspace/src/sequence/SequenceEntry.cpp
index b63bdd2ffca..6c25eeb2e7b 100644
--- a/extern/audaspace/src/sequence/SequenceEntry.cpp
+++ b/extern/audaspace/src/sequence/SequenceEntry.cpp
@@ -22,7 +22,7 @@
AUD_NAMESPACE_BEGIN
-SequenceEntry::SequenceEntry(std::shared_ptr<ISound> sound, double begin, double end, double skip, int id) :
+SequenceEntry::SequenceEntry(std::shared_ptr<ISound> sound, double begin, double end, double skip, float fps, int id) :
m_status(0),
m_pos_status(1),
m_sound_status(0),
@@ -31,6 +31,7 @@ SequenceEntry::SequenceEntry(std::shared_ptr<ISound> sound, double begin, double
m_begin(begin),
m_end(end),
m_skip(skip),
+ m_fps(fps),
m_muted(false),
m_relative(true),
m_volume_max(1.0f),
diff --git a/extern/audaspace/src/sequence/SequenceHandle.cpp b/extern/audaspace/src/sequence/SequenceHandle.cpp
index fca4e805df2..6021ce0ee59 100644
--- a/extern/audaspace/src/sequence/SequenceHandle.cpp
+++ b/extern/audaspace/src/sequence/SequenceHandle.cpp
@@ -241,10 +241,28 @@ bool SequenceHandle::seek(double position)
return false;
std::lock_guard<ILockable> lock(*m_entry);
- double seekpos = position - m_entry->m_begin;
- if(seekpos < 0)
- seekpos = 0;
- seekpos += m_entry->m_skip;
+ float seek_frame = (position - m_entry->m_begin) * m_entry->m_fps;
+ if(seek_frame < 0)
+ seek_frame = 0;
+ seek_frame += m_entry->m_skip * m_entry->m_fps;
+
+ AnimateableProperty *pitch_property = m_entry->getAnimProperty(AP_PITCH);
+
+ float target_frame = 0;
+
+ // XXX this can be optimized if there is only 1 point
+ if (pitch_property != nullptr){
+ for (int i = 0; i < seek_frame; i++){
+ float pitch;
+ pitch_property->read(i, &pitch);
+ target_frame += pitch;
+ }
+ } else {
+ target_frame = seek_frame;
+ }
+
+ double seekpos = target_frame / m_entry->m_fps;
+
m_handle->setPitch(1.0f);
m_handle->seek(seekpos);
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index 11c37a74a54..7a9f8465003 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -154,6 +154,11 @@ void BKE_sound_set_scene_sound_volume(void *handle, float volume, char animated)
void BKE_sound_set_scene_sound_pitch(void *handle, float pitch, char animated);
+void BKE_sound_set_scene_sound_pitch_constant_range(void *handle,
+ int frame_start,
+ int frame_end,
+ float pitch);
+
void BKE_sound_set_scene_sound_pan(void *handle, float pan, char animated);
void BKE_sound_update_sequencer(struct Main *main, struct bSound *sound);
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index d08fba0e657..2650ac36fac 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -819,6 +819,15 @@ void BKE_sound_set_scene_sound_pitch(void *handle, float pitch, char animated)
AUD_SequenceEntry_setAnimationData(handle, AUD_AP_PITCH, sound_cfra, &pitch, animated);
}
+void BKE_sound_set_scene_sound_pitch_constant_range(void *handle,
+ int frame_start,
+ int frame_end,
+ float pitch)
+{
+ AUD_SequenceEntry_setAnimationData_constant_range(
+ handle, AUD_AP_PITCH, frame_start, frame_end, &pitch);
+}
+
void BKE_sound_set_scene_sound_pan(void *handle, float pan, char animated)
{
AUD_SequenceEntry_setAnimationData(handle, AUD_AP_PANNING, sound_cfra, &pan, animated);
diff --git a/source/blender/sequencer/intern/sequencer.c b/source/blender/sequencer/intern/sequencer.c
index 95818633876..d263c2e0437 100644
--- a/source/blender/sequencer/intern/sequencer.c
+++ b/source/blender/sequencer/intern/sequencer.c
@@ -989,9 +989,7 @@ static bool seq_update_seq_cb(Sequence *seq, void *user_data)
}
BKE_sound_set_scene_sound_volume(
seq->scene_sound, seq->volume, (seq->flag & SEQ_AUDIO_VOLUME_ANIMATED) != 0);
- BKE_sound_set_scene_sound_pitch(seq->scene_sound,
- SEQ_sound_pitch_get(scene, seq),
- (seq->flag & SEQ_AUDIO_PITCH_ANIMATED) != 0);
+ SEQ_retiming_sound_animation_data_set(scene, seq);
BKE_sound_set_scene_sound_pan(
seq->scene_sound, seq->pan, (seq->flag & SEQ_AUDIO_PAN_ANIMATED) != 0);
}
diff --git a/source/blender/sequencer/intern/strip_retiming.cc b/source/blender/sequencer/intern/strip_retiming.cc
index a550ce2dd14..50d0511f17b 100644
--- a/source/blender/sequencer/intern/strip_retiming.cc
+++ b/source/blender/sequencer/intern/strip_retiming.cc
@@ -253,18 +253,25 @@ float SEQ_retiming_handle_speed_get(const Scene *scene,
}
#include <BKE_sound.h>
-void SE
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list