One of the problems with JMusic is that it doesn't support microtonal MIDI. That limits the range of available "Instruments" to waveforms described in code. I wrote one called OddHarmonicInst, but the other 3 are straight from JMusic libraries.
The range of MIDI instruments available is virtually limitless, but without microtonal support I can't do the Bohlen-Pierce scale as MIDI. I should write a test program that outputs the scale using each JMusic Instrument class so that I can compare them. Actually, I should have done that first, but I had this phasing idea that wouldn't wait...
Code: Select all
static BPScale scale;
// the notes of two otonal chords CGA and GBE are the only ones used
private static String notenames[] = {
"C1", "E1", "G1", "A2", "B2",
"C2", "E2", "G2", "A3", "B3", // C2 could be the bottom note for melodies
"C3", "E3", "G3", "A4", "B4", // A4 could be the top note for melodies
"C4", "E4", "G4", "A5", "B5"
};
/*********************************************************************************
* creates 4 similar melody files in "/Users/quasar/Music/Bohlen-Pierce/CoGo Phase
*/
static void writeCoGoPhase()
{
Instrument instruments[] = {
new SineInst(44100),
new SquareLPFInst(44100),
new OddHarmonicInst(44100),
new VibesInst(44100)
};
String instnames[] = { "Sine", "Square", "Odd", "Vibes"};
createMelodies();
// phase melody project
for (int i=0; i<4; i++) {
Score score = new Score();
score.setTempo(93.428571);
Part part = createMelodyPart(instnames[i]);
score.add(part);
Write.au(score,"/Users/quasar/Music/Bohlen-Pierce/CoGo Phase/" + instnames[i] + ".au", instruments[i]);
}
}
// 9-note melodies as note names
static String[][] melodies = new String[5][10];
static void createMelodies()
{
for (int i=0; i<5; ++i)
for (int j=0; j<9; ++j)
{
melodies[i][j] = notenames[randint(9) + 5]; // C2 to A4
}
}
static Part createMelodyPart(String name)
{
Part part = new Part(name);
//create the phrase note by note
for(int i=0; i<4; i++) // the 4 melodies
{
Phrase phrase = new Phrase(109.0 * (double)i); // each 9 note melody will repeat 12 times
phrase.add(new Rest(0.5));
for (int n=0; n<12; n++)
{
for (int j=0; j<9; ++j)
{
int dynamic = randint(32) + 64;
double time = 1.0; // quarter note
// randomize timing a wee bit
time += (Math.random() < 0.5 ? -0.00625 : 0.00625);
time += (Math.random() < 0.5 ? -0.00625 : 0.00625);
Note note = new Note(
scale.getFreq(melodies[i][j]),
time,
dynamic);
phrase.add(note);
}
}
phrase.add(new Rest(0.5));
// System.out.println(phrase.toString());
part.addPhrase(phrase);
}
return part;
}
The actual phasing was done with tempo changes of half of the melodies in Audacity.