Revision 5:75b744078d66 CollidoscopeApp

View differences:

CollidoscopeApp/include/AudioEngine.h
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 22
#pragma once
2 23

  
3 24
#include <array>
CollidoscopeApp/include/BufferToWaveRecorderNode.h
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
 This file incorporates work covered by the following copyright and permission notice: 
22

  
23
    Copyright (c) 2014, The Cinder Project
24

  
25
    This code is intended to be used with the Cinder C++ library, http://libcinder.org
26

  
27
    Redistribution and use in source and binary forms, with or without modification, are permitted provided that
28
    the following conditions are met:
29

  
30
    * Redistributions of source code must retain the above copyright notice, this list of conditions and
31
    the following disclaimer.
32
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
33
    the following disclaimer in the documentation and/or other materials provided with the distribution.
34

  
35
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
36
    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
37
    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
38
    ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
39
    TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40
    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41
    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42
    POSSIBILITY OF SUCH DAMAGE.
43
 
44
*/
45

  
1 46
#pragma once
2 47

  
3 48
#include "cinder/Cinder.h"
......
8 53

  
9 54
#include "Messages.h"
10 55

  
11
typedef std::shared_ptr<class BufferToWaveRecorderNode>	BufferToWaveRecorderNodeRef;
56
typedef std::shared_ptr<class BufferToWaveRecorderNode> BufferToWaveRecorderNodeRef;
12 57

  
13 58
typedef ci::audio::dsp::RingBufferT<RecordWaveMsg> RecordWaveMsgRingBuffer;
14 59

  
......
43 88
    void setNumSeconds(double numSeconds, bool shrinkToFit = false);
44 89

  
45 90
    //! Returns the length of the recording buffer in frames.
46
    size_t		getNumFrames() const	{ return mRecorderBuffer.getNumFrames(); }
91
    size_t      getNumFrames() const    { return mRecorderBuffer.getNumFrames(); }
47 92
    //! Returns the length of the recording buffer in seconds.
48
    double		getNumSeconds() const;
93
    double      getNumSeconds() const;
49 94

  
50 95
    //! \brief Returns a copy of the recored samples, up to the current write position.
51 96
    //!
52 97
    //! This method is non locking, and as such any resizing calls must be performed on the same thread or be otherwise synchronized.
53
    ci::audio::BufferRef	getRecordedCopy() const;
98
    ci::audio::BufferRef    getRecordedCopy() const;
54 99

  
55 100
    //! \brief Writes the currently recorded samples to a file at \a filePath
56 101
    //!
......
69 114

  
70 115

  
71 116
protected:
72
    void initialize()				override;
73
    void process(ci::audio::Buffer *buffer)	override;
117
    void initialize()               override;
118
    void process(ci::audio::Buffer *buffer) override;
74 119

  
75 120
    void initBuffers(size_t numFrames);
76 121

  
77 122
    static const float kMinAudioVal; 
78 123
    static const float kMaxAudioVal;
79 124

  
80
    ci::audio::BufferDynamic		mRecorderBuffer;
81
    ci::audio::BufferDynamicRef		mCopiedBuffer;
82
    std::atomic<uint64_t>	mLastOverrun;
125
    ci::audio::BufferDynamic        mRecorderBuffer;
126
    ci::audio::BufferDynamicRef     mCopiedBuffer;
127
    std::atomic<uint64_t>   mLastOverrun;
83 128

  
84 129
    RecordWaveMsgRingBuffer mRingBuffer;
85 130

  
CollidoscopeApp/include/Chunk.h
1
/*
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

  
1 24

  
2 25
#pragma once
3 26

  
......
26 49
    /**
27 50
     * Constructor, takes as argument the index of this chunk in the wave
28 51
     */ 
29
	Chunk( size_t index );
52
    Chunk( size_t index );
30 53

  
31 54
    /**
32 55
     * Sets the top value of this chunk. The value is passed in audio coordinates : [-1.0, 1.0]
......
49 72
     * Reset this chunks. When a chunk is reset it starts shrinking until it disappears.
50 73
     *
51 74
     */ 
52
	void reset(){
53
		mResetting = true;
54
	}
75
    void reset(){
76
        mResetting = true;
77
    }
55 78

  
56 79
    /**
57 80
     * Called in the graphic loop. It update this chunk. 
......
72 95
    /**
73 96
     * Informs this chunk that it's the first chunk of the selection.
74 97
     */ 
75
	void setAsSelectionStart(bool start){
76
		isSelectionStart = start;
77
	}
98
    void setAsSelectionStart(bool start){
99
        isSelectionStart = start;
100
    }
78 101

  
79 102
    /**
80 103
     * Informs this chunk that it's the last chunk of the selection.
81 104
     */ 
82
	void setAsSelectionEnd(bool end){
83
		isSelectionEnd = end;
84
	}
105
    void setAsSelectionEnd(bool end){
106
        isSelectionEnd = end;
107
    }
85 108

  
86 109
private:
87 110

  
CollidoscopeApp/include/Config.h
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 22
#pragma once
2 23

  
3 24
#include <string>
CollidoscopeApp/include/DrawInfo.h
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 22
#pragma once
2 23

  
3 24
#include "cinder/Area.h"
......
40 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 65
        /* clip into range [-1.1] */
45 66
        if (audioSample < -1.0f) {
46 67
            audioSample = -1.0f;
......
50 71
        }
51 72

  
52 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 77
        return ratio * mSelectionBarHeight; //remove  bounds.getY1() bound only needed for size of tier
57
	}
78
    }
58 79

  
59 80
    float getMaxChunkHeight() const 
60 81
    {
......
80 101
    /**
81 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 106
        if ( mWaveIndex == 0)
86
		    return mWindowHeight - y;
107
            return mWindowHeight - y;
87 108
        else
88 109
            return y;
89
	}
110
    }
90 111

  
91 112
    /**
92 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 118
        return x;
98
	}
119
    }
99 120

  
100 121

  
101 122
    // how much the wave is shrunk on the y axis with respect to the wave's tier 
CollidoscopeApp/include/EnvASR.h
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 22
#pragma once 
2 23

  
3 24
namespace collidoscope {
CollidoscopeApp/include/Log.h
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 22
#pragma once 
2 23

  
3 24

  
CollidoscopeApp/include/MIDI.h
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 22
#pragma once
2 23

  
3 24
#include "RtMidi.h"
CollidoscopeApp/include/Messages.h
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 22
#pragma once
2 23

  
3 24
/**
CollidoscopeApp/include/Oscilloscope.h
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 22
#pragma once
2 23

  
3 24
#include "cinder/gl/gl.h"
CollidoscopeApp/include/PGranular.h
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 22
#pragma once
2 23

  
3 24
#include <array>
CollidoscopeApp/include/PGranularNode.h
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 22
#pragma once
2 23

  
3 24
#include "cinder/Cinder.h"
......
54 75

  
55 76
protected:
56 77
    
57
    void initialize()							override;
78
    void initialize()                           override;
58 79

  
59
    void process( ci::audio::Buffer *buffer )	override;
80
    void process( ci::audio::Buffer *buffer )   override;
60 81

  
61 82
private:
62 83

  
CollidoscopeApp/include/ParticleController.h
1
/*
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

  
1 24
#pragma once
2 25

  
3 26
#include "cinder/gl/gl.h"
CollidoscopeApp/include/Resources.h
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 22
#pragma once
2 23
#include "cinder/CinderResources.h"
3 24

  
CollidoscopeApp/include/RingBufferPack.h
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 22
#pragma once
2 23

  
3 24
#include "cinder/audio/dsp/RingBuffer.h"
CollidoscopeApp/include/Wave.h
1
/*
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
*/
1 23
#pragma once
2 24

  
3 25

  
......
45 67
 */ 
46 68
class Wave
47 69
{
48
	friend class ParticleController;
70
    friend class ParticleController;
49 71

  
50 72
public:
51 73

  
......
53 75
     * The selection of the wave that is controlled by the big horizontal knob
54 76
     *
55 77
     */ 
56
	class Selection {
57
		
58
	public:
78
    class Selection {
79
        
80
    public:
59 81

  
60 82
        Selection( Wave * w, Color color );
61 83
        
......
63 85
        void setStart( size_t start );
64 86

  
65 87
        /** Sets the size of selection. size is the number of chunks the selection is made of */
66
		void setSize( size_t size );
67
		
88
        void setSize( size_t size );
89
        
68 90
        /** Particle spread is used to calculate the size of the cloud of particles */
69 91
        void inline setParticleSpread( float spread ){
70 92
            mParticleSpread = spread;
71
		}
93
        }
72 94

  
73
		size_t getStart(void) const { return mSelectionStart; }
74
		
95
        size_t getStart(void) const { return mSelectionStart; }
96
        
75 97
        size_t getEnd(void) const { return mSelectionEnd; }
76 98

  
77
		size_t inline getSize(void) const { 
78
			if (mNull)
79
				return 0;
80
			else
81
				return 1 + mSelectionEnd - mSelectionStart; 
82
		}
99
        size_t inline getSize(void) const { 
100
            if (mNull)
101
                return 0;
102
            else
103
                return 1 + mSelectionEnd - mSelectionStart; 
104
        }
83 105

  
84
		float inline  getParticleSpread() const { return mParticleSpread; }
106
        float inline  getParticleSpread() const { return mParticleSpread; }
85 107

  
86 108
        /** When selection is null no selection is showed on the wave */
87
		inline void setToNull(){
109
        inline void setToNull(){
88 110
            mParticleSpread = 1.0f;
89
			mNull = true;
90
		}
111
            mNull = true;
112
        }
91 113

  
92
		inline bool isNull() const{
93
			return mNull;
94
		}
114
        inline bool isNull() const{
115
            return mNull;
116
        }
95 117

  
96
		inline const Color & getColor() const{
97
			return mColor;
98
		}
118
        inline const Color & getColor() const{
119
            return mColor;
120
        }
99 121

  
100 122
    private:
101 123

  
......
111 133

  
112 134
        Wave * mWave;
113 135

  
114
	}; // class Selection
136
    }; // class Selection
115 137

  
116
	
138
    
117 139

  
118 140
#ifdef USE_PARTICLES
119
	ParticleController mParticleController;
141
    ParticleController mParticleController;
120 142
#endif 
121 143

  
122
	
144
    
123 145

  
124
	/* Maps id of the synth to cursor. There is one cursor for each Synth being played */
125
	std::map < SynthID, Cursor > mCursors;
146
    /* Maps id of the synth to cursor. There is one cursor for each Synth being played */
147
    std::map < SynthID, Cursor > mCursors;
126 148
    /** Holds the positions of the cursor, namely on which chunk the cursor is currently */
127
	std::vector<int> mCursorsPos;
149
    std::vector<int> mCursorsPos;
128 150

  
129 151
public:
130
	
152
    
131 153
    // value used to identify the loop for cursor position 
132 154
    static const int kLoopNote = -1;
133
	static const cinder::Color CURSOR_CLR;
134
	/* must be in sync with supercollider durationFactor ControlSpec max */
135
	static const int MAX_DURATION = 8;
155
    static const cinder::Color CURSOR_CLR;
156
    /* must be in sync with supercollider durationFactor ControlSpec max */
157
    static const int MAX_DURATION = 8;
136 158
#ifdef USE_PARTICLES
137
	static const int PARTICLESIZE_COEFF = 40;
159
    static const int PARTICLESIZE_COEFF = 40;
138 160
#endif
139 161

  
140 162
    /** Resetting a wave makes it shrink until it disappears. Each time a new sample is recorder the wave is reset
141 163
     *  \param onlyChunks if false the selection is also set to null, if true only the chunks are reset
142 164
     */
143
	void reset(bool onlyChunks);
165
    void reset(bool onlyChunks);
144 166

  
145 167
    /** sets top and bottom values for the chunk. 
146 168
     * \a bottom and \a top are in audio coordinates [-1.0, 1.0]
147 169
     */
148
	void setChunk(size_t index, float bottom, float top);
170
    void setChunk(size_t index, float bottom, float top);
149 171

  
150
	const Chunk & getChunk(size_t index);
172
    const Chunk & getChunk(size_t index);
151 173

  
152 174
    /** places the cursor on the wave. Every cursor is associated to a synth voice of the audio engine. 
153 175
     *  The synth id identifies uniquely the cursor in the internal map of the wave.
154 176
     *  If the cursor doesn't exist it is created */
155 177
    inline void setCursorPos( SynthID id, int pos, const DrawInfo& di ){
156 178

  
157
	    Cursor & cursor = mCursors[id];
158
	    cursor.pos = pos;
159
	    cursor.lastUpdate = ci::app::getElapsedSeconds();
179
        Cursor & cursor = mCursors[id];
180
        cursor.pos = pos;
181
        cursor.lastUpdate = ci::app::getElapsedSeconds();
160 182

  
161 183
#ifdef USE_PARTICLES
162
	    // The idea is that, if the duration is greater than 1.0, the cursor continues in form of particles
163
	    // The smaller the selection the more particles; the bigger the duration the more particles 
164
	    if (mSelection.getParticleSpread() > 1.0f){
165
		    /* amountCoeff ranges from 1/8 to 1 */
184
        // The idea is that, if the duration is greater than 1.0, the cursor continues in form of particles
185
        // The smaller the selection the more particles; the bigger the duration the more particles 
186
        if (mSelection.getParticleSpread() > 1.0f){
187
            /* amountCoeff ranges from 1/8 to 1 */
166 188
            const float amountCoeff = (mSelection.getParticleSpread() / MAX_DURATION);
167 189
                
168 190
            /* get radom point within seleciton as center of the particle */
......
173 195
            centrePoint.y = di.flipY( di.audioToHeigt(0.0) );
174 196

  
175 197
            const float wavePixelLen = mNumChunks * ( 2 + Chunk::kWidth);
176
		    centrePoint.x *= float(di.getWindowWidth()) / wavePixelLen;
198
            centrePoint.x *= float(di.getWindowWidth()) / wavePixelLen;
177 199

  
178
		    mParticleController.addParticles(
200
            mParticleController.addParticles(
179 201
                std::max( 1, (int)(amountCoeff * ParticleController::kMaxParticleAdd * mFilterCoeff) ), // amount of particles to add 
180
			    centrePoint,
202
                centrePoint,
181 203
                mSelection.getParticleSpread() * PARTICLESIZE_COEFF   // size of the cloud 
182
			    );
183
	    }
204
                );
205
        }
184 206
#endif
185 207

  
186
		
187
	}
208
        
209
    }
