comparison testApp.mm @ 8:e2c6cfe8c6b7

JSON logs and presets.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Thu, 10 Jan 2013 18:24:26 +0000
parents 845ea04f8e33
children 346807b47860
comparison
equal deleted inserted replaced
7:845ea04f8e33 8:e2c6cfe8c6b7
3 3
4 extern Grid theGridView; 4 extern Grid theGridView;
5 extern PresetManager presetManager; 5 extern PresetManager presetManager;
6 extern EventLogger eventLogger; 6 extern EventLogger eventLogger;
7 extern Frequencer frequencer; 7 extern Frequencer frequencer;
8 extern IViewController *iViewController;
8 //DeviceID3523537000 9 //DeviceID3523537000
9 //-------------------------------------------------------------- 10 //--------------------------------------------------------------
10 void testApp::setup(){ 11 void testApp::setup(){
11 ofSetOrientation(OF_ORIENTATION_90_LEFT);
12 12
13 ofBackground( 0, 0, 0 ); 13 ofBackground( 0, 0, 0 );
14 ofEnableAlphaBlending(); 14 ofEnableAlphaBlending();
15 15
16 // open an outgoing connection to HOST:PORT 16 // open an outgoing connection to HOST:PORT
53 freqIndexes.push_back(0); 53 freqIndexes.push_back(0);
54 freqIndexes.push_back(4); 54 freqIndexes.push_back(4);
55 freqIndexes.push_back(6); 55 freqIndexes.push_back(6);
56 freqIndexes.push_back(7); 56 freqIndexes.push_back(7);
57 freqIndexes.push_back(8); 57 freqIndexes.push_back(8);
58 58
59 keyboard = new ofxiPhoneKeyboard(500,380,320,32); 59 ofxiPhoneDeviceType device = ofxiPhoneGetDeviceType();
60 keyboard->setVisible(false); 60 cout << "Device: " << device << '\n';
61 keyboard->setBgColor(255, 255, 255, 255); 61
62 keyboard->setFontColor(0,0,0, 255); 62 ofxiPhoneSetOrientation( OF_ORIENTATION_DEFAULT ); // TODO orientation CRAP
63 keyboard->setFontSize(26); 63
64 64
65 ofxiPhoneSetOrientation( OF_ORIENTATION_90_RIGHT ); 65 //NSString * q = @"Why the hell did you do that? Are you mad?";
66 //[iViewController showQuestionPrompt:q];
66 67
67 //----------------- 68 //-----------------
68 // the number if libpd ticks per buffer, 69 // the number if libpd ticks per buffer,
69 // used to compute the audio buffer len: tpb * blocksize (always 64) 70 // used to compute the audio buffer len: tpb * blocksize (always 64)
70 int ticksPerBuffer = 8; // 8 * 64 = buffer len of 512 71 int ticksPerBuffer = 8; // 8 * 64 = buffer len of 512
114 { 115 {
115 116
116 if(((ofxUIButton *)e.widget)->getValue()){ 117 if(((ofxUIButton *)e.widget)->getValue()){
117 cout << "SAVE PRESET\n"; 118 cout << "SAVE PRESET\n";
118 stringstream n; 119 stringstream n;
119 double timemsd = [NSDate timeIntervalSinceReferenceDate]; 120 //double timemsd = [NSDate timeIntervalSinceReferenceDate];
120 long long timems = (long long)(timemsd*1000); 121 //long long timems = (long long)(timemsd*1000);
121 n << "P" << timems; 122 //n << "P" << timems;
122 string name = n.str(); 123 string name = n.str();
123 124
124 presetManager.addPreset(theGridView.getCoord(),name); 125 [iViewController showPresetNamePrompt:32];
125 eventLogger.logEvent(SAVE_PRESET, theGridView.getCoord()); 126
126 } 127 }
127 /* 128 /*
128 if(!keyboard->isKeyboardShowing()){ 129 if(!keyboard->isKeyboardShowing()){
129 keyboard->openKeyboard(); 130 keyboard->openKeyboard();
130 keyboard->setVisible(true); 131 keyboard->setVisible(true);
145 eventLogger.logEvent(SET_MIN_ZOOM); 146 eventLogger.logEvent(SET_MIN_ZOOM);
146 } 147 }
147 }else if(e.widget->getName() == "ZOOM MAX") 148 }else if(e.widget->getName() == "ZOOM MAX")
148 { 149 {
149 if(((ofxUIButton *)e.widget)->getValue()){ 150 if(((ofxUIButton *)e.widget)->getValue()){
150 cout << "ZOOM MAX\n"; 151 cout << "ZOOM MAX\n";
151 theGridView.setMaxZoom(); 152 theGridView.setMaxZoom();
152 eventLogger.logEvent(SET_MAX_ZOOM); 153 eventLogger.logEvent(SET_MAX_ZOOM);
153 //eventLogger.printAll(); 154
154 } 155 }
155 }else{ 156 }else{
156 cout << "GUI error : unknown event recieved\n"; 157 cout << "GUI error : unknown event recieved\n";
157 } 158 }
158 159
288 for(int i=0; i < 16; i++){ 289 for(int i=0; i < 16; i++){
289 seqSteps.addFloat(round(steps[i])); // rounding here?? 290 seqSteps.addFloat(round(steps[i])); // rounding here??
290 } 291 }
291 292
292 core.pd.sendList("fromOF", seqSteps); 293 core.pd.sendList("fromOF", seqSteps);
293 //core.pd.sendMessage("fromOF", "msg", seqSteps); 294
294
295 // implement synth param calculations here?
296 // oscshape, filt type , cut off, envelope, mod freq (fm for sine, ? for pulse, sync for saw)
297 // oscillators:
298 sendOscShape(sliderVals[5]); 295 sendOscShape(sliderVals[5]);
299 sendFiltType(sliderVals[6]); 296 sendFiltType(sliderVals[6]);
300 sendFiltFreq(sliderVals[7]); 297 sendFiltFreq(sliderVals[7]);
301 sendEnvShape(sliderVals[8]); 298 sendEnvShape(sliderVals[8]);
302 sendModFreq(sliderVals[9]); 299 sendModFreq(sliderVals[9]);
303 300
304 } 301 }
302 //--------------------------------------------------------------
305 #pragma mark STANDARD OF FUNCTIONS 303 #pragma mark STANDARD OF FUNCTIONS
306 //-------------------------------------------------------------- 304 //--------------------------------------------------------------
307 void testApp::update(){ 305 void testApp::update(){
308 //we do a heartbeat on iOS as the phone will shut down the network connection to save power 306 //we do a heartbeat on iOS as the phone will shut down the network connection to save power
309 //this keeps the network alive as it thinks it is being used. 307 //this keeps the network alive as it thinks it is being used.
568 } 566 }
569 567
570 //-------------------------------------------------------------- 568 //--------------------------------------------------------------
571 void testApp::deviceOrientationChanged(int newOrientation){ 569 void testApp::deviceOrientationChanged(int newOrientation){
572 cout << "orientation: " << newOrientation; 570 cout << "orientation: " << newOrientation;
573 keyboard->updateOrientation(); // takes ages , only applies to text box 571 //keyboard->updateOrientation(); // takes ages , only applies to text box
574 if(newOrientation == 4){ 572 if(newOrientation == 4){
575 ofxiPhoneSetOrientation( OF_ORIENTATION_90_RIGHT ); 573 ofxiPhoneSetOrientation( OF_ORIENTATION_90_RIGHT );
576 }else if(newOrientation == 3){ 574 }else if(newOrientation == 3){
577 ofxiPhoneSetOrientation( OF_ORIENTATION_90_LEFT ); 575 ofxiPhoneSetOrientation( OF_ORIENTATION_90_LEFT );
578 } 576 }
634 y2 = y1; 632 y2 = y1;
635 y1 = y0; 633 y1 = y0;
636 634
637 return y0; 635 return y0;
638 } 636 }
639 637 //---------------------------------------------------------------
640 void testApp::sendOscShape(int ctrlin){ 638 void testApp::sendOscShape(int ctrlin){
641 639
642 static int numpoints = 5; 640 static int numpoints = 5;
643 static int numcontrols = 5; 641 static int numcontrols = 5;
644 //float values[points][controls] = 642 //float values[points][controls] =
665 core.pd.sendList("fromOF", toPD); 663 core.pd.sendList("fromOF", toPD);
666 //cout << ctrlName[i] << "sending" << ctrlout[i] << "\n"; 664 //cout << ctrlName[i] << "sending" << ctrlout[i] << "\n";
667 } 665 }
668 666
669 } 667 }
668 //---------------------------------------------------------------
670 void testApp::sendFiltType(int ctrlin){ 669 void testApp::sendFiltType(int ctrlin){
671 static int numpoints = 3; 670 static int numpoints = 3;
672 static int numcontrols = 4; 671 static int numcontrols = 4;
673 //float values[points][controls] = 672 //float values[points][controls] =
674 float ctrlout[numcontrols]; 673 float ctrlout[numcontrols];
691 690
692 core.pd.sendList("fromOF", toPD); 691 core.pd.sendList("fromOF", toPD);
693 //cout << ctrlName[i] << "sending" << ctrlout[i] << "\n"; 692 //cout << ctrlName[i] << "sending" << ctrlout[i] << "\n";
694 } 693 }
695 } 694 }
695 //---------------------------------------------------------------
696 void testApp::sendFiltFreq(int ctrlin){ 696 void testApp::sendFiltFreq(int ctrlin){
697 List toPD; 697 List toPD;
698 698
699 toPD.addSymbol("filtFreq"); 699 toPD.addSymbol("filtFreq");
700 toPD.addFloat(ctrlin); 700 toPD.addFloat(ctrlin);
701 701
702 core.pd.sendList("fromOF", toPD); 702 core.pd.sendList("fromOF", toPD);
703 } 703 }
704 //---------------------------------------------------------------
704 void testApp::sendEnvShape(int ctrlin){ 705 void testApp::sendEnvShape(int ctrlin){
705 static int numpoints = 5; 706 static int numpoints = 5;
706 static int numcontrols = 3; 707 static int numcontrols = 3;
707 //float values[points][controls] = 708 //float values[points][controls] =
708 float ctrlout[numcontrols]; 709 float ctrlout[numcontrols];
727 728
728 core.pd.sendList("fromOF", toPD); 729 core.pd.sendList("fromOF", toPD);
729 //cout << ctrlName[i] << "sending" << ctrlout[i] << "\n"; 730 //cout << ctrlName[i] << "sending" << ctrlout[i] << "\n";
730 } 731 }
731 } 732 }
733 //---------------------------------------------------------------
732 void testApp::sendModFreq(int ctrlin){ 734 void testApp::sendModFreq(int ctrlin){
733 float fm = ctrlin/127.; 735 float fm = ctrlin/127.;
734 List toPD; 736 List toPD;
735 737
736 toPD.addSymbol("FMFreq"); 738 toPD.addSymbol("FMFreq");
737 toPD.addFloat(fm); // rounding here?? 739 toPD.addFloat(fm); // rounding here??
738 740
739 core.pd.sendList("fromOF", toPD); 741 core.pd.sendList("fromOF", toPD);
740 } 742 }
743 //---------------------------------------------------------------