-1

I have seen that you could adjust the volume of Clip, but after googling "Set volume of FileInputStream/BufferedInputStream", there wasn't really answers.

Is it possible to set this FIS/BIS audio volume? I use those in my MP3 player and want to make a method, where you could adjust the volume.

Any suggestions? Thanks in advance!

Timppa
  • 353
  • 2
  • 7
  • 24
  • 6
    You realize that `FileInputStream` and `BufferedInputStream` deal with general streams and thus don't have any notion related to audio data, don't you? If you want to set a volume you'd probably have to do that in whatever object (e.g. a player, converter, etc.) you feed that stream into. – Thomas May 23 '17 at 12:42
  • 1
    @Thomas Which part of the question makes you think that he realized that? ;-) – GhostCat May 23 '17 at 12:44
  • Nope, I did not know that. That's why this forum is here to let you ask questions :) – Timppa May 23 '17 at 12:47
  • Check this https://stackoverflow.com/questions/40514910/set-volume-of-java-clip – 11thdimension May 23 '17 at 12:49
  • I saw that topic, but is there a way to "set" the InputStream as clip or should I just use AudioInputStream instead? – Timppa May 23 '17 at 12:51

1 Answers1

2

Since setting the volume of a BufferedInputStream makes as much sense as adjusting the volume of your couch, it's more likely that you're looking for something like Mixer, which can be used to implement volume control.

It's been quite a few years since I've touched it, but it would allow you to adjust the volume with something like

Mixer mixer = // get Mixer somehow through a provider
FloatControl fc = (FloatControl)mixer.getControl(javax.sound.sampled.FloatControl.Type.MASTER_GAIN);
fc.setValue(1.0f);
Kayaman
  • 72,141
  • 5
  • 83
  • 121
  • My couch is pretty loud as I sit on it :o But yeah, I will check out and try to somehow get this to fit in my script. By the way, I used this tutorial from YouTube https://www.youtube.com/watch?v=LavMuqK5Is0&list=UULuXaf-zBsw8Lzz6nqr66Jw] to make the mp3. Just wanted to make a MP3 player with tutorial, and do the rest within myself (like add audio volume and able to rewind the song etc...). – Timppa May 23 '17 at 12:53