Mercurial > hg > opencollidoscope
comparison CollidoscopeApp/src/CollidoscopeApp.cpp @ 5:75b744078d66
added license
author | Fiore Martin <f.martin@qmul.ac.uk> |
---|---|
date | Wed, 13 Jul 2016 16:06:46 +0200 |
parents | 02467299402e |
children | 4c0e82b725d9 |
comparison
equal
deleted
inserted
replaced
4:ab6db404403a | 5:75b744078d66 |
---|---|
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 #include "cinder/app/App.h" | 22 #include "cinder/app/App.h" |
2 #include "cinder/app/RendererGl.h" | 23 #include "cinder/app/RendererGl.h" |
3 #include "cinder/gl/gl.h" | 24 #include "cinder/gl/gl.h" |
4 #include "cinder/Exception.h" | 25 #include "cinder/Exception.h" |
5 | 26 |
20 | 41 |
21 | 42 |
22 class CollidoscopeApp : public App { | 43 class CollidoscopeApp : public App { |
23 public: | 44 public: |
24 | 45 |
25 void setup() override; | 46 void setup() override; |
26 void setupGraphics(); | 47 void setupGraphics(); |
27 | 48 |
28 void receiveCommands(); | 49 void receiveCommands(); |
29 | 50 |
30 void keyDown( KeyEvent event ) override; | 51 void keyDown( KeyEvent event ) override; |
31 void update() override; | 52 void update() override; |
32 void draw() override; | 53 void draw() override; |
33 void resize() override; | 54 void resize() override; |
34 | 55 |
35 Config mConfig; | 56 Config mConfig; |
36 collidoscope::MIDI mMIDI; | 57 collidoscope::MIDI mMIDI; |
37 AudioEngine mAudioEngine; | 58 AudioEngine mAudioEngine; |
38 | 59 |
39 array< shared_ptr< Wave >, NUM_WAVES > mWaves; | 60 array< shared_ptr< Wave >, NUM_WAVES > mWaves; |
40 array< shared_ptr< DrawInfo >, NUM_WAVES > mDrawInfos; | 61 array< shared_ptr< DrawInfo >, NUM_WAVES > mDrawInfos; |
41 array< shared_ptr< Oscilloscope >, NUM_WAVES > mOscilloscopes; | 62 array< shared_ptr< Oscilloscope >, NUM_WAVES > mOscilloscopes; |
42 // buffers to read the wave messages as a new wave gets recorded | 63 // buffers to read the wave messages as a new wave gets recorded |
43 array< RecordWaveMsg*, NUM_WAVES> mRecordWaveMessageBuffers; | 64 array< RecordWaveMsg*, NUM_WAVES> mRecordWaveMessageBuffers; |
184 mAudioEngine.loopOff( 1 ); | 205 mAudioEngine.loopOff( 1 ); |
185 } | 206 } |
186 }; | 207 }; |
187 break; | 208 break; |
188 | 209 |
189 case 'm' : | 210 case 'm' : |
190 mAudioEngine.setGrainDurationCoeff(0, 8); | 211 mAudioEngine.setGrainDurationCoeff(0, 8); |
191 break; | 212 break; |
192 | 213 |
193 case 'n': { | 214 case 'n': { |
194 mAudioEngine.setGrainDurationCoeff( 0, 1 ); | 215 mAudioEngine.setGrainDurationCoeff( 0, 1 ); |
195 }; | 216 }; |
196 break; | 217 break; |
291 | 312 |
292 } | 313 } |
293 | 314 |
294 void CollidoscopeApp::draw() | 315 void CollidoscopeApp::draw() |
295 { | 316 { |
296 gl::clear( Color( 0, 0, 0 ) ); | 317 gl::clear( Color( 0, 0, 0 ) ); |
297 | 318 |
298 for ( int i = 0; i < NUM_WAVES; i++ ){ | 319 for ( int i = 0; i < NUM_WAVES; i++ ){ |
299 if ( i == 1 ){ | 320 if ( i == 1 ){ |
300 /* for the upper wave flip the x over the center of the screen which is | 321 /* for the upper wave flip the x over the center of the screen which is |
301 the composition of rotate on the y-axis and translate by -screenwidth*/ | 322 the composition of rotate on the y-axis and translate by -screenwidth*/ |
386 size_t numSelectionChunks = ci::lmap<size_t>( midiVal, 0, 127, 1, mConfig.getMaxSelectionNumChunks() ); | 407 size_t numSelectionChunks = ci::lmap<size_t>( midiVal, 0, 127, 1, mConfig.getMaxSelectionNumChunks() ); |
387 | 408 |
388 mWaves[waveIdx]->getSelection().setSize( numSelectionChunks ); | 409 mWaves[waveIdx]->getSelection().setSize( numSelectionChunks ); |
389 | 410 |
390 // how many samples in one selection ? | 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 mAudioEngine.setSelectionSize( waveIdx, selectionSize ); | 413 mAudioEngine.setSelectionSize( waveIdx, selectionSize ); |
393 | 414 |
394 }; | 415 }; |
395 break; | 416 break; |
396 | 417 |