is there an easy way to program arduino to carry out 2 tasks simultaneously?

for example:i'm developing code to interface with a sensor over a SPI interface. data readings from the sensor are clocked into arduino at about 500 times per second.i want to smooth the data using some routine similar to the [LINE] object in max, so that i can output a stream of data from arduino at a higher rate (about 6000 samples/sec) to another device.just wondering if there's a way to run the data smoothing routine AND the sensor acquisition routine simultaneously, without having to intersperse bits of code...?

the 'samples' i want to export are just 12-odd-bit numerical data, representing either musical pitches or other control information (sorry about my lack of technical vocab...). if serial is fast enough, i'll use that just because it's easy. otherwise i'll use as many spare digital pins as possible to improvise some kind of parallel interface.

i need to provide a relatively smooth, rapid stream of data, as compared to the data i get from the sensor, which is slow(ish) and sounds jittery when i feed it to a tone generator. the data could also be sent to some kind of DAC for conversion to control voltages, or perhaps routed over a midi interface, or sent to any number of different gadgets.

so ideally, i'd like to have some kind of program structure that splits arduino's processing time between the tasks of communicating with the sensor, and sending out a smoothed data stream.

another option is perhaps some kind of external processor that takes the data direct from the sensor, or arduino, and does the smoothing automatically... but i've never heard of such a thing, or know what it might be called...

any ideas?

Daniel

so you want to interpolate between the numbers, or fill in the blanks so to speak. Your sensor data is not going to be 'slowish' if it is coming in at 500hz, whcih is far apst he threshold of perception... but from what you're saying, the data jumps around?

Since CK is not here yet I will take shot at the answer and say that you have lots of clock cycles left after getting the sensor data on SPi to be able to blast it out over the serial port between sense data-taking.