![]() |
Mixxx
|
00001 /*************************************************************************** 00002 * * 00003 * This program is free software; you can redistribute it and/or modify * 00004 * it under the terms of the GNU General Public License as published by * 00005 * the Free Software Foundation; either version 2 of the License, or * 00006 * (at your option) any later version. * 00007 * * 00008 ***************************************************************************/ 00009 00010 #include <QtCore> 00011 #include "ladspacontrol.h" 00012 00013 // static variable 00014 int LADSPAControl::m_bufferSize = LADSPA_MAX_BUFFER_SIZE; 00015 00016 LADSPAControl::LADSPAControl() 00017 { 00018 m_pBuffer = new LADSPA_Data [m_bufferSize]; 00019 } 00020 00021 LADSPAControl::~LADSPAControl() 00022 { 00023 delete [] m_pBuffer; 00024 } 00025 00026 LADSPA_Data * LADSPAControl::getBuffer() 00027 { 00028 return m_pBuffer; 00029 } 00030 00031 void LADSPAControl::setValue(LADSPA_Data value) 00032 { 00033 #ifdef __LADSPA_SIMPLE_CONTROL__ 00034 m_Value = value; 00035 #else 00036 if (m_Value != value) 00037 { 00038 // value has changed 00039 LADSPA_Data step = (value - m_Value) / m_bufferSize; 00040 m_Value -= step; 00041 // phase 1: fill the buffer with smoothly changing values 00042 for (int i = 0; i < m_bufferSize; i++) 00043 { 00044 m_Value += step; 00045 m_pBuffer[i] = m_Value; 00046 } 00047 } 00048 else if (m_pBuffer[0] != value) 00049 #endif 00050 { 00051 // phase 2: the buffer is not filled with constant values yet 00052 for (int i = 0; i < m_bufferSize; i++) 00053 { 00054 m_pBuffer[i] = m_Value; 00055 } 00056 } 00057 } 00058 00059 void LADSPAControl::setBufferSize(int size) 00060 { 00061 // FIX: may crash after changing buffer size from smaller to bigger 00062 m_bufferSize = size; 00063 }