将wav文件放入由框架集合组成的arraylist中 [英] Putting a wav file into an arraylist consisiting of collections of frames

查看:40
本文介绍了将wav文件放入由框架集合组成的arraylist中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用代码从wav文件创建缓冲区,其中数据以100帧为单位读取。

请参阅以下链接获取原始代码:



http://www.labbookpages.co.uk/audio/javaWavFiles.html



我现在需要创建一个ArrayList每个元素由wav文件中的100帧组成(第一个元素0-99,第二个100-199等...)



我是什么尝试过:



我无法弄清楚如何在我目前尝试的代码中实现这个:







I have used code from to create a buffer from a wav file in which data is read in blocks of 100 frames.
Please see link below for original code:

http://www.labbookpages.co.uk/audio/javaWavFiles.html

I now need to create an ArrayList in which each element consists of 100 frames from the wav file (The first element 0-99, the second 100-199 etc...)

What I have tried:

I am having trouble figuring out how to implement this into the code I've currently tried:



// Display information about the wav file
     wavFile.display();

     // Get the number of audio channels in the wav file
     int numChannels = wavFile.getNumChannels();

     // Create a buffer of 100 frames
     double[] buffer = new double[100 * numChannels];

     int framesRead;


     do
     {
        // Read frames into buffer
        framesRead = wavFile.readFrames(buffer, 100);

      }
     while (framesRead != 0);

     // Close the wavFile
     wavFile.close();







我不知道应该用什么方式构建数组列表,或填充它。

关于如何实现这一目标的任何建议都将非常感激。




I am not sure what way in which I should construct the Array List, or populate it.
Any advice about how I can achieve this would be greatly appreciated.

推荐答案

什么是100帧的元素?另一个阵列?



如果是,那么你有一个数组阵列。



与流相比用得多。现在你必须弄清楚如何处理少于100帧的不完整元素。
What is the "element of a 100 frames"? Another array?

If yes, then you have an "array of arrays".

Not much use versus a stream. Now you have to figure out what to do with an "incomplete element" of less than 100 frames.


这篇关于将wav文件放入由框架集合组成的arraylist中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