AFGETFRAMESIZE(3)

πŸ’– AFGETFRAMESIZE(3) πŸ’–

okay bestie, welcome to section 3 of the manual (yes, 3, that's the library-functions girlies πŸ’…), and today's main character is afGetFrameSize. she's a lil function with one job and she eats every time: she tells you how many bytes a frame takes up in an audio track. that's it. that's the whole vibe. πŸŽ€


✨ NAME ✨

afGetFrameSize β€” calculate the frame size in bytes for an audio track πŸ¦‹


🌸 SYNOPSIS 🌸

#include <audiofile.h>

float afGetFrameSize (AFfilehandle file, int track, int expand3to4);

πŸŽ€ PARAMETERS πŸŽ€

  • file β€” a valid AFfilehandle. like, it has to be valid, bestie, don't come at her with a fake handle 😭
  • track β€” an integer that refers to a specific audio track in the file. and here's the tea: at present, no supported audio file format allows for more than one audio track inside a file, so track should always be AF_DEFAULT_TRACK. no cap. 🫢
  • expand3to4 β€” a boolean-valued integer that says whether the frame size calculation treats 24-bit data as having a size of 3 bytes or 4 bytes. yes, she's a boolean-valued integer, she contains multitudes. ✨

πŸ’… DESCRIPTION πŸ’…

afGetFrameSize returns the number of bytes in a frame in a given audio track. that's her whole thing, and she's obsessed with it. πŸ”₯

now let's talk about what a sample frame even is, because it's giving "you need to know this." a sample frame consists of one or more samples:

  • for a monaural track, a sample frame will always contain one sample.
  • for a stereophonic track, a sample frame will always contain two samples β€” one for the left channel and one for the right channel. iconic stereo behaviour. πŸ‘‘

and here's the crucial bit, so listen up: you should use a non-zero value of expand3to4 when you're calculating the frame size for storage in memory, because 24-bit audio data is presented in memory as a 4-byte sign-extended integer. meanwhile you use a value of zero for calculating storage on disk, where no padding is added. πŸ“

also, expand3to4 is literally ignored unless the specified audio track contains 24-bit audio data. she said "if it's not 24-bit, I don't see it, I don't know her." πŸ’€

🌈 AUTHOR 🌈

Michael Pruett <michael@68k.org> β€” we stan. πŸ’œ


and that's a wrap, bestie!! this page came to you courtesy of Audio File Library 0.3.6, dated 03/06/2013, and it's filed under AFGETFRAMESIZE(3). go forth and calculate those frame sizes correctly, mwah πŸ’–πŸ§šβœ¨

πŸ“¦ where this page comes from