Calculating the energy of a signal
Avoid recomputations

You compute the energy accumulated in a sliding window. When a window slides by 1, one sample shifts out, and one sample shifts in. The accumulated energy changes by s[n]^2 - s[n-40]^2. Therefore the inner loop is superficial. This alone will give you a 40-fold improvement.
Quadratic complexity

mysignal is only getting more signals appended to it, that is its initial parts are fed to functioneg over and over again, mostly producing the same result. In fact you only need 40 last of the processed samples to ramp up the new file.
Avoid reallocations

You don't really need the o1 array. sum1 can be computed on the fly.