Back to project page PsychoFlute.
The source code is released under:
GNU General Public License
If you think the Android project PsychoFlute listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* /* w w w . j ava2s . c o m*/ BaseCsoundActivity.java: Copyright (C) 2011 Victor Lazzarini, Steven Yi This file is part of Csound Android Examples. The Csound Android Examples is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. Csound is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Csound; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package la.noise.psychoflute; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import com.csounds.CsoundObj; public class BaseCsoundActivity extends Activity { protected CsoundObj csoundObj = new CsoundObj(); protected Handler handler = new Handler(); @Override public void onCreate(Bundle savedInstanceState) { csoundObj.setMessageLoggingEnabled(true); super.onCreate(savedInstanceState); } @Override protected void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); csoundObj.stopCsound(); } protected String getResourceFileAsString(int resId) { StringBuilder str = new StringBuilder(); InputStream is = getResources().openRawResource(resId); BufferedReader r = new BufferedReader(new InputStreamReader(is)); String line; try { while ((line = r.readLine()) != null) { str.append(line).append("\n"); } } catch (IOException ios) { } return str.toString(); } protected File createTempFile(String csd) { File f = null; try { f = File.createTempFile("temp", ".csd", this.getCacheDir()); FileOutputStream fos = new FileOutputStream(f); fos.write(csd.getBytes()); fos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return f; } }