Max msp and java

    Nov 24 2011 | 9:06 pm
    Hey, i would reallllly appreciate if someone can help me out pleasee. Well, i have the java code written, with the interface and sounds(predefined) in eclipse... But now, what i wanna do is send that sounds from eclipse to max msp, so that i can process that sound with effects through that max msp patch!! How to do that? HELP!!

    • Nov 25 2011 | 1:26 pm
      In other words, i have a code written in java, whose output is like keyboard and sounds when you press any key, normal pre defined sounds,, which is done in eclipse only... now what i wanna do is send these sound to max msp and add effects or manipulate those sounds through the max msp patch!! How can i do this? Anybody?
    • Nov 25 2011 | 5:33 pm
      you should have to rewrite your "eclipse" dsp routines so that they match the java msp API. Take a look at the java-doc folder, you will find there everything you need for doing the stuff. What i can say is that you have to write classes that extends the MSPPerformer or the MSPObject abstract classes and then implementing fixed methods for creating signal inlets and outlet, methods for setting up your dsp chains, and perform methods (for the process).
      good luck!
    • Nov 25 2011 | 5:49 pm
      Hey, thanks for replying! But, i m a lil confused. I don't need to make any 'max externals' right? Where exactly can i look this up? Java-doc folder? Where is it? Since searching on google is just giving me results only for 'max msp externals in java'..
    • Nov 25 2011 | 8:46 pm
      Hi, basically you have two options: either you create an MXJ-based external for MaxMSP in Java (and if you're already familiar with Eclipse and Java, I'd choose this way as the wrapper class you need to implement is quite simple if you already have your DSP methods previously implemented) or I'd route the output of your software into Max with, for instance a JACK server or some other virtual device. This might be more flexible and doesn't require you to embed your Java program into Max, however, you must make sure that your software is compliant with a routing software like the JACK server.
      Hope this helps, Ádám
    • Nov 26 2011 | 1:37 pm
      Hey, adam, thanks for replying. Are you on gmail or something where i can partly share the code.. Still having confusions. Would really appreciate it. please. Thanks.
    • Nov 26 2011 | 1:46 pm
      package music.instruments.MTPiano;
      import java.util.HashMap; import com.cycling74.max.*; import java.util.Map;
      import processing.core.PApplet; import ddf.minim.AudioOutput; import ddf.minim.Minim;
      public class NotePlayer {
      private PApplet app;
      public NotePlayer(PApplet app) { = app; keys = new HashMap(); }
      private Map keys;
      public void playNote(Key k) { closeMinim(k);
      Minim minim = new Minim(app); AudioOutput out = minim.getLineOut(Minim.MONO, 2048);
      NoteMinim nm = new NoteMinim(); nm.setMinim(minim); nm.setAudioOutput(out);
      keys.put(k, nm);
      if (k == Key.KEY_TYPE_A) { out.playNote("A"); } else if (k == Key.KEY_TYPE_B) { out.playNote("B"); } else if (k == Key.KEY_TYPE_C) { out.playNote("C"); } else if (k == Key.KEY_TYPE_D) { out.playNote("D"); } else if (k == Key.KEY_TYPE_E) { out.playNote("E"); } else if (k == Key.KEY_TYPE_F) { out.playNote("F"); } else if (k == Key.KEY_TYPE_G) { out.playNote("G"); } else if (k == Key.KEY_TYPE_C_SUST) { out.playNote("C#"); } else if (k == Key.KEY_TYPE_D_SUST) { out.playNote("D#"); } else if (k == Key.KEY_TYPE_F_SUST) { out.playNote("F#"); } else if (k == Key.KEY_TYPE_G_SUST) { out.playNote("G#"); } else if (k == Key.KEY_TYPE_A_SUST) { out.playNote("A#"); } else if (k == Key.KEY_TYPE_C_UP) { out.playNote("C5"); }
      if (out.isMuted()) { out.unmute(); } /* summer.pan();
      // create a SquareWave with a frequency of 440 Hz, // an amplitude of 1 and the same sample rate as summer SquareWave square; if (k == NotePlayer.Key.KEY_TYPE_C) { square = new SquareWave(240, 1, 44100); } else { square = new SquareWave(440, 1, 44100); } // create a LowPassSP filter with a cutoff frequency of 200 Hz // that expects audio with the same sample rate as summer LowPassSP lowpass = new LowPassSP(200, 44100);
      // now we can attach the square wave and the filter to our output summer.addSignal(square); summer.addEffect(lowpass);
      if (summer.isMuted()) { summer.unmute(); }*/ }
      public void stopNote(Key k) {
      private void closeMinim(Key k) { if (keys.containsKey(k)) { NoteMinim nm = keys.get(k); nm.getAudioOutput().mute(); nm.getAudioOutput().close(); nm.getMinim().stop(); } }
      private class NoteMinim { private AudioOutput out; private Minim minim;
      public AudioOutput getAudioOutput() { return out; }
      public void setAudioOutput(AudioOutput out) { this.out = out; }
      public Minim getMinim() { return minim; }
      public void setMinim(Minim minim) { this.minim = minim; } } }
      So this is part of code, using minim library, which is running fine... But i can replace the line with some object of max?????????
    • Nov 26 2011 | 1:52 pm
      By the way, i aint too good with java!
    • Nov 26 2011 | 4:11 pm