| 80 | |
| 81 | |
| 82 | bool VstEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) |
| 83 | { |
| 84 | if( !isEnabled() || !isRunning () ) |
| 85 | { |
| 86 | return false; |
| 87 | } |
| 88 | |
| 89 | if( m_plugin ) |
| 90 | { |
| 91 | const float d = dryLevel(); |
| 92 | #ifdef __GNUC__ |
| 93 | sampleFrame buf[_frames]; |
| 94 | #else |
| 95 | sampleFrame * buf = new sampleFrame[_frames]; |
| 96 | #endif |
| 97 | memcpy( buf, _buf, sizeof( sampleFrame ) * _frames ); |
| 98 | if (m_pluginMutex.tryLock(Engine::getSong()->isExporting() ? -1 : 0)) |
| 99 | { |
| 100 | m_plugin->process( buf, buf ); |
| 101 | m_pluginMutex.unlock(); |
| 102 | } |
| 103 | |
| 104 | double out_sum = 0.0; |
| 105 | const float w = wetLevel(); |
| 106 | for( fpp_t f = 0; f < _frames; ++f ) |
| 107 | { |
| 108 | _buf[f][0] = w*buf[f][0] + d*_buf[f][0]; |
| 109 | _buf[f][1] = w*buf[f][1] + d*_buf[f][1]; |
| 110 | } |
| 111 | for( fpp_t f = 0; f < _frames; ++f ) |
| 112 | { |
| 113 | out_sum += _buf[f][0]*_buf[f][0] + _buf[f][1]*_buf[f][1]; |
| 114 | } |
| 115 | #ifndef __GNUC__ |
| 116 | delete[] buf; |
| 117 | #endif |
| 118 | |
| 119 | checkGate( out_sum / _frames ); |
| 120 | } |
| 121 | return isRunning(); |
| 122 | } |
| 123 | |
| 124 | |
| 125 | |