To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / CollidoscopeApp / include / Chunk.h @ 5:75b744078d66
History | View | Annotate | Download (3.3 KB)
| 1 | 5:75b744078d66 | f | /*
|
|---|---|---|---|
| 2 | |||
| 3 | Copyright (C) 2015 Fiore Martin
|
||
| 4 | Copyright (C) 2016 Queen Mary University of London
|
||
| 5 | Author: Fiore Martin
|
||
| 6 | |||
| 7 | This file is part of Collidoscope.
|
||
| 8 | |||
| 9 | Collidoscope is free software: you can redistribute it and/or modify
|
||
| 10 | it under the terms of the GNU General Public License as published by
|
||
| 11 | the Free Software Foundation, either version 3 of the License, or
|
||
| 12 | (at your option) any later version.
|
||
| 13 | |||
| 14 | This program is distributed in the hope that it will be useful,
|
||
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
| 17 | GNU General Public License for more details.
|
||
| 18 | |||
| 19 | You should have received a copy of the GNU General Public License
|
||
| 20 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
| 21 | |||
| 22 | */
|
||
| 23 | |||
| 24 | 0:02467299402e | f | |
| 25 | #pragma once
|
||
| 26 | |||
| 27 | #include "cinder/Color.h" |
||
| 28 | #include "cinder/gl/Batch.h" |
||
| 29 | |||
| 30 | class DrawInfo; |
||
| 31 | |||
| 32 | 2:dd889fff8423 | f | /**
|
| 33 | *
|
||
| 34 | * A chunk of audio in Collidoscope low-fi visual wave.
|
||
| 35 | *
|
||
| 36 | * The visual wave of Collidoscope is made out of a number of bars that mimics in a low-fi fashion the typical waveform based representation of audio.
|
||
| 37 | * A Chunk is one of the bars of the visual wave.
|
||
| 38 | *
|
||
| 39 | */
|
||
| 40 | |||
| 41 | 0:02467299402e | f | class Chunk |
| 42 | {
|
||
| 43 | |||
| 44 | public:
|
||
| 45 | |||
| 46 | const static float kWidth; |
||
| 47 | const static float kHalfWidth; |
||
| 48 | |||
| 49 | 2:dd889fff8423 | f | /**
|
| 50 | * Constructor, takes as argument the index of this chunk in the wave
|
||
| 51 | */
|
||
| 52 | 5:75b744078d66 | f | Chunk( size_t index ); |
| 53 | 0:02467299402e | f | |
| 54 | 2:dd889fff8423 | f | /**
|
| 55 | * Sets the top value of this chunk. The value is passed in audio coordinates : [-1.0, 1.0]
|
||
| 56 | */
|
||
| 57 | 0:02467299402e | f | void inline setTop(float t) { mAudioTop = t; mAnimate = 0.0f; mResetting = false; /* startes the animation to crate a chunk */ } |
| 58 | 2:dd889fff8423 | f | /**
|
| 59 | * Sets the bottom value of this chunk. The value is passed in audio coordinates : [-1.0, 1.0]
|
||
| 60 | */
|
||
| 61 | 0:02467299402e | f | void inline setBottom(float b) { mAudioBottom = b; mAnimate = 0.0f; mResetting = false; } |
| 62 | 2:dd889fff8423 | f | /**
|
| 63 | * Get the top value of this chunk. The value is returned in audio coordinates : [-1.0, 1.0]
|
||
| 64 | */
|
||
| 65 | 0:02467299402e | f | float inline getTop() const { return mAudioTop; } |
| 66 | 2:dd889fff8423 | f | /**
|
| 67 | * Get the bottom value of this chunk. The value is returned in audio coordinates : [-1.0, 1.0]
|
||
| 68 | */
|
||
| 69 | 0:02467299402e | f | float inline getBottom() const { return mAudioBottom; } |
| 70 | |||
| 71 | 2:dd889fff8423 | f | /**
|
| 72 | * Reset this chunks. When a chunk is reset it starts shrinking until it disappears.
|
||
| 73 | *
|
||
| 74 | */
|
||
| 75 | 5:75b744078d66 | f | void reset(){
|
| 76 | mResetting = true;
|
||
| 77 | } |
||
| 78 | 0:02467299402e | f | |
| 79 | 2:dd889fff8423 | f | /**
|
| 80 | * Called in the graphic loop. It update this chunk.
|
||
| 81 | */
|
||
| 82 | 0:02467299402e | f | void update( const DrawInfo& di ); |
| 83 | |||
| 84 | 2:dd889fff8423 | f | /**
|
| 85 | * Called in the graphic loop. It draws this chunk.
|
||
| 86 | */
|
||
| 87 | 0:02467299402e | f | void draw( const DrawInfo& di, ci::gl::BatchRef &batch ); |
| 88 | |||
| 89 | 2:dd889fff8423 | f | /**
|
| 90 | * Called in the graphic loop. It draws this chunk all the way to the bottom of the screen.
|
||
| 91 | * This method is called when the chunk is the first or last in a selection.
|
||
| 92 | */
|
||
| 93 | 0:02467299402e | f | void drawBar( const DrawInfo& di, ci::gl::BatchRef &batch ); |
| 94 | |||
| 95 | 2:dd889fff8423 | f | /**
|
| 96 | * Informs this chunk that it's the first chunk of the selection.
|
||
| 97 | */
|
||
| 98 | 5:75b744078d66 | f | void setAsSelectionStart(bool start){ |
| 99 | isSelectionStart = start; |
||
| 100 | } |
||
| 101 | 0:02467299402e | f | |
| 102 | 2:dd889fff8423 | f | /**
|
| 103 | * Informs this chunk that it's the last chunk of the selection.
|
||
| 104 | */
|
||
| 105 | 5:75b744078d66 | f | void setAsSelectionEnd(bool end){ |
| 106 | isSelectionEnd = end; |
||
| 107 | } |
||
| 108 | 0:02467299402e | f | |
| 109 | private:
|
||
| 110 | |||
| 111 | float mAudioTop;
|
||
| 112 | float mAudioBottom;
|
||
| 113 | |||
| 114 | float mX;
|
||
| 115 | |||
| 116 | float mAnimate = 1.0; |
||
| 117 | int mIndex;
|
||
| 118 | |||
| 119 | bool isSelectionStart = false; |
||
| 120 | bool isSelectionEnd = false; |
||
| 121 | |||
| 122 | bool mResetting = false; |
||
| 123 | |||
| 124 | }; |