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 798f3d5 commit e0b2e47
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions opus.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,18 @@ func (i *OpusReader) getPage() ([]byte, error) {
return payload, err
}
fmt.Printf("i.pageIndexl: %v\n", i.pageIndex)
i.currentSampleLen, _ = i.calculateSampleDuration(uint32(granulePosition - i.previousGranulePosition))
fmt.Printf("Sample len : %v\n", i.currentSampleLen)
i.previousGranulePosition = granulePosition

//skipping checksum
io.CopyN(ioutil.Discard, i.stream, 4)

var segments uint8
if err := binary.Read(i.stream, binary.LittleEndian, &segments); err != err {
return payload, err
}

i.currentSampleLen, _ = i.calculateSampleDuration(uint32(granulePosition - i.previousGranulePosition))
fmt.Printf("Sample len : %v\n", i.currentSampleLen)
i.previousGranulePosition = granulePosition

var payloadLen uint32
for x := 1; x <= int(segments); x++ {
var segSize uint8
Expand Down Expand Up @@ -250,15 +251,16 @@ func (i *OpusReader) getPageSingle() ([]byte, error) {
return payload, err
}
fmt.Printf("i.pageIndexl: %v\n", i.pageIndex)
i.currentSampleLen, _ = i.calculateSampleDuration(uint32(granulePosition - i.previousGranulePosition))
fmt.Printf("Sample len : %vms\n", i.currentSampleLen)
i.previousGranulePosition = granulePosition
//skipping checksum
io.CopyN(ioutil.Discard, i.stream, 4)

if err := binary.Read(i.stream, binary.LittleEndian, &i.segments); err != err {
return payload, err
}
i.currentSampleLen, _ = i.calculateSampleDuration(uint32(granulePosition - i.previousGranulePosition))
fmt.Printf("Sample len : %vms\n", i.currentSampleLen)
i.previousGranulePosition = granulePosition

var x uint8
for x = 1; x <= i.segments; x++ {
var segSize uint8
Expand Down

0 comments on commit e0b2e47

Please sign in to comment.