Java sound


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Java sound

  1. #1
    Join Date
    Jul 2006
    Posts
    14

    Java sound

    I am trying to write a program that takes a sound file (mp3 currently) and adds a certain amount of hertz to each second of data. Currently I have the following (a summary):

    byte[] data = new byte[4096];
    SourceDataLine line (initialization hidden)
    AudioInputStream din(initialization hidden)

    while (nBytesRead != -1) {
    nBytesRead = din.read(data, 0, data.length);

    if (nBytesRead != -1) nBytesWritten = line.write(updateByteArray(data, 20000), 0, nBytesRead);
    }

    public byte[] updateByteArray(byte[] initial, int shift){
    byte[] base = convertIntegertoByte(shift);
    byte[] op = initial;
    int pos = 0;
    for (int i = 0; i < initial.length; i = i + 1){
    op[i] = new Integer(op[i] + base[pos]).byteValue();
    if (pos == base.length - 1){
    pos = 0;
    } else {
    pos = pos + 1;
    }
    }
    return op;
    }


    public byte[] convertIntegertoByte(int i){
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    try{
    dos.writeInt(i);
    } catch (Exception e){
    e.printStackTrace();
    }
    return bos.toByteArray();
    }

    It succeeds in playing the mp3 file yet the pitch is the same as usual. Any help is welcome.

  2. #2
    Join Date
    Jul 2006
    Posts
    14
    Anyone?

Similar Threads

  1. Is the Java Sound API too complex?
    By RikMeucci in forum Java
    Replies: 2
    Last Post: 12-05-2005, 06:59 AM
  2. Java vs. .Net. A questionnaire
    By Basil in forum .NET
    Replies: 1
    Last Post: 05-13-2005, 06:46 AM
  3. DevX does seem one sideded
    By Rob Abbe in forum Talk to the Editors
    Replies: 44
    Last Post: 01-13-2003, 02:57 PM
  4. learning c# very confusing.
    By Mike Tsakiris in forum .NET
    Replies: 11
    Last Post: 10-04-2002, 05:32 PM
  5. Re: VB vs. Visual Age for Java
    By JJ in forum Enterprise
    Replies: 1
    Last Post: 07-06-2000, 04:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center