     
     /// Get a new track
     public func newTrack() {
-        var newMusicTrack = MusicTrack()
-        MusicSequenceNewTrack(sequence, &newMusicTrack)
-        var count: UInt32 = 0
-        MusicSequenceGetTrackCount(sequence, &count)
-        tracks.append(AKMusicTrack(musicTrack: newMusicTrack))
-        initTracks()
+        if(!isAvSeq){
+            var newMusicTrack = MusicTrack()
+            MusicSequenceNewTrack(sequence, &newMusicTrack)
+            var count: UInt32 = 0
+            MusicSequenceGetTrackCount(sequence, &count)
+            tracks.append(AKMusicTrack(musicTrack: newMusicTrack))
+            initTracks()
+        }else{
+            //cannot
+        }
+    }
+    
+    public func genData()-> NSData? {
+        var status = OSStatus(noErr)
+        var data:Unmanaged<CFData>?
+        status = MusicSequenceFileCreateData(sequence,
+                                             MusicSequenceFileTypeID.MIDIType,
+                                             MusicSequenceFileFlags.EraseFile,
+                                             480, &data)
+        if status != noErr {
+            print("error creating MusicSequence Data")
+            return nil
+        }
+        let ns:NSData = data!.takeUnretainedValue()
+        data?.release()
+        return ns
     }
     
     /// Print sequence to console

        loadMIDIFile(filename)
    }
    
    /// Set loop functionality of entire sequence
    public func loopToggle() {
        (loopEnabled ? loopOff() : loopOn())

    }
    
    /// Set the tempo of the sequencer
    public func setBPM(bpm: Double) {
        if isAvSeq {
            //not applicable
        } else {
