Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Last active April 17, 2025 18:41
Show Gist options
  • Save thinkphp/96905485a48e2443ff864ab578f424ff to your computer and use it in GitHub Desktop.
Save thinkphp/96905485a48e2443ff864ab578f424ff to your computer and use it in GitHub Desktop.
WaveFile VA07 Task
public class WavFile extends SampledFile {
public WaveFile() {
super();
}
public WavFile(String path) {
}
public void readAndSetDurationFromFile() {
WavParamReader.readParams(getPathname());
float frameRate = WavParamReader.getFrameRate();
long numberofFrames = WavParamReader.getNumberOfFrames();
this.duration = computeDuration(frameRate, numberofFrames);
}
public static long computeDuration(float frameRate, long numberofFrames) {
//calculate duration in microseconds
double durationInSeconds = numberofFrames / frameRate;
long durationInMicroseconds = (long) (durationInSeconds * 1000000000);
return durationInMicroseconds;
}
@Override
public String toString() {
return super.toString() + " - " + formatDuration();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment