Revision: 39629
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39629
Author:   nexyon
Date:     2011-08-22 18:59:56 +0000 (Mon, 22 Aug 2011)
Log Message:
-----------
3D Audio GSoC:
Final GSoC commit.

* Bugfix: Negative frames crashed
* Bugfix: JOS sample buffer size prediction error (wasted memory)
* Optimisation: for JOS upsampling (around 12 % difference measured here)
* Optimisation: Better filter for JOS resampling
* Bugfix: Error in relative 3D audio code.
* Removed Attenuation
* Bugfix: Multiple scenes in BGE lead to errors, BGE audio now all relative, to 
support multiple scenes.

Modified Paths:
--------------
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.cpp
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_JOSResampleReader.cpp
    
branches/soc-2011-pepper/intern/audaspace/intern/AUD_JOSResampleReaderCoeff.cpp
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_SoftwareDevice.cpp
    branches/soc-2011-pepper/release/scripts/startup/bl_ui/space_sequencer.py
    branches/soc-2011-pepper/source/blender/makesrna/intern/rna_sequencer.c
    branches/soc-2011-pepper/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
    branches/soc-2011-pepper/source/gameengine/Ketsji/KX_SoundActuator.cpp

Modified: branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.cpp
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.cpp      
2011-08-22 18:56:13 UTC (rev 39628)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.cpp      
2011-08-22 18:59:56 UTC (rev 39629)
@@ -967,7 +967,10 @@
 {
        AUD_AnimateableProperty* prop = (*entry)->getAnimProperty(type);
        if(animated)
-               prop->write(data, frame, 1);
+       {
+               if(frame >= 0)
+                       prop->write(data, frame, 1);
+       }
        else
                prop->write(data);
 }
@@ -976,7 +979,10 @@
 {
        AUD_AnimateableProperty* prop = 
dynamic_cast<AUD_SequencerFactory*>(sequencer->get())->getAnimProperty(type);
        if(animated)
-               prop->write(data, frame, 1);
+       {
+               if(frame >= 0)
+                       prop->write(data, frame, 1);
+       }
        else
                prop->write(data);
 }

Modified: 
branches/soc-2011-pepper/intern/audaspace/intern/AUD_JOSResampleReader.cpp
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_JOSResampleReader.cpp  
2011-08-22 18:56:13 UTC (rev 39628)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_JOSResampleReader.cpp  
2011-08-22 18:59:56 UTC (rev 39629)
@@ -100,7 +100,7 @@
 
        // then check if afterwards the length is enough for the maximum rate
        if(len + size < num_samples * AUD_RATE_MAX)
