Last active
April 17, 2025 18:41
-
-
Save thinkphp/96905485a48e2443ff864ab578f424ff to your computer and use it in GitHub Desktop.
WaveFile VA07 Task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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