Forums > MaxMSP

Is there a way to convert sampled data from an Arduino into MSP audio?

February 26, 2014 | 7:47 pm

Hi, I am using an Arduino to sample data (EMG data from surface electrodes to be precise).  I have successfully transferred the stream to Max using the serial object, and am able to display it using the multislider object.  However, I was wondering if I could convert it into an audio signal which will allow me to use all the MSP objects.  I tried using sig~ but that seems to only take the first sample from every stream that gets banged out of the serial object.  Does MaxMSP have the capability to convert a burst of serial packets into a uniformly sampled audio signal (essentially resampling a Max sequence of numbers into MSP audio)?  Thanks.


February 27, 2014 | 7:08 am

sure, you’l have to iterate through the list at the right rate.
Depending on your settings, there will be some jitter though.
Look at the [zl] family, I think of [zl lookup]+[counter] in particular.
then go with these numbers into [sig~] one by one


February 27, 2014 | 5:00 pm

Thanks, WOYTEG. I tried [zl queue] and banged out my serial data with a [metro] at my sample rate. You are right, there is some jitter, but it seems to have done the trick. I don’t seem to be able to reduce the sampling rate in MSP using the Audio Status menu (it’s 44.1 kHz and up), but this is much further than I was before your help. Thanks again.


March 3, 2014 | 7:48 pm

Hi Woyteg,

Sorry another add-on to my question. So I performed what I described above: I routed [serial] which bursts out 1 kHz samples into [zl queue] and banged out the queue every 1 ms using [metro]. The output of [zl queue] is routed to [sig~].

Here’s something I observed though, when I hooked up [sig~] to [capture~], I notice that values in capture change every 64 samples. This probably has to do with my Signal Vector Size set at 64. But my samples are coming in at 1 kHz, being resampled at 44.1 kHz by [sig~], so I should get a new value in [capture~] roughly every 44 samples, not 64. This is where I think it’s skipping some samples. Any thoughts on this?

Also, I was wondering if instead of repeating 64 (or hopefully 44) samples, there’s any way to interpolate between samples. I tried to use [line~] but that didn’t seem to work. The problem is repeating the samples ends up affecting the signal in the frequency domain, creating harmonic distortion.

If you have an ideas for a solution, I’d really appreciate it. I’ve literally been beating my head over this for hours.

Thanks,
Patrick


March 4, 2014 | 3:36 am

Hi,
Hard to say without seeing the patch. Try changing your vector size to make sure it has anything to do with it, as I’d doubt it.
Try interpolating using [slide~] or a custom lowpass.(filterdesign)


March 4, 2014 | 3:37 am

If you wish for a low sampling rate use poly~.


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