Package com.peterphi.std.types
Class SampleCount
java.lang.Object
com.peterphi.std.types.SampleCount
A number of samples at a given sample rate
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(SampleCount that) addPrecise
(SampleCount that) boolean
getRate()
long
long
getSamples
(Timebase newRate) Returns the number of samples represented by this SampleCount, converted tonewRate
.
This method can lose precision if the samples cannot be precisely represented.long
getSamplesPrecise
(Timebase newRate) Returns the number of samples represented by this SampleCount, converted tonewRate
.double
Compute the duration of this sample count in seconds
The intention of this method is to be used for presentation, rather than accurate computation so it does not warn about resampling errorsint
hashCode()
static SampleCount
parseVidispine
(String countAndRate) Deprecated.Resample this sample count to another ratestatic SampleCount
subtract
(SampleCount that) subtractPrecise
(SampleCount that) Returns the sample count in FFmpeg's time-based duration format.toString()
Encode the SampleCount assamples@[str_timebase|nom[:denom]]
(e.g.Deprecated.static SampleCount
Parse a sample count & timebase assamples@[str_timebase|nom[:denom]]
N.B.
-
Constructor Details
-
SampleCount
-
-
Method Details
-
resample
Resample this sample count to another rate- Parameters:
newRate
-- Returns:
-
add
-
addPrecise
- Throws:
ResamplingException
-
subtract
-
subtractPrecise
- Parameters:
that
- the sample count to subtract- Returns:
- Throws:
ResamplingException
- if the delta cannot be expressed without losing accuracy
-
getRate
-
getSamples
public long getSamples() -
getSamples
Returns the number of samples represented by this SampleCount, converted tonewRate
.
This method can lose precision if the samples cannot be precisely represented. UsegetSamplesPrecise
for lossless-or-exception resampling
- Parameters:
newRate
-- Returns:
-
getSamplesPrecise
Returns the number of samples represented by this SampleCount, converted tonewRate
. If precision would be lost this method throws an exception
This method usesTimebase.resamplePrecise
for lossless-or-exception resampling
- Parameters:
newRate
-- Returns:
- Throws:
ResamplingException
- if precision would be lost by the resample
-
toString
Encode the SampleCount assamples@[str_timebase|nom[:denom]]
(e.g. 124222@44100, 400@30000:1001) -
toFfmpegString
Returns the sample count in FFmpeg's time-based duration format. The format of the sample count is hh:mm:ss:uuuuuu (where u = microseconds).- Returns:
- See Also:
-
parseVidispine
Deprecated.Parse a vidispine sample count & timebase as represented in point 1 of http://wiki.vidispine.com/vidiwiki/Time#Time_codes
N.B. This does NOT consider the case where only a sample count is specified: it MUST include a timebase- Parameters:
countAndRate
- A sample count and a time base. The syntax is {number of samples}@{textual representation of time base} 124222@44100, 400@30000:1001, 400@NTSC- Returns:
-
valueOf
Parse a sample count & timebase assamples@[str_timebase|nom[:denom]]
N.B. This does NOT consider the case where only a sample count is specified: it MUST include a timebase- Parameters:
countAndRate
- A sample count and a time base. The syntax is {number of samples}@{textual representation of time base} 124222@44100, 400@30000:1001, 400@NTSC- Returns:
-
seconds
-
toVidispineString
Deprecated. -
getSeconds
public double getSeconds()Compute the duration of this sample count in seconds
The intention of this method is to be used for presentation, rather than accurate computation so it does not warn about resampling errors- Returns:
-
hashCode
public int hashCode() -
equals
-