Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / Java Sound & OpenAL / Re: Converting wav's to mp3's on: 2009-10-06 21:55:05
I guess this will have to do:
1  
2  
3  
4  
5  
   public void wavToMP3(String waveFileName, String mp3FileName) throws Exception
   {
      Runtime runtime = Runtime.getRuntime();
      Process proc = runtime.exec(LAME_PATH+" "+waveFileName+" "+mp3FileName);
   }
2  Java Game APIs & Engines / Java Sound & OpenAL / Re: Converting wav's to mp3's on: 2009-10-02 16:31:10
I found a link to JLayer and it only seems to be able to go from mp3->wav but has no way of going back again, is there a library to do this that doesn't require an EasyJNI license?
3  Java Game APIs & Engines / Java Sound & OpenAL / Re: Converting wav's to mp3's on: 2009-09-30 19:51:29
the final format needs to be mp3 to be playable in flash(this is on the server) and as far as I know it doesn't support ogg, flac or ape

it also seems javazoom's domain is down
4  Java Game APIs & Engines / Java Sound & OpenAL / Converting wav's to mp3's on: 2009-09-29 22:16:41
I'm trying to make a tool to convert wav's to mp3's then send out a notification when it's done. (The wav's will always be 44100Hz 16-bit Stereo files)

My first attempt was to link to JMF then attempt to do this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
   public void wavToMP3(String waveFileName, String mp3FileName) throws Exception
   {
      File file = new File(waveFileName);
      AudioInputStream in = AudioSystem.getAudioInputStream(file);
      AudioInputStream out;
      AudioFormat.Encoding encodedFormat = new AudioFormat.Encoding(javax.media.format.AudioFormat.MPEGLAYER3);
      out = AudioSystem.getAudioInputStream(encodedFormat, in);
      File outfile = new File(mp3FileName);
      AudioSystem.write(out, new AudioFileFormat.Type("MP3","mp3"), outfile);
   }


but that results in this error:

Exception in thread "main" java.lang.IllegalArgumentException: Unsupported conversion: mpeglayer3 from PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian

I can't seem to find what I need to change to fix this, any suggestions?
5  Java Game APIs & Engines / Java Sound & OpenAL / Re: Java equivelant to AS3's sound.extract()? on: 2009-09-02 22:19:19
hrmm I'll look into it, but right now I've got this working:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
import java.io.*;

import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;


public class JMFTest {

   public static void main(String[] args) throws Exception {
       FileInputStream in = new FileInputStream("test.mp3");
       AudioInputStream source = AudioSystem.getAudioInputStream(new BufferedInputStream(in, 1024));
       AudioInputStream pcm = AudioSystem.getAudioInputStream(AudioFormat.Encoding.PCM_SIGNED, source);
       File newFile = new File("test.wav");
       AudioSystem.write(pcm, AudioFileFormat.Type.WAVE, newFile);
       FileInputStream fis = new FileInputStream(newFile);
       ByteArrayOutputStream boas = new ByteArrayOutputStream(new Long(newFile.length()).intValue());
       byte[] buf = new byte[8 * 1024];
       for(int len=0; (len = fis.read(buf)) != -1;)
       {
          boas.write(buf,0,len);
       }
       byte[] ba = boas.toByteArray();
       for(int i = 44; i < ba.length; i+=2)
       {
          float value = ((ba[i] & 0xFF) | (ba[i + 1] << 8))/ 32768.0F;
          value /= 2.0;
          ba[i + 1] = (byte)((int)(value * 32768) >> 8);
          ba[i] = (byte)((int)(value * 32768) & 0xFF);
       }
       System.out.println(ba.length - 44);
       File newerFile = new File("test1.wav");
       FileOutputStream fos = new FileOutputStream(newerFile);
       fos.write(ba);
    }
}

right now it halves the volume of the sound file, but only seems to work in the format I want if the mp3 used is in the same format, so I'm looking for a simpler and more consistent way to do this, I'll look into JLayer, and see if I can find what I'm looking for.
6  Java Game APIs & Engines / Java Sound & OpenAL / Java equivelant to AS3's sound.extract()? on: 2009-09-01 19:15:22
I'm trying to port some Actionscript code to Java, and I'm looking for a way to get an array of frequencies in a format where it's 1 float per sample per channel and there's 2 channels from an mp3 file.

Anyone have an example available on how to accomplish this?
7  Java Game APIs & Engines / Java Sound & OpenAL / EasyOgg problem.. on: 2006-12-19 20:54:04
Well I'm having problems with EasyOgg in that it's not playing anything, and it's not throwing any exceptions. I used a random ogg that plays through xmms but won't in my application:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
import java.io.IOException;
import java.util.Scanner;
import org.newdawn.easyogg.OggClip;

public class SoundTest
{
   OggClip clip;
   public static void main(String args[])
   {
      new SoundTest();
     
   }
   public SoundTest()
   {
      try
      {
         clip = new OggClip("startup2.ogg");
         clip.loop();
         System.out.println("sound looping!");
      } catch (IOException e)
      {
         e.printStackTrace();
      }
      Scanner input=new Scanner(System.in);
      do
      {
         System.out.println("Quit?");
      }
      while(!input.nextLine().equals("Y"));
   }
}

sound looping! prints, and Quit? prints, but there's no sound playing  Huh

EDIT:debugger output with breakpoint on clip.loop();
http://dec19.imghost.us/uEzu.png

EDIT2: adding Thread.sleep(100); after clip.loop(); makes it work, but is there a more reliable way to ensure that the sound will play?
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (39 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (25 views)
2014-08-16 06:20:21

Tekkerue (36 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!