public static long calcLength(AudioBuffer buf) { // Assumes later getBuffer() will find the buffer from AudioManager instead // of the current local reference... that's why I'm not directly using sound_buf here. // Required buffer functions not yet implemented long num_frames; int frequency; if (buf != null) { num_frames = buf.getLength(); frequency = buf.getFrequency(); } else { // No buffer attached! num_frames = 0; frequency = 0; } /* long num_frames = 1; long frequency = 125; */ if (frequency <= 0) { // Protect against divide-by-zero errors return (0l); } else { return ((1000 * num_frames) / frequency); } }