Ensoniq Mirage Editor- Wavsyn

You hate programming the Mirage. Let’s fix that. I know there are really old Mirage software tools (20-30 years old!) so a modern version will be useful unless you are into vintage computers.

Just to wet your appetite, have a look at my initial work (call it a proof of concept) in Python for processing audio samples and making disks for the Ensoniq Mirage. That early work is now part of my software, Wavsyn, which add s a Mirage Program Editor.

The Plan

I need to make a regular desktop application, vice just some command line tools in Python in order to create a proper Ensoniq Mirage Editor. I also want it to be cross-platform. I decided to go with the Electron framework since I already know Javascript, HTML, CSS. I have done desktop development in Python and Java. Python is just not a good choice for a desktop app (poor tools and licensing restrictions). Java is easier to work with and JaxaFX is great for the UI layer, but app distribution and update support is lacking. Javascript has its warts, too, but Electron and ElectronForge provide many useful features the other options do not. I did a quick look at the modules available for NodeJS (the Javascript back-end for Electron apps) and saw it had some MIDI capabilities I needed, as well as all the other things you would expect for a first-class desktop programming environment.

My first development step was to learn Electron. I decided to create a reusable template for building apps and have published it for anyone to use and also wrote about it. My Electron template is available on Github https://github.com/mogrifier/electron-template See this Medium article for usage details.

Everything about Wavsyn is here:

https://github.com/mogrifier/wavsyn

I picked Visual Studio Code for development- very good tool. After getting my template running, I began the job of creating a UI for my Python proof of concept code and rewriting it in Javascript. The screenshot is below.

Wavsyn Audio Processor

This part of Wavsyn provides a simple way to perform useful batch audio processing on audio files so they can be used in the Mirage. You can load audio directly into a disk image file so you do not need to sample into the Mirage and you get much higher quality. You can also create floppy disk or HFE image files with it. I designed it to be simple to add new features as the need arises and it is open source so you can add your own!

Operating Systems

By the way, I am developing Wavsyn on Windows 10. I expect to get it running on Mac and Linux, but need to do some work making RTMidi and the Node MIDI module work on those environments. I also have to build the Mac and Linux versions on a Mac. I intend to support Debian (and hence, Ubuntu) Linux distros. This is another great place you could help if you are a developer.

Mirage SYSEX

The next step was learning how to work with MIDI System Exclusive (SYSEX) messages on the Mirage, since everything I need to do involves sending SYSEX commands. It turns out there are two different MIDI implementations, depending on which OS you boot the Mirage with. To run Wavsyn, you must boot the Mirage with the Mirage Advanced Sampling OS to get access to special features the application needs. Contact me if you need the MASOS disk/hfe files. Dealing with the Mirage MIDI implementation was the biggest challenge. those details are at the end of the blog.

Features

The Wavsyn Editor is just focused on program editing. Not global parameters or wavesamples. The intent is to let you load up programs from a sound (Ensoniq’s term for a group of patches associated with a set of wavesamples), and easily tweak and save them. I plan to add basic MIDI playback into the app as well, to simplify getting feedback on your edited program. I am also trying to make sure the editor will keep you from making mistakes and generally help you remember where you are (there is a log window). If it does get out of sync with the Mirage (like if you press some buttons on the Mirage), you just go to the View menu and click Reload. You may loose whatever edits were in the application, but it will get all back in sync with the Mirage once you load a sound and start editing again.

So How Does it Work?

Wasyvn Program Editor

The first think you do is click Configure MIDI. This will load the list of MIDI in and out ports into the drop down boxes. Select the ones your Mirage is connected to.

Next, click Load Sound. This will send commands to have the Mirage load from a floppy (or emulator) and send all the program data back to the editor. The parameters in the UI will load with data, and the ADSR graphs will be drawn.

Now you edit parameters by simply clicking the corresponding up and down arrows. The Mirage display will show the values changing.

The UI will keep track of which bank and sound you are editing, what program you are on, and if there are changes. The editor will also warn you if you have not saved changes or if trying to save them to a different location.

When done editing, choose a location and click Save Sound. The programs will all be saved to the sound location you choose. That’s it!

Installation- Warning: Alpha software

For the brave of heart, you can also download a release and try it out, just consider it alpha software (and documentation is lacking) and be sure you have backups of your Mirage disks. There is a bug or two and I am developing the app constantly so beyond a basic install, load, and simple edit, I wouldn’t try to much (especially around program changes).

Install is simple on windows, since I provide an *.exe file. I am an “unknown publisher,” so you have to give permission to install the app. [Just wait until TPM hits with Windows 11. That could make M$FT a lot of money in making people like me pay developer fees.] Let me know how it goes!

Of course, if you are a developer, you can pull the source and try to get it running on Mac or Linux. If you do, let me know.

Below are some programming details

The Dirty Bits

The MASOS Manual has byte offset tables into various blocks of data – wavesamples, segment lists, and sound program parameters. The data for the four programs for a sound is 625 bytes; however, it is stored on disk as 1250 bytes so requires some processing to get into a useful format in the editor. Page 100 of the manual describes the layout.

The data is stored at the beginning of the data for each sound. Tracks 2, 15, 28, 41, 54, 67 on the floppy are the start points of each sound. The parameters are stored in sector 0 of the track, which is a 1024 byte sector. All that really matters is where the Program 1-4 data is. Byte offsets 481, 517, 533 and 589 are where the data for programs 1-4 starts.

Mirage Program Data Analysis

Tracks are always 5,632 bytes. So track 2 starts at 11264. I opened a Mirage image file up in a resource editor to view the binary data. Below is the 36 byte dataset for a Mirage program. These bytes were read from a Mirage Disk Image and matched up to the Program Parameter Block description in the MASOS manual (page 102)- and it is a perfect match.

