WWDC example of signal generator outputs files with 0 duration

Using the example from WWDC, with the following command ./SignalGenerator -signal square -duration 3 -output ./uncompressed.wav I can generate an audio file, which is not playable, and its Get Info is:

  • Duration: 00:00
  • Audio channels: Mono
  • Sample rate: 44,1 kHz
  • Bits per sample: 32

Although for MacOS Preview the duration is zero, this file is playable in VLC and convertible to other formats, so its content is ok. To get more information about the format of an output file I changed the example to print outputFormatSettings:

["AVLinearPCMBitDepthKey": 32, "AVLinearPCMIsBigEndianKey": 0, "AVSampleRateKey": 44100, "AVFormatIDKey": 1819304813, "AVLinearPCMIsFloatKey": 1, "AVNumberOfChannelsKey": 1, "AVLinearPCMIsNonInterleaved": 1]

I don’t know how to interpret the “number of AVFormatIDKey": 1819304813. The documentation says:

let AVFormatIDKey: String - For information about the possible values for this key, see Audio Format Identifiers

Having red this, I still don't know the relation of AVFormatIDKey and listed Audio Format Identifiers.

If I knew which file format to expect, it might have helped to guess why the duration of the generated files is always 0? Can you help me with both questions? Thanks.

I can’t offer any insight into your main questions — audio really isn’t my thing — but I can answer this:

I don’t know how to interpret the “number of AVFormatIDKey": 1819304813.

In hex that’s 0x6c70636d, aka kAudioFormatLinearPCM.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

With specified outputFormatSettings[AVFormatIDKey] = kAudioFileWAVEType instead of generating WAVE files, the code example crashes with

Error Domain=com.apple.coreaudio.avfaudio Code=1718449215 "(null)" UserInfo={failed call=err}
zsh: illegal hardware instruction  ./SignalGenerator -duration 3 -output ./output.wav

where 1718449215 is the code for kAudioFormatUnsupportedDataFormatError.

WWDC example of signal generator outputs files with 0 duration
 
 
Q