|
|
Original |
Transposition |
|
|
|
Mod.transpose(Note note, final int transposition, final int[] mode, int key)
Where
@param note Note to be transposed @param transposition the amount to transpose in semitones @param mode the scale to use for the transposition (the JMC has some scale constants) @param key the chromatic note to be used as the root of the mode. i.e., 0 = C, 1 = C# etc.
Let's have a closer look at the code that produced the above scores.
import jm.JMC;
import jm.music.data.*;
import jm.music.tools.Mod;
import jm.util.*;
public class TransposeDiatonicTest implements JMC {;
public static void main(String[] args) {;
Phrase original = new Phrase(0.0);
for(int i=0;i<10;i++) {
Note n = new Note((int)(Math.random() * 12) + 60, 0.25);
original.addNote(n);
}
View.notate(original);
Phrase trans = original.copy();
Mod.transpose(trans, 4, MAJOR_SCALE, C4);
View.notate(trans, 10, 300);
}
}
|
It is important to copy the phrase before transposing it if you want both the original and transposed version for your music. If you simply assign a new phrase to the old one, as in Phrase trans = original, then when you transpose trans the original will also be transposed (Java references objects by default - duplicating jmusic objects is done by copying them).
|
|
|
|
|
© 2001 Andrew Brown |
|
|