Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8017901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:58:29+00:00 2026-06-04T20:58:29+00:00

I am making a Vocoder in java built into a synthesizer built based on

  • 0

I am making a Vocoder in java built into a synthesizer built based on a tutorial from Dr. Dobb’s and whenever i try to get samples from the microphone it just returns zeros for the samples even when there is mic input.
This is the settings of the AudioFormat:

// AudioFormat parameters
public  static final int     SAMPLE_RATE = 22050;
private static final int     SAMPLE_SIZE = 16;
private static final int     CHANNELS = 1;
private static final boolean SIGNED = true;
private static final boolean BIG_ENDIAN = true;
// Chunk of audio processed at one time
public static final int BUFFER_SIZE = 1000;
public static final int SAMPLES_PER_BUFFER = BUFFER_SIZE / 2;    

VoiceProvider (mic sample providing class):

public class VoiceProvider implements ISynthProvider{
    private TargetDataLine line;
    public VoiceProvider(){
        DataLine.Info info = new DataLine.Info(TargetDataLine.class, 
            Player.format); // format is an AudioFormat object
        if (!AudioSystem.isLineSupported(info)) {
            System.out.println("o_0 line not supported!");

        }

        // Obtain and open the line.
        try {
            line = (TargetDataLine) AudioSystem.getLine(info);
            line.start();
            line.open(Player.format);

        } catch (LineUnavailableException ex) {
            // Handle the error ... 
        }

    }
    @Override
    public double getSample() {
        byte[] a = {0,0}; 
        if (line.isOpen()){
            //System.out.println("0_0");
            line.read(a, 0, 2);
        }else{
            //System.out.println("o_0");
        }
        System.out.println(Arrays.toString(a));
        return readShort(a,0);

    }
    public static short readShort(byte[] data, int offset) {
    return (short) (((data[offset] << 8)) | ((data[offset + 1] & 0xff)));
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:58:31+00:00Added an answer on June 4, 2026 at 8:58 pm
    try {
            line = (TargetDataLine) AudioSystem.getLine(info);
            line.start();
            line.open(Player.format);
    
        } catch (LineUnavailableException ex) {
            // Handle the error ... 
        }
    

    should be:

    try {
            line = (TargetDataLine) AudioSystem.getLine(info);
            line.open(Player.format);
            line.start();
    
        } catch (LineUnavailableException ex) {
            // Handle the error ... 
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

making a new jsp and got a mock-up from some analyst. Notice the sections
Making a small WCF test program which is based on a Store that has
Making the transition from Vim to gVim, I would like to disable all toolbars
Making a quick JQuery demo where clicking a table element changes it from black
Recently making the switch from Prototype to jQuery , I am struggling with some
making a thumbnail from video using the picker is straight forward. However, when I
Making a specific word entered into a textbox trigger a password prompt that when
im making an application where i have to load my database from html file
Im making a game in Java with a few other people but we are
When making a call to jQuery get , how does one specify HTML elements

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.