# Smoothening EMG signals from Myo armband

**URL:** https://discourse.processing.org/t/smoothening-emg-signals-from-myo-armband/2479
**Category:** Coding Questions
**Created:** [August 8, 2018, 12:20pm UTC](https://discourse.processing.org/t/smoothening-emg-signals-from-myo-armband/2479 "2018-08-08T12:20:57Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![palashsomani](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@palashsomani](https://discourse.processing.org/u/palashsomani)
#### Post date: [August 8, 2018, 12:20pm UTC](https://discourse.processing.org/t/smoothening-emg-signals-from-myo-armband/2479/1 "2018-08-08T12:20:57Z")

</div>

Hello everyone! I am doing a project using Myo armband with Processing. Using the myo-for-processing library, the signal data processing receives for the device is raw and hence very jittery. I need to smoothen that signal data for better output. Can anyone help regarding this?

---

<div class="post-metadata">

### Author: ![MxFxM](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@MxFxM](https://discourse.processing.org/u/MxFxM)
#### Post date: [August 8, 2018, 12:55pm UTC](https://discourse.processing.org/t/smoothening-emg-signals-from-myo-armband/2479/2 "2018-08-08T12:55:18Z")

</div>

Collect multiple values and then get the medain. Alternatively or additionally you can make it so the code doesn’t jump to the next value but increases / decreases the variable until the value is the same.

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [August 8, 2018, 2:20pm UTC](https://discourse.processing.org/t/smoothening-emg-signals-from-myo-armband/2479/3 "2018-08-08T14:20:33Z")

</div>

Usually you can implement a smoothing algorithm to work in your myo data. I believe there is a library that also remove noise. You can install it through the Contribution manager in the PDE and see if you can make it to work. Notice this library is not built for myo but it is more of a general library. You still need to create some code to use it for your purpose.

Just out of curiosity, what myo arm version are you using?

Kf

---

<div class="post-metadata">

### Author: ![palashsomani](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@palashsomani](https://discourse.processing.org/u/palashsomani)
#### Post date: [August 8, 2018, 7:55pm UTC](https://discourse.processing.org/t/smoothening-emg-signals-from-myo-armband/2479/4 "2018-08-08T19:55:05Z")

</div>

Can you help me out a bit here?

import de.voidplus.myo.\*;

Myo myo;  
ArrayList\<ArrayList\> sensors;

void setup() {  
size(800, 400);  
background(255);  
noFill();  
stroke(0);  
// …  
myo = new Myo(this, true); // true, with EMG data  
sensors = new ArrayList\<ArrayList\>();  
for (int i=0; i\<8; i++) {  
sensors.add(new ArrayList());  
}  
}

void draw() {  
background(255);  
// …

// Drawing:  
synchronized (this) {  
for (int i=0; i\<8; i++) {  
if (!sensors.get(i).isEmpty()) {  
beginShape();  
for (int j=0; j\<sensors.get(i).size(); j++) {  
vertex(j, sensors.get(i).get(j)+(i\*50));  
}  
endShape();  
}  
// println(sensors.get(i));  
}  
}  
}

// ----------------------------------------------------------

void myoOnEmgData(Device myo, long timestamp, int [] data) {

// Data:  
synchronized (this) {  
for (int i = 0; i\< data.length; i++) {  
sensors.get(i).add((int) map(data[i], -128, 127, 0, 50)); // [-128 - 127]  
}  
while (sensors.get(0).size() \> width) {  
for(ArrayList sensor : sensors) {  
sensor.remove(0);  
}  
}  
}  
println(“data [0]”, " = ", data[0]);  
//println(“data [1]”, " = ", data[1]);  
// println(“data [6]”, " = ", data[6]);  
//println(“data [7]”, " = ", data[7]);  
}

Here, int [] data is the signal data I am receiving every millisecond from 8 EMG sensors. How do I retrieve the values from it ? Sorry to bother you, I am not really proficient in processing. 😛

---

<div class="post-metadata">

### Author: ![palashsomani](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@palashsomani](https://discourse.processing.org/u/palashsomani)
#### Post date: [August 8, 2018, 7:59pm UTC](https://discourse.processing.org/t/smoothening-emg-signals-from-myo-armband/2479/5 "2018-08-08T19:59:31Z")

</div>

Hi,

I tried using the signal filter library but for some reason, it’s just crashing my sketch. Do you know of any other library that would help me do the job? Also, I am using this Myo : [https://www.youtube.com/watch?v=1u5-G6DPtkk](https://www.youtube.com/watch?v=1u5-G6DPtkk)

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [August 8, 2018, 8:15pm UTC](https://discourse.processing.org/t/smoothening-emg-signals-from-myo-armband/2479/6 "2018-08-08T20:15:24Z")

</div>

### _Please format your code_ 😊

It consist on these two steps:

1. In your code editor (PDE, VS code, Eclipse, etc) ensure you execute the beautifier function. This function automatically indents your code. Auto-indenting makes your code easier to read and helps catching bugs due to mismatch parenthesis, for instance. In the PDE, you use the key combination: `ctrl+t`
2. You copy and paste your code in the forum. Then you select the code and you hit the formatting button aka. the button with this symbol: `</>`

That’s it! Please notice you do not create a new post in case you need to format something you already posted. You can edit your post, copy the code to the PDE, indent the code properly there and then past it back here, format the code and \>\> **save** \<\< the edits.

## Extra info:

Formatting your code makes everybody’s life easier, your code looks much better plus it ensures your code integrity is not affected by the forum’s formatting (Do you know the forum processes markup code?) Please visit the sticky posts or the FAQ section/post to learn about this, other advantages and super powers you can get in this brand new forum.

Kf

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [August 8, 2018, 8:34pm UTC](https://discourse.processing.org/t/smoothening-emg-signals-from-myo-armband/2479/7 "2018-08-08T20:34:53Z")

</div>

Check these links:

> [Smoothing - Wikipedia](https://en.wikipedia.org/wiki/Smoothing)  
> [http://195.134.76.37/applets/AppletSmooth/Appl\_Smooth2.html](http://195.134.76.37/applets/AppletSmooth/Appl_Smooth2.html)  
> [Intro. to Signal Processing:Smoothing](https://terpconnect.umd.edu/~toh/spectrum/Smoothing.html)

You can implement a moving average as it is one of the simple ones.

> [@palashsomani](#):
>
> I tried using the signal filter library but for some reason, it’s just crashing my sketch

Do you mind showing your attempt?

Kf

---

<div class="post-metadata">

### Author: ![MxFxM](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@MxFxM](https://discourse.processing.org/u/MxFxM)
#### Post date: [August 10, 2018, 11:02am UTC](https://discourse.processing.org/t/smoothening-emg-signals-from-myo-armband/2479/8 "2018-08-10T11:02:18Z")

</div>

Not really to answer your question but related to the topic:  
Does anybody know how that band works?  
Does it pick up electric signals of the nerves and if so what voltage levels can be expected here and how does it pick those up? Wires?  
Or is it a capacitive sensor? Or pressure? Or acceleration and gyro?

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [August 10, 2018, 9:22pm UTC](https://discourse.processing.org/t/smoothening-emg-signals-from-myo-armband/2479/9 "2018-08-10T21:22:29Z")

</div>

@MxFxM Check section V in this pdf: [https://zapdf.com/recognition-of-human-arm-gestures-using-myo-armband-for-the.html](https://zapdf.com/recognition-of-human-arm-gestures-using-myo-armband-for-the.html)

Kf

---

<div class="post-metadata">

### Author: ![MxFxM](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@MxFxM](https://discourse.processing.org/u/MxFxM)
#### Post date: [August 13, 2018, 2:15pm UTC](https://discourse.processing.org/t/smoothening-emg-signals-from-myo-armband/2479/10 "2018-08-13T14:15:01Z")

</div>

@kfrajer wow that’s an interesing read. Thank you!
