                 sampleIteration += 1
             }
 
-            let startNote = soundDict.objectForKey(startNoteKey)! as! Int
-            let endNote = soundDict.objectForKey(endNoteKey)! as! Int
+            
+            var startNote = soundDict.objectForKey(startNoteKey) as? Int
+            var endNote = soundDict.objectForKey(endNoteKey) as? Int
             let rootNote = soundDict.objectForKey(rootNoteKey)! as! Int
-            let tempSampleZoneXML: String = AKAUPresetBuilder.generateZone(i, rootNote: rootNote, startNote: startNote, endNote: endNote, wavRef: sampleNum)
+            startNote = (startNote == nil ? rootNote : startNote)
+            endNote = (endNote == nil ? rootNote : endNote)
+            let trigModeStr = soundDict.objectForKey(triggerModeKey) as? String
+            let trigMode : SampleTrigMode
+            let loopBool = false //in progress
+            let tempSampleZoneXML: String = AKAUPresetBuilder.generateZone(i, rootNote: rootNote, startNote: startNote!, endNote: endNote!, wavRef: sampleNum, loopEnabled: loopBool)
 
             sampleZoneXML.appendContentsOf(tempSampleZoneXML)
             soundDict.setObject(sampleNum, forKey: "sampleNum")
             loadSoundsArr.append(soundDict)
-        }
-
-        let envelopesXML = AKAUPresetBuilder.generateEnvelope(0, delay: 0, attack: attack!, hold: 0, decay: 0, sustain: 1, release: release!)
-        let str = AKAUPresetBuilder.buildInstrument(instrumentName, envelopes: envelopesXML, zones: sampleZoneXML, filerefs: sampleIDXML)
+            
+            let envelopesXML = AKAUPresetBuilder.generateEnvelope(0, delay: 0, attack: attack!, hold: 0, decay: 0, sustain: 1, release: release!)
+            switch trigModeStr {
+            case SampleTrigMode.Hold.rawValue?:
+                trigMode = SampleTrigMode.init(rawValue: SampleTrigMode.Hold.rawValue)!
+            default:
+                
+                trigMode = SampleTrigMode.init(rawValue: SampleTrigMode.Trig.rawValue)!
+            }
+            if trigMode == .Trig{
+                let tempLayerXML = AKAUPresetBuilder.generateLayer(AKAUPresetBuilder.generateMinimalConnections(i+1), envelopes: envelopesXML, zones: tempSampleZoneXML, layer: i+1, numVoices: 1, ignoreNoteOff: true)
+                layerXML.appendContentsOf(tempLayerXML)
+            }else if trigMode == .Hold{
+                let tempLayerXML = AKAUPresetBuilder.generateLayer(AKAUPresetBuilder.generateMinimalConnections(i+1), envelopes: envelopesXML, zones: tempSampleZoneXML, layer: i+1, numVoices: 1, ignoreNoteOff: false)
+                layerXML.appendContentsOf(tempLayerXML)
+            }
+        }//end sounds
+        
+        let str = AKAUPresetBuilder.buildInstrument(instrumentName, layers:layerXML, filerefs: sampleIDXML)
 
         //write to file
         do {

        return str
    }
    
    static public func generateZone(id: Int,
                             rootNote: Int,
                             startNote: Int,
                             endNote: Int,

    }

}

public enum SampleTrigMode: String {
    case Hold = "hold"
    case Trig = "trig"
    case Loop = "loop"
}
/*
 making notes of parameters as I reverse engineer them...
 to access a the next layer, add 256
