Week 4: Writing my first plugin!

Apr 02, 2021

From last week, I went over the basic thoughts I had on a new plugin I am going
to write. For this week, I have successfully created a new plugin,
CombineTracksWeighted, to the Weaver system. This post is going to cover the
algorithm, the implementation, and the result of the new plugin.

Algorithm overview

Different from the original CombineTrack, which calculates the average of all
the tracking, I use a weighted average to calculate the track: for all the
audio in one track, I will give the outlier, the one furtherest from the
average, a weight of 0.5 instead of one, and give the rest of the track the
same weight such that the sum of all the weights is one. Weighted track is
another option for combining the track.

Adding checkboxes

We need to add a checkbox to the plugin so that the user can decide whether to
use the weighted option or not by checking the check box. In order to create
one, we should not adding the code directly to the Weaver project. Instead, we
can use the ToolBox feature in my coding editor, Visual Studio, to add a
graphic checkbox to the plugin. The screenshot of ToolBox alongside the plugin
is shown below.





After that, we can select the checkbox we wrote and use “Property” by right
clicking on it and then change the display name and the name of the checkbox.

Adding Code

Now it is time for us to add the code. First we have to detect whether the
user has checked the checkbox by using ‘chkOutlier.Checked’, where the name
chkOutlier is the name of our checkbox. Then, we construct a one-dimension
array called trackSum to store all the sum of tracks in each track, and a
array called stdev to store the deviation of trackings in one track. Then, we
get the deviation by taking the absolute value of difference between tracks
and the average of the trackSum. Finally, we get the index of the outlier and
give it a weight of 0.5, while the other has a weight bigger than one. The
code is shown below.

else if (chkOutlier.Checked)
int num = track[0].Count – 2;
double [] stdev = new double[num + 2];
double [] trackSum = new double[track.Count];
for (int i = 0; i < track.Count; i++)
trackSum[i] = 0;
for (int j = 2; j < track[i].Count; j++)
trackSum[i] += track[i][j];
trackSum[i] /= num;
for(int i = 0; i < track.Count; i++)
double max = -1;
int max_index = 0;
for (int j = 2; j<track[i].Count; j++)
stdev[j] = Math.Abs(track[i][j] – trackSum[i]);
if(max < stdev[j])
max = stdev[j];
max_index = j;
double small_weight = 0.5;
double big_weight = (Convert.ToDouble(track.Count) – 0.5)*(track.Count – 1);
double sum = 0;
for (int j = 2; j < track[i].Count; j++)
if (j == max_index) sum += small_weight * track[i][j];
else sum += big_weight * track[i][j];
sum /= num;
track[i][1] = sum;


After compiling the code and running Weaver, we load the tiff image, three
Loadtrack Plugins to load the track produced by three different filters, and
our CombineTracksWeighted plugin. The following image is after running my


My plugin runs successfully! The audio produced is also different from the
ones before. Although we can hear the song in the audio, there are still much
noise, and I will further explore how to decrease them.

Next week

For next week, I am going to cover how I eliminate the ghosting light and more
on my development on plugins.

2 Replies to “Week 4: Writing my first plugin!”

  1. Peter L. says:

    Congrats on developing your first very own plugin! It seems that our projects are very similar, though with different approaches. I like how you are adding helpful things such as checkboxes to your UI, though I am curious as to what do you mean with the “average” and “outlier” of tracks. Does outlier mean the song that sounds the most different, has the most diverse frequencies/sounds, or something else? Looking forward to what you’ll do next! 🙂

  2. Eric M. says:

    Sounds like you’re making great developments! Pun intended

Leave a Reply