Skip to content

Commit

Permalink
get current sample duration for a single sample
Browse files Browse the repository at this point in the history
  • Loading branch information
csiwek committed Jul 29, 2019
1 parent e0b2e47 commit daa8dab
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions opus.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ func (i *OpusReader) calculateSampleDuration(deltaGranulePosition uint32) (uint3
if i.sampleRate == 0 {
return 0, errors.New("Wrong samplerate")
}
if i.segments == 0 {
return 0, errors.New("Wrong number of segments")
}

deltaTime := i.currentSamples * 1000 / i.sampleRate / uint32(i.segments)
return uint32(deltaTime), nil
}
Expand Down

0 comments on commit daa8dab

Please sign in to comment.