Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.wav到数组的转换 import java.io.BufferedInputStream; 导入java.io.ByteArrayOutputStream; 导入java.io.File; 导入java.io.FileInputStream; 导入java.io.IOException; 导入javax.sound.sampled.AudioInputStream; 导入javax.sound.sampled.AudioSystem; 导入javax.sound.sampled.unsupportDaudioFileException; 公共类音频字节到字节{ 公共静态void main(字符串args[])引发IOException { File WAV_File=新文件(“/home/cybersecurity/Desktop/scream.WAV”); ByteArrayOutputStream out=新建ByteArrayOutputStream(); AudioInputStream in=null; 试一试{ in=AudioSystem.getAudioInputStream(WAV_文件); }捕获(不支持的数据文件异常e){ e、 printStackTrace(); }捕获(IOE异常){ e、 printStackTrace(); } int-read,i; 字节[]buff=新字节[1024]; 而((read=in.read(buff))>0) { out.write(buff,0,read); } out.flush(); byte[]audioBytes=out.toByteArray(); 对于(i=0;i_Java_Arrays_Wav - Fatal编程技术网

.wav到数组的转换 import java.io.BufferedInputStream; 导入java.io.ByteArrayOutputStream; 导入java.io.File; 导入java.io.FileInputStream; 导入java.io.IOException; 导入javax.sound.sampled.AudioInputStream; 导入javax.sound.sampled.AudioSystem; 导入javax.sound.sampled.unsupportDaudioFileException; 公共类音频字节到字节{ 公共静态void main(字符串args[])引发IOException { File WAV_File=新文件(“/home/cybersecurity/Desktop/scream.WAV”); ByteArrayOutputStream out=新建ByteArrayOutputStream(); AudioInputStream in=null; 试一试{ in=AudioSystem.getAudioInputStream(WAV_文件); }捕获(不支持的数据文件异常e){ e、 printStackTrace(); }捕获(IOE异常){ e、 printStackTrace(); } int-read,i; 字节[]buff=新字节[1024]; 而((read=in.read(buff))>0) { out.write(buff,0,read); } out.flush(); byte[]audioBytes=out.toByteArray(); 对于(i=0;i

.wav到数组的转换 import java.io.BufferedInputStream; 导入java.io.ByteArrayOutputStream; 导入java.io.File; 导入java.io.FileInputStream; 导入java.io.IOException; 导入javax.sound.sampled.AudioInputStream; 导入javax.sound.sampled.AudioSystem; 导入javax.sound.sampled.unsupportDaudioFileException; 公共类音频字节到字节{ 公共静态void main(字符串args[])引发IOException { File WAV_File=新文件(“/home/cybersecurity/Desktop/scream.WAV”); ByteArrayOutputStream out=新建ByteArrayOutputStream(); AudioInputStream in=null; 试一试{ in=AudioSystem.getAudioInputStream(WAV_文件); }捕获(不支持的数据文件异常e){ e、 printStackTrace(); }捕获(IOE异常){ e、 printStackTrace(); } int-read,i; 字节[]buff=新字节[1024]; 而((read=in.read(buff))>0) { out.write(buff,0,read); } out.flush(); byte[]audioBytes=out.toByteArray(); 对于(i=0;i,java,arrays,wav,Java,Arrays,Wav,原始文件是不相关的,因为WAVE文件是使用块构造的。我建议先理解这些块,才能理解WAVE文件。你有没有尝试过序列化概念?为什么字节会成为一个边界值?是什么让你产生了这个想法?数字会滚动。我用许多音频文件尝试过我的程序,而且我一直在使用它t最后的100-150个值为-128或-127,仅适用于所有文件,因为我不熟悉这一点,所以想到asking@bmorris591问题是,我必须识别尖叫声,所以我需要执行FFTCA的准确值。我可以将音频转换成实数吗?网络上有大量的规范向你展示了这一点。这也是另一个问

原始文件是不相关的,因为WAVE文件是使用块构造的。我建议先理解这些块,才能理解WAVE文件。

你有没有尝试过序列化概念?为什么字节会成为一个边界值?是什么让你产生了这个想法?数字会滚动。我用许多音频文件尝试过我的程序,而且我一直在使用它t最后的100-150个值为-128或-127,仅适用于所有文件,因为我不熟悉这一点,所以想到asking@bmorris591问题是,我必须识别尖叫声,所以我需要执行FFTCA的准确值。我可以将音频转换成实数吗?网络上有大量的规范向你展示了这一点。这也是另一个问题我已经在我的问题下的评论中回答了为什么这个转换是必要的,在搜索之后我发现pcm格式可以帮助我,所以我没有发现这个不相关的问题
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;


public class Audio_to_bytes {

    public static void main(String args[]) throws IOException
{
    File WAV_FILE = new File("/home/cybersecurity/Desktop/scream.wav");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    AudioInputStream in = null;
    try {
        in = AudioSystem.getAudioInputStream(WAV_FILE);
    } catch (UnsupportedAudioFileException e) {

        e.printStackTrace();
    } catch (IOException e) {

        e.printStackTrace();
    }


    int read,i;
    byte[] buff = new byte[1024];
    while ((read = in.read(buff)) > 0)
    {
        out.write(buff, 0, read);
    }
    out.flush();
    byte[] audioBytes = out.toByteArray();
    for(i=0;i<audioBytes.length;i++)
        System.out.println(audioBytes[i]);
}
}