Making a front end for LAME

I want to make a front end for LAME. I'm totally lost on how to communicate with the Library. I want to make a Windows version first and then a OSX version, although I'm a Linux user.

Basically, I'm sick of all the badly encoded podcasts which I regularly listen to. I am going to fix this issue! It's costs bandwidth, therefor electricity, therefor places a burden on the environment. Also it just annoys me, and my bandwidth is limited since I must use a VPN to get through the great firewall of China.

I'm an experienced coded, but, again, I'm totally lost on how I might use Processing with LAME. Would I have to tie in the source or can I tie in the binary object like the .dll under windows.

Please help, thank you!

Answers

  • edited August 2016

    Thank you for the reply. I see that I am suppose to:

    Write the Java code. 
    Compile the Java code. 
    Create the C/C++ header file. 
    Write the C/C++ code. (Use LAME source)
    Create the shared library file. 
    Run the Java program.
    

    So I actually have to modify and compile my own version of LAME?

    There's no way for me to just pass parameters to the binary?

    How do other programs call LAME without their own version of the binary?

    Like some how call: "lame -q0 -V 6 -p -m j --replaygain-accurate input.wav output.mp3"

    Sorry if these questions seem obtuse. I've never used other programs like this before.

  • ...me ...like ...

    Thank you! fist bump

  • did you not think that someone had perhaps done this before and googled for 'java lame'?

    http://lamejb.sourceforge.net/ java interface to the lame libraries

    http://openinnowhere.sourceforge.net/lameonj/ ditto

    https://github.com/nwaldispuehl/java-lame a port of lame to java

    you probably want one of the first two. and they look outdated, almost, but then lame hasn't really changed in the last few years so they are probably ok.

  • edited August 2016

    I would look into ProcessBuilder. I wrote a small program that uses ProcessBuilder to run a binary called Potrace (which Processing looks for in the data folder).

    The application looks for a png in the data folder, loads it, and then saves it as a black and white bmp, which is the format that Potrace requires. Then an instance of Potrace is started with ProcessBuilder using commandline specific to Potrace. Potrace then generates an svg file using the parameters put forth in the commandline. The application then deletes the bmp, which was only a temporary file needed for Potrace.

    I know you are not looking to trace an image, but the steps are the same, I presume, with Lame. Here is the code I used to do this:

    import java.lang.ProcessBuilder;
    ProcessBuilder pb;
    Process p;
    File errorFile;
    PImage photo;
    
    
    void setup() {
      size(200, 200);
      photo = loadImage("\\data\\traceImage.png");
      PGraphics alter = createGraphics(photo.width, photo.height);
      alter.beginDraw();
      alter.background(255);
      photo.filter(THRESHOLD, 0.7);
      alter.image(photo, 0, 0);
      alter.endDraw();
      File outputFile = new File(sketchPath() + "\\bmp\\traceImage.bmp");
      alter.save(outputFile.getAbsolutePath());
      pb = new ProcessBuilder(sketchPath() + "\\data\\potrace.exe", "-o", sketchPath()+ "\\svg\\output.svg", "-s", "-O", "0.2", "-r", "72", "-C", "#5F5548", "--fillcolor", "#EDE3D5", "-M", "0.0", "--", sketchPath() + "\\bmp\\traceImage.bmp" );
      pb.directory(new File(sketchPath()+ "\\svg\\"));
      errorFile = new File(sketchPath() + "error.txt");
      pb.redirectOutput(errorFile);
      try {
        p = pb.start();
      } 
      catch (Exception e) {
        println("Error");
      }
      try {
        println(outputFile.getAbsolutePath());
        outputFile.deleteOnExit();
      }
      catch (Exception e) {
        println("Can't delete");
      }
      exit();
    }
    
  • @Bird what is the advantage of ProcessBuilder compared to use open with params?

    Not a critique but serious question

  • Well, I'm certainly no expert, but I like the ability to define the process independent of the parameters of the actual program, i.e.- error file. I'm still learning about ProcessBuilder (and Process), but for me it allows more options. That might be of use for your chess engine.

  • Thank you!

    Exactly ....

  • I've already finished a Windows version a couple days ago... I'll make a Linux version, and a mac version later. It's mostly for podcasts and audiobooks.

    https://sourceforge.net/projects/tired-of-bad-encoding/

  • off topic: the solution for my chess-engine problem was to use ProcessBuilder

    thanks @Bird !!! Life saver.

Sign In or Register to comment.