QuasiMusic screen shot

QuasiMusic turns quasiperiodic tilings of the plane into something like a MIDI version of a player-piano roll. This was inspired by a suggestion made by Akira Bergman in a discussion with John Baez.

John Baez has created some wonderful ambient music that uses the output of this program as a starting point; his tracks are available here.

Applet vs desktop

If you have a browser and a version of Java that supports applets, just load one of the demos and hit the PLAY button, or read on to learn how to make your own music. Be warned, though, that the applet version does not let you save your work to disk.

But Java support in browsers is increasingly uncommon, and if the applet doesn’t appear above, you will need to download the desktop version, by right-clicking on this link to QuasiMusic.jar. To run the application, you can place the file QuasiMusic.jar in whatever directory you like. It might run directly from the desktop if you double-click its icon (this will depend on your particular operating system), but if that doesn’t work go to your system’s command line console, make the directory in which you put QuasiMusic.jar your current directory, and type:

java -jar QuasiMusic.jar

The Java MIDI system can be a bit erratic at times. It will occasionally fall silent for no reason, or sustain notes endlessly. If this applet goes either mute or berserk, the only surefire cure is to quit it and restart. You can sometimes fix the problem by starting and stopping PLAY a few times, but that doesn’t always work.

Also, support for instruments above the first 128 standard General MIDI instruments appears to be very erratic. If any of these extra instruments are available, their names are shown in coloured text: green for bank 1, red for bank 2, and blue for banks 3 or higher. [A “bank” is a numbered collection of up to 128 instruments, with bank 0 referring to the standard set that every synthesiser is supposed to implement.] As of mid-2012, my own experience using a Mac and the soundbank file that comes with the standard Java 6 installation is that none of the bank 2 instruments make any sound at all, and the bank 3 instruments, though given various exotic titles, really just repeat the bank 0 instruments! So all I can suggest is that you try things out and see what works for your own setup, but don’t be surprised if whole banks are silent or make sounds that have no connection with their titles.

How the tiling is used to cue music

Imagine a series of up to 16 vertical lines running down the tiling panel. Each time one of these lines crosses into a new tile, it triggers the sound associated with that tile (which can be chosen differently for each of the vertical lines, or “channels”). When you play a tiling, the little white rectangles that appear (which are meant to be reminiscent of the holes in a player-piano roll) mark these cues.

When you choose an n-dimensional lattice, there are different tiles for every pair of dimensions, for a total of n(n–1)/2. For example, for the 7-dimensional lattice that we call Z7 there are 7 × 6 / 2 = 21 different tiles. Some of these will have the same shape as each other, but they are still distinguished by their orientation. (You can read more about the geometry of the lattices and tilings in these notes on the deBruijn applet.) For each channel, sounds can be associated with as few or as many of the tiles as you like.

Play, Rewind, Randomise, Solo

PLAY always resumes playing from the current point in the tiling visible on screen. REWIND will take you back to a notional starting point in the tiling. The RANDOMISE button gives you a new geometry for the whole tiling each time you hit it, but if you hold down the SHIFT key, SHIFT-RANDOMISE will step back through the same sequence of possibilities.

If the SOLO option is checked, only the current channel is played.

How the demos work

When you hit one of the LOAD DEMO buttons, sounds are associated with all the tiles of the current lattice, for a set of channels that differs from demo to demo (some use just one channel, some use all sixteen). The demos use a particular, fixed instrument for each channel, and then associate various notes with the tiles. (It’s not necessary to work that way, though — it’s possible to use a variety of instruments on each channel if you wish.)

If you change the lattice to a higher-dimensional one after loading a demo, you will see that some tiles turn white. That’s because new pairs of dimensions have appeared for which no notes have been assigned. You can still play the tiling; it will simply have a sparser set of cues.

You can also make the lattice larger or smaller, with the LATTICE SIZE gadget. A larger lattice will play at a slower tempo, because the cues will be farther apart.

Making your own tile notes

Starting from either a blank slate or a demo, you can choose your own sounds to associate with the tiles.

First, use the CHANNEL gadget to pick a channel to work on. While the tiling isn’t playing, all tiles without a sound associated with them for this particular channel appear white. When the tiling is playing, it doesn’t matter what the current channel is: each tile that has a sound associated with it on any of the channels will be drawn in colour.

To hear the sound associated with a coloured tile, just click it. It will brighten while it’s playing.

