本文整理汇总了Java中jm.util.Play类的典型用法代码示例。如果您正苦于以下问题:Java Play类的具体用法?Java Play怎么用?Java Play使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Play类属于jm.util包,在下文中一共展示了Play类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import jm.util.Play; //导入依赖的package包/类
public void generate(String fileName, int barNumber, long seed) {
Random generator = new Random(seed);
Tonality tonality = learner_.getTonalityVector().getValue(generator);
Harmonic harmonic = new Harmonic(tonality, learner_.getMarkovDegree(), learner_.getEndingsVector());
ArrayList<ChordDegree> harmonicBase = harmonic.generateHarmonicBase(barNumber, generator, 10000);
System.out.println(harmonicBase);
int beatperbar = learner_.getBeatPerBarVector().getValue(generator);
double barUnit = learner_.getBarUnitVector().getValue(generator);
Rhythm rhythm = new Rhythm(harmonicBase, learner_.getRhythmMatrices_(), beatperbar * barUnit, generator);
ArrayList<GeneratedNote> melody = rhythm.generateRhythms();
MelodicGenerator melodicGenerator = new MelodicGenerator(new Random(seed), tonality, learner_.getMelodicLearner());
melodicGenerator.fillWithPitches(melody);
score_ = new Score();
Part part = new Part();
CPhrase chords = new CPhrase();
// Jmusic take int[] and not ArrayList<Integer> for the
for (GeneratedNote gn : melody) {
// Only in Java 8
int[] pitches = gn.getChordPitches().stream().mapToInt(i -> i).toArray();
for (int i = 0; i < pitches.length; ++i)
if (pitches[i] > 125)
pitches[i] = pitches[i] % 12 + 12 * 4;
chords.addChord(pitches, gn.getRhythm());
}
/*
CPhrase degrees = new CPhrase();
for (ChordDegree degree : harmonicBase) {
System.out.println(degree);
degrees.addChord(harmonic.getChord(degree,12),
(double) (beatperbar * barUnit) / (double)degree.getBarFractionDen());
}
*/
part.addCPhrase(chords);
score_.add(part);
Part acc = new Part();
//acc.addCPhrase(degrees);
score_.add(acc);
// Code to play the file
Play.midi(score_);
// Code to write the file
System.out.println("TOTO: " + fileName);
Write.midi(score_, fileName);
}
示例2: playBackMidi
import jm.util.Play; //导入依赖的package包/类
private void playBackMidi() {
Play.midi(score, false);
}
示例3: tiNaTinKano
import jm.util.Play; //导入依赖的package包/类
private static void tiNaTinKano() throws Exception {
Score score = new Score();
score.addPart(new Part(Instruments.PIANO));
Phrase phrase = new Phrase();
score.getPart(0).addPhrase(phrase);
int[] pitches = new int[] {C4, C4, C4, F4, GS4, A1, G4, F4, F4, DS4, DS4, A1, CS4, CS4, CS4, F4, GS4, BF4, GS4, GS4, G4, G4};
double[] lengths = new double[] {SIXTEENTH_NOTE, SIXTEENTH_NOTE, SIXTEENTH_NOTE, EIGHTH_NOTE, EIGHTH_NOTE,
SIXTEENTH_NOTE,
EIGHTH_NOTE, SIXTEENTH_NOTE, SIXTEENTH_NOTE, SIXTEENTH_NOTE, EIGHTH_NOTE,
SIXTEENTH_NOTE,
SIXTEENTH_NOTE, SIXTEENTH_NOTE, SIXTEENTH_NOTE, EIGHTH_NOTE, EIGHTH_NOTE, EIGHTH_NOTE, EIGHTH_NOTE, SIXTEENTH_NOTE, SIXTEENTH_NOTE, SIXTEENTH_NOTE};
// off-beat
phrase.addRest(new Rest(SIXTEENTH_NOTE));
int idx = 0;
for (Integer pitch : pitches) {
double length = SIXTEENTH_NOTE;
if (lengths.length > idx) {
length = lengths[idx];
}
if (pitch != A1) {
Note note = new Note(pitch, length);
phrase.add(note);
} else {
phrase.addRest(new Rest(length));
}
idx++;
}
score.getPart(0).getPhrase(0).addRest(new Rest(SIXTEENTH_NOTE));
score.getPart(0).addPhrase(new Phrase(phrase.getNoteArray()));
Part accompaniment = new Part(Instruments.PIANO);
//score.addPart(accompaniment);
Phrase accPhrase = new Phrase();
accompaniment.addPhrase(accPhrase);
accPhrase.addRest(new Rest(SIXTEENTH_NOTE));
accPhrase.addChord(new int[] {C4, F4, GS4}, WHOLE_NOTE - SIXTEENTH_NOTE);
accPhrase.addChord(new int[] {C4, F4, GS4}, WHOLE_NOTE);
Play.midi(score);
Write.midi(score, new FileOutputStream("c:/tmp/tinatin.mid"));
}