     func decodeAudio(
         fromUrl: NSURL,
         withMaxLength maxLength: Int ,
-        forContext context: UnsafeMutablePointer<ChromaprintContext>) -> Int {
+        forContext context: UnsafeMutablePointer<ChromaprintContext>) -> Double {
         
             let asset = AVURLAsset(URL: fromUrl)
             let reader = try! AVAssetReader(asset: asset)
             let audioTracks = asset.tracksWithMediaType(AVMediaTypeAudio)
+            
             if audioTracks.count == 0 {
                 print("Error: No audio tracks found")
                 return 0

            
            let sampleData      = NSMutableData()
            var totalBuf: Int = 0
            /// start off chromaprint
            chromaprint_start(context, sampleRate!, sampleChannels!)
            
            while reader.status == AVAssetReaderStatus.Reading {
                if let sampleBufferRef = trackOutput.copyNextSampleBuffer() {
                    if let blockBufferRef = CMSampleBufferGetDataBuffer(sampleBufferRef) {
                        /**
                        size_t lengthAtOffset;
                        size_t totalLength;
                        char* data;

*/
//                        var lengthAtOffset = 0
//                        var totalLength = 0
//                        var dataPointer = UnsafeMutablePointer<Int8>.alloc(1)
//                        defer {
//                            dataPointer.destroy()
//                            dataPointer.dealloc(1)
//                        }
//
//                        if CMBlockBufferGetDataPointer(blockBufferRef,
//                            0,                  /// start from offset zero
//                            &lengthAtOffset,    /// will be set to bytelength from above offset
//                            &totalLength,       /// will be set to bytelength from offset 0
//                            &dataPointer) == kCMBlockBufferNoErr {
//                            print("Datapointer \(dataPointer), \(lengthAtOffset), \(totalLength)")
//                                for idx in 0..<totalLength {
//                                    print(String(format:"%X", dataPointer[idx]))
//                                }
//                        }
                        
                        /// bufferLength is the total number of bytes in the buffer
                        let bufferLength = CMBlockBufferGetDataLength(blockBufferRef)
                        totalBuf += bufferLength
                        

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

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

            var sampleRate : Int32?
            var sampleChannels : Int32?
            
//            print("Format descriptions \(audioTrack.formatDescriptions)")
            let descriptions = audioTrack.formatDescriptions
            for d in 0..<descriptions.count {
                let item = descriptions[d] as! CMAudioFormatDescriptionRef