To associate a new sound with a tile, SHIFT-click it. It will turn yellow. Then choose an instrument from the instruments list, and play something by clicking a key (or a sequence of keys) on the piano keyboard. You can also control various attributes of the notes you play with the sliders below the piano. When you’re finished, SHIFT-click the tile again, and it will change to its usual colour. You can then hear the sound you’ve stored for this tile/channel combination by clicking on it. There’s no need to rush to play the first note after SHIFT-clicking a tile: any silence until you play the first note is cut out. But if you play one note, wait five seconds, and then play another, that timing will be reproduced when the tile is triggered.

If you like, you can tell the applet that you’re finished defining the sound for a tile by SHIFT-clicking on a different tile that you want to work on next, saving you the step of explicitly closing the previous tile.

To remove the sound associated with a tile, just SHIFT-click it twice in succession: that is, open it, play nothing, then close it again.

(NB: MIDI uses channel 10 differently from the other channels. Instead of different keys giving different pitches, they make different percussive sounds. These sounds depend only on the “note” you choose, and the selected “instrument” is ignored.)

Playing chords

What if you want to play a chord rather than a single note, when you’re associating a sound with a tile? The way to do this is to make use of the CHORD KEYS to the right of the piano. Before choosing a tile, you can SHIFT-click one of the chord keys – it will turn yellow, to show that it’s currently selected – and then strike a succession of ordinary keys on the piano to add them to the chord. Hitting any piano key a second time removes it from the chord. When you’re done, SHIFT-click the chord key again, and then any ordinary clicks on that key will play the chord you’ve defined.

Note that once you’ve used a chord key to give a sound to a tile, if you later redefine that chord it won’t change the sound of the tile; the individual notes for the chord at the time it’s played are stored for the tile.

Importing MIDI into a tile

You can use the IMPORT MIDI button to give a sound to a tile, after SHIFT-clicking the tile to select it. The applet will show you a list of the music found in the MIDI file; you can choose to import the sound from just one of the file’s channels, or all of them. This is likely to work best with fairly short pieces.

Clearing

Hit the CLEAR THIS CHANNEL button to erase all the notes associated with the current channel, or the CLEAR ALL button to clear them all.

Copy and paste

Hitting the COPY CHANNEL NOTES button will place in the clipboard a copy of all the notes assigned to the tiles for the currently selected channel. If you then select a different channel and hit the PASTE CHANNEL NOTES button, the newly selected channel will now have all those notes.

Impose an instrument

To force all the notes for the current channel to be played on a particular instrument, select that instrument from the list and then hit the IMPOSE INSTRUMENT button.

One easy way to make new tile notes is to start with one of the demos, and then use this to change the instruments. You can also extend the channels in a demo using copy and paste, or prune away unwanted channels with clear.

Loading and saving tile notes

If you’re using the application version of QuasiMusic, you can save all the associations between tiles and notes in a file, which you can later reload and play or edit further. Click the SAVE AS button to choose the file to save in; the SAVE button will store your tile notes again in the same file.

Recording MIDI files

If you’re using the application version, hitting the RECORD MIDI button works much like the PLAY button, except that everything played is accumulated, and when you stop you can save the whole “performance” to a MIDI file. Note that when you play back this file with another program, it might not sound identical to the instruments you heard from the applet; that will depend on the particular MIDI system you’re using to play the file. QuasiMusic itself can play back its own MIDI files, so that will guarantee that you hear them with the original Java soundbank instruments.

If the SOLO option is checked, only the current channel is recorded.

Acknowledgement

Parts of this applet are adapted from the MidiSynth.java module of the JavaSound demo, by Brian Lichtenwalter. The licence is reproduced below, as required by the terms of reuse of the code. The original demo can be downloaded from the Java web site.

/*
 * @(#)MidiSynth.java	1.15	99/12/03
 *
 * Copyright (c) 1999 Sun Microsystems, Inc. All Rights Reserved.
 *
 * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
 * modify and redistribute this software in source and binary code form,
 * provided that i) this copyright notice and license appear on all copies of
 * the software; and ii) Licensee does not utilize the software in a manner
 * which is disparaging to Sun.
 *
 * This software is provided "AS IS," without a warranty of any kind. ALL
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
 * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
 * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
 * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
 * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
 * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
 * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES.
 *
 * This software is not designed or intended for use in on-line control of
 * aircraft, air traffic, aircraft navigation or aircraft communications; or in
 * the design, construction, operation or maintenance of any nuclear
 * facility. Licensee represents and warrants that it will not use or
 * redistribute the Software for such purposes.
 */


Almost valid HTML Valid CSS
Applets Gallery / QuasiMusic / created Sunday, 24 June 2012 / revised Wednesday, 27 June 2012
If you link to this page, please use this URL: https://www.gregegan.net/APPLETS/34/34.html
Copyright © Greg Egan, 2012. All rights reserved.