2013-12-08 22:44:43 +01:00
|
|
|
/*
|
|
|
|
* Author: Harry van Haaren 2013
|
|
|
|
* harryhaaren@gmail.com
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2013-10-02 03:40:44 +02:00
|
|
|
|
|
|
|
#include "controllerupdater.hxx"
|
|
|
|
|
2013-11-10 19:12:28 +01:00
|
|
|
#include "eventhandler.hxx"
|
|
|
|
|
2013-10-02 03:40:44 +02:00
|
|
|
ControllerUpdater::ControllerUpdater()
|
|
|
|
{
|
2013-10-07 16:34:41 +02:00
|
|
|
// CAREFUL size of controllers: otherwise malloc() called
|
|
|
|
c.reserve( CONTROLLERS_PREALLOC );
|
2013-10-02 03:40:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerUpdater::registerController( Controller* controller )
|
|
|
|
{
|
2013-12-04 15:13:13 +01:00
|
|
|
if (!controller)
|
2014-08-10 23:20:57 +02:00
|
|
|
{
|
2013-12-04 15:13:13 +01:00
|
|
|
LUPPP_ERROR("Register Controller passed NULL controller!");
|
2014-08-10 23:20:57 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-12-04 15:13:13 +01:00
|
|
|
|
2013-12-04 15:46:44 +01:00
|
|
|
//LUPPP_NOTE("Registering controller %s", controller->getName().c_str() );
|
2013-12-04 15:13:13 +01:00
|
|
|
|
2013-10-02 03:40:44 +02:00
|
|
|
// store the controller instance
|
|
|
|
c.push_back( controller );
|
|
|
|
|
|
|
|
// and tell it to register itself (MidiObserver / AudioObserver etc)
|
|
|
|
controller->registerComponents();
|
|
|
|
}
|
|
|
|
|
2013-11-10 19:12:28 +01:00
|
|
|
void ControllerUpdater::removeController( int id )
|
|
|
|
{
|
|
|
|
for( unsigned int i = 0; i < c.size(); i++)
|
|
|
|
{
|
|
|
|
if ( c.at(i)->getID() == id )
|
|
|
|
{
|
|
|
|
// keep pointer: otherwise we mem-leak
|
2013-11-10 23:52:53 +01:00
|
|
|
Controller* removed = c.at( i );
|
|
|
|
|
|
|
|
cout << "Removing item " << i << " with name " << removed->getName() << endl;
|
2013-11-10 19:12:28 +01:00
|
|
|
|
|
|
|
// remove the instance at
|
2013-11-10 23:52:53 +01:00
|
|
|
c.erase( c.begin() + i );
|
2013-11-10 19:12:28 +01:00
|
|
|
|
|
|
|
// send it for de-allocation
|
|
|
|
EventControllerInstance e( removed );
|
|
|
|
writeToGuiRingbuffer( &e );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-10-19 13:54:26 +02:00
|
|
|
Controller* ControllerUpdater::getController(int id)
|
2013-10-18 02:06:34 +02:00
|
|
|
{
|
2013-10-19 13:54:26 +02:00
|
|
|
// search controllers for ID, if found return a pointer to it
|
|
|
|
for( unsigned int i = 0; i < c.size(); i++)
|
2013-11-10 21:13:41 +01:00
|
|
|
{
|
2013-10-19 13:54:26 +02:00
|
|
|
if ( c.at(i)->getID() == id )
|
2013-11-10 21:13:41 +01:00
|
|
|
{
|
|
|
|
LUPPP_NOTE("getController target ID: %i, found ID: %i, returning %s", id, i, c.at(i)->getName().c_str() );
|
2013-10-19 13:54:26 +02:00
|
|
|
return c.at(i);
|
2013-11-10 21:13:41 +01:00
|
|
|
}
|
|
|
|
}
|
2013-10-18 02:06:34 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-02 03:40:44 +02:00
|
|
|
void ControllerUpdater::reset()
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++)
|
|
|
|
c.at(i)->reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerUpdater::mute(int t, bool b)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++)
|
|
|
|
c.at(i)->mute(t,b);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerUpdater::masterVolume(float v)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++)
|
|
|
|
c.at(i)->masterVolume(v);
|
|
|
|
}
|
|
|
|
|
2013-11-21 15:11:06 +01:00
|
|
|
void ControllerUpdater::masterReturnVolume(float v)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++)
|
|
|
|
c.at(i)->masterReturnVolume( v );
|
|
|
|
}
|
|
|
|
|
2013-10-02 03:40:44 +02:00
|
|
|
void ControllerUpdater::setTrackSceneProgress(int t, int s, float p)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++)
|
|
|
|
c.at(i)->progress(t,s,p);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerUpdater::setTrackSendActive(int t, int send, bool v)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++)
|
|
|
|
c.at(i)->trackSendActive(t, send, v);
|
|
|
|
}
|
|
|
|
void ControllerUpdater::setTrackSend(int t, int send, float v)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++)
|
|
|
|
c.at(i)->trackSend(t, send, v);
|
|
|
|
}
|
|
|
|
|
2013-12-04 14:50:08 +01:00
|
|
|
void ControllerUpdater::specialScene(int t, int scene)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++)
|
|
|
|
c.at(i)->specialScene(t, scene);
|
|
|
|
}
|
|
|
|
|
2013-11-09 22:50:21 +01:00
|
|
|
void ControllerUpdater::masterInputToActive(int to, bool v)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++)
|
|
|
|
c.at(i)->masterInputToActive( to, v);
|
|
|
|
}
|
|
|
|
void ControllerUpdater::masterInputTo( int to, float v )
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++)
|
|
|
|
c.at(i)->masterInputTo( to, v);
|
|
|
|
}
|
2013-11-09 23:11:45 +01:00
|
|
|
void ControllerUpdater::masterInputVol( float v )
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++)
|
|
|
|
c.at(i)->masterInputVol( v );
|
|
|
|
}
|
2013-11-09 22:50:21 +01:00
|
|
|
|
2013-10-02 03:40:44 +02:00
|
|
|
void ControllerUpdater::launchScene( int scene )
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++)
|
|
|
|
c.at(i)->launchScene(scene);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerUpdater::setSceneState(int t, int clip, GridLogic::State s)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++)
|
|
|
|
c.at(i)->setSceneState(t,clip,s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerUpdater::recordArm(int t, bool r)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++)
|
|
|
|
c.at(i)->recordArm(t,r);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerUpdater::volume(int t, float v)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++) c.at(i)->volume(t,v);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerUpdater::tapTempo(bool b)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++) c.at(i)->tapTempo(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerUpdater::metronomeEnable(bool b)
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < c.size(); i++) c.at(i)->metronomeEnable(b);
|
|
|
|
}
|