Skip to content

Commit

Permalink
Fix documentation for Int24 and add PutInt32 method.
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonklaus committed Aug 17, 2018
1 parent e7b6b93 commit 00e7307
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion portaudio.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,29 @@ func IsFormatSupported(p StreamParameters, args ...interface{}) error {
return newError(C.Pa_IsFormatSupported(s.inParams, s.outParams, C.double(p.SampleRate)))
}

// Int24 is a 24-bit signed integer with little-endian byte order.
// Int24 holds the bytes of a 24-bit signed integer in native byte order.
type Int24 [3]byte

// PutInt32 puts the three most significant bytes of i32 into i24.
func (i24 *Int24) PutInt32(i32 int32) {
if littleEndian {
i24[0] = byte(i32 >> 8)
i24[1] = byte(i32 >> 16)
i24[2] = byte(i32 >> 24)
} else {
i24[2] = byte(i32 >> 8)
i24[1] = byte(i32 >> 16)
i24[0] = byte(i32 >> 24)
}
}

var littleEndian bool

func init() {
x := 1
littleEndian = *(*byte)(unsafe.Pointer(&x)) == 1
}

// Stream provides access to audio hardware represented
// by one or more PaDevices. Depending on the underlying
// Host API, it may be possible to open multiple streams
Expand Down

0 comments on commit 00e7307

Please sign in to comment.