188 210

  
189 211
    void update( double secondsPerChunk, const DrawInfo& di );
190 212

  
191 213
    void removeCursor( SynthID id ) { mCursors.erase( id ); }
192 214

  
193 215
    /** Sets the transparency of this wave. \a alpha ranges from 0 to 1 */
194
	inline void setselectionAlpha(float alpha){ mFilterCoeff = alpha;}
216
    inline void setselectionAlpha(float alpha){ mFilterCoeff = alpha;}
195 217

  
196 218
    void draw( const DrawInfo& di );
197 219

  
198
	Selection& getSelection() { return mSelection; };
220
    Selection& getSelection() { return mSelection; };
199 221

  
200
	size_t getSize() const{ return mChunks.size();  }
222
    size_t getSize() const{ return mChunks.size();  }
201 223

  
202
	void setScopePoint(int index, float audioVal);
224
    void setScopePoint(int index, float audioVal);
203 225

  
204 226
    Wave( size_t numChunks, Color selectionColor );
205 227

  
CollidoscopeApp/src/AudioEngine.cpp
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
*/
22

  
1 23
#include "AudioEngine.h"
2 24
#include "cinder/app/App.h"
3 25
//FIXME remove App.h include 
CollidoscopeApp/src/BufferToWaveRecorderNode.cpp
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
 This file incorporates work covered by the following copyright and permission notice: 
22

  
23
    Copyright (c) 2014, The Cinder Project
24

  
25
    This code is intended to be used with the Cinder C++ library, http://libcinder.org
26

  
27
    Redistribution and use in source and binary forms, with or without modification, are permitted provided that
28
    the following conditions are met:
29

  
30
    * Redistributions of source code must retain the above copyright notice, this list of conditions and
31
    the following disclaimer.
32
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
33
    the following disclaimer in the documentation and/or other materials provided with the distribution.
34

  
35
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
36
    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
37
    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
38
    ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
39
    TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40
    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41
    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42
    POSSIBILITY OF SUCH DAMAGE.
43
 
44
*/
45

  
1 46
#include "BufferToWaveRecorderNode.h"
2 47
#include "cinder/audio/Context.h"
3 48
#include "cinder/audio/Target.h"
CollidoscopeApp/src/Chunk.cpp
1
/*
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

  
1 25
#include "Chunk.h"
2 26
#include "DrawInfo.h"
3 27

  
......
45 69

  
46 70
void Chunk::draw( const DrawInfo& di, ci::gl::BatchRef &batch ){
47 71
    using namespace ci;
48
	
72
    
49 73
    gl::pushModelMatrix();
50 74

  
51 75
    const float chunkHeight = mAnimate * mAudioTop * di.getMaxChunkHeight();
......
65 89

  
66 90

  
67 91
void Chunk::drawBar( const DrawInfo& di, ci::gl::BatchRef &batch ){
68
	using namespace ci;
92
    using namespace ci;
69 93

  
70 94
    gl::pushModelMatrix();
71 95

  
......
81 105

  
82 106

  
83 107
const float Chunk::kWidth = 7.0f;
84
const float Chunk::kHalfWidth = 3.5f;
108
const float Chunk::kHalfWidth = 3.5f;
CollidoscopeApp/src/CollidoscopeApp.cpp
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 22
#include "cinder/app/App.h"
2 23
#include "cinder/app/RendererGl.h"
3 24
#include "cinder/gl/gl.h"
......
22 43
class CollidoscopeApp : public App {
23 44
  public:
24 45

  
25
	void setup() override;
46
    void setup() override;
26 47
    void setupGraphics();
27 48

  
28 49
    void receiveCommands();
29 50

  
30
	void keyDown( KeyEvent event ) override;
31
	void update() override;
32
	void draw() override;
51
    void keyDown( KeyEvent event ) override;
52
    void update() override;
53
    void draw() override;
33 54
    void resize() override;
34 55

  
35
	Config mConfig;
56
    Config mConfig;
36 57
    collidoscope::MIDI mMIDI;
37 58
    AudioEngine mAudioEngine;
38
	
59
    
39 60
    array< shared_ptr< Wave >, NUM_WAVES > mWaves;
40 61
    array< shared_ptr< DrawInfo >, NUM_WAVES > mDrawInfos;
41 62
    array< shared_ptr< Oscilloscope >, NUM_WAVES > mOscilloscopes;
......
186 207
    };
187 208
        break;
188 209

  
189
	case 'm' :
190
		mAudioEngine.setGrainDurationCoeff(0, 8);
191
		break;
210
    case 'm' :
211
        mAudioEngine.setGrainDurationCoeff(0, 8);
212
        break;
192 213

  
193 214
    case 'n': {
194 215
        mAudioEngine.setGrainDurationCoeff( 0, 1 );
......
293 314

  
294 315
void CollidoscopeApp::draw()
295 316
{
296
	gl::clear( Color( 0, 0, 0 ) );
317
    gl::clear( Color( 0, 0, 0 ) );
297 318

  
298 319
    for ( int i = 0; i < NUM_WAVES; i++ ){
299 320
        if ( i == 1 ){
......
388 409
                mWaves[waveIdx]->getSelection().setSize( numSelectionChunks );
389 410

  
390 411
                // how many samples in one selection ?
391
				size_t selectionSize = mWaves[waveIdx]->getSelection().getSize() * (mConfig.getWaveLen() * mAudioEngine.getSampleRate() / mConfig.getNumChunks());
412
                size_t selectionSize = mWaves[waveIdx]->getSelection().getSize() * (mConfig.getWaveLen() * mAudioEngine.getSampleRate() / mConfig.getNumChunks());
392 413
                mAudioEngine.setSelectionSize( waveIdx, selectionSize );
393 414

  
394 415
            };
CollidoscopeApp/src/Config.cpp
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 22
#include "Config.h"
2 23

  
3 24

  
CollidoscopeApp/src/Log.cpp
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 22

  
2 23
#include "cinder/Log.h"
3 24

  
CollidoscopeApp/src/MIDI.cpp
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 22
#include "MIDI.h"
2 23
#include "Config.h"
3 24

  
CollidoscopeApp/src/PGranularNode.cpp
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 22
#include "PGranularNode.h"
2 23

  
3 24
#include "cinder/audio/Context.h"
CollidoscopeApp/src/ParticleController.cpp
1
/*
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

  
1 24
#include "ParticleController.h"
2 25
#include "cinder/Rand.h"
3 26

  
CollidoscopeApp/src/Wave.cpp
1
/*
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

  
1 24
#include "Wave.h"
2 25
#include "DrawInfo.h"
3 26

  
......
6 29

  
7 30
Wave::Wave( size_t numChunks, Color selectionColor ):
8 31
    mNumChunks( numChunks ),
9
	mSelection( this, selectionColor ),
10
	mColor(Color(0.5f, 0.5f, 0.5f)),
32
    mSelection( this, selectionColor ),
33
    mColor(Color(0.5f, 0.5f, 0.5f)),
11 34
    mFilterCoeff( 1.0f )
12 35
{
13
	mChunks.reserve( numChunks );
36
    mChunks.reserve( numChunks );
14 37

  
15
	for ( size_t i = 0; i < numChunks; i++ ){
16
		mChunks.emplace_back( i );
17
	}
38
    for ( size_t i = 0; i < numChunks; i++ ){
39
        mChunks.emplace_back( i );
40
    }
18 41

  
19 42
    // init cinder batch drawing
20 43
    auto lambert = gl::ShaderDef().color();
......
24 47

  
25 48
void Wave::reset( bool onlyChunks )
26 49
{
27
	for (size_t i = 0; i < getSize(); i++){
28
		mChunks[i].reset();
29
	}
50
    for (size_t i = 0; i < getSize(); i++){
51
        mChunks[i].reset();
52
    }
30 53

  
31
	if (onlyChunks)
32
		return;
54
    if (onlyChunks)
55
        return;
33 56

  
34
	mSelection.setToNull();
57
    mSelection.setToNull();
35 58
}
36 59

  
37 60

  
38 61
void Wave::setChunk(size_t index, float bottom, float top)
39 62
{
40
	Chunk &c = mChunks[index];
41
	c.setTop(top);
42
	c.setBottom(bottom);
63
    Chunk &c = mChunks[index];
64
    c.setTop(top);
65
    c.setBottom(bottom);
43 66
}
44 67

  
45 68
inline const Chunk & Wave::getChunk(size_t index)
46 69
{
47
	return mChunks[index];
70
    return mChunks[index];
48 71
}
49 72

  
50 73
void Wave::update( double secondsPerChunk, const DrawInfo& di ) {
......
89 112
void Wave::draw( const DrawInfo& di ){
90 113

  
91 114

  
92
	/* ########### draw the particles ########## */
