diff -ru /Volumes/Document1/Developpement/ProjectsCVS/ArdourCVS/ardour-0.9beta30-old/libs/ardour/ardour/mix.h /Volumes/Document1/Developpement/ProjectsCVS/ArdourCVS/ardour-0.9beta30/libs/ardour/ardour/mix.h --- /Volumes/Document1/Developpement/ProjectsCVS/ArdourCVS/ardour-0.9beta30-old/libs/ardour/ardour/mix.h 2005-09-08 21:40:55.000000000 +0200 +++ /Volumes/Document1/Developpement/ProjectsCVS/ArdourCVS/ardour-0.9beta30/libs/ardour/ardour/mix.h 2005-09-19 13:24:51.000000000 +0200 @@ -49,6 +49,18 @@ #endif +#if defined (__APPLE__) + +float veclib_compute_peak (ARDOUR::Sample *buf, jack_nframes_t nsamples, float current); + +void veclib_apply_gain_to_buffer (ARDOUR::Sample *buf, jack_nframes_t nframes, float gain); + +void veclib_mix_buffers_with_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, jack_nframes_t nframes, float gain); + +void veclib_mix_buffers_no_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, jack_nframes_t nframes); + +#endif + /* non-optimized functions */ float compute_peak (ARDOUR::Sample *buf, jack_nframes_t nsamples, float current); diff -ru /Volumes/Document1/Developpement/ProjectsCVS/ArdourCVS/ardour-0.9beta30-old/libs/ardour/globals.cc /Volumes/Document1/Developpement/ProjectsCVS/ArdourCVS/ardour-0.9beta30/libs/ardour/globals.cc --- /Volumes/Document1/Developpement/ProjectsCVS/ArdourCVS/ardour-0.9beta30-old/libs/ardour/globals.cc 2005-09-08 21:40:55.000000000 +0200 +++ /Volumes/Document1/Developpement/ProjectsCVS/ArdourCVS/ardour-0.9beta30/libs/ardour/globals.cc 2005-09-19 13:06:00.000000000 +0200 @@ -49,6 +49,10 @@ #include +#if defined (__APPLE__) + #include // For Gestalt +#endif + #include "i18n.h" ARDOUR::Configuration* ARDOUR::Config = 0; @@ -217,13 +221,27 @@ } -#else - Session::compute_peak = compute_peak; - Session::apply_gain_to_buffer = apply_gain_to_buffer; - Session::mix_buffers_with_gain = mix_buffers_with_gain; - Session::mix_buffers_no_gain = mix_buffers_no_gain; - - info << "No H/W specific optimizations in use" << endmsg; +#else if defined (__APPLE__) + long sysVersion = 0; + if (noErr != Gestalt(gestaltSystemVersion, &sysVersion)) + sysVersion = 0; + + if (sysVersion >= 0x00001040) { // Tiger at least + Session::compute_peak = veclib_compute_peak; + Session::apply_gain_to_buffer = veclib_apply_gain_to_buffer; + Session::mix_buffers_with_gain = veclib_mix_buffers_with_gain; + Session::mix_buffers_no_gain = veclib_mix_buffers_no_gain; + + info << "Apple VecLib H/W specific optimizations in use" << endmsg; + } else { + Session::compute_peak = compute_peak; + Session::apply_gain_to_buffer = apply_gain_to_buffer; + Session::mix_buffers_with_gain = mix_buffers_with_gain; + Session::mix_buffers_no_gain = mix_buffers_no_gain; + + info << "No H/W specific optimizations in use" << endmsg; + } + #endif } else { diff -ru /Volumes/Document1/Developpement/ProjectsCVS/ArdourCVS/ardour-0.9beta30-old/libs/ardour/mix.cc /Volumes/Document1/Developpement/ProjectsCVS/ArdourCVS/ardour-0.9beta30/libs/ardour/mix.cc --- /Volumes/Document1/Developpement/ProjectsCVS/ArdourCVS/ardour-0.9beta30-old/libs/ardour/mix.cc 2005-09-07 22:19:26.000000000 +0200 +++ /Volumes/Document1/Developpement/ProjectsCVS/ArdourCVS/ardour-0.9beta30/libs/ardour/mix.cc 2005-09-19 13:37:13.000000000 +0200 @@ -114,4 +114,35 @@ } } +#if defined (__APPLE__) +#include + +float +veclib_compute_peak (ARDOUR::Sample *buf, jack_nframes_t nsamples, float current) +{ + vDSP_maxv(buf, 1, ¤t, nsamples); + return current; +} + +void +veclib_apply_gain_to_buffer (ARDOUR::Sample *buf, jack_nframes_t nframes, float gain) +{ + vDSP_vsmul(buf, 1, &gain, buf, 1, nframes); +} + +void +veclib_mix_buffers_with_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, jack_nframes_t nframes, float gain) +{ + vDSP_vsma(src, 1, &gain, dst, 1, dst, 1, nframes); +} + +void +veclib_mix_buffers_no_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, jack_nframes_t nframes) +{ + // It seems that a vector mult only operation does not exist... + float gain = 1.0f; + vDSP_vsma(src, 1, &gain, dst, 1, dst, 1, nframes); +} + +#endif