Need help writing non-gui JMF program

I need to write a program that will convert a WAV file from a ULAW format to a GSM WAV file format. I first tried this with the Java Sound API and the WAV file format of GSM was not supported so I stumbled across JMF.
I can use the JMStudio and Export GUI programs that come with JMF to convert the wav file as needed. But now I'm trying to write a batch program (non-gui) to convert the file on the fly.
First, is this possible. Second, does anyone have any code samples of a batch java program using JMF in batch.
Thanks,
Scott

Not exactly what I was looking for. After 2 days of beating my head against the wall this is what I got to work. Include the jmf.jar in my project. Here is my code.
import java.io.IOException;
import javax.media.DataSink;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.NoDataSourceException;
import javax.media.Processor;
import javax.media.control.TrackControl;
import javax.media.format.AudioFormat;
import javax.media.protocol.DataSource;
import javax.media.protocol.FileTypeDescriptor;
import jmapps.util.StateHelper;
public class TestAudio5 {
     public static void main(String[] args) {
          try {
               Processor p = null;
               StateHelper sh = null;
               DataSource inSource = Manager.createDataSource(
                         new MediaLocator("file:c:\\ASSURANCE_THREE_MINUTE.wav"));
               p = Manager.createProcessor(inSource);
               sh = new StateHelper(p);
//               Configure the processor
               if (!sh.configure(10000)) {
                         System.out.println("can't configure");
                    System.exit(-1);
               p.setContentDescriptor(new
                                   FileTypeDescriptor(FileTypeDescriptor.WAVE));
               //AudioFormat(java.lang.String encoding, double sampleRate, int sampleSizeInBits, int channels)
               //AudioFormat(
               //          java.lang.String encoding,
               //          double sampleRate,
               //          int sampleSizeInBits,
               //          int channels,
               //          int endian,
               //          int signed,
               //          int frameSizeInBits,
               //          double frameRate,
               //          java.lang.Class dataType)
               AudioFormat outputFormat = new javax.media.format.AudioFormat(
                                        AudioFormat.GSM_MS,
                                        8000.0,
                                        0,
                                        1,
                                        0,
                                        1,
                                        520,
                                        1625.0,
                                        null);
               System.out.println("outputFormat: " + outputFormat.toString());
               TrackControl tc[] = p.getTrackControls();
               for ( int i = 0; i < tc.length; i++ ) {
                    tc.setEnabled(true);
                    System.out.println("before format: " + tc[i].getFormat().toString());
                    tc[i].setFormat(outputFormat);
                    System.out.println("after format: " + tc[i].getFormat().toString());
               if (!sh.realize(10000)) {
                                   System.out.println("can't realize");
                                   System.exit(-1);
               // get the output of the processor
               DataSource source = p.getDataOutput();
               // create a File protocol MediaLocator with the location
               // of the file to which bits are to be written
               MediaLocator dest = new MediaLocator("file://c:\\test.wav");
               // create a datasink to do the file writing & open the
               // sink to make sure we can write to it.
               DataSink filewriter = null;
               filewriter = Manager.createDataSink(source, dest);
               filewriter.open();
               // now start the filewriter and processor
               filewriter.start();
               sh.playToEndOfMedia(5000);
               sh.close();
               filewriter.close();
          } catch (NoDataSourceException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          } catch (IOException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          catch (Exception e) {
                         // TODO Auto-generated catch block
               e.printStackTrace();
          System.out.println("done!");
          System.exit(-1);

Similar Messages

  • I need help writing a dive scoring program in C#, Help Please?

    The state diving commission wants to computerize the scoring at its diving competitions. I have to write a program to automate the scoring of dives. Requirements:
    After each dive, the user will be prompted to enter the:
    diver's name;                    
    diver's city;                    
    degree of difficulty (ranges from 1.00 to 1.67); and                     
    scores from five judges (scores can range from 0 to 10).
    If an invalid score is entered, an error message will be displayed. The user will be prompted for the score repeatedly until a valid score is entered.
    The program will then display the following information:
    Diver's name                    
    Diver's city                    
    Dive final score: This is calculated by dropping the highest and lowest of the five judges' scores. The remaining three scores are added together, and the result is divided by 3 and then multiplied by the degree of difficulty.
    The program will then prompt the user if she/he wants to process another dive. The user can type "Y" or "y" to continue, and "N" or "n" to quit.

    Hi,
    The forum supports VS setup and installation. I think your issue is not about the forum.
    Please clarify your project type. Is it webform or winform?
    If it is webform, please post your issue to ASP.NET forum.
    If it is winform, please post it to
    winform forum.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Need help writing host program using LabView.

    Need help writing host program using LabView.
    Hello,
    I'm designing a HID device, and I want to write a host program using National Instrument's LabView. NI doesn't have any software support for USB, so I'm trying to write a few C dll files and link them to Call Library Functions. NI has some documentation on how to do this, but it's not exactly easy reading.
    I've written a few C console programs (running Win 2K) using the PC host software example for a HID device from John Hyde's book "USB by design", and they run ok. From Hyde's example program, I've written a few functions that use a few API functions each. This makes the main program more streamlined. The functions are; GetHIDPath, OpenHID, GetHIDInfo, Writ
    eHID, ReadHIC, and CloseHID. As I mentioned, my main program runs well with these functions.
    My strategy is to make dll files from these functions and load them into LabView Call Library Functions. However, I'm having a number of subtle problems in trying to do this. The big problem I'm having now are build errors when I try to build to a dll.
    I'm writing this post for a few reasons. First, I'm wondering if there are any LabView programmers who have already written USB HID host programs, and if they could give me some advice. Or, I would be grateful if a LabView or Visual C programmer could help me work out the programming problems that I'm having with my current program. If I get this LabView program working I would be happy to share it. I'm also wondering if there might already be any USB IHD LabView that I could download.
    Any help would be appreciated.
    Regards, George
    George Dorian
    Sutter Instruments
    51 Digital DR.
    Novato, CA 94949
    USA
    [email protected]
    m
    (415) 883-0128
    FAX (415) 883-0572

    George may not answer you.  He hasn't been online here for almost eight years.
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

  • Need help writing small program!

    Hi. I'm learning Java programming, and I need help writing a small program. Please someone help me.
    Directions:
    Create a program called CerealCompare using an if-then-else structure that obtains the price and number of ounces in a box for two boxes of cereal. The program should then output which box costs less per ounce.

    class CerealCompare {
        public static void main(String[] args) {
            // your code goes here
    }Hope that helps.
    P.S. Java does not have an if-then-else statement.

  • Need Help Writing Server side to submit form via API

    Hey
    I need help writing a serverside application to submit
    information via API to a separate server.
    I have a client that uses constant contact for email
    campaigns. We want to add to her website a form taht submits the
    information needed to subscribe to her email list, to constant
    contact via API.
    FORM.asp :: (i got this one under control)
    name
    email
    and submits to serverside.asp
    SERVERSIDE.ASP
    In serverside.asp i need to have
    the API URL
    (https://api.constantcontact.com/0.1/API_AddSiteVisitor.jsp)
    username (of the constant contact account)
    password (of the constant contact account)
    name (submited from form.asp)
    email (submitted from form.asp)
    redirect URL (confirm.asp)
    Can anyone help get me going in the right direction?
    i have tried several things i found on the net and just cant
    get anyone to work correctly.
    One main issue i keep having is that if i get it to submit to
    the API url correctly - i get a success code, it doesnt redirect to
    the page i am trying to redirect to.
    ASP or ASP.NET code would be find.
    THANKS
    sam

    > This does require server side programming.
    > if you dont know what that is, then you dont know the
    answer to my question. I
    > know what i need to do - i just dont know HOW to do it.
    If you are submitting a form to a script on a remote server,
    and letting
    that script load content to the browser, YOU have no control
    over what it
    loads UNLESS there is some command you can send it that it
    will understand.
    No amount of ASP on your server is going to change what the
    remote script
    does.
    http://www.constantcontact.com/services/api/index.jsp
    they only allow their customers to see the instructions for
    the API so i
    can't search to see IF there is a redirect you can send with
    the form info.
    But posts on their support board say that there is.
    Alan
    Adobe Community Expert, dreamweaver
    http://www.adobe.com/communities/experts/

  • Need help in my assignment, Java programing?

    Need help in my assignment, Java programing?
    It is said that there is only one natural number n such that n-1 is a square and
    n + 1 is a cube, that is, n - 1 = x2 and n + 1 = y3 for some natural numbers x and y. Please implement a program in Java.
    plz help!!
    and this is my code
    but I don't no how to finsh it with the right condition!
    plz heelp!!
    and I don't know if it right or wrong!
    PLZ help me!!
    import javax.swing.JOptionPane;
    public class eiman {
    public static void main( String [] args){
    String a,b;
    double n,x,y,z;
    boolean q= true;
    boolean w= false;
    a=JOptionPane.showInputDialog("Please enter a number for n");
    n=Double.parseDouble(a);
    System.out.println(n);
    x=Math.sqrt(n-1);
    y=Math.cbrt(n+1);
    }

    OK I'll bite.
    I assume that this is some kind of assignment.
    What is the program supposed to do?
    1. Figure out the value of N
    2. Given an N determine if it is the correct value
    I would expect #1, but then again this seem to be a strange programming assignment to me.
    // additions followI see by the simulpostings that it is indeed #1.
    So I will give the tried and true advice at the risk of copyright infringement.
    get out a paper and pencil and think about how you would figure this out by hand.
    The structure of a program will emerge from the mists.
    Now that I think about it that advice must be in public domain by now.
    Edited by: johndjr on Oct 14, 2008 3:31 PM
    added additional info

  • I need help writing a script that finds the first instance of a paragraph style and then changes it

    I need help writing a script that finds the first instance of a paragraph style and then changes it to another paragraph style.  I don't necessarily need someone to write the whole thing, by biggest problem is figuring how to find just the first instance of the paragraph style.  Any help would be greatly appreciated, thanks!

    Hi,
    Do you mean first instance of the paragraph style
    - in a chosen story;
    - on some chosen page in every text frames, looking from its top to the bottom;
    - in a entire document, looking from its beginning to the end, including hidden layers, master pages, footnotes etc...?
    If story...
    You could set app.findTextPreferences.appliedParagraphStyle to your "Style".
    Story.findText() gives an array of matches. 1st array's element is a 1st occurence.
    so:
    Story.findText()[0].appliedParagraphStyle = Style_1;
    //==> this will change a paraStyle of 1st occurence of story to "Style_1".
    If other cases...
    You would need to be more accurate.
    rgds

  • Need help writing Labview Program!!!!!

    I have a labview project that needs to be finished. I was not the original creator of the program and the guy who created no longer is involved with the project and I am left to finish it. Could you make the final adjustment so I can turn this into my professor and get the final grade. Thanks! Willing to pay! Negeotiable price!!!!!!!!

    Need help completing assignment! Could anyone assist me in this project!
    Attachments:
    dial tone detection.zip ‏1253 KB

  • Need help in creating a java program

    Hi everyone.
    I'd like to say before i start about my problem, that i've only begun learning java and my teacher hasn't explained anything at all. He only showed us by doing it himself and then showing us the final version. I've searched a little on how to program but i get little success in finding a good tutorial.
    I need help creating a program which has been assigned to me due in a few days in which i can't contact my teacher for help.
    I need to write a java program which inputs 3 items. The number of kilometres you drove, the number of litres of gas you used and the price you paid for the gas. Then, the program must calculate the number of litres used per 100km driven, which is litres divided by kilometres times 100, how much it costs to drive 100km, which is the result (a) times the price per litre and the number of miles per American gallon of gas ( one American gallon = 3.785 litres, and one mile = 1.609 km.
    The program has to output my name, the inputs given, the results computed and a message saying "Program Complete".
    To give you what i've done to begin with, from what i understood, is:
    import javax.swing.JOptionPane;
    public class prog1
         public static void main(String args[])
              final double americanGallon = 3.785;
              final double mile = 1.609;
              kilometresDriven,
              gasUsed;
              priceOfLiterGas;
              System.out.println("My Name");
              System.out.println("Number of kilometres driven:");
              kilometresDriven = JOptionPane.showInputDialog ("Kilometres Driven");
              System.out.println("Number of Litres of gas used:");
              gasUsed = JOptionPane.showInputDialog ("Litres of gas used");
              System.out.println("Price of a liter of gas:");
              priceOfLiterGas = JoptionPane.showInputDialog("Price per liter");
    Up to now, that's all i've got. i know i'm wrong, but i'm not sure how to do this. Could someone give me an outline of what this program is suppose to look like?
    Thanks in advance.

    Here's an update on my program. I've worked on certain details and would need your comments whether it contains errors. I'd also want to know if it would work or not because i don't know how to check it on my computer.
    Here's the update:
    import javax.swing.JOptionPane;
    public class Prog1
    public static void main(String args[])
    String name;
    double kmDriven;
    double litresUsed;
    double pricePaidForGas;
    double priceOfALiter;
    name = JOptionPane.showInputDialog("Name");
    input = JOptionPane.showInputDialog("Number of km driven");
    kmDriven = Double.parseDouble (input);
    input = JOptionPane.showInputDialog("Number of litres of gas used");
    litresUsed = Double.parseDouble (input);
    input = JOptionPane.showInputDialog("Price paid for gas");
    pricePaidForGas = Double.parseDouble (input);
    input = JOptionPane.showInputDialog("Price of a litre of gas");
    priceOfALiter = Double.parseDouble (input);
    a = (litresUsed/kmDriven)*100;
    b = ((litresUsed/kmDriven)*100)*priceOfALiter);
    c = (kmDriven/1.609)
    System.out.println("Name:" + name);
    System.out.println("Number of litres used per 100km:" + a);
    System.out.println("Cost of driving 100km" + b);
    System.out.println("Number of miles per American Gallon of Gas:" + c);
    System.out.println("Program Complete");
    System.exit(0);
    Comments please.
    Thanks in advance

  • Need help on combining these two program

    Hi all,
     I needed some help on combining these two program. But i not very sure how to do it.
    My program in working with TimeIn/TimeOut attendance taking. The snippet vi "insert data" is the where i start to TimeIn and insert into the microsoft access. And i wanted to insert it together with a camera catching the user's face. But i have no clues on how to combine them.
     Can u guys give me some ideas to help me ?
    Thanks in advance.
    Attachments:
    IMAQdx.png ‏55 KB
    insert data.png ‏68 KB

    Hi Himanshu,
    But if i put everything inside the IMAQdx loop ,it make my whole program more complicated. 
    This is how my program looks like below.
    I only want to display the image only when i "insert" all data into the database ( which i given at the perivous post).
    Is there other way?? And how do u make the IMAQdx loop stop without putting a stop button?? Because everytime i run the program,it will run continuously at the IMAQdx loop..
    Thank in Advance.
    Attachments:
    FYP.png ‏205 KB

  • Need help writing a query for following scenario

    Hi all, I need some help writing a query for the following case:
    One Table : My_Table
    Row Count: App 5000
    Columns of Interest: AA and BB
    Scenario: AA contains some names of which BB contains the corresponding ID. Some
    names are appearing more than once with different IDs. For example,
    AA BB
    Dummy 10
    Me 20
    Me 30
    Me 40
    You 70
    Me 50
    Output needed: I need to write a query that will display only all the repeating names with their corresponding IDs excluding all other records.
    I would appreciate any input. Thanks

    Is it possible to have a records with the same values for AA and BB? Are you interested in these rows or do you only care about rows with the same value of AA and different BB?
    With a slight modification of a previous posting you can only select those rows that have distinct values of BB for the same value of AA
    WITH t AS (
    SELECT 'me' aa, 10 bb FROM dual
    UNION ALL
    SELECT 'me' aa, 20 bb FROM dual
    UNION ALL
    SELECT 'you' aa, 30 bb FROM dual
    UNION ALL
    SELECT 'you' aa, 30 bb FROM dual
    SELECT DISTINCT aa, bb
      FROM (SELECT aa, bb, COUNT(DISTINCT bb) OVER(PARTITION BY aa) cnt FROM t)
    WHERE cnt > 1;

  • I need help with TV Capture Card program

    Hello,
    I want to create a JAVA program so I can schedule that the recording with my TV Capture Card begins in x seconds.
    Now to start a recording, you must press Ctrl+M and to stop an recording you must click the mouse.
    How can I realise that a Java application can "press" Ctrl+M. I have to create an timer, that must be do-able... but I don't know how the program can simulate the pressing of Ctrl+M. I also need to know how the Java program can do a mouse click for me to end the recording.
    Thanks in advance for helping me.
    Chris.

    Thank you... I think this was exactly what I needed.

  • I need help finding a workable web program that is not CSS based.  I tried IWeb and it just won't work for me.  Way too limiting.  I've been using a 12 year old copy of Macromedia Dreamweaver, but the new Dreamweaver is CSS

    Been building web pages for nearly 20 years, starting with GoLive.  Went to Dreamweaver about 12 years ago, the Macromedia version.  Tried going to iWeb when it came with a new Mac, but found it way too limiting with it's CSS template base.   Unknowlingly, I then bought a new copy of Dreamweaver.   Ooops, Adobe had bought Macromedia and Dreamweaver, too, is now CSS based, which for my money makes it useless to anyone who likes simplicity.   Now I find that even iWeb has been discontinued.  I was told yesterday that Apple doesn't have a web program any more.   At 12 years old, I just don't think it's practical to try to load my old Macromedia Dreamweaver into the new Mountain Lion (I'm getting a new Mac), though it is running, barely, in Snow Leopard.
    I need to find a web builder program that will permit simple construction of educational pages, nothing fancy, nothing artistic, just create a page, give it a color, type or drag in text, insert a table, insert pix in the table blocks, add text under the pix... done!    I should note that I am not looking to build traffic.  I teach simple things for free and people who want to learn those things (antique sewing machine repair, quilting, building longbows) find me.
    I've downloaded trial versions of half a dozen or so programs and looked at maybe 20 more, but all are either CSS based and drive me insane with requirments for constantly making rules and template models, and/or require that you base your web presence in their server.   Also, many will not work with pages built in other programs.  I maintian a volume of over 1000 web pages, many requiring regular updating, and they have been with the same server for more than 15 years.  I'm not about to change.
    So, anybody know a simple, old fashioned web builder that's happpy on a Mac platform?
    Captain Dick

    Although not supported anymore, iWeb does still function using Mountain Lion...
    http://www.iwebformusicians.com/iWeb/mountain-lion.html
    ... and you can purchase it from Amazon.
    Start with a blank page using the Black or WHite template.
    All modern websites use CSS and there are thousands of free templates to be had if you want to use a code entry style application. You will need to go this route if you want to create a site that is viewable on mobile devices although you can create an iPhone version using iWeb...
    http://www.iwebformusicians.com/iWeb/Mobile-iWeb.html
    Search this forum for numerous topics about iWeb alternatives.

  • Need help writing a script

    I am trying to convert my prcess from DTS to SSIS. I am running this report out of SAP and then using Monarch to put into the correct form, then I am using the DTS to put it into the database on the SQL server.  I am able to get all the other info to
    move out having so much trouble here to get the plant number. The issuse is that it is on top on the page and it will change when a new plant is needed.
    Thanks for any help
    I need help wrting a script that will put that 7010 into a cloumn nnamed plant number.

    To convert from DTS packages to SSIS you can just open the DTS package in a new SSIS project (depends on target SSIS version by using SSDT or BIDS).
    The rest is mechanics how the iteration with SAP is done and may be beyond the scope of this forum.
    Arthur
    MyBlog
    Twitter

  • Need Help writing program

    very new to java, i conceptually know what i want to do, but it is hard to apply that to writing the program. this is very introductory so i'd appreciate all and any help.
    i am trying to write a program such that if I select an integer, n, as in input, the program can convert that integer into it's binary representation. for example, if the integer is 4, then the program would output 001 as the binary representation of 4.
    that is the first part, the second part is to have the binary representation go from most significan bit to least significant bit, so for the integer 4 it will come out as 100 (or 000100 or 00100).
    ok basically i know i want the program to divide the chosen integer by 2 and take the remainder (n%2), which will be 1 or 0. i then want the program to take the value (n/2) and have that be the new n value, then repeat the steps over and over till my n just becomes 0. i am trying to do this with a while loop, but if there is an easier way to do this, please let me know. so far wha ti have is below, kinda stuck on how to write this program, please help. the output just keeps giving me 0 and doesn't end.
    import java.util.*;
    class Q3a{
    static Scanner console = new Scanner (System.in);
         public static void main(String args[]){
              int n;
              n = console.nextInt();
              System.out.print("Choose an integer value :");
              while (true) {
              System.out.println("Remainder on dividing " + n + " by 2 is " + n%2);
              n = n/2;}
              System.out.println("New value of n is n/2 which is " + n);
              System.out.println("Remainder on dividing " + n + " by 2 is " + n%2);
              n = n/2;
              System.out.println("New value of n is n/2 which is " + n);
              System.out.println("Remainder on dividing " + n + " by 2 is " + n%2);
              n = n/2;
              System.out.println("New value of n is n/2 which is " + n);Message was edited by:
    kribraider414

    consider
    while (n != 0){
      System.out.println(n%2);
      n = n/2;
    }put the reverse of the stoping condition in the parens for the loop
    This loop will run while n is NOT zero. It wil stop when n is zero. Try it for a few numbers and see what it does.
    Pay particular attention to what it does if the number you supplied is zero (which is the one binary number that does not have a single one in it.)
    Also take a look at what it does for negative numbers and decide what you want to do in that case.

Maybe you are looking for