Audio:
authorJoerg Mueller <nexyon@gmail.com>
Sun, 11 Sep 2011 12:24:11 +0000 (12:24 +0000)
committerJoerg Mueller <nexyon@gmail.com>
Sun, 11 Sep 2011 12:24:11 +0000 (12:24 +0000)
* Fix for high quality upsampling which was wrong.
* Fix for doppler effects which were calculated wrong for scenes.
* Improved animation evaluation at the beginning and end of a scene.

intern/audaspace/intern/AUD_JOSResampleReader.cpp
intern/audaspace/intern/AUD_SequencerHandle.cpp
intern/audaspace/intern/AUD_SequencerHandle.h
intern/audaspace/intern/AUD_SequencerReader.cpp
source/blender/editors/sound/sound_ops.c

index 8da3d55acae273c7384b9bb21099d99dc165e4a5..82b784a43bf3eddd18f3791a26d2f3eb87780669 100644 (file)
@@ -118,7 +118,8 @@ void AUD_JOSResampleReader::updateBuffer(int size, double factor, int samplesize
 {\
        sample_t* buf = m_buffer.getBuffer();\
 \
-       int P, l, end, channel, i;\
+       unsigned int P, l;\
+       int end, channel, i;\
        double eta, v, f_increment, factor;\
 \
        m_sums.assureSize(m_channels * sizeof(double));\
@@ -222,7 +223,7 @@ void AUD_JOSResampleReader::updateBuffer(int size, double factor, int samplesize
 \
                        for(channel = 0; channel < m_channels; channel++)\
                        {\
-                               *buffer = f_increment / m_L * sums[channel];\
+                                                               *buffer = factor * sums[channel];\
                                buffer++;\
                        }\
                }\
@@ -230,7 +231,7 @@ void AUD_JOSResampleReader::updateBuffer(int size, double factor, int samplesize
                m_P += fmod(1.0 / factor, 1.0);\
                m_n += floor(1.0 / factor);\
 \
-               if(m_P >= 1.0)\
+               while(m_P >= 1.0)\
                {\
                        m_P -= 1.0;\
                        m_n++;\
@@ -364,9 +365,9 @@ void AUD_JOSResampleReader::read(int& length, bool& eos, sample_t* buffer)
        double factor = AUD_MIN(target_factor, m_last_factor);
 
        if(factor >= 1)
-               len = (m_n - m_cache_valid) + int(ceil(length / factor)) + ceil(num_samples);
+               len = (int(m_n) - m_cache_valid) + int(ceil(length / factor)) + ceil(num_samples);
        else
-               len = (m_n - m_cache_valid) + int(ceil(length / factor) + ceil(num_samples / factor));
+               len = (int(m_n) - m_cache_valid) + int(ceil(length / factor) + ceil(num_samples / factor));
 
        if(len > 0)
        {
index c9cf46ccdc3f9457b722b702790a756c089f2568..87f5eb29d70dab3f8af43f99c3ce491d53fcbf09 100644 (file)
@@ -66,7 +66,7 @@ void AUD_SequencerHandle::stop()
                m_handle->stop();
 }
 
-void AUD_SequencerHandle::update(float position, float frame)
+void AUD_SequencerHandle::update(float position, float frame, float fps)
 {
        if(!m_handle.isNull())
        {
@@ -132,7 +132,7 @@ void AUD_SequencerHandle::update(float position, float frame)
                m_3dhandle->setSourceLocation(v);
                m_entry->m_location.read(frame + 1, v2.get());
                v2 -= v;
-               m_3dhandle->setSourceVelocity(v2);
+               m_3dhandle->setSourceVelocity(v2 * fps);
 
                if(m_entry->m_muted)
                        m_handle->setVolume(0);
index 9703d2b00597d7ce68d3750c7812d83d37a8d3ab..ab86bf49b0f63dee77247d520222b4ecb588ee27 100644 (file)
@@ -94,8 +94,9 @@ public:
         * Updates the handle for playback.
         * \param position The current time during playback.
         * \param frame The current frame during playback.
+        * \param fps The animation frames per second.
         */
-       void update(float position, float frame);
+       void update(float position, float frame, float fps);
 
        /**
         * Seeks the handle to a specific time position.
index 0b8a400a97b464bdd6aa3a9bc88221e85e8aff27..c468de19580f9dce02031852480e9f2ad944cf56 100644 (file)
@@ -162,7 +162,7 @@ void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
 
                for(AUD_HandleIterator it = m_handles.begin(); it != m_handles.end(); it++)
                {
-                       (*it)->update(time, frame);
+                       (*it)->update(time, frame, m_factory->m_fps);
                }
 
                m_factory->m_volume.read(frame, &volume);
@@ -174,7 +174,7 @@ void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
                m_device.setListenerLocation(v);
                m_factory->m_location.read(frame + 1, v2.get());
                v2 -= v;
-               m_device.setListenerVelocity(v2);
+               m_device.setListenerVelocity(v2 * m_factory->m_fps);
 
                m_device.read(reinterpret_cast<data_t*>(buffer + specs.channels * pos), len);
 
index 72dbbd9da9a1af870c085a89d0a9c6bf5557b3a9..19cae6aa67dba936ccd27fc3fd55297ca60271db 100644 (file)
@@ -691,7 +691,7 @@ static int bake_animation_exec(bContext *C, wmOperator *UNUSED(op))
 
        update_animation_flags_exec(C, NULL);
 
-       for(cfra = scene->r.sfra; cfra <= scene->r.efra; cfra++)
+       for(cfra = scene->r.sfra > 0 ? scene->r.sfra - 1 : 0; cfra <= scene->r.efra + 1; cfra++)
        {
                scene->r.cfra = cfra;
                scene_update_for_newframe(bmain, scene, scene->lay);