Simulating accelerando and ritardando by modifying the tempo of a melody with a noise value per a measure or phrase. 4 Conclusion and Future Work.
Generating and Modifying Melody Using Editable Noise Function Yong-Woo Jeon, In-Kwon Lee, and Jong-Chul Yoon Dept. of Computer Science, Yonsei University, Seoul, Korea {ywjeon, iklee, media19}@cs.yonsei.ac.kr http://visualcomputing.yonsei.ac.kr
Abstract. This paper introduces a way to generate or modify a melody using the editable noise function. The band-limited random numbers generated by the noise function are converted to the various property values of notes such as pitch and duration. Using this technique, we can modify an existing melody to produce new, similar melodies. The noise values can be edited, if necessary, while preserving the statistical characteristics of the noise function. By using this noise editing method, the noise function can generate a melody that satisfies given constraints.
1
Introduction
Composing music with mathematical concepts or formal processes has been studied since the early twentieth century. Many composers have produced works in this way. The stochastic music introduced by Xenakis [1, 2] and the use of pure randomness in composing and performing music by John Cage [3, 4] are typical examples of it. In this paper, we consider Perlin noise [5, 6] as another tool that gives accidental elements to music. Perlin noise, which has been used in many applications in computer graphics [6], is different from white noise (plain random numbers). It is a function that satisfies the conditions for the ideal noise function, which is bounded, band-limited, non-periodic, stationary, and isotropic [6]. Because of its properties, the Perlin noise function is also proper for giving controlled randomness to music. Music can be parameterized with many property values such as pitch, duration, etc. This paper explains how the noise function generates or modifies melodies by applying noise values to the parameters of the melodies. Although various probabilistic and algorithmic composition methods, such Markov chain and cellular automata [7, 8, 9] have been proposed, it is hard to implement intuitive composing and modifying processes that include randomness but are controllable and predictable. With the editing power of the noise function, we can give some user-defined constraints to the generated music, which permits users to control the composition process. For example, when we modify an existing melody, constraints can be given to prevent some notes from being R. Kronland-Martinet, T. Voinier, and S. Ystad (Eds.): CMMR 2005, LNCS 3902, pp. 164–168, 2006. c Springer-Verlag Berlin Heidelberg 2006
Generating and Modifying Melody Using Editable Noise Function
165
changed while other notes are changed by noise values. The noise editing method preserves the statistical characteristics of the noise function, which keeps the fair randomness of the output while satisfying the constraints defined by users.
2
Noise Function and Editing
Our method is based on Perlin’s gradient noise algorithm. The following outline explains how the noise generation algorithm operates when a 1D coordinate x is supplied as an input [5] (see Fig. 1(a) for an example of 1D noise). Step 1: Generate M PRNs (pseudorandom numbers) in [−1, 1] and store them in a table G[0 : M − 1] of size M . Prepare another table P [0 : M − 1] that holds a random permutation of the set of integers from 0 to M − 1. Step 2: Obtain the integer interval [q0 , q1 ], where q0 = x mod M , and q1 = (q0 + 1) mod M . Step 3: Obtain two PRNs gj = G[P [qj ]], j = 0, 1. Step 4: The noise value is computed by: Noise(x) = (1−s(d0 ))g0 d0 +s(d0 )g1 d1 , where dj = qj − x, j = 0, 1, and s(t) = 6t5 − 15t4 + 10t3 is an ease curve. Note that −1 ≤ Noise(x) ≤ 1. Taking sum of noise functions of various frequencies is more suitable in many applications. This kind of fractal sum [10] has been used for modeling more complex change in various frequencies. The general fractal sum of N noise functions having different frequencies fj and amplitudes aj is defined as Fsum(x) = N j=1 aj Noise (fj x), where aj ≥ aj+1 and fj ≤ fj+1 , for j = 1, . . . , N − 1. Fig. 1(b) shows an example of a fractal sum. Yoon et al. [10] introduced the noise editing method to generate a PRN table G satisfying a given user constraint: Noise(x∗ ) = H∗ which represents a user’s demand to fix a noise value at a specific position x∗ to a desirable value H∗ . To preserve the statistical characteristics of the noise function, they suggested an optimization-based method to minimize the Chi-square statistic of the edited random number distributions. The Chi-square statistic is used to test whether an unknown distribution is near a desirable distribution. In noise editing, the Chi-square statistic is minimized to make the new distribution as similar as possible to the uniform distribution (the pure random distribution). Thus, the minimization problem is stated as follows: Minimize D2 subject to Noise(x∗ ) = H∗ where D2 is a Chi-square statistic of the target distribution of the table G. Fig. 1(c) shows an example of the noise editing result using this method. We can see that the edited result preserves the statistical characteristics of the original noise function, keeping the function shape similar to the original function. However, a number of modifications of the noise function without considering the statistical characteristics make the resulting function totally different from the original one (see Fig. 1(d)). Refer to [10] for more details about noise editing.
166
Y.-W. Jeon, I.-K. Lee, and J.-C. Yoon
(a)
(b)
(c)
(d)
Fig. 1. (a) 1D noise function, (b) fractal sum, (c) a result after several editing operations of the original noise function in (a) (arrows denote the edited positions), (d) a modified function without considering the statistical characteristics of the noise function
3
Applying Noise to Melody
Noise values can be applied to various properties of melody notes such as pitch, duration, note-on time, volume, tempo, etc. Noise to Pitch. Pitch is one of the most important properties of a note, and a relatively small change is recognized easily. In this work, a pitch is quantified as a MIDI note number, and the noise function is applied to the pitch value to modify the pitches of an existing melody or generate a pitch sequence for a new melody. Noise values–Noise(t)s–can be added to the pitch values–Pitch(t)s–of the notes in an existing melody to generate a new melody, where t is the note-on time of the note: (1) Pitch (t) = Pitch(t) + s · Noise(t), where s is a scale factor. Or, we can use the ordered index n of each note as a 1D variable: Pitch (n) = Pitch(n) + s · Noise(n). (2) The resulting melody gives listeners feelings similar to the original melody, but it is not exactly the same as the original music. Fig. 2(b) shows a modified version of an original melody in Fig. 2(a). To make a note at t∗ have a specific pitch H∗ , a constraint Pitch (t∗ ) = H∗ is set, and the noise function is edited to satisfy the constraint. Fig. 2(c) is another version of a modified melody that has some constrained-pitch notes represented with the arrows. A completely new melody can be created by noise function. Given a skeleton note or set of notes, the noise values are added to create a unique melody line: Pitch (t) = Pitchskeleton (t) + s · Noise(t) or Pitch (t) = Pitchskeleton (t) + s · Fsum(t).
(3)
Fig. 3 shows an example of a melody line created by adding the fractal sum values to the middle C notes.
Generating and Modifying Melody Using Editable Noise Function
(a) E Ì (b) E Ì (c)
E Ì Ĺ
¡
¡
¡
¡ ¡
¡
¡ ¡
¡
D¡
¡ ¡
¡
D¡ D¡
D¡
¡ D¡ ¡ ¡ ¡ ¡ ¡ Ì ¡
¡
¡ D¡ ¡ D¡ ¡ ¡ ¡ ¡ Ì
¡
¡ D¡ ¡ ¡ ¡ ¡ D¡ D¡ Ì Ĺ
¡
¡
D¡
¡ ¡
¡
D¡ ¡
167
¡ Ì
D¡ ¡¡
Ì
¡ ¡ ¡ DÌ Ĺ
Fig. 2. Example of modifications of pitches in a melody: (a) original melody, (b) modified melody, and (c) modification with noise editing technique: one note (F) is constrained to be fixed as in the original melody, and the changes of two pitches (A and D) are explicitly given as the constraints
¡¡ ¶ S S E ¡ ¡¡D¡O¡ ¡ ¶ D¡O¡ D¡¡ ¡ ¶ ¡¡ ¶ ¡¡ D¡D¡ ¡ O¡ ¡ ¡ D ¡ ¡ ¡D¡ ¡ ¡¡ ¡ ¡ ¡¡ ¡ "E À D ¡ O¡¶ D ¡ ¶ ¡¶ ¶ ¡ ¡ ¡ ¶ ¶ D ¡D ¡ 4 4 ¡ O¡ ¡ ¡ ¡ ¡
¡ ¡ ¡¡¡
¡¡ ¡ ¡ ¡ ¡ ¡ D¡ ¡
Fig. 3. Example of generating melody: pitch sequence is generated by the fractal sum of noises: Pitch(t) = 72 + 12Noise(t) + 6Noise(4t) + 3Noise(16t)
Noise to Timing Information. Note-on times and durations are perturbed using noise function, too. For applying noise, duration and note-on time values are quantified as tick values of the MIDI protocol. In this case, the resulting notes may be out of their original measures and beats, which should be corrected in a postprocessing stage. The total length of the melody may also be changed, but because the noise function is unbiased and the mean value of the distribution is almost 0, the change is usually very little. Noise to Other Properties. Noise can be applied to many other properties of a note such as dynamic, tempo, etc., to produce other effects as follows: – Humanizing a melody by perturbing tempo and the dynamics of notes. – Simulating crescendo and decrescendo by modifying the dynamics of notes with a noise value per a measure or phrase. – Simulating accelerando and ritardando by modifying the tempo of a melody with a noise value per a measure or phrase.
4
Conclusion and Future Work
Noise function makes the modification of an existing melody easy and fast. The modified melody shares the basic form of the original melody, but the details are randomly different. The extreme changes that can be caused by white noise are not found in the modification because of the ideal band-limited feature of
168
Y.-W. Jeon, I.-K. Lee, and J.-C. Yoon
the noise function. By noise editing, it is possible to control the composition or modification process precisely to reflect a composer’s intent in the work. There are some limitations to this approach. When pitches are generated using the noise function, many atonal notes can occur, so that the original tonal melody loses its tonality. If note-on values are changed, beat feel is decreased, too. Applying noise is more suitable for atonal, non-beat, and avant-garde music based on probability and accidents than classical music structured by tonality and meters. That is, the noise method can be a tool for algorithmic composition with randomness and some constraints from a composer that should be satisfied. To produce more practical output, we need to postprocess the output to revise the atonal notes to be tonal using other musical rules. For example, we can slightly shift an atonal note up or down to the nearest tonal note. We are trying to find more properties or elements of music to which the noise value can be applied. For example, editing a fine tune or micro control of dynamics would generate natural effects such as vibrato, tremolo, and glissando. Timbres and spatial parameters can also be considered as targets of the research. Though we considered only 1D noise in this paper, the noise function can be extended in any higher dimension. It will be interesting to construct more complex musical structures in higher dimensions at which the noise function can be applied. Acknowledgement. This work was supported by the Ministry of Information & Communications, Korea, under the Information Technology Research Center (ITRC) Support Program.
References 1. Harley, J.: The Electroacoustic Music of Iannis Xenakis. Computer Music Journal 26:1 (2002) 33-57 2. Pape, G.: Iannis Xenakis and the “Real” of Musical Composition. Computer Music Journal 26:1 (2002) 16–21 3. Pritchett, J., Whittall, A.: The music of John Cage (Music in the Twentieth Century). Cambridge University Press (1996) 4. Kostka, S.: Materials and Techniques of Twentieth-Century Music. Prentice Hall (1999) 5. Perlin, K.: Improving noise. SIGGRAPH ’02 Proceedings (2002) 729–735 6. Ebert, D., Musgrave, F.K., Peachey D., Perlin, K., Worley, S., Mark, B., Hart, J.: Texture & Modeling: A Procedual Approach 3rd Edition. Morgan Kaufmann (2002) 7. McAlpine: Making music with algorithms. Computer Music Journal 23:2 (1999) 19–30 8. Millen, D.: An Interactive Cellular Automata Music Application in Cocoa. Proceedings of ICMC (2004) 9. Miranda, E.R.: Composing Music with computers. Focal Press (2001) 10. Yoon, J-. C., Lee., I-. K., Choi, J-.J.: Editing Noise. Journal of Computer Animation and Virtual Worlds 15:3 (2004) 277–287