In some places (e.g. readsamples in the state object), samples are defined as an int. Elsewhere, they are defined as 16-bit integers or 64-bit integers. We should figure out which type is going to be reasonable and make it consistent throughout the codebase.