Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Programming

Panos Matsinopoulos pmatsinopoulos

💻
Programming
View GitHub Profile
View ap_ExtendedAudioConversion_09.m
#define OUTPUT_FILE_NAME "output.caf"
#define OUTPUT_FILE_TYPE kAudioFileCAFType
View ap_ExtendedAudioConversion_08.m
void InitializeOutputAudioFile (AudioStreamBasicDescription iAudioBasicStreamDescription,
const char *iFileName,
AudioFileTypeID iAudioFileTypeID,
const char *iMessage,
AudioFileID *oAudioFileID) {
CheckError(AudioFileCreateWithURL((__bridge CFURLRef) CharPointerFilenameToNSURLp(iFileName),
iAudioFileTypeID,
&iAudioBasicStreamDescription,
kAudioFileFlags_EraseFile,
oAudioFileID),
View ap_ExtendedAudioConversion_07.m
InitializeOutputAudioFile(audioConverterSettings.outputFormat,
OUTPUT_FILE_NAME,
OUTPUT_FILE_TYPE,
"Initializing Output Audio File",
&audioConverterSettings.outputFile);
View ap_ExtendedAudioConversion_07.m
void SetUpAudioDataSettingsForOutputFile (AudioConverterSettings *outAudioConverterSettings) {
outAudioConverterSettings->outputFormat.mFormatID = kAudioFormatLinearPCM;
outAudioConverterSettings->outputFormat.mSampleRate = outAudioConverterSettings->inputFormat.mSampleRate;
outAudioConverterSettings->outputFormat.mChannelsPerFrame = outAudioConverterSettings->inputFormat.mChannelsPerFrame;
if (outAudioConverterSettings->outputFormat.mFormatID == kAudioFormatLinearPCM) {
// if the output format is PCM create a 16-bit int PCM file format description as an example
outAudioConverterSettings->outputFormat.mBitsPerChannel = 16;
outAudioConverterSettings->outputFormat.mBytesPerFrame = outAudioConverterSettings->outputFormat.mBitsPerChannel / 8 * outAudioConverterSettings->outputFormat.mChannelsPerFrame;
outAudioConverterSettings->outputFormat.mFramesPerPacket = 1;
View ap_ExtendedAudioConversion_06.m
SetUpAudioDataSettingsForOutputFile(&audioConverterSettings);
View ap_ExtendedAudioConversion_05.m
GetExtendedFileAudioStreamBasicDescription(audioConverterSettings.inputFile,
&audioConverterSettings.inputFormat);
View ap_ExtendedAudioConversion_04.m
void GetExtendedFileAudioStreamBasicDescription(ExtAudioFileRef iExtAudioFileRef,
AudioStreamBasicDescription *oAudioStreamBasicDescription) {
UInt32 propertyValueSize = 0;
Boolean writable = false;
CheckError(ExtAudioFileGetPropertyInfo(iExtAudioFileRef,
kExtAudioFileProperty_FileDataFormat,
&propertyValueSize,
&writable),
"Getting the file data format property value size of audio file");
View ap_ExtendedAudioConversion_03.m
OpenExtendedAudioFile(argv[1], &audioConverterSettings.inputFile);
View ap_ExtendedAudioConversion_02.m
void OpenExtendedAudioFile(const char *iFileName, ExtAudioFileRef *oExtAudioFileRef) {
CheckError(ExtAudioFileOpenURL((__bridge CFURLRef) CharPointerFilenameToNSURLp(iFileName),
oExtAudioFileRef),
"Opening the audio file");
}
View ap_ExtendedAudioConversion_01.m
typedef struct AudioConverterSettings {
AudioStreamBasicDescription outputFormat;
AudioStreamBasicDescription inputFormat;
ExtAudioFileRef inputFile;
AudioFileID outputFile;
UInt32 outputBufferSizeInPackets;
} AudioConverterSettings;