                 
                 sampleIteration += 1
             }
-            let startNote = soundDict.objectForKey(startNoteKeyStr)! as! Int
-            let endNote = soundDict.objectForKey(endNoteKeyStr)! as! Int
-            let rootNote = soundDict.objectForKey(rootNoteKeyStr)! as! Int
+            let startNote = soundDict.objectForKey(startNoteKey)! as! Int
+            let 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)
             
             sampleZoneXML.appendContentsOf(tempSampleZoneXML)

        }//end sounds
        
        let envelopesXML = AKAUPresetBuilder.generateEnvelope(0, delay: 0, attack: attack!, hold: 0, decay: 0, sustain: 1, release: release!)
        let templateStr = AKAUPresetBuilder.buildInstrument(instName, envelopes: envelopesXML, zones: sampleZoneXML, filerefs: sampleIDXML)
        
        //print(templateStr) //debug
        //write to file
        do {
            print("Writing to \(path)")
            try templateStr.writeToFile(path, atomically: false, encoding: NSUTF8StringEncoding)
        } catch let error as NSError {
            print(error)
        }
    }//end func createAUPresetFromDict
    
    // This functions returns 1 dictionary entry for a particular sample zone. You then add this to an array, and feed that
    // into createAUPresetFromDict
    public static func generateTemplateDictionary(
        rootNote: Int,
        filename: String,
        startNote: Int,
        endNote: Int) -> NSMutableDictionary {
        
        let rootNoteKeyStr = "rootnote"
        let startNoteKeyStr = "startnote"
        let endNoteKeyStr = "endnote"
        let filenameKeyStr = "filename"
        let defaultObjects: [NSObject] = [rootNote, startNote, endNote, filename]
        let keys: [String] = [rootNoteKeyStr, startNoteKeyStr, endNoteKeyStr, filenameKeyStr]
        return NSMutableDictionary.init(objects: defaultObjects, forKeys: keys)
    }
    
    static public func buildInstrument(name: String = "Coded Instrument Name",

     instName is the name of the aupreset
     */
    static public func createAUPresetFromDict(dict: NSDictionary, path: String, instName: String, attack: Double? = 0, release: Double? = 0) {
        let rootNoteKey = "rootnote"
        let startNoteKey = "startnote"
        let endNoteKey = "endnote"
        let filenameKey = "filename"
        var loadSoundsArr = Array<NSMutableDictionary>()
        var sampleZoneXML: String = String()
        var sampleIDXML: String = String()
