Standardising various variable types #27
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Define two type aliases:
sample_count_t
, which represents a number of samples (and also sample rates, since these are technically # samples / second); andsample_t
, which represents a single mono sample of audio data. These clarify a little more in the code itself what various variables represent, make it easier to standardise the type across different functions, and allow the type to be changed more easily if desired for whatever reason.Sample counts are standardised to use
long
. The C++ standard should guarantee we can store up to at least 2147483647, which should be sufficient for almost all audio files at most sample rates. As a back of the napkin calculation, 2147483647 samples @ 44100Hz is 13.5hrs, and 2147483647 samples @ 220500Hz (which should be complete overkill here!) is 2.7hrs. These are far longer than any individual GSF I've encountered, and would allow an extremely long loop before any overflow effects would be encountered. In reality, GCC tends to use 8-bitlong
s, which has a maximum of 9223372036854775807, leading to maximum sample numbers corresponding to millions of years of continuous playback. I suspect this will be more than long enough (:Samples, as we are using 16-bit audio, are simply
int16_t
. The type alias is more for clarity than any other reason.I'll use this in a local build for a while to make sure nothing is obviously broken, then I can look at merging this.
Closes #26.