To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (2.5 KB)

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