@@ -27,6 +27,21 @@ void ofApp::setup(){
2727 text.setFillColor (ofColor (245 , 58 , 135 ));
2828
2929 doShader = false ;
30+
31+
32+ // SOUND
33+ // ofSetOrientation(OF_ORIENTATION_90_LEFT);
34+ loadok = synth.loadSound (" sounds/synth.wav" );
35+ loadok = beats.loadSound (" sounds/1085.mp3" );
36+ loadok = vocals.loadSound (" sounds/Violet.mp3" );
37+ synth.setVolume (1 .0f );
38+ beats.setVolume (0 .75f );
39+ vocals.setVolume (1 .0f );
40+ synth.setMultiPlay (true );
41+ beats.setMultiPlay (false );
42+ vocals.setMultiPlay (true );
43+
44+
3045}
3146
3247void ofApp::exit (){
@@ -35,7 +50,8 @@ void ofApp::exit(){
3550
3651// --------------------------------------------------------------
3752void ofApp::update (){
38-
53+ // update the sound playing system:
54+ ofSoundUpdate ();
3955}
4056
4157// --------------------------------------------------------------
@@ -46,10 +62,6 @@ void ofApp::draw(){
4662 int b = 128 + 50 * sinf (ofGetElapsedTimef ());
4763
4864 ofBackground (r,g,b);
49-
50- // ofSetColor(245, 58, 135);
51- // ofFill();
52- // font.drawStringAsShapes("meditate", 300, 400);
5365
5466 if ( doShader ){
5567 shader.begin ();
@@ -69,9 +81,6 @@ void ofApp::draw(){
6981 if ( doShader ){
7082 shader.end ();
7183 }
72-
73-
74-
7584}
7685
7786// --------------------------------------------------------------
@@ -92,11 +101,32 @@ void ofApp::windowResized(int w, int h){
92101// --------------------------------------------------------------
93102void ofApp::touchDown (int x, int y, int id){
94103 doShader = true ;
104+
105+ float widthStep = ofGetWidth () / 3 .0f ;
106+ if (x < widthStep){
107+ float pct = x / widthStep;
108+ synth.play ();
109+ synth.setSpeed ( 0 .1f + ((float )(ofGetHeight () - y) / (float )ofGetHeight ())*2 .0f );
110+ synth.setPan (2.0 *pct-1.0 );
111+ }
112+ else if (x >= widthStep && x < widthStep*2 ){
113+ beats.play ();
114+ }
115+ else {
116+ vocals.play ();
117+ vocals.setSpeed ( 0 .1f + ((float )(ofGetHeight () - y) / (float )ofGetHeight ())*2 .0f );
118+ vocals.setPan (2.0 *(float )(x - widthStep*2 ) / (float )widthStep-1.0 );
119+ }
95120}
96121
97122// --------------------------------------------------------------
98123void ofApp::touchMoved (int x, int y, int id){
99-
124+ // continuously control the speed of the beat sample via drag,
125+ // when in the "beat" region:
126+ float widthStep = ofGetWidth () / 3 .0f ;
127+ if (x >= widthStep && x < widthStep*2 ){
128+ beats.setSpeed ( 0 .5f + ((float )(ofGetHeight () - y) / (float )ofGetHeight ())*1 .0f );
129+ }
100130}
101131
102132// --------------------------------------------------------------
0 commit comments