         }
     }
     
-    //length is length of longest track in the sequence
-    public var length:Double{
+    /// Length of longest track in the sequence
+    public var length: Double {
         var length:MusicTimeStamp = 0
         var tmpLength:MusicTimeStamp = 0
 //        var size:UInt32 = 0

        MusicPlayerSetSequence(musicPlayer, sequence)
    }
    
    //inits the sequence with a midi file
    public convenience init(filename:String){
        self.init()
        loadMidiFile(filename)
    }
    
    //inits the sequence with a midi file and audioengine
    public convenience init(filename:String, engine:AVAudioEngine){
        self.init()
        avSeq = AVAudioSequencer(audioEngine: engine)
        loadMidiFile(filename)
    }
    
    //set loop functionality of entire sequence
    public func loopToggle(){
        (loopEnabled ? loopOff() : loopOn())
    }
    public func loopOn(){
        setLoopInfo(length, numLoops: 0)
        for track in avSeq.tracks{
            track.loopingEnabled = true
            track.loopRange = AVMakeBeatRange(0, self.length)
        }
        loopEnabled = true
    }
    public func loopOff(){
        setLoopInfo(0, numLoops: 0)
        for track in avSeq.tracks{
            track.loopingEnabled = false
        }
        loopEnabled = false
    }
    //set looping of all tracks
    public func setLoopInfo(duration:Double, numLoops:Int){
        let size:UInt32 = 0
        let num:Int32 = Int32(numLoops)
        let len = MusicTimeStamp(duration)
        var loopInfo = MusicTrackLoopInfo(loopDuration: len, numberOfLoops: num)
        for( var i = 0; i < self.numTracks; ++i){
            var musicTrack = MusicTrack()
            MusicSequenceGetIndTrack(sequence, UInt32(i), &musicTrack)
            MusicTrackSetProperty(musicTrack, kSequenceTrackProperty_LoopInfo, &loopInfo, size)
        }
    }
    //set length of all tracks
    public func setLength(length:Double){
        let size:UInt32 = 0
        var len = MusicTimeStamp(length)
        for( var i = 0; i < self.numTracks; ++i){
            var musicTrack = MusicTrack()
            MusicSequenceGetIndTrack(sequence, UInt32(i), &musicTrack)
            MusicTrackSetProperty(musicTrack, kSequenceTrackProperty_TrackLength, &len, size)

        return Double(length)
    }
    
    /// Play the sequence
    public func play() {
//        MusicPlayerStart(musicPlayer)
        do{
            try avSeq.start()
