Help us understand the problem. What is going on with this article?

javaでsin波を鳴らすだけ(javax.sound.sampled.SourceDataLine)

More than 3 years have passed since last update.
audio.java
import  javax.sound.sampled.*;
import  java.lang.Math;

public class Audio {
    static  final   int freq=44100;//サンプリングレートは44100(=CD並
    static  final   double  hz=400;//音は400hz
    public  Audio(){
        try{
            AudioFormat fmt=new AudioFormat(freq, 8, 1, true, false);
            SourceDataLine  audio=(SourceDataLine)AudioSystem.getSourceDataLine(fmt);
            audio.open(fmt);
            byte[]  data=new    byte[freq];
            for(int i=0;i<freq;i++){
                data[i]=(byte)(127*Math.sin(2*Math.PI*hz*i/freq));
            }
            audio.start();
            audio.write(data, 0, freq);
        }catch(Exception e){
            e.printStackTrace();
            System.exit(1);
        }
    }
    public static void main(String[] args){
        new Audio();
    }
}

audio.start()を忘れてて梃子摺った。
一サンプルあたりのバイト数をどうやれば上げられるのか分からない。
short[]とかわwrite関数が受け取ってくれないしどうしようか?

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした