JavaScript Examples

Welcome to the Developer Tools JavaScript Examples.

These examples show you how to use JavaScript ES5 and the Wildword Soundworks interface to generate music and control your device. The first three examples include a brief overview of music theory and programming.

Click on the link in the table to open the example.

LinkConcepts
Chromatic Scale
Sound, Frequency, Pitch, Octave
Notes and Chromatic Scale
MIDI Notes, Note-On and Note-Off
JavaScript Programming and Events
Timing, Beats per Minute and Sleep
Diatonic Scale
Diatonic Scale and the 7 Note Names
Sharps and Flats
Minor and Major Scales and Modes
Terminology
Playing Scales
Chords
Sound, Frequency and Ratios
Structural Harmonies
Thirds, Fifths and Chords
Naming Sharps and Flats
Application to MIDI
Chord Visualizer
Custom Views
Drawing Primitives
Colors
Device Properties
Header, Client Area and Footer
Chord Types
Note Names
Events

Developer Tools

To run the examples, you need start the Developer Tools on your device. Use the Network menu on your device and select Connect to WIFI. After you're connected, select Start Web Server.

Following the initial connection, the device remembers the access point, and it will prompt to reconnect so that you don't have to select the access point and enter a password again. Alternatively, if you want to start WIFI every time you start your device, you can select the Configure on Startup menu item. Or if you want to reconnect manually, you can press your device's WIFI quick connect button.

The URL for the Developer Tools is of the form http://w.x.y.z/tools.html where w.x.y.z is the Current Address displayed in the Network menu. For example, if the Current Address is 192.168.1.202, navigate to http://192.168.1.202/tools.html in the browser. Be sure to use http (not https). If you can’t connect, click the address bar in the browser and make sure the browser didn’t change the protocol to https. If it did, change it back.

See Developer Tools Quick Start Guide for more information.

JavaScript ES5

The Developer Tools provide support for JavaScript ES5. This version of JavaScript is ideally suited for the limited hardware capabilities of small devices. It achieves this by not providing language features such as arrow functions, async promises, the let / const / class keywords and template literals.

Some may wonder why the devices don't use MicroPython or Lua or some other scripting language. The reality is that the language doesn't really matter that much. The core features of all these languages are very similar and the main purpose is to control the underlying device, which is easy given any modern scripting language.

Running an Example

Click on the link for the example in the table above. A new page opens with an overview and JavaScript. Take a look at the overview and scroll down to the JavaScript. Press the Copy button to copy the example to the clipboard.

Back in the Developer Tools, navigate to a folder on the device (e.g. local) and create a new folder for your examples using the New Folder menu item. Then click on the new folder to make it the current folder. Click on the New File menu item and paste the clipboard into the editor pane on the top right.

Press Save As to save the example to the current folder.

Press the Run button to run the example. If you want, you can press the Interrupt button to stop the example before it finishes.

Future Directions

More examples will be added as time permits. If you would like information on programming a specific function please Contact Wildwood Soundworks.