Results 1 to 2 of 2
  1. #1
    lokmeinmatz is offline Member
    Join Date
    Oct 2016
    Rep Power

    Question Audio-Analysis with sound.sampled gives -1

    Hey guys, I'm quite new to Java and wanted to access the Volume of the Mic-Sound for a
    simple Audio-Visualizer. I got everything working except for my AudioInput class.
    It doesn't throw exceptions or errors but the line.getlevel returns constantly -1.
    If anyone has experience with that and could tell me what is wrong, it would be awesome.

    My AudioInput class:

    Java Code:
    package audio;
    import javax.sound.sampled.AudioFormat;
    import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.DataLine;
    import javax.sound.sampled.LineUnavailableException;
    import javax.sound.sampled.TargetDataLine;
    public class audioInput {
        float sampleRate = 48000;
        int sampleSizeinBits = 16;
        int channels = 1;
        boolean signed = true;
        boolean bigE = true;
        AudioFormat format;
        DataLine.Info info;
        DataLine line;
        public audioInput(){
            format = new AudioFormat(sampleRate, sampleSizeinBits, channels, signed, bigE);
            info = new DataLine.Info(TargetDataLine.class, format);
            try {
                line = (TargetDataLine) AudioSystem.getLine(info);
            } catch (LineUnavailableException e) {
            try {
            } catch (LineUnavailableException e) {
                // TODO Auto-generated catch block
        public float getVol(){
            return line.getLevel();

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Audio-Analysis with sound.sampled gives -1

    You need to provide a minimal version that will compile without errors and that demonstrates the problem.

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 0
    Last Post: 04-27-2016, 02:27 PM
  2. No proper soundplaying with Javax.sound.sampled
    By sandydo in forum New To Java
    Replies: 1
    Last Post: 04-05-2014, 03:35 PM
  3. Replies: 1
    Last Post: 06-23-2013, 02:52 PM
  4. Details using javax.sound.sampled
    By toadaly in forum Advanced Java
    Replies: 0
    Last Post: 04-20-2010, 06:37 AM
  5. javax.sound.sampled
    By carderne in forum New To Java
    Replies: 5
    Last Post: 02-28-2009, 11:12 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts