Data interpolation and audification
Hi!
I will begin with a brief explanation of my goal and then upload my patch. There are some threads about interpolation but only for audio files or Gen users (I believe I'm not) and non of them was helpful for me.
I am trying to import a data set in Max, which in the specific case is an Electromyography (EMG) recording, that is stored in a .txt file. Then I want to "listen" to it, so I thought as long as I play it back with the right sampling rate (2048 samples/sec) and just use a sig~ object I would be able to hear how the muscles sound. I have successfully done all that but I realized I listen to many clicks instead of a waveform.
I am relatively new to the "interpolation" term but I think that's what I need. My problem is that I couldn't find any interpolation algorithms for data sets (and not audio files) in order to do that. There is an interpolation example that uses gen~ but I can't edit any objects cause I haven't got this add-on. (correct me if there is a way and I can do that)
Is there anything equivalent for non-audio files. I've noticed there are many different ways of doing it when you're using a buffer~ etc. but I have stored the data set in a multislider.
Or maybe
Is there a way for storing the data set inside a buffer~? I have read the help file and it says only .aiff .wav files can be imported but I might be missing something as am new to Max.
Thanks!
Thomas
Hi,
for a non-audio interpolation object I may suggest you [sadam.interpol]
, an interpolation-extrapolation object that I developed as part of my library, see https://cycling74.com/forums/announce-the-sadam-library-version-2012-10-08 . However, in your particular case, this is not the root of your problems. The thing is, that you're reading your data file at control rate while you try to create a signal in signal-rate. So when you send a number to the [sig~]
object, what you actually do is that you change the signal each once a while (when the control messages actually reach the signal generator) and then the signal is kept constant between successive control messages.
What you should do instead would be to write your data into a [buffer~]
(see the [peek~]
object) and then simply play it back from the buffer itself.
Hope that helps,
Ádám
If I understand your post correctly, it sounds like what you're experiencing is basically the same as digital audio without a reconstruction filter. In other words, you need to low-pass filter your data at half the sample rate (1024 samples per second, in your case) to smooth out the discontinuities between successive samples. A simple low-pass averaging filter would probably be a decent place to start. I'd do this just before it hits the [sig~].
I'm with Ádám here; load it into buffer~ using peek~, THEN consider if you need to filter it.
this is the loading part (and basic playback, no interp ):
Hey,
Thanks everyone for your help! Problem is now solved. I was going to use the buffer~
object as Adam suggested but Terry's patch has already everything in it.
Regards,
Thomas