The weighted average: very elegant! Another hurdle taken...
to do: Put analogValues into the temp_record_array.
Bottlenecks:
I don't know how to stop the recording "for" loop.
I need to know how to determine the number of bytes in the temp_record_array.
I get held up by syntax errors again and again (an again...
) , so no practical solutions from me at this time. I greatly appreciate your contributions.
Draw_Waveform: press "record", draw a waveform from analogIn, press "end record". Depending on how fast you draw you get a different number of samples each recording. Put these in a temporary array, count the number of samples. Now devide this number by x, to get 32 (roughly).
How's that done by the way?
Here's how: (number of bytes drawn)/32 = x
Now this returns an integer x , but discards the remainder.
Next take evey x'th sample from the temporary array, put them in the 32 byte waveform array, ....
An example: we recorded 647 bytes in the temporary array. Devide by 32: x= 20. Remainder is 7 bytes.
Take every 20'th sample from our 647-byte array indeed yields 32 bytes to put in the wavetable to be generated. But again discards 7 bytes, witch may result in a badly looped single waveform. Worst case scenario is 31 bytes being discarded.
May be acceptable , especially as I expect some smoothing to be desirable anyway, either to compensate fore these unwanted artifacts, or as a filter effect.
I havn't figured out yet if it's possible to completely discard a chosen entry from an array.
If so, maybe we could use Modulo. Then (number of bytes drawn) % 32 = (remainder).
Next, devide (number of bytes drawn) by (remainder). Taking the above example: 647/7 = 92.
Now select every 92th byte and completely erase them. If then we select every x'th byte we end up with a waveform array that more accurately follows our drawing gesture.