             internalAudioFile.framePosition = Int64(theStartFrame)
             framesToPlayCount = theEndFrame - theStartFrame
             
+            
+            //AKLog("framesToPlayCount: \(framesToPlayCount) frameCapacity \(totalFrameCount)")
+            
             audioFileBuffer = AVAudioPCMBuffer(
                 pcmFormat: internalAudioFile.processingFormat,
                 frameCapacity: AVAudioFrameCount(totalFrameCount) )
+            
             do {
                 // read the requested frame count from the file
                 try internalAudioFile.read(into: audioFileBuffer!, frameCount: framesToPlayCount)
                 
-                // AKLog("AKAudioPlayer.updatePCMBuffer() \(audioFileBuffer!.frameLength)")
+                AKLog("read \(audioFileBuffer!.frameLength) frames into buffer")
+                
             } catch {
                 AKLog("ERROR AKaudioPlayer: Could not read data into buffer.")
                 return

    /// Play the file back from a certain time, to an end time (if set). You can optionally set a scheduled time to play (in seconds).
    ///
    ///  - Parameters:
    ///    - time: Time into the file at which to start playing back
    ///    - endTime: Time into the file at which to playing back will stop / Loop
    ///    - scheduledTime: Time in the future to start playback. This is useful for scheduling a group of sounds to
    ///         start concurrently, or to simply schedule the start time.
    ///
    open func play(from time: Double, to endTime: Double = 0, when scheduledTime: Double = 0) {
        
        if endTime > 0 {
            self.endTime = endTime
        }
        
        self.startTime = time
        
        if endingFrame > startingFrame {
            stop()
            self.scheduledTime = scheduledTime
            start()
        } else {
            AKLog("ERROR AKaudioPlayer:  cannot play, \(internalAudioFile.fileNamePlusExtension) is empty or segment is too short!")
        }
    }
    
    
    // MARK: - Private Methods
    

//  AKAudioPlayer.swift
//  AudioKit
//
//  Created by Aurelius Prochazka, Laurent Veliscek & Ryan Francesconi, revision history on Github.
//  Copyright © 2017 AudioKit. All rights reserved.
//

import Foundation
