Methods Summary |
---|
public static long | audioLenToTime(long len, javax.media.format.AudioFormat af)Convert audio: length (bytes) to duration (nanoseconds).
return af.computeDuration(len);
|
public static long | audioTimeToLen(long duration, javax.media.format.AudioFormat af)Convert audio: duration (nanoseconds) to length (bytes).
long units, bytesPerSec;
if (af.getSampleSizeInBits() > 0) {
units = (long)(af.getSampleSizeInBits() * af.getChannels());
bytesPerSec = (long)((units * af.getSampleRate()) / 8);
} else if (af.getFrameSizeInBits() != Format.NOT_SPECIFIED &&
af.getFrameRate() != Format.NOT_SPECIFIED) {
units = af.getFrameSizeInBits();
bytesPerSec = (long)((units * af.getFrameRate()) / 8);
} else {
units = bytesPerSec = 0;
}
// The length returned needs to be in multiples of audio sample
// chunk unit.
return (bytesPerSec == 0 ? 0 :
(long)((duration * bytesPerSec) / 1000000000) / units * units);
|
public long | getValue()
return value;
|
public void | setValue(long t)
value = t;
|
public boolean | update(int len, long ts, javax.media.Format f)
if (f instanceof AudioFormat) {
long t;
if ((t = ((AudioFormat)f).computeDuration(len)) > 0)
value += t;
else if (ts > 0)
value = ts;
else
return false;
} else if (ts > 0)
value = ts;
else
return false;
return true;
|