示例#1
0
 /**
  * put all of the compiled synth definitions from assets in the filesystem
  *
  * @param directory to place synths
  */
 public void deliverSynthDefs(String directory) { // "" defaults to assets folder
   try {
     String[] names = owner.getAssets().list(directory);
     for (String filename : names) {
       if (filename.contains(".scsyndef")) { // we only want .scsyndef files
         deliverSynthDef(filename);
         // Toast.makeText(this, filename, 3000).show();
       }
     }
   } catch (IOException e) {
     Toast.makeText(owner, e.getMessage(), 3000).show();
   }
 }
示例#2
0
 /**
  * put the new definition in the filesystem
  *
  * @param s synth to open
  */
 public void deliverSynthDef(String s) { // expecting s to be of form: *.scsyndef
   try {
     InputStream is = owner.getAssets().open(s);
     OutputStream os = new FileOutputStream("/sdcard/supercollider/synthdefs/" + s);
     byte[] buf = new byte[1024];
     int bytesRead = 0;
     while (-1 != (bytesRead = is.read(buf))) {
       os.write(buf, 0, bytesRead);
     }
     is.close();
     os.close();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }