Created
September 30, 2026 18:14
-
-
Save Buggem/a75ee54ba7a13e53f42c412a520bda20 to your computer and use it in GitHub Desktop.
Quick and dirty C gadget to convert sndfile formats to PortAudio formats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <portaudio.h> | |
| #include <sndfile.h> | |
| static inline PaSampleFormat sndFileToPa(int format) | |
| { | |
| switch(format & SF_FORMAT_SUBMASK) | |
| { | |
| case SF_FORMAT_PCM_S8: | |
| return paInt8; | |
| case SF_FORMAT_PCM_16: | |
| return paInt16; | |
| case SF_FORMAT_PCM_24: | |
| return paInt24; | |
| case SF_FORMAT_PCM_32: | |
| return paInt32; | |
| case SF_FORMAT_PCM_U8: | |
| return paUInt8; | |
| case SF_FORMAT_FLOAT: | |
| return paFloat32; | |
| } | |
| return (PaSampleFormat)-1; // error | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment