Categories
Electronic Work

Music With Moons

«Music With Moons» – screenshot (during second section)


Please use Google Chrome or Microsoft Edge when playing the piece—the JavaScript engine in Firefox is too slow while the other two browsers perform signigicantly better here. A sufficiently fast computer is recommended as well.

Music written in JavaScript

Music With Moons is an audiovisual composition that is intended to be staged in an internet browser such as Google Chrome or Microsoft Edge. Basically, it uses the same sound library as the Typophone that I have written previously in 2021-22. Similar to the Typophone Music With Moons makes use of a software sampler included in the JavaScript library Tone.js. Additionally I have recorded a few more sounds for this piece and some other new sounds have been created in SuperCollider. All in all the entire piece consists of prerecorded instrumental sound samples which are put together on the fly and in a most flexible way every time the piece starts. It was crucial for me that the piece stays unpredictable to a certain, yet well-defined extent.

musical form and randomness

Unpredictability of a composition might seem to be inconsistant with a clear musical form. However, this alleged contradition can be found extremely often in classical masterpieces. Albeit a concerto by Mozart will follow a well-known formal pattern—to a certain extent—an thus remains predictable, many key events will occur surprisingly at unforeseen moments. The balance between answering the listener’s expectations and not satisfying them is the traditional game a composer plays. This game involves a third and critical protagonist, the performer. When the performer is a computer, this play gets easily distortet and a fixed media composition becomes predictable when we have listened to it once or twice. I tried hard to find a compositional method that turns the computer into a real performer of my music. That means that every performance of the piece must differ from every other interpretation of the piece.

How do we turn a computer in a performer? What kind of interpretative decisions can a computer make? This is the point where randomness comes into play. When it gets down to taking random decisions, computers outmatch humans by far. We must determine a range of numbers or events from wich a computer chooses randomly, though. And of course we can consider the distribution of the probabilities for any event to happen. Take a simple array of numbers for instance: [1, 2, 3, 4, 5, 6] It is equally probable that the element 6 from this list is chosen by a random function as the element 1. If we add another element 6 to this array, thus [1, 2, 3, 4, 5, 6, 6], it is more likely that 6 is chosen than all the other elements. Here is the point where the artistic work starts—to distinguish between events that are more likely to happen from events that occur less likely only due to aesthetic reasons.

Sketch of the form of the piece (left side, dated 08/28/2022) and technical sketch of the moon shape that appears in the second section.

Let’s get back to the question of musical form. Music With Moons consists of four main parts. Each part is triggered, when several conditions are complied. There is a counter running in the background, for example, that increases every time a drawn line hits the margin of the screen. Another counter sums up the amount of spirals already drawn and even another one the overall amount of triangles. When a triangle is drawn or when one counter surpasses a certain value, a sound is triggered. In this way, the graphical events are linked closely to the sound events and vice versa.

I decided that in every performance, all prominent events should appear at least once. In the first part, some triangles, spirals, twirly lines and the abstract dancer is drawn (or whatever else it might be—the figures are not supposed to convey any kind of meaning at all) and at its end, a series of loud gong strikes will be heard. In the second part, the harmony will chance completely and a moon will occur as well as an eye on the left side of the screen. The third part will start with a white line sweeping the screen and after that, thin green lines will flow down from the top. It will climax in a thick and loud metallic 2-1-rhythm. In the final section the screen will turn dark and an owl will pick the moon symbol from my work Mondviolen up from the bottom of the screen. Meanwhile, tree-like structures will emerge from the black background.

harmony

Working with a sampler allowed me to realise any desired intonation or (de)tuning. I defined several scales as a basic material in order to establish a great harmonic contrast between the structures whenever there was a need for such a distinction. One scale consists of an octave being devided into 10 equal parts, another scale of an octave devided into 16 equal parts, for a third scale an octave is devided into 24 quartertones. The most interesting scale is a fourth scale in which a fifth is devided into four equal parts. This scale is featured prominently at the beginning of the second part when the pale moon symbol arises on the right side of the screen.

Sketch of the eye that appears in the second section where all the control points of the BĂ©zier curves are marked.

Other than that, I occasionally implemented more traditional structures such as chords that approximate the natural harmonic series as can be heard in the opening sequence. Harmony relies mainly on redundancy. Redundancy again is something that can be established easily by distributing the probabilities for events to occur. Let’s get back to our trivial array from before. Instead of numbers, let’s take pitches this time. If we have a comuputer choose a melody of 30 notes randomly from this array, it will sound pellmell:

pitchArray1 = [C, C#, D, D#, E, F, F#, G, G#, A, A#, B]
resultingMelody = A-D#-C#-C#-G#-E-F#-D#-E-A#-G#-B-C#-C-F-G-C-A#-E-B-A#-F-G#-B-G-E-E-B-D#-D

However, if we alter it and make it look like this array, it will play a melody that strongly suggests the feeling of C-major to the listener:

pitchArray 2 = [C, C, C, C, C, C, C, C, C, C, C#, D, D, D#, E, E, E, E, F, F, F#, G, G, G, G, G, G#, A, A, A#, B, B]
resultingMelody = C-C-G-A-G-E-D#-B-F#-G-G-E-A-C-F-C-E-C-C-C-G-F-G-F-F-E-A-C-C-E-A-C

Source Code:

<!DOCTYPE html>
<html>
<body>

<p>Result pitchArray1</br/>
<span id="result1"></span></p>
<p>Result pitchArray2</br/>
<span id="result2"></span></p>
<script>

let pitchArray1 = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'];
let len1 = pitchArray1.length;
let melody1 = 'resultingMelody = ';
for (let i = 0; i < len1; i++) {
	melody1 += pitchArray1[Math.floor(Math.random() * len1)];
	if (i < (len1 - 1)) {
		melody1 += '-';
	}
}

let pitchArray2 = ['C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C#', 'D', 'D', 'D#', 'E', 'E', 'E', 'E', 'F', 'F', 'F#', 'G', 'G', 'G', 'G', 'G', 'G#', 'A', 'A', 'A#', 'B', 'B'];
let len2 = pitchArray2.length;
let melody2 = 'resultingMelody = ';
for (let i = 0; i < len2; i++) {
	melody2 += pitchArray2[Math.floor(Math.random() * len2)];
	if (i < (len2 - 1)) {
		melody2 += '-';
	}
}

document.getElementById('result1').innerHTML = melody1;
document.getElementById('result2').innerHTML = melody2;

</script>

</body>
</html>
up next

After more than five months of work on this particular software I’d like to call it finished for now. Nonetheless some problems concerning the source code are left over. Of course no software, however important, can ever considered ‹complete› as long as it is being used. My programme—that is to say my composition or whatever else you would like to consider it (an animation?, a movie?)—is finished rather in an artistic way than in a technical one. As for the latter, I have not yet found a good solution for the PanVol object (which is responsible for the panorama as well as for the levels of the samples as its name suggests). I believe my software architecture is somewhat less than perfect to pull it charitably. Moreover all the samples should be recorded again in a very professional way. This should ideally be done in a studio and it would take a lot of time and it would cost a lot, too. As for now, I have focussed entirely on the artistic work, so let’s consider it an experimental composition. I hope, you’ll like it, though.

INSTRUMENTATION:
computer

DURATION:
approx. 7 minutes

PERFORMANCE MATERIAL:
https://chrenhart.eu/lib/moons/musicwithmoons.html

PREMIERE:
January 6, 2023 • Internet

Categories
Miscellaneous News

Typophone

The Typophone is an electronic instrument that runs in a web browser.

A JavaScript-based sampler with adjustable panning functions

From summer 2021 onwards I have been experiementing around with JavaScript in order to create a software which can be uses as an electronic part (as an electronic instrument) of new compositions – ready to run in your standard browser.

What to do with it

Let’s get down to the most important question: What can be done with this software and given that it is an instrument, how does it sound? There is a very best answer for it: Find it out!

The Typophone is basically a sampler writting in JavaScript using the Tone.js library. Additionally it provides the user some panning functions and a random mode. Moreover all keyboard events are being displayed – they can be made visible during a performance using a video beamer.

It might seem strange at first sight that such a software is written in JavaScript as most software that is used for sound synthesis and live electronics is usually written in a programming language optimised for sound synthesis (such as SuperCollider or Max MSP or Pd whereas JavaScript clearly is not), however, using JavaScript provides us a crucial advantage in my opinion that clocks off SuperCollider or Max. It’s running in your internet browser and everyone has got one.

Run it in your browser

Why is it crucial that such a software should be browser-based? There is a stunningly simple answer: Musicians can use it for practising. One of the major problems when it gets down to including live electronics into compositions is the fact that usually the setup is rather complicated and requires a spcialist capable of getting a Max/SC/Pd-program or similar to run. We cannot expect from a normal musician to have the technical expertise of handling and setting up a complex audio-environment and doing all the (admittingly quite exciting) spatialization stuff. However, as a composer I do expect my musicians to practise extensivly on a new piece. Thus, if a new piece has an electronic part, the musicians must have a viable way of practising with it. Hence I decided that a browser-based software would be most suitable.

Another fundamental decision was implementing stereophony. We might consider monophony an option as well–natural instruments and some electronic instruments such as electric guitars act as monophonic sound sources too–however, I did not want to take a pass on the excitement of having interesting panning effects. Moreover, every computer comes along with a stereo output, so I decided to make use of its scope. Neither quadrophony was an option for that very purpose (computers having usually only a stereo jack as a standard audio output) nor 5.1 surround sound.

Onstage

The Typophone is designed for two main application fields: It should work well and without installing anything complicated at home in your rehearsal room and onstage. While it can be assumed that everyone is connected to the internet at home (and thus you can comfortably use the typophone by just visiting a website) we can not be sure if in a concert hall WLAN or an ethernet connection is always or easily available. In short, the Typophone has to work offline too. Now, before running it offline we need to know a little bit about how interenet works. Usually we are navigating through the WWW in a web browser. If we enter a web address (an URL) in our browser it will try to start communicating with a server which hosts the page we want to see or the file we would like to download. To make a long story short, browsers rely on the client (browser) and server (a computer somewhere in the world that has the material we want) principle. The Typophone works according to this principle. All sounds are provided by a server and whenever the client asks for such a file, the server will deliver it. Now, what happens, if we just download all the files and doubleclick on player.html while we are offline? The site will open, and the browser will try to retrieve all sound files from the server, however there is no server available unless we run one on our own machine and tell our browser, where it is. So that’s exactly what we’ll have to do, if we’d like to use the Typophone onstage or offline. Sounds a little difficult, right? But don’t get discouraged, its quite easy to run a server. I have made a short tutorial that explains what to do in ten steps:

Using it in my works

Thus far I have written two solo-pieces that involve the Typophone as an electronic part, Drei Illustrationen von Pflanzen for mezzosoprano being the first and Chameleon for one percussionist the other of the two compositions. In the work for mezzo-soprano and Typophone the text is being conveyd to the audience in several ways: Some parts are sung, some fragments are typed and projected to the wall while all the letters produce a distinctive or random sound at the same time and naturally the music itself reacts to the texts emotionally too. Using the Typophone in my compositions thus allows me to deal with any text quite contrapuntally. I instantly liked making use of it in my new works. Furthermore I have been looking for a way to make the process of a player creating a sound on an electronic device visible to the audience in a very straightforward way for a long time. I believe that I have now accomplished this end.

Up next

For now, the Typophone needs to prove successful in concert. I’m still not sure if my notation is already ideal. I decided to use quite a rudimentary kind of tablature, that seemed most logically. The program has got 10 modes, the pitches of the modes 1 to 9 are fixed and could be notated as normal notes, however mode 0 means random sounds. If I notated the actual pitches, it were necessary to have a tablature only for mode 0. That did not convince me. Using tablature would also be more flexible for future implementations like other tunings, other samples (maybe more noisy ones). At this juncture I have recorded a lot of bell-like sounds such as bowls or a gong. Naturally a software can be extended in so many ways that a notation for this instrument must remain extremely flexible or rudimentary. I will definitely continue noodling around with different tuning systems or detunings (seen technically this can be implemented very easily). So stay tuned and enjoy playing the Typophone (the current version is 1.4).

Categories
Miscellaneous News

Harmonic Series Calculator

Christoph Renhart's Harmonic Series Calculator
Getting an arbitrarily large amount of partials of a freely chosen fundamental is now just one click away.

How to get countably many partials of any tone you like in a very quick way

This program is dedicated to all friends of spectral music as well as composers and music theorists who have spent hours of their precious time writing down harmonic series of a given fundamental, calculate all the partials meticulously using a pocket calculator and comparing two or more overtone series on a piece of sheet music. Here’s the good news: There’s no need to make things more complicated than they should be. Let’s get all the numeracy done by using the computer. Remember the meaning of the word «computer»—computing things belongs to its core skills. And it keeps computing things flawlessly.

What can be done with this program? Suppose we would like to get the first 32 partials of the tone E2. Select E as tempered fundamental and 2 from the list of octaves (remember: C1 is the lowest C on the piano). Next click on Calculate and find the results below. In the table of results you will see the exact frequecy of each partial as well as its pitch (e.g. the 7th partial of a tone with a fundamental frequency of 32.703 Hz (C1) is 228.921 Hz which is A#3 minus 31 Cents).

Naturally all the frequencies depend significantly on the standard pitch. So we might want to compare the 17th partial on A2 using 440 Hz as a concert pitch with the 17th partial of A2 using 443 Hz as standard pitch. This can also done easily with the program. Let’s do the 440 Hz first:

  1. Enter 440 Hz as standard pitch
  2. Select A as tempered fundamental
  3. Select 2 as octave
  4. Click Calculate

Next, let’s run the program again with a different standard pitch:

  1. Enter 443 Hz as standard pitch
  2. Select A as tempered fundamental
  3. Select 2 as octave
  4. Click Calculate

Finally, compare the two results:

Fundamental A2 — 440 Hz standard pitch:

1110.000A2 plus 0 Cents
2220.000A3 plus 0 Cents
3330.000E4 plus 2 Cents
4440.000A4 plus 0 Cents
5550.000C#5 minus 14 Cents
6660.000E5 plus 2 Cents
7770.000G5 minus 31 Cents
8880.000A5 plus 0 Cents
9990.000B5 plus 4 Cents
101100.000C#6 minus 14 Cents
111210.000D#6 minus 49 Cents
121320.000E6 plus 2 Cents
131430.000F6 plus 41 Cents
141540.000G6 minus 31 Cents
151650.000G#6 minus 12 Cents
161760.000A6 plus 0 Cents
171870.000A#6 plus 5 Cents
Fundamental: A2 — results for 440 Hz as standard pitch

Fundamental A2 — 443 Hz standard pitch:

1110.750A2 plus 0 Cents
2221.500A3 plus 0 Cents
3332.250E4 plus 2 Cents
4443.000A4 plus 0 Cents
5553.750C#5 minus 14 Cents
6664.500E5 plus 2 Cents
7775.250G5 minus 31 Cents
8886.000A5 plus 0 Cents
9996.750B5 plus 4 Cents
101107.500C#6 minus 14 Cents
111218.250D#6 minus 49 Cents
121329.000E6 plus 2 Cents
131439.750F6 plus 41 Cents
141550.500G6 minus 31 Cents
151661.250G#6 minus 12 Cents
161772.000A6 plus 0 Cents
171882.750A#6 plus 5 Cents
Fundamental: A2 — results for 443 Hz as standard pitch

As you can see, the frequencies differ from each other. With 440 Hz as concert pitch the 17th partial of A2 is 1870 Hz (A#6 + 5 Ct.), whereas using a concert pitch of 443 Hz the 17th partial of A2 is 1882.75 Hz (also A#6 + 5 Ct. of course).

Moreover, you can also choose a non-tempered fundamental frequency in relation to any concert pitch you like. Let’s say, for instance, our concert pitch is 443 Hz and our fundamental is 60 Hz. As the fundamental is (possibly) not equal to a tempered tone, we select Other from the list of pitches and also Other from the list of octaves (it was somehow difficult to find an appropriate name for the input field and perhaps I’m gonna rename it as Other is admittingly not ideal here). Finally enter 60 in the field Fundamental / Grundfrequenz. Choose any amount of partials and click Calculate. Let’s have a look at the first 32 partials:

NumberFrequencyTone
160.000A#1 plus 39 Cents
2120.000A#2 plus 39 Cents
3180.000F3 plus 41 Cents
4240.000A#3 plus 39 Cents
5300.000D4 plus 25 Cents
6360.000F4 plus 41 Cents
7420.000G#4 plus 8 Cents
8480.000A#4 plus 39 Cents
9540.000C5 plus 43 Cents
10600.000D5 plus 25 Cents
11660.000E5 minus 10 Cents
12720.000F5 plus 41 Cents
13780.000G5 minus 21 Cents
14840.000G#5 plus 8 Cents
15900.000A5 plus 27 Cents
16960.000A#5 plus 39 Cents
171020.000B5 plus 44 Cents
181080.000C6 plus 43 Cents
191140.000C#6 plus 36 Cents
201200.000D6 plus 25 Cents
211260.000D#6 plus 10 Cents
221320.000E6 minus 10 Cents
231380.000F6 minus 33 Cents
241440.000F6 plus 41 Cents
251500.000F#6 plus 12 Cents
261560.000G6 minus 21 Cents
271620.000G6 plus 45 Cents
281680.000G#6 plus 8 Cents
291740.000A6 minus 32 Cents
301800.000A6 plus 27 Cents
311860.000A#6 minus 16 Cents
321920.000A#6 plus 39 Cents
Fundamental: 60 Hz — results for 443 Hz as standard pitch

That’s it. Try it out and feel free to use it whenever you need to work with harmonic series.

Link to the calculator:
https://chrenhart.eu/lib/ttgen/ttgen.html

Special thanks to Daniel Mayer for checking the results with a SuperCollider patch and for some great advise to make the program’s interface more user-friendly!