f@0
|
1 /*
|
f@0
|
2 Cross-Modal DAW Prototype - Prototype of a simple Cross-Modal Digital Audio Workstation.
|
f@0
|
3
|
f@0
|
4 Copyright (C) 2015 Queen Mary University of London (http://depic.eecs.qmul.ac.uk/)
|
f@0
|
5
|
f@0
|
6 This program is free software: you can redistribute it and/or modify
|
f@0
|
7 it under the terms of the GNU General Public License as published by
|
f@0
|
8 the Free Software Foundation, either version 3 of the License, or
|
f@0
|
9 (at your option) any later version.
|
f@0
|
10
|
f@0
|
11 This program is distributed in the hope that it will be useful,
|
f@0
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
f@0
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
f@0
|
14 GNU General Public License for more details.
|
f@0
|
15
|
f@0
|
16 You should have received a copy of the GNU General Public License
|
f@0
|
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
|
f@0
|
18 */
|
f@0
|
19 package uk.ac.qmul.eecs.depic.daw;
|
f@0
|
20
|
f@0
|
21 import uk.ac.qmul.eecs.depic.patterns.Sequence;
|
f@0
|
22
|
f@0
|
23 /**
|
f@0
|
24 *
|
f@0
|
25 * This class represent a value in an Automation. An automation is a set of line envelopes and
|
f@0
|
26 * a value represent one end of an automation line.
|
f@0
|
27 *
|
f@0
|
28 * Therefore an automation value normally points to where the automation changes its slope.
|
f@0
|
29 *
|
f@0
|
30 * Since an automation is a 2D graph
|
f@0
|
31 *
|
f@0
|
32 *
|
f@0
|
33 */
|
f@0
|
34 public abstract class AutomationValue implements Comparable<AutomationValue>, Sequence.Value {
|
f@0
|
35 private float position;
|
f@0
|
36 /* ranges from 0.0 to 1.0 */
|
f@0
|
37 private float value;
|
f@0
|
38
|
f@0
|
39 public AutomationValue(float position, float value){
|
f@0
|
40 this.position = position;
|
f@0
|
41 this.value = value;
|
f@0
|
42 }
|
f@0
|
43
|
f@0
|
44 public void setTimePosition(float position){
|
f@0
|
45 this.position = position;
|
f@0
|
46 }
|
f@0
|
47
|
f@0
|
48 /**
|
f@0
|
49 * Returns the position of this automation value in milliseconds
|
f@0
|
50 *
|
f@0
|
51 * The position represents where this value is on time
|
f@0
|
52 *
|
f@0
|
53 * @return the position of this automation value in milliseconds
|
f@0
|
54 */
|
f@0
|
55 public float getTimePosition() {
|
f@0
|
56 return position;
|
f@0
|
57 }
|
f@0
|
58
|
f@0
|
59 public float getValue() {
|
f@0
|
60 return value;
|
f@0
|
61 }
|
f@0
|
62
|
f@0
|
63 public void setValue(float value) {
|
f@0
|
64 this.value = value;
|
f@0
|
65 }
|
f@0
|
66
|
f@0
|
67
|
f@0
|
68 public void setLocation(float position, float value){
|
f@0
|
69 setTimePosition(position);
|
f@0
|
70 setValue(value);
|
f@0
|
71 }
|
f@0
|
72
|
f@0
|
73 /**
|
f@0
|
74 * Returns the enclosing Automation.
|
f@0
|
75 *
|
f@0
|
76 * @return the enclosing Automation.
|
f@0
|
77 */
|
f@0
|
78 public abstract Automation getAutomation();
|
f@0
|
79
|
f@0
|
80 @Override
|
f@0
|
81 public int compareTo(AutomationValue v) {
|
f@0
|
82 if(v == null)
|
f@0
|
83 return 1;
|
f@0
|
84 if(position < v.getTimePosition())
|
f@0
|
85 return -1;
|
f@0
|
86 else if(position > v.getTimePosition())
|
f@0
|
87 return 1;
|
f@0
|
88 else
|
f@0
|
89 return 0;
|
f@0
|
90 }
|
f@0
|
91
|
f@0
|
92 @Override
|
f@0
|
93 public String toString(){
|
f@0
|
94 return "Automation Value. position:"+position+" value:"+value;
|
f@0
|
95 }
|
f@0
|
96
|
f@0
|
97 }
|