Skip to content
Browse files

more house keeping

  • Loading branch information...
1 parent aeee619 commit 3350868104557adbf13f976c349c8aa6855e2da7 @rorywalsh rorywalsh committed
Showing with 0 additions and 226 deletions.
  1. +0 −12 csoundo/src/csoundo/Cast.java
  2. +0 −141 csoundo/src/csoundo/Engine.java
  3. +0 −73 csoundo/src/csoundo/Mutex.java
View
12 csoundo/src/csoundo/Cast.java
@@ -1,12 +0,0 @@
-package csoundo;
-
-class Cast<T extends Number> {
-
- public float toFloat(T t) {
- return t.floatValue();
- }
-
- public T toCast(Number n){
- return (T) n;
- }
-}
View
141 csoundo/src/csoundo/Engine.java
@@ -1,141 +0,0 @@
-/**
- * A Csound interface library for Processing.
- *
- * (c) 2010
- *
- * This library 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.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307 USA
- *
- * @author Jacob Joaquin http://csoundblog.com
- * @modified 09/02/2010
- * @version 0.1.2
- */
-
-package csoundo;
-
-import csnd.*;
-import java.io.*;
-
-/**
- * This class is for getting Csound up and running.
- */
-public class Engine {
- private String csd;
- private String path;
- public String options = "-g -odac";
- private String tempCSD = "__CSOUNDO__.csd";
-
- public int compile;
- public boolean isRunning = false, androidMode=false;
-
- public Csound csound;
- public CsoundFile csoundFile;
- public CsoundPerformanceThread perfThread;
-
- public SWIGTYPE_p_void v;
- public SWIGTYPE_p_CSOUND_ csound_p;
- public Mutex mutex;
-
- /**
- * The Engine constructor, usually called in the setup() method in your
- * sketch to initialize and start the library.
- *
- * @param _csd The name of the csd file
- * @param _path The path to the csd
- */
-
- //Android Mode Constructor
- public Engine(String _csd) {
- csound = new AndroidCsound();
- csd = _csd;
- androidMode=true;
- }
-
- //Java Mode Constructor
- public Engine(String _csd, String _path) {
- csound = new Csound();
- csd = _csd;
- path = _path;
- }
-
- /**
- * Setup the Csound engine and play it.
- */
- private void csoundPerf() {
- // TODO: Make sure csound isn't already running
- if (true) {
- csnd.csoundInitialize(null, null,
- csnd.CSOUNDINIT_NO_SIGNAL_HANDLER);
-
- csound_p = csound.GetCsound();
- csoundFile = new CsoundFile();
- csoundFile.setCSD(fileToString(csd));
-
- if(androidMode){
- csoundFile.exportForPerformance();
- csound.PreCompile();
- compile = csound.Compile(csd);
- }
- else{
- // TODO: csd should get unique names, in case of multiple
- // instances.
- csoundFile.setCommand(options + " " + path + "\\" +tempCSD);
- csoundFile.exportForPerformance();
- compile = csound.Compile(path + "\\" + tempCSD);
-
- }
- System.out.println("compile status: " + compile);
-
- if (compile == 0) {
- isRunning = true;
- perfThread = new CsoundPerformanceThread(csound_p);
- perfThread.Play();
- //mutex = new Mutex();
- }
- }
- }
-
- /**
- * Reads a csd file into a string
- */
- private String fileToString(String path) {
- FileInputStream fin;
- StringBuilder sb = new StringBuilder();
-
- try {
- fin = new FileInputStream(csd);
- BufferedReader d = new BufferedReader(new InputStreamReader(fin));
- String line;
- while ((line = d.readLine()) != null) {
- sb.append(line + "\n");
- }
-
- fin.close();
- } catch (IOException e) {
- System.err.println ("Unable to read CSD file.");
- System.err.println (csd);
-
- }
-
- return sb.toString();
- }
-
- /**
- * Start Csound.
- */
- public void start() {
- csoundPerf();
- }
-}
View
73 csoundo/src/csoundo/Mutex.java
@@ -1,73 +0,0 @@
-/**
- * A Csound interface library for Processing.
- *
- * (c) 2010
- *
- * This library 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.
- *
- * This library 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 this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307 USA
- *
- * @author Jacob Joaquin http://csoundblog.com
- * @modified 09/02/2010
- * @version 0.1.2
- */
-
-package csoundo;
-
-import csnd.*;
-
-/**
- * Experimental class for thread locking/memory protection.
- */
-public class Mutex {
- // FIXME: My tests have confirmed that I have no idea what I'm doing
- // here.
-
- SWIGTYPE_p_void m; // Mutex
- private int locks = 0; // Number of active locks
- private boolean useLocks = false; // Use locks?
-
- public Mutex() {
- m = csnd.csoundCreateMutex(1);
- }
-
- public int activeThreads() {
- return locks;
- }
-
- public void cleanup() {
- if (!useLocks) return;
- while (locks > 0) {
- unlock();
- }
- }
-
- public void lock() {
- if (!useLocks) return;
- csnd.csoundLockMutex(m);
- locks++;
- }
-
- public void unlock() {
- if (!useLocks) return;
- if (locks > 0) {
- locks--;
- csnd.csoundUnlockMutex(m);
- } else {
- System.out.println("Warning: Mutex trying to unlock imaginary threads.");
- }
- }
-}
-
-

0 comments on commit 3350868

Please sign in to comment.
Something went wrong with that request. Please try again.