1
/***************************************************************************
2
controlpotmeter.cpp - description
4
begin : Wed Feb 20 2002
5
copyright : (C) 2002 by Tue and Ken Haste Andersen
7
***************************************************************************/
9
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
16
***************************************************************************/
18
#include "controlpotmeter.h"
20
/* -------- ------------------------------------------------------
21
Purpose: Creates a new potmeter
23
midino - number of the midi controller.
24
master - pointer to the control to which the potmeter is
25
attached. This control is acknowledged when the
27
midicontroller - pointer to the midi controller.
28
-------- ------------------------------------------------------ */
29
//ControlPotmeter::ControlPotmeter() {}
30
ControlPotmeter::ControlPotmeter(char* n, short int _midino, MidiObject *_midi,
31
FLOAT _minvalue=0.0, FLOAT _maxvalue=1.0)
34
position = middlePosition;
37
valuerange = maxvalue-minvalue;
38
value = minvalue + 0.5*(maxvalue-minvalue);
42
midi->addpotmeter(this);
45
ControlPotmeter::~ControlPotmeter() {
46
midi->removepotmeter(this);
49
char* ControlPotmeter::print()
54
/* -------- ------------------------------------------------------
55
Purpose: Set the position of the potmeter, and change the
56
value correspondingly.
57
Input: The (new) position.
58
Output: The value is updated.
59
-------- ------------------------------------------------------ */
60
void ControlPotmeter::slotSetPosition(int _newpos)
62
char newpos =(char)_newpos;
64
char static const maxPosition = 127;
65
char static const minPosition = 0;
67
// Ensure that the position is within bounds:
68
position = std::max(minPosition,std::min(newpos, maxPosition));
69
// Calculate the value linearly:
70
value = (valuerange/positionrange)*
71
((maxPosition-newpos)-minPosition)+minvalue;
73
emit valueChanged(value);
76
char ControlPotmeter::getPosition()
81
void ControlPotmeter::setValue(FLOAT newvalue)
84
emit valueChanged(value);
87
FLOAT ControlPotmeter::getValue()
92
char ControlPotmeter::getmidino()