Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

MP3 and byte array conversion

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I have some code which converts 16bit audio from byte data to short arrays (or any type of arrays) for processing. Once all sorts of possible processing is done, it is then converted back to a byte array for playback. I've attached the code which does this initial conversion at the bottom of this email.

I've recently starting using the jlayer, mp3spi, and tritonus_share libraries. So far i'm able to get metadata from the mp3 files easily, however i'm struggling to get the audio converted into a format that's playable by my software. When i use: int bytesread = din.read(bytes, 0, (int) bufSize);

'bytesread' is only 4068 regardless of the mp3 file, or the values of bufSize/the size of the bytes[] array. When using 16bit wavs, bytesread is the same size as bufSize and bytes[]. All the audio which comes out after conversion from a byte array (from the code below) is silent/has a value of 0.

Can anyone let me know why i can't 'access' this raw byte data for conversion?

'din' is the decoded audioInputStream, you can see the 'standard' audio code here:



When i try to use 'int bytesread = audioInputStream.read(bytes, 0, (int) bufSize); - all i get is white noise!

Many thanks,

Eddie

============


 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No idea what's going on, but I still think you would have an easier time using JMF. Is there a particular reason you want to use MP3SPI?
 
Eddie Shakarchi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf,

The mains reasons are, if i'm not mistaken:

1) With MP3SPI, you can simply reuse all the javasound code, which i have already implemented

2) With MP3SPI, i believe i can access the raw byte data, convert it using the code above (i.e. treat it like a wav), and then convert it back to 16bit byte data for play back - all using the same mechanisms as i am familar with - i.e. the javasound API. The software i'm coding for is not a small app that simply requires an mp3 playing in the background, or anything like that.

Please correct me if i'm wrong, or if i can do this with JMF!

Many thanks

Eddie
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic