Mercurial > hg > opencollidoscope
comparison CollidoscopeApp/include/DrawInfo.h @ 5:75b744078d66
added license
author | Fiore Martin <f.martin@qmul.ac.uk> |
---|---|
date | Wed, 13 Jul 2016 16:06:46 +0200 |
parents | 7fb593d53361 |
children | a4a336624f5a |
comparison
equal
deleted
inserted
replaced
4:ab6db404403a | 5:75b744078d66 |
---|---|
1 /* | |
2 | |
3 Copyright (C) 2016 Queen Mary University of London | |
4 Author: Fiore Martin | |
5 | |
6 This file is part of Collidoscope. | |
7 | |
8 Collidoscope is free software: you can redistribute it and/or modify | |
9 it under the terms of the GNU General Public License as published by | |
10 the Free Software Foundation, either version 3 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 */ | |
21 | |
1 #pragma once | 22 #pragma once |
2 | 23 |
3 #include "cinder/Area.h" | 24 #include "cinder/Area.h" |
4 | 25 |
5 /** | 26 /** |
38 | 59 |
39 /** | 60 /** |
40 * Maps a value in the audio space [-1.0, 1.0] to a position on the y axis of this DrawInf's bounding area. | 61 * Maps a value in the audio space [-1.0, 1.0] to a position on the y axis of this DrawInf's bounding area. |
41 * | 62 * |
42 */ | 63 */ |
43 float audioToHeigt(float audioSample) const { | 64 float audioToHeigt(float audioSample) const { |
44 /* clip into range [-1.1] */ | 65 /* clip into range [-1.1] */ |
45 if (audioSample < -1.0f) { | 66 if (audioSample < -1.0f) { |
46 audioSample = -1.0f; | 67 audioSample = -1.0f; |
47 } | 68 } |
48 else if ( audioSample > 1.0f ){ | 69 else if ( audioSample > 1.0f ){ |
49 audioSample = 1.0f; | 70 audioSample = 1.0f; |
50 } | 71 } |
51 | 72 |
52 /* map from [-1,1] to [0,1] */ | 73 /* map from [-1,1] to [0,1] */ |
53 float ratio = (audioSample - (-1.0f)) * 0.5f; // 2 = 1 - (-1) | 74 float ratio = (audioSample - (-1.0f)) * 0.5f; // 2 = 1 - (-1) |
54 | 75 |
55 /* get bottom and add the scaled height */ | 76 /* get bottom and add the scaled height */ |
56 return ratio * mSelectionBarHeight; //remove bounds.getY1() bound only needed for size of tier | 77 return ratio * mSelectionBarHeight; //remove bounds.getY1() bound only needed for size of tier |
57 } | 78 } |
58 | 79 |
59 float getMaxChunkHeight() const | 80 float getMaxChunkHeight() const |
60 { | 81 { |
61 return mSelectionBarHeight * mShrinkFactor; | 82 return mSelectionBarHeight * mShrinkFactor; |
62 } | 83 } |
78 } | 99 } |
79 | 100 |
80 /** | 101 /** |
81 * Flips y according to the index of the wave. It is needed because the second wave in collidoscope is upside down from the orientation oftthe screen. | 102 * Flips y according to the index of the wave. It is needed because the second wave in collidoscope is upside down from the orientation oftthe screen. |
82 */ | 103 */ |
83 int flipY(int y) const | 104 int flipY(int y) const |
84 { | 105 { |
85 if ( mWaveIndex == 0) | 106 if ( mWaveIndex == 0) |
86 return mWindowHeight - y; | 107 return mWindowHeight - y; |
87 else | 108 else |
88 return y; | 109 return y; |
89 } | 110 } |
90 | 111 |
91 /** | 112 /** |
92 * Returns x. not used at he moment. | 113 * Returns x. not used at he moment. |
93 * | 114 * |
94 */ | 115 */ |
95 int flipX(int x) const | 116 int flipX(int x) const |
96 { | 117 { |
97 return x; | 118 return x; |
98 } | 119 } |
99 | 120 |
100 | 121 |
101 // how much the wave is shrunk on the y axis with respect to the wave's tier | 122 // how much the wave is shrunk on the y axis with respect to the wave's tier |
102 float getShrinkFactor() const | 123 float getShrinkFactor() const |
103 { | 124 { |