3
SimpleTest1Activity.java:
5
Copyright (C) 2011 Victor Lazzarini, Steven Yi
7
This file is part of Csound Android Examples.
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.
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.
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
26
package com.csounds.examples.tests;
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;
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;
43
public class SimpleTest1Activity extends BaseCsoundActivity implements CsoundObjCompletionListener {
45
ToggleButton startStopButton = null;
48
/** Called when the activity is first created. */
50
public void onCreate(Bundle savedInstanceState) {
51
super.onCreate(savedInstanceState);
52
setContentView(R.layout.simple_test_1);
54
startStopButton = (ToggleButton) findViewById(R.id.onOffButton);
55
fSlider = (SeekBar) findViewById(R.id.slider);
56
startStopButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
59
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
61
String csd = getResourceFileAsString(R.raw.test);
62
File f = createTempFile(csd);
63
csoundObj.addSlider(fSlider, "slider", 0.,
65
csoundObj.addCompletionListener(SimpleTest1Activity.this);
66
csoundObj.startCsound(f);
68
csoundObj.stopCsound();
76
csoundObj.addValueCacheable(new CsoundValueCacheable() {
79
public void updateValuesToCsound() {
80
// TODO Auto-generated method stub
85
public void updateValuesFromCsound() {
86
// TODO Auto-generated method stub
91
public void setup(CsoundObj csoundObj) {
92
Log.d("CsoundAndroidActivity", "ValueCacheable setup called");
96
public void cleanup() {
97
Log.d("CsoundAndroidActivity", "ValueCacheable cleanup called");
103
public void csoundObjComplete(CsoundObj csoundObj) {
104
handler.post(new Runnable() {
106
startStopButton.setChecked(false);