Forums > MaxMSP

Data interpolation and audification

February 19, 2013 | 11:33 pm

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

– Pasted Max Patch, click to expand. –
Attachments:
  1. 32Ch29156.txt

February 20, 2013 | 12:41 am

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 http://cycling74.com/forums/topic.php?id=42930 . 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


February 20, 2013 | 12:53 am

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~].


February 20, 2013 | 8:41 am

I’m with Ádám here; load it into buffer~ using peek~, THEN consider if you need to filter it.


February 20, 2013 | 11:03 am

this is the loading part (and basic playback, no interp ):

– Pasted Max Patch, click to expand. –

February 20, 2013 | 6:42 pm

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


Viewing 6 posts - 1 through 6 (of 6 total)