I just realized that I never published the setup used to recognize the movements in the project
home, so here it is.

As you can see we finally used Kmeans object with a distance calculation based on the closest value instead of the average values for one class. This works very well for different movement speeds. The setup is:

signal -> PCA -> Kmeans -> Turing -> Midi

play.rk

#!/usr/local/bin/rubyk

c=Cabox(port:"/dev/tty.usbserial-FTHOME2" bauds:115200 buffer:48)

c => cut
cut = Cut(from:1 to:-1 flat:1)
cut => pca
cut => tur
pca = PCA(vector:576 keep:20 data:"data/raw" processed:"data/after_pca")
pca => km

# ============= ENERGY =================
c => diff
diff = Diff(distance:10)
diff => abs
abs = Abs()
abs => sum
sum = Sum()
sum => sbuf
sbuf = Buffer(20)
sbuf => avg
avg = Average()
avg => ac
ac = Sum() # just to flatten to a value
ac => 3.tur

# # =========== km =====================
km = Kmeans(vector:20 distance:"Closest" data:"data/after_pca" threshold:0)
km => 4.tur
km.2 => 5.tur

tur = Turing(load:"play.tur")
tur => midi

c => print_buff
print_buff = Buffer(640)
print_buff => p
p = Plot(line:4 group:3)

# =========== MIDI ====================
midi = Midi(0)

pca.learn
km.learn

play.tur

You can download the turing machine definition:

txt document

9 Kb

play