0

I roughly have the following code in Swift:

var inputFileURL : NSURL
var inputFile : AudioFileID
inputFileURL = NSURL.fileURLWithPath("/Bird.wav")
status = AudioFileOpenURL(inputFileURL, Int8(kAudioFileReadPermission), 0, &inputFile)
status = AudioUnitSetProperty( inUnit: AudioFilePlayerAU, inID: kAudioUnitProperty_ScheduledFileIDs, inScope: kAudioUnitScope_Global, inElement: 0, inData: self.inputFile, inDataSize: sizeof(inputFile) )

The problem is I cannot use sizeof() [as shown in most Core Audio Examples] to for setting that parameter of the AudioUnitSetProperty function.

I get and error:

173:37: error: 'AudioFileID' is not convertible to 'T.Type'
            inDataSize: sizeof(self.inputFile) )
                                    ^
Swift.sizeof:1:6: note: in call to function 'sizeof'
func sizeof<T>(_: T.Type) -> Int

How am I suppose to go about getting data size for a audio file in Swift?

Thanks

FTNomad
  • 175
  • 8

1 Answers1

2

sizeof() in Swift takes a type for argument, not a variable. Try sizeof(AudioFileID). You'll also need to convert the result from Int to UInt32 for inDataSize i.e. UInt32(sizeof(AudioFileID))

macduff
  • 1,583
  • 1
  • 9
  • 9