~ubuntu-branches/ubuntu/precise/csound/precise

« back to all changes in this revision

Viewing changes to android/CsoundAndroidExamples/src/com/csounds/examples/tests/SimpleTest1Activity.java

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2012-04-19 09:26:46 UTC
  • mfrom: (3.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20120419092646-96xbj1n6atuqosk2
Tags: 1:5.17.6~dfsg-1
* New upstream release
 - Do not build the wiimote opcodes (we need wiiuse).
* Add new API function to symbols file
* Disable lua opcodes, they were broken. Requires OpenMP to be enabled.
* Backport fixes from upstream:
  - Link dssi4cs with dl. Backport
  - Fix building of CsoundAC

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 
 
3
 SimpleTest1Activity.java:
 
4
 
 
5
 Copyright (C) 2011 Victor Lazzarini, Steven Yi
 
6
 
 
7
 This file is part of Csound Android Examples.
 
8
 
 
9
 The Csound Android Examples is free software; you can redistribute it
 
10
 and/or modify it under the terms of the GNU Lesser General Public
 
11
 License as published by the Free Software Foundation; either
 
12
 version 2.1 of the License, or (at your option) any later version.   
 
13
 
 
14
 Csound 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 Lesser General Public License for more details.
 
18
 
 
19
 You should have received a copy of the GNU Lesser General Public
 
20
 License along with Csound; if not, write to the Free Software
 
21
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
22
 02111-1307 USA
 
23
 
 
24
 */
 
25
 
 
26
package com.csounds.examples.tests;
 
27
 
 
28
import java.io.File;
 
29
 
 
30
import android.os.Bundle;
 
31
import android.util.Log;
 
32
import android.widget.CompoundButton;
 
33
import android.widget.CompoundButton.OnCheckedChangeListener;
 
34
import android.widget.SeekBar;
 
35
import android.widget.ToggleButton;
 
36
 
 
37
import com.csounds.CsoundObj;
 
38
import com.csounds.CsoundObjCompletionListener;
 
39
import com.csounds.examples.BaseCsoundActivity;
 
40
import com.csounds.examples.R;
 
41
import com.csounds.valueCacheable.CsoundValueCacheable;
 
42
 
 
43
public class SimpleTest1Activity extends BaseCsoundActivity implements CsoundObjCompletionListener {
 
44
 
 
45
        ToggleButton startStopButton = null;
 
46
        SeekBar fSlider;
 
47
        
 
48
        /** Called when the activity is first created. */
 
49
        @Override
 
50
        public void onCreate(Bundle savedInstanceState) {
 
51
                super.onCreate(savedInstanceState);
 
52
                setContentView(R.layout.simple_test_1);
 
53
                
 
54
                startStopButton = (ToggleButton) findViewById(R.id.onOffButton);
 
55
                fSlider = (SeekBar) findViewById(R.id.slider);
 
56
                startStopButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
 
57
                        
 
58
                        @Override
 
59
                        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
 
60
                                if(isChecked) {
 
61
                                        String csd = getResourceFileAsString(R.raw.test);
 
62
                                        File f = createTempFile(csd);
 
63
                                        csoundObj.addSlider(fSlider, "slider", 0.,
 
64
                                                        1.);
 
65
                                        csoundObj.addCompletionListener(SimpleTest1Activity.this);
 
66
                                        csoundObj.startCsound(f);
 
67
                                } else {
 
68
                                        csoundObj.stopCsound();
 
69
                                }
 
70
                                
 
71
                        }
 
72
                });
 
73
                
 
74
        
 
75
                
 
76
                csoundObj.addValueCacheable(new CsoundValueCacheable() {
 
77
                        
 
78
                        @Override
 
79
                        public void updateValuesToCsound() {
 
80
                                // TODO Auto-generated method stub
 
81
                                
 
82
                        }
 
83
                        
 
84
                        @Override
 
85
                        public void updateValuesFromCsound() {
 
86
                                // TODO Auto-generated method stub
 
87
                                
 
88
                        }
 
89
                        
 
90
                        @Override
 
91
                        public void setup(CsoundObj csoundObj) {
 
92
                                Log.d("CsoundAndroidActivity", "ValueCacheable setup called");
 
93
                        }
 
94
                        
 
95
                        @Override
 
96
                        public void cleanup() {
 
97
                                Log.d("CsoundAndroidActivity", "ValueCacheable cleanup called");
 
98
                        }
 
99
                });
 
100
        }
 
101
 
 
102
        @Override
 
103
        public void csoundObjComplete(CsoundObj csoundObj) {
 
104
                handler.post(new Runnable() {
 
105
                        public void run() {
 
106
                                startStopButton.setChecked(false);
 
107
                        }
 
108
                });
 
109
        }
 
110
        
 
111
}