 
     }
     
-    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")

            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.")

    var ringBuffer = RingBuffer()
    var orientationBuffer = RingBuffer()
    let magValue = 1.5
    let maxMagValue = 6.0
    
    var numDataPoints = 0
    var recording = false

