Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (512)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Decoding raw sound data??  (Read 2348 times)
0 Members and 1 Guest are viewing this topic.
Offline Kevdog

Junior Duke





« Posted 2003-06-20 16:35:00 »

I've been looking at Jlgui (Java MP3 player).

I've got access to the raw sound data being sent to the line to play the MP3.  I'm trying to find the format of the data so I can decode it and do neat things (equalizier output, or other sound controlled visuals).  But so far I haven't found any reference as to how to interpret the data.

Anyone have any references?

Thanks

There are only 10 types of people, those who understand binary and those who don't!
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #1 - Posted 2003-06-23 00:04:54 »

I don't know for sure.. the line can be configured in different ways.. but the chances are that you have pairs (left/right) of 16 bit samples.. the byte order (endian-ness) I think is the most likely thing to vary from one platform to another.

Do you have the code that sets up the line? Then you could be sure of the format.

Offline Kevdog

Junior Duke





« Reply #2 - Posted 2003-06-23 14:47:56 »

Well, I just "played" with the data off the data stream.  I was able to get a pair of waveform displays by using bytes 2 and 4 of a 4 byte block.  Based on your description I'm probably just  truncating the upper bytes of info Tongue  Now I imagine this only works for a stereo bitstream, as a mono bitstream wouldn't have 4 bytes but rather 2 bytes per block.

So it looks like the frequencies are derived from the values in the bitstream and not directly encoded?

Here's the code that sets up the line.  It looks to be based off the loaded sound file.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
            AudioFormat sourceFormat = m_audioInputStream.getFormat();
            trace(1, getClass().getName(), "Source format : ", sourceFormat.toString());

            AudioFormat targetFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, sourceFormat.getSampleRate(), 16, sourceFormat.getChannels(), sourceFormat.getChannels() * 2, sourceFormat.getSampleRate(), false);

            trace(1, getClass().getName(), "Target format: " + targetFormat);
            m_audioInputStream = AudioSystem.getAudioInputStream(targetFormat, m_audioInputStream);

            AudioFormat audioFormat = m_audioInputStream.getFormat();
            trace(1, getClass().getName(), "Create Line : ", audioFormat.toString());

            DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat, AudioSystem.NOT_SPECIFIED);
            m_line = (SourceDataLine) AudioSystem.getLine(info);

There are only 10 types of people, those who understand binary and those who don't!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #3 - Posted 2003-06-23 20:09:00 »

Quote
So it looks like the frequencies are derived from the values in the bitstream and not directly encoded?


Sounds like you are missing a fundamental thing here.   The data you pass to the line is TIME DOMAIN data..  It's the amplitude of the audio wave sampled at regular intervals in time (typically every 1/48000 of a second or 1/44100 of a second for high quality audio).  MP3 and other compressed formats work in the FREQUENCY domain,  do some googling and you will learn much...

Offline Kevdog

Junior Duke





« Reply #4 - Posted 2003-06-27 20:05:00 »

Indeed I am missing a fundamental thing.  I basically have absolutely no knowledge of the data stream, but managed to "hack" a wave graph out of it anyway Cheesy

What keywords should I google for?  I kept looking for info, but couldn't find any Sad

There are only 10 types of people, those who understand binary and those who don't!
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #5 - Posted 2003-07-04 12:37:26 »

Just look for general intros to Digital Signal Processing.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (49 views)
2014-10-17 03:59:02

Norakomi (39 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (35 views)
2014-10-15 16:18:58

TehJavaDev (65 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (55 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (43 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!