Looking for Java developers to help me tidy-up an mp3-streaming external

    Nov 21 2010 | 4:53 pm
    I've made a mxj external that can stream mp3s. It works OKish and you can check it out here:
    But, it's probably pretty poorly coded and very inefficient, so I'm looking for some more experienced Java coders to help me out. Most of the work is done, it just needs some stream-lining. So if anyone's interested in helping to add decent mp3 support to MSP once and for all, give me a shout!

    • Nov 23 2010 | 12:21 am
      Hi Rob, I'm interested in improving your code but I have some problems when compiling, - RandomAccessFileInputStream cannot be resolved to a type. I think it would help if you would post java source mainly RandomAccessFileInputStream.java file.
    • Nov 23 2010 | 5:47 pm
      Cheers man! Glad you're keen. Here is the source for RandomAccessFileInputStream:
      import java.io.*;
      public class RandomAccessFileInputStream extends InputStream { private RandomAccessFile raf;
      public RandomAccessFileInputStream(File file) throws FileNotFoundException { raf = new RandomAccessFile(file, "r"); }
      /** * Skip ahead in the file by the specified bytes. */ synchronized public void seek(long bytes) throws IOException { raf.seek((int) bytes); }
      /** * Skip ahead in the file by the specified bytes. */ synchronized public void skipForward(long bytes) throws IOException { raf.skipBytes((int) bytes); }
      /** * Skip backward in the file by the specified bytes. */ synchronized public void skipBackward(long bytes) throws IOException { long pos = raf.getFilePointer() - bytes;
      if (pos < 0) pos = 0;
      raf.seek(pos); }
      /** * Returns the current position within the file. */ public long getPosition() throws IOException { return raf.getFilePointer(); }
      /** * Returns the current position within the file as a percentage String. */ public String getPercentage() throws IOException { int pos = (int) ((((float) raf.getFilePointer()) / ((float) raf .length())) * 100);
      if (pos < 10) return "0" + pos + "%"; else return pos + "%";
      /** * Returns the length of the file in bytes. */ public long getLength() throws IOException { return raf.length(); }
      // ---------------------------- // InputStream methods: synchronized public int read() throws IOException { return raf.read(); }
      synchronized public int read(byte[] b) throws IOException { return raf.read(b); }
      synchronized public int read(byte[] b, int off, int len) throws IOException { return raf.read(b, off, len); }
      synchronized public long skip(long n) throws IOException { long left = raf.length() - raf.getFilePointer();
      if (n > left) n = left;
      return raf.skipBytes((int) n); }
      public int available() throws IOException { return 0; }
      public void close() throws IOException { raf.close(); }
      public void mark(int readlimit) {
      public void reset() throws IOException {
      public boolean markSupported() { return false; }
      Good luck and let me know how it goes. If you need any explanations of the code (it isn't commented) let me know.
    • Jan 14 2011 | 6:45 pm
      hello, i tried to launch your mp3play, but i got error and i cant make it work... any help?
      java.lang.NoClassDefFoundError: mp3play$1 Caused by: java.lang.ClassNotFoundException: mp3play$1 at com.cycling74.max.MXJClassLoaderImpl.lookupClassData(MXJClassLoaderImpl.java:198) at com.cycling74.max.MXJClassLoaderImpl.doLoadClass(MXJClassLoaderImpl.java:111) at com.cycling74.max.MXJClassLoaderImpl.loadClass(MXJClassLoaderImpl.java:88) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) (mxj~) unable to alloc instance of mp3play