XML Feeds

.

[java-dev] Bug in AudioFileBuffer with different sample sizes?

volker böhm vboehm at gmx.ch
Sat Mar 22 05:30:15 MDT 2008


hallo,
i'm using AudioFileBuffer from the max mxj api to read soundfiles  
with varying sample sizes.
when i try to output the floating point data from the buf field, i  
get correct results only for 16 bit files.
8 bit, 24 bit and 32 bit are all wrong, which to me looks like errors  
in int-to-float-conversion.
do i overlook something here?
thanks, volker.

simple test class:

import com.cycling74.max.*;
import com.cycling74.msp.*;

public class test_afb extends MaxObject
{
	private AudioFileBuffer afb = null;
	
	public test_afb (Atom[] args) {
		declareInlets(new int[]{DataTypes.ALL});
		declareOutlets(new int[]{DataTypes.ALL});
	}
		
	 /* load  
soundfile----------------------------------------------------*/
	 publicvoid open( String path ) {		
		 String fname = MaxSystem.locateFile(path);
		 post("filename: "+fname);
		
		 try {
			 afb = new AudioFileBuffer(fname);
			 System.out.println("frame length: "+ afb.getFrameLength());
			 System.out.println("samp size in bits: "+ afb.getSampleSizeInBits 
());
			 System.out.println("num channels: "+ afb.getChannels());
			 System.out.println("big endian: "+ afb.isBigEndian());
			 System.out.println("sample rate: "+ afb.getSampleRate());
		 }
		 catch(Exception e) {
			 error("mxj test_afb: sorry, can't open that file!");
		 }		
	 }
	
	 /* output sample value at index from channel 1-------------------*/
	 publicvoid inlet (int index) {	
		outlet(0, afb.buf[0][index]);	
	 }
}


simple test patch:

#P window setfont "Sans Serif" 9.;
#P flonum 225 196 67 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 93 194 67 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 225 121 44 9 0 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 225 166 54 196617 peek~ aha;
#P newex 93 117 68 196617 prepend open;
#P newex 93 166 93 196617 mxj test_afb;
#P newex 351 118 81 196617 prepend replace;
#P button 93 39 15 0;
#P newex 93 62 56 196617 opendialog;
#P newex 351 140 83 196617 buffer~ aha 100;
#P comment 217 105 100 196617 sample index;
#P fasten 8 0 5 0 230 151 98 151;
#P connect 8 0 7 0;
#P connect 5 0 9 0;
#P connect 6 0 5 0;
#P connect 3 0 2 0;
#P connect 2 0 6 0;
#P connect 7 0 10 0;
#P fasten 2 0 4 0 98 88 356 88;
#P connect 4 0 1 0;
#P window clipboard copycount 11;


More information about the java-dev mailing list