 
     }
     
-    func postFeatureHandler(data:Data?, urlResponse:URLResponse?, error:Error?) -> Void{
-        if(!(error != nil)){
-//            print(urlResponse!)
-            if let responseData = try? JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers) as! Dictionary<String, Any> {
-//                print(responseData)
-                
-                if let prediction = responseData["prediction"] as? String {
-                    
-                    if let gesture = drumKits[selectedDrumKit].gestures[prediction] {
-                        let instrument = gesture.instrument
-                        
-                        let date = self.players[instrument]!["time"] as! Date
-                        let now = Date()
-                        let seconds = now.timeIntervalSince(date)
-//                        print("Seconds: ",seconds)
-                        
-                        if seconds > TIME_DELAY {
-                            self.players[instrument]!["time"] = now
-                            self.players[instrument]!["index"] = ((self.players[instrument]!["index"] as! Int)+1)%3
-                        }
-                        
-                        (self.players[instrument]!["players"] as! Array<AVAudioPlayer>)[self.players[instrument]!["index"] as! Int].play()
-                    }
-                    else {
-                        print("Gesture not in use.", prediction)
-                    }
-                }
-                else {
-                    print("could not convert prediction to string")
-                }
-            }
-            else {
-                print("Could not convert to dict")
-            }
-            
-        } else{
-            print(error!)
-        }
-    }
-    
-    
-    func getPredictionData(data:NSArray) {
-        let baseUrl = "\(SERVER_URL)/PredictOne"
-        let postUrl = NSURL(string: baseUrl)
-        self.numDataPoints = self.numDataPoints + 1
-        
-        
-        let jsonUpload:NSDictionary = ["feature": data, "dsid": DSID]
-        
-        let requestBody = try! JSONSerialization.data(withJSONObject: jsonUpload, options: JSONSerialization.WritingOptions.prettyPrinted)
-        var request = URLRequest(url: postUrl as! URL)
-        request.httpBody = requestBody
-        request.httpMethod = "POST"
-        
-        
-        let postTask = self.session.dataTask(with: request, completionHandler: postFeatureHandler)
-        
-        
-        
-        postTask.resume()
-//        print(self.numDataPoints)
-    }
+    
+    //OLD POST REQUEST
+//    func postFeatureHandler(data:Data?, urlResponse:URLResponse?, error:Error?) -> Void{
+//        if(!(error != nil)){
+////            print(urlResponse!)
+//            if let responseData = try? JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers) as! Dictionary<String, Any> {
+////                print(responseData)
+//                
+//                if let prediction = responseData["prediction"] as? String {
+//                    
+//                    if let gesture = drumKits[selectedDrumKit].gestures[prediction] {
+//                        let instrument = gesture.instrument
+//                        
+//                        let date = self.players[instrument]!["time"] as! Date
+//                        let now = Date()
+//                        let seconds = now.timeIntervalSince(date)
+////                        print("Seconds: ",seconds)
+//                        
+//                        if seconds > TIME_DELAY {
+//                            self.players[instrument]!["time"] = now
+//                            self.players[instrument]!["index"] = ((self.players[instrument]!["index"] as! Int)+1)%3
+//                        }
+//                        
+//                        (self.players[instrument]!["players"] as! Array<AVAudioPlayer>)[self.players[instrument]!["index"] as! Int].play()
+//                    }
+//                    else {
+//                        print("Gesture not in use.", prediction)
+//                    }
+//                }
+//                else {
+//                    print("could not convert prediction to string")
+//                }
+//            }
+//            else {
+//                print("Could not convert to dict")
+//            }
+//            
+//        } else{
+//            print(error!)
+//        }
+//    }
+    
+    //OLD MACHINE LEARNING
+//    func getPredictionData(data:NSArray) {
+//        let baseUrl = "\(SERVER_URL)/PredictOne"
+//        let postUrl = NSURL(string: baseUrl)
+//        self.numDataPoints = self.numDataPoints + 1
+//        
+//        
+//        let jsonUpload:NSDictionary = ["feature": data, "dsid": DSID]
+//        
+//        let requestBody = try! JSONSerialization.data(withJSONObject: jsonUpload, options: JSONSerialization.WritingOptions.prettyPrinted)
+//        var request = URLRequest(url: postUrl as! URL)
+//        request.httpBody = requestBody
+//        request.httpMethod = "POST"
+//        
+//        
+//        let postTask = self.session.dataTask(with: request, completionHandler: postFeatureHandler)
+//        
+//        
+//        
+//        postTask.resume()
+////        print(self.numDataPoints)
+//    }
 
     func toggleRecording(sender: AnimatableButton) {
         print("touched")

            "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3", "Gesture 3"]



//        let labels = ["Gesture 1", "Gesture 2", "Gesture 3"]
//        let features = [[0.03490489,-0.02601342, 0.936972],[0.2710942, -2.89515, 1.256121],[-0.09389891, -3.128638, 1.631254]]


        
        if(mag > self.magValue) {
            print(mag)
            self.backQueue.addOperation({() -> Void in self.motionEventOccurred(mag:mag)})
        }
    }
    
