Hey guys,
So i'm making a poi that makes sound as you swing it around. For those who don't know, a poi is pretty much just a weight on the end of a short tether, that is spun around the hand in various motions. In a nutshell what I have Is a teensy with a speaker on the end of a short rope.

My problem is that I have the poi making sound and reacting to motion really well, but if I leave it turned on for more than a minute or two, the sound reactivity gets really laggy. This becoming worse the longer I leave it turned on.
If you run my code on your own teensy you can see this by rotating and shaking the teensy, and hearing the sound react smoothly, then come back a few minutes later and the sound will no longer react smoothly and will be jumpy and laggy.

My hardware setup is at its core this:

18650 LiPo -> Sparkfun powercell -> Teensy with Prop shield -> Speakers

I also have a few pushbuttons connected and an external usb port connected to the teensy and the Powercell for charging and programming

Here is my code:
Note that my actual code is way larger than this, but this is the smallest version of what I have that still replicates the lagging effect.

#include <NXPMotionSense.h>
#include <EEPROM.h>

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioSynthWaveform       waveform1;      //xy=242,270
AudioMixer4              mixer1;         //xy=456,258
AudioOutputAnalog        dac1;           //xy=662,263
AudioConnection          patchCord1(waveform1, 0, mixer1, 0);
AudioConnection          patchCord2(mixer1, dac1);
// GUItool: end automatically generated code

NXPMotionSense imu;
NXPSensorFusion filter;

void setup() {
  // Initialize IMU and filter

  // Turn on amp
  dac1.analogReference(EXTERNAL); // much louder!
  delay(50);             // time for DAC voltage stable
  pinMode(5, OUTPUT);
  digitalWrite(5, HIGH); // turn on the amplifier
  delay(10);             // allow time to wake up

  //set waveform parameters


void loop() {
  float ax, ay, az;
  float gx, gy, gz;
  float mx, my, mz;

  // Read motion sensors and filter the results
  imu.readMotionSensor(ax, ay, az, gx, gy, gz, mx, my, mz);
  filter.update(gx, gy, gz, ax, ay, az, mx, my, mz);

  //accel and gyro values added up to one value using pythagoreas
  float acc = sqrt(ax * ax + ay * ay + az * az);
  float gyro = sqrt(gx * gx + gy * gy + gz * gz);

  //accel and gyro added together to get overall motion of device
  //this number ranges from 0 at freefall to around 5000 at full motion
  //the reason for this is i want the teensy to be silent when not moving, and also silent when in freefall
  float both = acc * gyro;

  //motion based volume
  //view the floatmap function below to understand how this works
  mixer1.gain(0, floatMap(both, 100, 5000, 0, 1));


//used for scaling max and min sensor values to synth values
//I think this might be causing the lag but not sure
//also I dont know how to scale values any other way

float floatMap(float x,
               float inMin,
               float inMax,
               float outMin,
               float outMax) {

  // Set bounds
  if ( x < inMin ) x = inMin;
  if ( x > inMax ) x = inMax;

  return (x - inMin) * (outMax - outMin) /
         (inMax - inMin) + outMin;
I'm suspecting it might have something to do with the floatmap function but I don't know for sure. It's the only thing that Isn't straight from the audio or NXp library as I got it from some random example on the internet.

Any help would be greatly appreciated.