• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Could setting ByteArrayInputStream as InputStream deteriorate sound quality?

 
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The music is sent through a server. The music is received by a client. When all the music has been received, it sends it in a byte array (byte[]) to the following method :


Could the following line deteriorate the sound?


I am asking this because when it is sent through the server to the client and played, it has bad quality to the sound. I have posted this in different forums on Coderanch (one I believe, possible two). The difference is that this is asking a different question (about the ByteArrayInputStream). I am just trying to cover all my bases and figure out why the sound is so bad. I felt this belonged here because this is about sampled audio specifics.
 
Ranch Hand
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What sound format is the sound in originally?

Just to give an example, a WAV file (raw audio) has each sound sample encoded as a signed short (16 bit integer). The value of the sample is dependent on the volume of the sound at that point in time. I could see sound getting messed up if someone were to try to play each sample of sound as two samples (i.e. encode a wav file in an array of bytes). (I've never actually tried to do this, so I don't know what it would sound like.)

Have you tried writing the byte stream out to file and playing it with a media player? That should help you isolate the problem, whether the songsToPlay variable contains bad data, or if, as you suppose, the ByteArrayInputStream is somehow at fault here.
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your suggestion. This is what I put in my code :

reRoute method :


I tried it and it still sounded really bad. It's not with reading it. It's with the network transfer. Thanks for you suggestion. I can now cross this off the list.

EDIT : I just thought, I'm saving the incoming bytes in a StringBuilder. Maybe that is the issue. I'm going to make a new post in the I/O section about StringBuilder to Bytes. Hopefully, that will be the problem and I will somehow be able to fix it.

Thanks again for your help,
John Price
reply
    Bookmark Topic Watch Topic
  • New Topic