115
    /* ########### draw the particles ########## */
93 116
#ifdef USE_PARTICLES
94
	mParticleController.draw();
117
    mParticleController.draw();
95 118
#endif
96 119

  
97
	/* ########### draw the wave ########## */
98
	/* scale the wave to fit the window */
99
	gl::pushModelView(); 
120
    /* ########### draw the wave ########## */
121
    /* scale the wave to fit the window */
122
    gl::pushModelView(); 
100 123

  
101
	
102
	const float wavePixelLen =  ( mNumChunks * ( 2 + Chunk::kWidth ) );
103
	/* scale the x-axis for the wave to fit the window precisely */
104
	gl::scale( ((float)di.getWindowWidth() ) / wavePixelLen , 1.0f);
105
	/* draw the chunks */
106
	if (mSelection.isNull()){
107
		/* no selection: all chunks the same color */
108
		gl::color(mColor); 
109
		for (size_t i = 0; i < getSize(); i++){
110
			mChunks[i].draw( di, mChunkBatch );
111
		}
112
	}
124
    
125
    const float wavePixelLen =  ( mNumChunks * ( 2 + Chunk::kWidth ) );
126
    /* scale the x-axis for the wave to fit the window precisely */
127
    gl::scale( ((float)di.getWindowWidth() ) / wavePixelLen , 1.0f);
