Click here to Skip to main content
14,084,843 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
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.
Posted
Updated 3 days ago

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web03 | 2.8.190518.1 | Last Updated 15 May 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100