 
     /// Clear all events from the track
     public func clear() {
+        clearMetaEvents()
         if !isEmpty {
             MusicTrackClear(internalMusicTrack, 0, length)
         }
-        clearMetaEvents()
     }
     
     func clearMetaEvents(){

    /// - parameter duration: How long the loop will last, from the end of the track backwards
    ///
    public func setLength(duration: AKDuration) {

        let size: UInt32 = 0
        var len = duration.musicTimeStamp
        var tmpSeq: MusicSequence = nil

        var eventData: UnsafePointer<Void> = nil
        var eventDataSize: UInt32 = 0
        var hasNextEvent: DarwinBoolean = false
        MusicEventIteratorHasCurrentEvent(iterator, &hasNextEvent)
        while(hasNextEvent) {
            MusicEventIteratorGetEventInfo(iterator, &eventTime, &eventType, &eventData, &eventDataSize)
            
            outBool = false
            //print("time is \(eventTime) - type is \(eventType)")
            //print("data is \(eventData)")
            MusicEventIteratorNextEvent(iterator)
            MusicEventIteratorHasCurrentEvent(iterator, &hasNextEvent)
        }