128
    /* draw the chunks */
129
    if (mSelection.isNull()){
130
        /* no selection: all chunks the same color */
131
        gl::color(mColor); 
132
        for (size_t i = 0; i < getSize(); i++){
133
            mChunks[i].draw( di, mChunkBatch );
134
        }
135
    }
113 136
    else{ 
114 137
        // Selection not null 
115
		gl::color(this->mColor); 
138
        gl::color(this->mColor); 
116 139

  
117 140
        // update the array with cursor positions 
118 141
        mCursorsPos.clear();
......
120 143
            mCursorsPos.push_back( cursor.second.pos );
121 144
        }
122 145

  
123
		gl::enableAlphaBlending();
146
        gl::enableAlphaBlending();
124 147

  
125
		const float selectionAlpha = 0.5f + mFilterCoeff * 0.5f;
148
        const float selectionAlpha = 0.5f + mFilterCoeff * 0.5f;
126 149

  
127 150

  
128
		for (size_t i = 0; i < getSize(); i++){
129
			/* when in selection use selection color */
130
			
131
			if (i == mSelection.getStart()){
132
				/* draw the selection bar with a transparent selection color */
133
				gl::color(mSelection.getColor().r, mSelection.getColor().g, mSelection.getColor().b, 0.5f);
151
        for (size_t i = 0; i < getSize(); i++){
152
            /* when in selection use selection color */
153
            
154
            if (i == mSelection.getStart()){
155
                /* draw the selection bar with a transparent selection color */
156
                gl::color(mSelection.getColor().r, mSelection.getColor().g, mSelection.getColor().b, 0.5f);
134 157
                mChunks[i].drawBar( di, mChunkBatch );
135 158

  
136
				/* set the color to the selection */
137
				gl::color(mSelection.getColor().r, mSelection.getColor().g, mSelection.getColor().b, selectionAlpha);
138
			}
159
                /* set the color to the selection */
160
                gl::color(mSelection.getColor().r, mSelection.getColor().g, mSelection.getColor().b, selectionAlpha);
161
            }
139 162

  
140 163
            // check if one of the cursors is positioned in this chunk  
141
			if (std::find(mCursorsPos.begin(), mCursorsPos.end(),i) != mCursorsPos.end() ){
142
				gl::color(CURSOR_CLR);
143
				mChunks[i].draw( di, mChunkBatch );
144
				gl::color(mSelection.getColor().r, mSelection.getColor().g, mSelection.getColor().b, selectionAlpha);
145
			}
146
			else{
147
				/* just draw with current color */
148
				mChunks[i].draw( di, mChunkBatch );
149
			}
150
			
151
			/* exit selection: go back to wave color */
152
			if (i == mSelection.getEnd()){
153
				/* draw the selection bar with a transparent selection color */
154
				gl::color(mSelection.getColor().r, mSelection.getColor().g, mSelection.getColor().b, 0.5f);
164
            if (std::find(mCursorsPos.begin(), mCursorsPos.end(),i) != mCursorsPos.end() ){
165
                gl::color(CURSOR_CLR);
166
                mChunks[i].draw( di, mChunkBatch );
167
                gl::color(mSelection.getColor().r, mSelection.getColor().g, mSelection.getColor().b, selectionAlpha);
168
            }
169
            else{
170
                /* just draw with current color */
171
                mChunks[i].draw( di, mChunkBatch );
172
            }
173
            
174
            /* exit selection: go back to wave color */
175
            if (i == mSelection.getEnd()){
176
                /* draw the selection bar with a transparent selection color */
177
                gl::color(mSelection.getColor().r, mSelection.getColor().g, mSelection.getColor().b, 0.5f);
155 178
                mChunks[i].drawBar( di, mChunkBatch );
156
				/* set the colo to the wave */
157
				gl::color(this->mColor);  
158
			}
159
		}
160
		gl::disableAlphaBlending();
161
	}
162
	
179
                /* set the colo to the wave */
180
                gl::color(this->mColor);  
181
            }
