Project Overview
The aim of this project was to compose an original Gamelan piece that could be performed in the Supercollider programme. For this composition, there was an intent to maintain elements of traditional Javanese music such as rhythm, pitch selection and structure, and contrast this with less traditional elements including harmony and rhythmic variations. You can listen to the recording of its original performance here:
The majority of the sounds used were created within the Supercollider programme itself. This was achieved by recording each pitch of the main instruments from the University of York’s Gamelan Sekar Petak and analysing the data to determine frequencies, ring times and relative loudness. The information was then put into Supercollider to create virtual instruments.
From these virtual instruments, sequences of pitches and rests were created in the programme as dictated by the composition (including their durations). By combining these sequences, the composition was realised in its most simplistic form.
In order to make a more realistic sounding performance, small elements of randomisation within Supercollider were attached to aspects such as pitch, appropriate reverberation was added, and stereo imaging was also implemented to reflect the layout of the Gamelan.
Additional instruments such as the Kendhang (drum) and Rebab (string instrument) were composed outside of the programme and recorded in multi-track via live midi performance using pre-made virtual instruments. The resulting track was then loaded into a buffer within supercollider and called upon to play in conjunction with the code containing the Gamelan composition.
Composition
The original composition for this project follows many Javanese traditions. These include pitch selection, rhythm, structure, instrumentation & function of instruments. Due to the choice of using the Pélog tuning system, there were seven pitches available. Though only five (possibly six) of these pitches are usually used within a given composition, a different variation was used for each individual section of the work. This was to explore the differences between using the third and fourth pitch. The piece is ABA form with an introduction (Buka), and the first and second A sections are repeated. Pitches 1,2,3,5,6,7 are used for the more traditional A section, and 1,2,4,5,6 for the more contemporary B section.
The instruments of the Gamelan can be categorized into groups with specific functions. Some of these functions are Balungan (core melody) which is made up of the Saron, Demung, Slenthem and Peking; punctuation (time-marking and phrase-marking for example) which is a role often performed by the Gong/Kempul, Kenong, Kethuk/Kempyang and Kendhang; and melodic decoration which is often played by the Gendér and Bonang. The Bonang usually also plays the Buka. The Virtual Gamelan piece adheres to these groupings but does not include the Gendér or Kempul.
Rhythmically, the Peking follows a very basic traditional style of playing twice the speed of the Balungan melody and doubling the notes played to achieve this. The Kendhang also follows a traditional Lancaran style, following the standard patterns for tempo changes.
While not following any of the traditional Javanese Gamelan structures strictly, the piece shares similarities with the Ketawang, Landrang and Lancaran structures. The following shows the basic structure of each gongan (space between gong strikes) in the Virtual Gamelan piece:
pTpW pTpN pTpN pTpG
p = Kempyang T = Kethuk W = Wela (rest) N = Kenong G = Gong
The composition features changes in tempo that are essential to Gamelan music. In the full performance, the piece slows down towards the B section and speeds up in the final section, building towards a final slowing of the tempo and the characteristic sound of the slightly delayed final gong. The remaining Gamelan instruments play their final note after the gong has been struck for the final time.
In the B section, there are contrasting, less traditional elements. These include harmonies, choice of pitch, rhythmic elements and instrumentation. This is largely represented by the introduction of the Rebab; a two stringed melodic instrument. Although a traditional Gamelan instrument, here it is used in a more contemporary way. The pitches for this instrument in the Virtual Gamelan piece are actually the closest Western equivalents to the Pélog system rather than the Pélog pitches themselves. As such, this creates unusual harmonies. Intricate non-traditional rhythmic and melodic variations also occur within the Rebab part.
Process of Synth Creation
In order to call the required sounds in Supercollider, SynthDefs were created for each pitch of each instrument. This was necessary due to the complexities of the sounds being replicated and meant that 54 SynthDefs were required. The first task regarding the creation of the SynthDefs was to record all of the pitches of every instrument within the Gamelan ensemble. In order to synthesise these sounds, it was necessary to carry out spectral analysis on the recordings. This made it possible to determine the numerous frequencies that could be heard in each pitch of each instrument, as well as their ring times and relative loudness. To accomplish this, I used the Sonic Visualiser software. While the frequencies were quite precise, the ring times and relative loudness were approximated from the visuals and fined tuned aurally.
To create the sounds within Supercollider, I used the Klank and dynKlank classes. These allow the user to input multiple frequencies, their ring times and relative loudness as well as the exciter used (such as Impulse or WhiteNoise). The following is an example from the code for the Slenthem SynthDef (Pélog pitch 1):
SynthDef(\sl1, {arg out=0, freqDev= 1;
var sig, sig1, sig2;
sig1 = DynKlank.ar(`[[140, 394.7, 628.7, 736.5, 1557.4, 1857, 2638.6]*freqDev, [13, 9, 8, 5,5, 2, 2], [4, 1.5, 4, 3, 2, 2, 2]], Impulse.ar(0,0,0.1))*EnvGen.kr(Env.linen(7, 0.5, 0.8, 1), doneAction: 2);
sig2 = DynKlank.ar(`[[140, 394.7, 628.7, 736.5, 1557.4]*freqDev, [13, 10, 10, 5,5, 2, 2], [4, 1.5, 6, 4.5, 2, 2, 2]], Impulse.ar(0,0,0.1))*EnvGen.kr(Env.adsr(1, 0.5, 0.8, 1));
sig = (sig1*0.4) + (sig2*0.4);
Out.ar(out, Pan2.ar(sig, 0.1));
}).add;
Using EnvGen within the signals, it was possible to create SynthDefs that had more realistic characteristics. The attacks, decays and releases could be determined by aural comparison. By combining two signals and using two EnvGens with different data, there is an ability to fine tune the envelope. This was necessary as there is often an initial attack when the mallet makes contact with the metallophone, and then a subsequent, somewhat more gradual rise in dynamics thereafter (this is especially true of the gong).
Detailed stereo imaging was possible by using the two channel equal power panner (Pan2). This allows for small changes of stereo position by using the pos argument where -1 is left and +1 is right.
Inputting the Composition into Supercollider
With the SynthDefs created, the next task was the input of the composition. This was to be achieved by calling the relevant rests and pitches for each instrument via its individual SynthDef, and defining their durations. Pseq was used to create the sequences of each instrument within Supercollider. In order to add very minor frequency deviations and durations, Pbind was used. This also allowed for repeats of sections and the combination of sections of singular instrumental sequences into one event stream. To allow multiple instrumental sequences to be performed together, Ppar was used as this allows multiple event streams to be performed simultaneously.
In addition to the coded aspect of the composition, the Rebab and Kendhang parts were recorded individually via live midi performance alongside the Supercollider performance. The sounds used were from East West’s RA library. The two tracks were combined and bounced into one file that could then be loaded into a buffer within Supercollider:
p = Buffer.read(s, “…/Drum and Rebab.wav”)
{ PlayBuf.ar(2, p.bufnum, 1,1, 0, 0)*5 }.play;
This file could now be played in conjunction with the Gamelan metallophone SynthDefs.
To make the piece more realistic, appropriate reverberation was added to replicate the acoustics of a traditional performance environment via the FreeVerb class. This allows the user to input values for basic aspects of reverberation such the room size and dry/wet balance. Pdefs and Ndefs were used to implement the reverberation. The Pdef allows the user to reference a stream and the Ndef allows for effects such as reverberation to be attached to this:
Pdef(\piece1, Ppar([a,b,c,d,e,f,g,h]) );
Ndef(\pattern1, Pdef(\piece1) );
Ndef(\reverb, { FreeVerb.ar( Ndef.ar(\pattern1), 0.5, 0.55, 0.5) * 0.8});
Ndef(\reverb).play;
Final Thoughts
This project successfully achieved its aims in that the metallophone sounds were created entirely within Supercollider and an original Gamelan piece was composed and performed through Supercollider at the University of York’s Rymer Auditorium in 2017. That said, there are a few areas that could be developed. This includes further development of the SynthDefs and potentially a more interactive performance. This could allow for more natural movement in the piece and make further use of the capabilities of the Supercollider programme.
If you’d like to use my work or improve on it, I’d love to see how you get on, so please get in touch by using the comment section below or the contact page.
I hope this post has provided a valuable insight into the process of music composition through code. Please feel free to share your thoughts or projects below, and if you want to learn more about Supercollider or Gamelan music, the following reading list is useful.
Further Reading
Pickvance, Richard. A Gamelan Manual: A Player’s Guide to the Central Javanese Gamelan. Richard Pickvance/Jaman Mas Books, 2006.
Sorrell, Neil. A Guide to the Gamelan. New York: Society for Asian Music, 2000.
Lindsay, Jennifer. Javanese Gamelan: Traditional Orchestra of Indonesia. Singapore: Oxford University Press, 1992.
Online Resources
FreeVerb. Accessed April 10, 2017. http://doc.sccode.org/Classes/FreeVerb.html.
Pattern Guide 03: What Is Pbind. Accessed April 10, 2017. http://doc.sccode.org/Tutorials/A-Practical-Guide/PG_03_What_Is_Pbind.html.
Ppar Embed Event Streams in Parallel – SuperCollider 3.2 Help Files. Accessed April 18, 2017. http://danielnouri.org/docs/SuperColliderHelp/Streams-Patterns-Events/Ppar.html.
Pan2. Accessed April 10, 2017. http://doc.sccode.org/Classes/Pan2.html.
16. Sequencing with Patterns. Accessed April 10, 2017. http://doc.sccode.org/Tutorials/Getting-Started/16-Sequencing-with-Patterns.html.
SynthDef. Accessed April 10, 2017. http://doc.sccode.org/Classes/SynthDef.html.
Klank. Accessed April 10, 2017. http://doc.sccode.org/Classes/Klank.html.