                     sampleChannels = Int32(desc.mChannelsPerFrame)
                 }
             }
+
             /// Sanity check
             guard (sampleRate != nil) && (sampleChannels != nil) else {
                 return 0

class AppDelegate: NSObject, NSApplicationDelegate {

    let desktopPath = "/Users/teo/Desktop/"
//    let fileName = "64.mp3"
//    let fileName = "low.wav"
    let fileName = "64.wav"
//        let fileName = "small64.m4a"
    
    func applicationDidFinishLaunching(aNotification: NSNotification) {

        let maxLength = 1200
        /** Create a single instance of an unsafe mutable Int8 pointer so we can 
            pass it to chromaprint_get_fingerprint without errors. 
            The defer ensures it is not leaked.
        */
        var fingerprint = UnsafeMutablePointer<Int8>.alloc(1)
        defer {
            print("Destroy & dealloc fingerprint")
            fingerprint.destroy()
            fingerprint.dealloc(1)
        }
        
        /// Start by creating a chromaprint context.
        /// Not sure why CHROMAPRINT_ALGORITHM_DEFAULT isn't defined here.
//        let algo : Int32 = 1 //UInt32(CHROMAPRINT_ALGORITHM_TEST2.rawValue)
        let algo = Int32(CHROMAPRINT_ALGORITHM_TEST2.rawValue)
        let chromaprintContext = chromaprint_new(algo)

        /// Get the song
//        let fileName = "low.wav"

//        let songUrl = NSURL(fileURLWithPath: "/Users/teo/Desktop/64.mp3" )
        let songUrl = NSURL(fileURLWithPath: desktopPath+fileName )
        
        /// Decode the song
        let duration = decodeAudio(songUrl, withMaxLength: maxLength, forContext: chromaprintContext)
        /** Make a fingerprint from the song data.
            (Note we can also get a hash back with chromprint_get_fingerprint_hash)
        */

            let audioTrack = audioTracks[0]
            let trackOutput = AVAssetReaderTrackOutput(track: audioTrack, outputSettings: outputSettings)

            /// Get the duration.
            let durationInSeconds = CMTimeGetSeconds(audioTrack.timeRange.duration)

            var sampleRate : Int32?
            var sampleChannels : Int32?
            let descriptions = audioTrack.formatDescriptions
            
            for d in 0..<descriptions.count {
                let item = descriptions[d] as! CMAudioFormatDescriptionRef
                let desc = CMAudioFormatDescriptionGetStreamBasicDescription(item).memory
