Revision 5:75b744078d66 CollidoscopeApp/src
| 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