182
        }
183
        gl::disableAlphaBlending();
184
    }
185
    
163 186

  
164
	gl::popModelView();
187
    gl::popModelView();
165 188

  
166 189
}
167 190

  
......
180 203

  
181 204
void Wave::Selection::setStart(size_t start)  {
182 205

  
183
	/* deselect the previous */
206
    /* deselect the previous */
184 207
    mWave->mChunks[mSelectionStart].setAsSelectionStart( false );
185
	/* select the next */
208
    /* select the next */
186 209
    mWave->mChunks[start].setAsSelectionStart( true );
187
	
188
	mNull = false;
210
    
211
    mNull = false;
189 212

  
190 213
    size_t size = getSize();
191 214

  
192
	mSelectionStart = start;
215
    mSelectionStart = start;
193 216
    mSelectionEnd = start + size - 1;
194 217
    if ( mSelectionEnd > mWave->getSize() - 1 )
195 218
        mSelectionEnd = mWave->getSize() - 1;
......
210 233
        size = mWave->mNumChunks - mSelectionStart - 1;
211 234
    }
212 235

  
213
	/* deselect the previous */
236
    /* deselect the previous */
214 237
    mWave->mChunks[mSelectionEnd].setAsSelectionEnd( false );
215 238

  
216 239
    mSelectionEnd = mSelectionStart + size;
217
	/* select the next */
240
    /* select the next */
218 241
    mWave->mChunks[mSelectionEnd].setAsSelectionEnd( true );
219 242

  
220
	mNull = false;
243
    mNull = false;
221 244
}
222 245

  
223 246

  

Also available in: Unified diff