annotate CollidoscopeApp/include/Chunk.h @ 18:f1ff1a81be20 tip

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