-               len = size - num_samples * AUD_RATE_MAX;
+               len = num_samples * AUD_RATE_MAX - size;
 
        if(m_n > len)
        {
@@ -130,58 +130,101 @@
 \
        for(unsigned int t = 0; t < length; t++)\
        {\
-               factor = (m_last_factor * (length - t) + target_factor * t) / 
length;\
+               factor = (m_last_factor * (length - t - 1) + target_factor * (t 
+ 1)) / length;\
 \
+               memset(sums, 0, sizeof(double) * m_channels);\
+\
                if(factor >= 1)\
-                       f_increment = m_L;\
-               else\
-                       f_increment = factor * m_L;\
+               {\
+                       P = double_to_fp(m_P * m_L);\
 \
-               P_increment = double_to_fp(f_increment);\
-               P = double_to_fp(m_P * f_increment);\
+                       end = floor(m_len / double(m_L) - m_P) - 1;\
+                       if(m_n < end)\
+                               end = m_n;\
 \
-               end = (int_to_fp(m_len) - P) / P_increment - 1;\
-               if(m_n < end)\
-                       end = m_n;\
+                       data = buf + (m_n - end) * m_channels;\
+                       l = fp_to_int(P);\
+                       eta = fp_rest_to_double(P);\
+                       l += m_L * end;\
 \
-               memset(sums, 0, sizeof(double) * m_channels);\
+                       for(i = 0; i <= end; i++)\
+                       {\
+                               v = coeff[l] + eta * (coeff[l+1] - coeff[l]);\
+                               l -= m_L;\
+                               left\
+                       }\
 \
-               P += P_increment * end;\
-               data = buf + (m_n - end) * m_channels;\
-               l = fp_to_int(P);\
+                       P = int_to_fp(m_L) - P;\
 \
-               for(i = 0; i <= end; i++)\
-               {\
+                       end = floor((m_len - 1) / double(m_L) + m_P) - 1;\
+                       if(m_cache_valid - m_n - 2 < end)\
+                               end = m_cache_valid - m_n - 2;\
+\
+                       data = buf + (m_n + 2 + end) * m_channels - 1;\
+                       l = fp_to_int(P);\
                        eta = fp_rest_to_double(P);\
-                       v = coeff[l] + eta * (coeff[l+1] - coeff[l]);\
-                       P -= P_increment;\
-                       l = fp_to_int(P);\
-                       left\
+                       l += m_L * end;\
+\
+                       for(i = 0; i <= end; i++)\
+                       {\
+                               v = coeff[l] + eta * (coeff[l+1] - coeff[l]);\
+                               l -= m_L;\
+                               right\
+                       }\
+\
+                       for(channel = 0; channel < m_channels; channel++)\
+                       {\
+                               *buffer = sums[channel];\
+                               buffer++;\
+                       }\
                }\
+               else\
+               {\
+                       f_increment = factor * m_L;\
+                       P_increment = double_to_fp(f_increment);\
+                       P = double_to_fp(m_P * f_increment);\
 \
-               P = -P;\
+                       end = (int_to_fp(m_len) - P) / P_increment - 1;\
+                       if(m_n < end)\
+                               end = m_n;\
 \
-               end = (int_to_fp(m_len) - P) / P_increment - 1;\
-               if(m_cache_valid - m_n - 2 < end)\
-                       end = m_cache_valid - m_n - 2;\
+                       P += P_increment * end;\
+                       data = buf + (m_n - end) * m_channels;\
+                       l = fp_to_int(P);\
 \
-               P += P_increment * end;\
-               data = buf + (m_n + 2 + end) * m_channels - 1;\
-               l = fp_to_int(P);\
+                       for(i = 0; i <= end; i++)\
+                       {\
+                               eta = fp_rest_to_double(P);\
+                               v = coeff[l] + eta * (coeff[l+1] - coeff[l]);\
+                               P -= P_increment;\
+                               l = fp_to_int(P);\
+                               left\
+                       }\
 \
-               for(i = 0; i <= end; i++)\
-               {\
-                       eta = fp_rest_to_double(P);\
-                       v = coeff[l] + eta * (coeff[l+1] - coeff[l]);\
-                       P -= P_increment;\
+                       P = -P;\
+\
+                       end = (int_to_fp(m_len) - P) / P_increment - 1;\
+                       if(m_cache_valid - m_n - 2 < end)\
+                               end = m_cache_valid - m_n - 2;\
+\
+                       P += P_increment * end;\
+                       data = buf + (m_n + 2 + end) * m_channels - 1;\
                        l = fp_to_int(P);\
-                       right\
-               }\
 \
-               for(channel = 0; channel < m_channels; channel++)\
-               {\
-                       *buffer = f_increment / m_L * sums[channel];\
-                       buffer++;\
+                       for(i = 0; i <= end; i++)\
+                       {\
+                               eta = fp_rest_to_double(P);\
+                               v = coeff[l] + eta * (coeff[l+1] - coeff[l]);\
+                               P -= P_increment;\
+                               l = fp_to_int(P);\
+                               right\
+                       }\
+\
+                       for(channel = 0; channel < m_channels; channel++)\
+                       {\
+                               *buffer = f_increment / m_L * sums[channel];\
+                               buffer++;\
+                       }\
                }\
 \
                m_P += fmod(1.0 / factor, 1.0);\

Modified: 
branches/soc-2011-pepper/intern/audaspace/intern/AUD_JOSResampleReaderCoeff.cpp
===================================================================
--- 
branches/soc-2011-pepper/intern/audaspace/intern/AUD_JOSResampleReaderCoeff.cpp 
    2011-08-22 18:56:13 UTC (rev 39628)
+++ 
branches/soc-2011-pepper/intern/audaspace/intern/AUD_JOSResampleReaderCoeff.cpp 
    2011-08-22 18:59:56 UTC (rev 39629)
@@ -1,29295 +1,32517 @@
 #include "AUD_JOSResampleReader.h"
 
-// sinc filter coefficients, Nz = 138, L = 2048, freq = 0.965, Kaiser Window B 
= 16
+// sinc filter coefficients, Nz = 136, L = 2304, freq = 0.963904, Kaiser 
Window B = 16
 
+const int AUD_JOSResampleReader::m_len = 325078;
+const int AUD_JOSResampleReader::m_L = 2304;
+
 const float AUD_JOSResampleReader::m_coeff[] = {
-       9.650000000e-01f, 9.649996475e-01f, 9.649985899e-01f, 9.649968274e-01f, 
9.649943598e-01f, 9.649911871e-01f, 9.649873095e-01f, 9.649827268e-01f, 
9.649774392e-01f, 9.649714465e-01f,
-       9.649647489e-01f, 9.649573462e-01f, 9.649492386e-01f, 9.649404260e-01f, 
9.649309085e-01f, 9.649206860e-01f, 9.649097586e-01f, 9.648981263e-01f, 
9.648857891e-01f, 9.648727470e-01f,
-       9.648590001e-01f, 9.648445483e-01f, 9.648293917e-01f, 9.648135302e-01f, 
9.647969640e-01f, 9.647796931e-01f, 9.647617174e-01f, 9.647430369e-01f, 
9.647236518e-01f, 9.647035620e-01f,
-       9.646827676e-01f, 9.646612685e-01f, 9.646390649e-01f, 9.646161567e-01f, 
9.645925440e-01f, 9.645682268e-01f, 9.645432051e-01f, 9.645174791e-01f, 
9.644910486e-01f, 9.644639137e-01f,
-       9.644360745e-01f, 9.644075311e-01f, 9.643782833e-01f, 9.643483314e-01f, 
9.643176753e-01f, 9.642863151e-01f, 9.642542508e-01f, 9.642214824e-01f, 
9.641880100e-01f, 9.641538336e-01f,
-       9.641189534e-01f, 9.640833693e-01f, 9.640470813e-01f, 9.640100896e-01f, 
9.639723941e-01f, 9.639339950e-01f, 9.638948922e-01f, 9.638550858e-01f, 
9.638145760e-01f, 9.637733626e-01f,
-       9.637314459e-01f, 9.636888257e-01f, 9.636455023e-01f, 9.636014756e-01f, 
9.635567458e-01f, 9.635113128e-01f, 9.634651767e-01f, 9.634183376e-01f, 
9.633707956e-01f, 9.633225507e-01f,
-       9.632736029e-01f, 9.632239524e-01f, 9.631735992e-01f, 9.631225434e-01f, 
9.630707850e-01f, 9.630183241e-01f, 9.629651608e-01f, 9.629112952e-01f, 
9.628567272e-01f, 9.628014571e-01f,
-       9.627454848e-01f, 9.626888104e-01f, 9.626314341e-01f, 9.625733558e-01f, 
9.625145757e-01f, 9.624550939e-01f, 9.623949103e-01f, 9.623340252e-01f, 
9.622724385e-01f, 9.622101504e-01f,
-       9.621471609e-01f, 9.620834702e-01f, 9.620190782e-01f, 9.619539852e-01f, 
9.618881911e-01f, 9.618216961e-01f, 9.617545002e-01f, 9.616866036e-01f, 
9.616180063e-01f, 9.615487084e-01f,
-       9.614787100e-01f, 9.614080113e-01f, 9.613366122e-01f, 9.612645129e-01f, 
9.611917135e-01f, 9.611182140e-01f, 9.610440147e-01f, 9.609691155e-01f, 
9.608935166e-01f, 9.608172180e-01f,
-       9.607402200e-01f, 9.606625225e-01f, 9.605841256e-01f, 9.605050296e-01f, 
9.604252344e-01f, 9.603447402e-01f, 9.602635472e-01f, 9.601816553e-01f, 
9.600990647e-01f, 9.600157755e-01f,
-       9.599317879e-01f, 9.598471019e-01f, 9.597617176e-01f, 9.596756352e-01f, 
9.595888548e-01f, 9.595013764e-01f, 9.594132003e-01f, 9.593243264e-01f, 
9.592347550e-01f, 9.591444862e-01f,
-       9.590535200e-01f, 9.589618566e-01f, 9.588694961e-01f, 9.587764387e-01f, 
9.586826844e-01f, 9.585882334e-01f, 9.584930858e-01f, 9.583972417e-01f, 
9.583007013e-01f, 9.582034646e-01f,
-       9.581055319e-01f, 9.580069031e-01f, 9.579075786e-01f, 9.578075583e-01f, 
9.577068425e-01f, 9.576054313e-01f, 9.575033247e-01f, 9.574005229e-01f, 
9.572970262e-01f, 9.571928345e-01f,
-       9.570879480e-01f, 9.569823669e-01f, 9.568760914e-01f, 9.567691215e-01f, 
9.566614573e-01f, 9.565530992e-01f, 9.564440471e-01f, 9.563343012e-01f, 
9.562238616e-01f, 9.561127286e-01f,
-       9.560009023e-01f, 9.558883827e-01f, 9.557751701e-01f, 9.556612646e-01f, 
9.555466663e-01f, 9.554313754e-01f, 9.553153921e-01f, 9.551987165e-01f, 
9.550813487e-01f, 9.549632890e-01f,
-       9.548445374e-01f, 9.547250941e-01f, 9.546049594e-01f, 9.544841332e-01f, 
9.543626158e-01f, 9.542404074e-01f, 9.541175082e-01f, 9.539939182e-01f, 
9.538696376e-01f, 9.537446666e-01f,
-       9.536190054e-01f, 9.534926541e-01f, 9.533656130e-01f, 9.532378821e-01f, 
9.531094616e-01f, 9.529803517e-01f, 9.528505526e-01f, 9.527200644e-01f, 
9.525888874e-01f, 9.524570216e-01f,
-       9.523244673e-01f, 9.521912246e-01f, 9.520572938e-01f, 9.519226749e-01f, 
9.517873681e-01f, 9.516513737e-01f, 9.515146919e-01f, 9.513773227e-01f, 
9.512392664e-01f, 9.511005231e-01f,
-       9.509610931e-01f, 9.508209765e-01f, 9.506801736e-01f, 9.505386844e-01f, 
9.503965092e-01f, 9.502536481e-01f, 9.501101014e-01f, 9.499658693e-01f, 
9.498209518e-01f, 9.496753493e-01f,
-       9.495290619e-01f, 9.493820898e-01f, 9.492344333e-01f, 9.490860923e-01f, 
9.489370673e-01f, 9.487873584e-01f, 9.486369657e-01f, 9.484858895e-01f, 
9.483341300e-01f, 9.481816874e-01f,
-       9.480285618e-01f, 9.478747535e-01f, 9.477202627e-01f, 9.475650895e-01f, 
9.474092343e-01f, 9.472526971e-01f, 9.470954782e-01f, 9.469375778e-01f, 
9.467789961e-01f, 9.466197334e-01f,
-       9.464597897e-01f, 9.462991654e-01f, 9.461378606e-01f, 9.459758756e-01f, 
9.458132105e-01f, 9.456498657e-01f, 9.454858412e-01f, 9.453211373e-01f, 
9.451557543e-01f, 9.449896923e-01f,
-       9.448229516e-01f, 9.446555323e-01f, 9.444874348e-01f, 9.443186592e-01f, 
9.441492057e-01f, 9.439790746e-01f, 9.438082660e-01f, 9.436367803e-01f, 
9.434646176e-01f, 9.432917782e-01f,
-       9.431182623e-01f, 9.429440701e-01f, 9.427692018e-01f, 9.425936577e-01f, 
9.424174380e-01f, 9.422405430e-01f, 9.420629728e-01f, 9.418847278e-01f, 
9.417058080e-01f, 9.415262138e-01f,

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to