annotate CollidoscopeApp/include/Chunk.h @ 2:dd889fff8423

added some comments
author Fiore Martin <f.martin@qmul.ac.uk>
date Mon, 11 Jul 2016 17:03:40 +0200
parents 02467299402e
children 75b744078d66
rev   line source
f@0 1
f@0 2 #pragma once
f@0 3
f@0 4 #include "cinder/Color.h"
f@0 5 #include "cinder/gl/Batch.h"
f@0 6
f@0 7 class DrawInfo;
f@0 8
f@2 9 /**
f@2 10 *
f@2 11 * A chunk of audio in Collidoscope low-fi visual wave.
f@2 12 *
f@2 13 * 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.
f@2 14 * A Chunk is one of the bars of the visual wave.
f@2 15 *
f@2 16 */
f@2 17
f@0 18 class Chunk
f@0 19 {
f@0 20
f@0 21 public:
f@0 22
f@0 23 const static float kWidth;
f@0 24 const static float kHalfWidth;
f@0 25
f@2 26 /**
f@2 27 * Constructor, takes as argument the index of this chunk in the wave
f@2 28 */
f@0 29 Chunk( size_t index );
f@0 30
f@2 31 /**
f@2 32 * Sets the top value of this chunk. The value is passed in audio coordinates : [-1.0, 1.0]
f@2 33 */
f@0 34 void inline setTop(float t) { mAudioTop = t; mAnimate = 0.0f; mResetting = false; /* startes the animation to crate a chunk */ }
f@2 35 /**
f@2 36 * Sets the bottom value of this chunk. The value is passed in audio coordinates : [-1.0, 1.0]
f@2 37 */
f@0 38 void inline setBottom(float b) { mAudioBottom = b; mAnimate = 0.0f; mResetting = false; }
f@2 39 /**
f@2 40 * Get the top value of this chunk. The value is returned in audio coordinates : [-1.0, 1.0]
f@2 41 */
f@0 42 float inline getTop() const { return mAudioTop; }
f@2 43 /**
f@2 44 * Get the bottom value of this chunk. The value is returned in audio coordinates : [-1.0, 1.0]
f@2 45 */
f@0 46 float inline getBottom() const { return mAudioBottom; }
f@0 47
f@2 48 /**
f@2 49 * Reset this chunks. When a chunk is reset it starts shrinking until it disappears.
f@2 50 *
f@2 51 */
f@0 52 void reset(){
f@0 53 mResetting = true;
f@0 54 }
f@0 55
f@2 56 /**
f@2 57 * Called in the graphic loop. It update this chunk.
f@2 58 */
f@0 59 void update( const DrawInfo& di );
f@0 60
f@2 61 /**
f@2 62 * Called in the graphic loop. It draws this chunk.
f@2 63 */
f@0 64 void draw( const DrawInfo& di, ci::gl::BatchRef &batch );
f@0 65
f@2 66 /**
f@2 67 * Called in the graphic loop. It draws this chunk all the way to the bottom of the screen.
f@2 68 * This method is called when the chunk is the first or last in a selection.
f@2 69 */
f@0 70 void drawBar( const DrawInfo& di, ci::gl::BatchRef &batch );
f@0 71
f@2 72 /**
f@2 73 * Informs this chunk that it's the first chunk of the selection.
f@2 74 */
f@0 75 void setAsSelectionStart(bool start){
f@0 76 isSelectionStart = start;
f@0 77 }
f@0 78
f@2 79 /**
f@2 80 * Informs this chunk that it's the last chunk of the selection.
f@2 81 */
f@0 82 void setAsSelectionEnd(bool end){
f@0 83 isSelectionEnd = end;
f@0 84 }
f@0 85
f@0 86 private:
f@0 87
f@0 88 float mAudioTop;
f@0 89 float mAudioBottom;
f@0 90
f@0 91 float mX;
f@0 92
f@0 93 float mAnimate = 1.0;
f@0 94 int mIndex;
f@0 95
f@0 96 bool isSelectionStart = false;
f@0 97 bool isSelectionEnd = false;
f@0 98
f@0 99 bool mResetting = false;
f@0 100
f@0 101 };