AFOPENFILE(3)

πŸ’– AFOPENFILE(3) πŸ’–

okay bestie, welcome to the Audio File Library glow-up zone ✨ this is the page for afOpenFile, and it's literally the moment your audio file gets a handle β€” like, an actual AFfilehandle β€” so every other call in the library has something to hold onto. no cap. 🫢


✨ NAME ✨

afOpenFile β€” open an audio file and create a file handle structure used for subsequent calls to the Audio File Library πŸŽ€


🌸 SYNOPSIS 🌸

#include <audiofile.h>

AFfilehandle afOpenFile(const char *path, const char *mode,
    AFfilesetup setup);

πŸ’… PARAMETERS πŸ’…

  • path β€” the path to the file you wanna open. that's it, that's the vibe. πŸ—‚οΈ
  • mode β€” tells it how you're opening the file: "r" for reading or "w" for writing. pick your fighter. ✨
  • setup β€” an AFfilesetup created by afNewFileSetup(3). here's the tea though: this value is ignored for files opened for reading, except when the file format is AF_FILE_RAWDATA. so raw data is the one exception that gets to be main character. πŸ‘‘

🌈 RETURN VALUE 🌈

Upon success, afOpenFile returns a valid AFfilehandle which can be used in subsequent calls to the Audio File Library. slay. πŸŽ‰

Upon failure, afOpenFile returns NULL and generates an error. not slay. 😭

When you're done with the file, afCloseFile(3) is what you use to close it β€” don't just ghost it, bestie. πŸ’–


πŸ”₯ ERRORS πŸ”₯

afOpenFile can produce the following errors β€” here's the full roster, no skipping:

  • AF_BAD_OPEN β€” A call to open failed. πŸ’€
  • AF_BAD_READ β€” A call to read failed
  • AF_BAD_WRITE β€” A call to write failed.
  • AF_BAD_LSEEK β€” A call to lseek failed.
  • AF_BAD_MALLOC β€” Memory allocation failed. the malloc said no πŸ’”
  • AF_BAD_FILEFMT β€” setup specifies a file format which is unsupported for mode.
  • AF_BAD_SAMPFMT β€” The file's sample format is not supported.
  • AF_BAD_WIDTH β€” The file's sample width is not supported.
  • AF_BAD_RATE β€” The file's sample rate is not supported.
  • AF_BAD_CHANNELS β€” The number of channels in the file is not supported.
  • AF_BAD_FILESETUP β€” setup specifies an invalid or unsupported configuration.
fr fr, if you get one of these, something about your file or your setup just did not pass the vibe check. πŸ™ˆ

πŸ¦‹ SEE ALSO πŸ¦‹


πŸ‘‘ AUTHOR πŸ‘‘

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


and that's the whole page, bestie!! this was Audio File Library 0.3.6, dated 03/06/2013, and honestly? it ate. go open that file. periodt. πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from