comparison CollidoscopeApp/src/CollidoscopeApp.cpp @ 6:4c0e82b725d9

added command line arguments for window size
author Fiore Martin <f.martin@qmul.ac.uk>
date Thu, 14 Jul 2016 15:08:31 +0200
parents 75b744078d66
children 20bb004a36de
comparison
equal deleted inserted replaced
5:75b744078d66 6:4c0e82b725d9
17 17
18 You should have received a copy of the GNU General Public License 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/>. 19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */ 20 */
21 21
22
22 #include "cinder/app/App.h" 23 #include "cinder/app/App.h"
23 #include "cinder/app/RendererGl.h" 24 #include "cinder/app/RendererGl.h"
24 #include "cinder/gl/gl.h" 25 #include "cinder/gl/gl.h"
25 #include "cinder/Exception.h" 26 #include "cinder/Exception.h"
27 #include <stdexcept>
26 28
27 29
28 #include "Config.h" 30 #include "Config.h"
29 #include "Wave.h" 31 #include "Wave.h"
30 #include "DrawInfo.h" 32 #include "DrawInfo.h"
44 public: 46 public:
45 47
46 void setup() override; 48 void setup() override;
47 void setupGraphics(); 49 void setupGraphics();
48 50
51 /** Receives MIDI command messages from MIDI thread */
49 void receiveCommands(); 52 void receiveCommands();
53 /** Prints command line usage */
54 void usage();
50 55
51 void keyDown( KeyEvent event ) override; 56 void keyDown( KeyEvent event ) override;
52 void update() override; 57 void update() override;
53 void draw() override; 58 void draw() override;
54 void resize() override; 59 void resize() override;
120 char c = event.getChar(); 125 char c = event.getChar();
121 126
122 switch (c){ 127 switch (c){
123 case 'r' : 128 case 'r' :
124 mAudioEngine.record( 0 ); 129 mAudioEngine.record( 0 );
125 mAudioEngine.record( 1 );
126 break; 130 break;
127 131
128 case 'w': { 132 case 'w': {
133
129 mWaves[0]->getSelection().setSize(mWaves[0]->getSelection().getSize() + 1); 134 mWaves[0]->getSelection().setSize(mWaves[0]->getSelection().getSize() + 1);
130 135
131 size_t numSelectionChunks = mWaves[0]->getSelection().getSize(); 136 size_t numSelectionChunks = mWaves[0]->getSelection().getSize();
132 // how many samples in one selection ? 137 // how many samples in one selection ?
133 size_t selectionSize = numSelectionChunks * (mConfig.getWaveLen() * mAudioEngine.getSampleRate() / mConfig.getNumChunks()); 138 size_t selectionSize = numSelectionChunks * (mConfig.getWaveLen() * mAudioEngine.getSampleRate() / mConfig.getNumChunks());
465 /* delete the array for wave messages from audio thread */ 470 /* delete the array for wave messages from audio thread */
466 delete[] mRecordWaveMessageBuffers[chan]; 471 delete[] mRecordWaveMessageBuffers[chan];
467 } 472 }
468 } 473 }
469 474
475
470 CINDER_APP( CollidoscopeApp, RendererGl, [] ( App::Settings *settings) { 476 CINDER_APP( CollidoscopeApp, RendererGl, [] ( App::Settings *settings) {
471 settings->setWindowSize( 1920, 1080 ); 477
472 settings->setMultiTouchEnabled( false ); 478 const std::vector< string > args = settings->getCommandLineArgs();
473 settings->disableFrameRate(); 479
480 int width = 0;
481 int height = 0;
482
483 try {
484 if( args.size() != 3 )
485 throw std::invalid_argument("");
486
487 width = std::stoi( args[1] );
488 height = std::stoi( args[2] );
489
490 }
491 catch( std::invalid_argument & e ){
492 console() << "Error: invalid arguments" << std::endl;
493 console() << "Usage: ./Collidoscope window_width window_height" << std::endl;
494 console() << "For example: ./Collidoscope 1024 768 " << std::endl;
495
496 settings->setShouldQuit( true );
497 return;
498 }
499
500 settings->setWindowSize( width, height );
501 settings->setMultiTouchEnabled( false );
502 settings->disableFrameRate();
474 503
475 } ) 504 } )