Below are the bytes in order and some sample hex values I read from a Mirage disk of mine for a program. The starting point (byte offset) for these in a Mirage disk image is the track number (for the sound) * 5632 + 481 (for program 1).

  • mono mode switch: 00
  • LFO Freq: 0E
  • LFO Depth: 00
  • Osc detune: 0B
  • Osc Mix: 88
  • Mix Velocity Sensitivity: 04
  • Filter cutoff freq: 7E
  • Resonance: 48
  • Filter Keyboard tracking: 01
  • Spare: 00
  • Initial Wavesample: 00
  • Mix Mode Switch: 00
  • Filter envelope (APDSR): 1B 1E 1F 11 1F
  • Filter envelope velocity sensitivity (APDSR) 00 00 00 00 00
  • Amplitude envelope (APDSR): 14 18 0F 14 0F
  • Amplitude envelope velocity sensitivity (APDSR): 00 2C 00 2C 00
  • 4 spare bytes: 00 00 00 00

The general config parameters for the Mirage global settings could also be programmed, but I have not found where there are stored yet. It is just 28 bytes. I could set them to a known pattern (like ascending values) and search the disk for the pattern, but a basic editor is my priority.

Not a lot of parameters to control in a program, but such a pain doing it on the Mirage! My UI started to take shape and the latest iteration is below. This is not a final color scheme or layout, but the functions I need are there and just about everything works at the time of this writing, but I still have more testing to do and to look into getting this running cross-platform.

What Not To Do

While this same exercise can be done for Wavesamples (only 24 bytes to define each), the manual says don’t do it. Other changes occur to data in the Mirage (the segment list), so changing the info externally would mess that up.

MIDI from NodeJS to the Mirage

There are many MIDI modules for node. I will be using node-midi and maybe easymidi (whiich is an abstraction on top of node-midi).

I ran into build errors with node-midi. There were supposed syntax errors in the v8.h file. They did not look like legitimate errors. I went digging around and down a rabbit hole for an hour. As a result, I installed the C++ compiler for Microsoft Visual Studio, thinking I would have to build rtmidi.

As you can see below, my system was trying to use Visual Studio 14 and VS2015. I had the “2015 Shell (Isolated)” installed?? This was causing trouble.

⠹ Preparing native dependencies: 0 / 1gyp info find Python using Python version 3.6.6 found at "C:\Users\eizde\AppData\Local\Programs\Python\Python36\python.exe"
⠏ Preparing native dependencies: 0 / 1gyp info find VS using VS2015 (14.0) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio 14.0"

After installing a C++ compiler into Visual Studio 2017 (which was also installed), I tried to run the app again. Apparently something updated internally so running gyp again (it is kicked off by “npm run start” until it successfully rebuilds node-midi) found the newer version of Visual Studio and the build worked!

⠸ Preparing native dependencies: 0 / 1gyp info find Python using Python version 3.6.6 found at "C:\Users\eizde\AppData\Local\Programs\Python\Python36\python.exe"
⠋ Preparing native dependencies: 0 / 1gyp info find VS using VS2017 (15.8.28010.2050) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community"

But MIDI functions in my code did NOT work 😦 After a lot of digging I found a key note in the manual of course.

This is the Mirage MIDI implementation available after booting from the MASOS disk.

Advanced Sampler’s Guide

Editors will ONLY work if you boot MASOS first. That is interesting. As soon as I did that I was able to execute a few SYSEX commands from MIDI-OX and they worked mostly as expected. Lots of quirks and oddities.

A Few SYSEX Tidbits

Program numbers are 1-4 in the Mirage display, but stored internally as 0-3. when sending a sysex command to change them, you specify 0-3, but what is returned depends on whether it is a lower or upper program. If an upper program, bit 5 is set so you can get hex 10 for upper 0, hex 11 for upper 1, an so on.

Setting a program is horrible. You can’t just set “upper 1”. You have to know what you are starting from. If in upper, then you CAN just send a 0-3, but if in lower, you have to SWITCH to upper first, just like when using the front panel.

Reading a parameter will give you the program (upper or lower). This is handy.

  • select the resonance parameter: F0 0F 01 01 0C 03 07 0D 7F F7
  • 0c means parameter number follows; 03 07 is 37. 0D means return the value.
  • returns F0 0F 01 0D 10 25 08 04 F7

Here is how to interpret the response string:

  1. 0D – returning a parameter value
  2. 10 – upper 1 program
  3. 25 – hex for program 37
  4. 08 04 is the value, but sent as nybbles and in reverse order (common Mirage trick). 04 is upper half byte, which means 64. 08 is just 8. 8 + 64 is 72, but resonance only goes to 40! That is, in the display. Internally it goes to 160, so you divide it by 4 to get the display value of 72/4 = 18.

You also cannot set a parameter value – you have to send SYSEX commands for how many up or down arrows to send. Computers are way too fast- you can’t just send a bunch in a loop because the Mirage can’t keep up and will miss a bunch of commands. My Editor UI ensures you can get one and only one up or down arrow per click on a parameter arrow button.

In order to read new config parameters using SYSEX from the Mirage after changing them they must be SAVED TO DISK. Bizarre. Save command is 14 then press ENTER.

Saving to Floppy with SYSEX: F0 0F 01 01 01 01 01 0A 7f F7 This string simulates a series of key presses (1, 1, 1, enter) to save the current sound/programs to lower bank 1.

Rabbit hole alert!! Read my issues log to see more details of how SYSEX works on Mirage.

Crazy MIDI Functions

You can use SYSEX commands to perform wavesample manipulations. Just send the right commands to the Mirage and it does them for you. Interesting.

Leave a comment