Automate tasks with Neon!

Starting with the next release, Electric-sun, we will add the possibility to automate tasks with scripting support!

Some history behind automating with Helium

In earlier versions of Helium we used a concept called Actions which could be used to run one or more specific jobs in a batch with a specific selection of files.

An Action was an operation without user-interface or interaction. For example you could change a specific tag field, delete a specific tag type or calculate AcoustId.

Actions were a great and widely used tool, although a bit too limited since it was not possible to add any logic to how the Actions were executed or to ignore a specific Action based on a condition.

Therefore we are now exposing a scripting engine which let you do almost anything by executing a script on a specific selection of files.

The core engine

You can write scripts with any text editor of your choice, we recommend an editor such as Notepad++ or Visual Studio Code which comes with color coding and intellisense support.

Scripts are written against the .NET framework in the C# language and when executed they are pre-compiled and will give you feedback of the script compiled successfully or not. If it was a successfull compilation it will be executed.

The anatomy of a script

A script needs to follow a specific structure to be able to be executed from Neon.

In short, a namespace needs to be set, a constant name for the entry point (class) needs to be set and last a static method signature needs to be written.

Does it sounds complex? It is not:

using System;
using NeonScripting; 
using System.Threading.Tasks;
using System.Collections;
using System.IO;
using System.Text;
using System.Linq;

namespace Neon
    public class Script
        public bool Run(INeonScriptHost host)
            // The actual code will be placed here

In the above code there are some important parts marked in bold:

  1. Using directives, System and NeonScripting must be referred
  2. The namespace must be set to Neon
  3. The class name must be Script
  4. The Run method is the entry point and must be defined as a bool method. If true is returned the script executed OK, otherwise not.

When the above skeleton is set, you are ready to do some scripting.

In general you can do everything that you can with C# and the .NET language, plus invoking Neon specific functions. These specific calls can be accessed via the host.RemoteCalls member.

So, what can it be used for?

Above we mentioned the “old” system with Actions and its limitations. With a script you can easily do the same but control it in more powerful ways. Below follows some examples:

foreach(var track in host.Tracks)
    if (track.Bpm <= 0)
        track.Bpm = host.RemoteCalls.CalculateBpm(track.fullFilename);
        track.IgnoreChanges = true;

In this example, we iterate over the selected tracks, check if the track contains a value for Bpm or not. If not, the Bpm will be calculated and set. Finally all changes will be commited (saved) to tags and the database.

Several different RemoteCalls are exposed from Neon allowing you to easily perform tagging, getting track-, album- and artist information, calculating bpm, renaming files (database will of course also be updated), executing the rename template engine and much more.

There are also several help functions available as remote calls which will allow you to select a specific output folder, output filename, execute confirmation dialogs and update progress.

We will include some sample scripts with the release that shows how scripting can be used in various ways, ranging from simple tag operations like switching field contents to renaming operations and more complex list generating functions.

Since the .NET framework is used a lot of functions will already be available to just use!

We can write a whole novel about all nice things and details that will be possible with scripting, but we would like to leave the creativity to you – the users.

We are eager to see what you will come up with using this new scripting support!



2 thoughts on “Automate tasks with Neon!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s