当前位置: 首页 > 工具软件 > JFugue > 使用案例 >

Atitit jfugue midi make tour attilx sumup 目录 1.1. Jyepu prob not support ,gazi nonge map trans支持简谱解决

冀胤运
2023-12-01

Atitit jfugue midi make tour attilx sumup

目录

1.1. Jyepu prob not support ,gazi nonge map trans支持简谱解决方案 1

1.2. Tone len problem??note 音符 音长 1

1.3. Jyepai spltor prob ,,mosi not need   jyepu hto d just for readd 节拍分隔符问题 1

1.4. 保存为mid文件 1

1.5. 分析mid文件为txt 4

 

1.1. Jyepu prob not support ,gazi nonge map trans支持简谱解决方案

1.2. Tone len problem??note 音符 音长

A5h   ,,must mid has 5.beir ingore

 

1.3. Jyepai spltor prob ,,mosi not need   jyepu hto d just for readd 节拍分隔符问题

 

1.4. 保存为mid文件

 

package midtool;

 

import java.io.File;

import java.io.IOException;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

 

import org.jfugue.midi.MidiFileManager;

import org.jfugue.pattern.Pattern;

import org.jfugue.player.Player;

import org.staccato.ReplacementMapPreprocessor;

import org.staccato.maps.SolfegeReplacementMap;

 

import com.attilax.collection.listBuilder;

import com.attilax.util.timestampUtil;

import com.google.common.base.Joiner;

import com.google.common.collect.Lists;

 

public class SolfegeReplacementMapDemo {

public static void main(String[] args) throws IOException {

 Map rules = new HashMap() {{

          put("1", "c");

          put("2", "d");

          put("3", "e");

          put("4", "f");

          put("5", "g");

          put("6", "a");

          put("7", "b"  );

          put("H", "H"  );

         

    }};

    

    

//ReplacementMapPreprocessor rmp = ReplacementMapPreprocessor.getInstance();

//rmp.setReplacementMap(rules).setRequireAngleBrackets(false);

//Player player = new Player();

//player.play(new Pattern("do re mi fa so la ti do")); // This will play "C D E F G A B"

 

// This next example brings back the brackets so durations can be added

//rmp.setRequireAngleBrackets(true);

//player.play(new Pattern("<Do>q <Re>q <Mi>h | <Mi>q <Fa>q <So>h | <So>q <Fa>q <Mi>h | <Mi>q <Re>q <Do>h"));

Pattern Pattern1 = new Pattern();   

String s="1155665-  4433221-  5544332-    5544332-     1155665-    4433221-";//  5544332    5544332     1155665    4433221

listBuilder listBuilder = strService.$(s).replace("    aaa","\\|").toList().trimElement();

List li=processToneLen(listBuilder.liObj,rules);

//String s2=listBuilder.join(" ").build();

String joinSpaceAfted = Joiner.on(" ").join(li);

System.out.println(joinSpaceAfted);

Pattern1.add(joinSpaceAfted);  

File file = new File( timestampUtil.join("c:\\0log\\atifirstmid@tmstmp@.mid").asTimeStamp_millsec_filenameencode() );

new MidiFileManager().savePatternToMidi(Pattern1, file);

System.out.println("--");

}

 

private static List processToneLen(List liObj, Map rules) {

 List li=Lists.newArrayList();

String lasttone;

for (Object object : liObj) {

String tone=(String) object.toString().trim();

if(tone.trim().length()==0)

continue;

if(!tone.equals("-") )

{

String trueTone=(String) rules.get(tone);

li.add(trueTone);continue;

}

if(tone.equals("-") )

{

int indexlast = li.size()-1;

String li_lasttone=(String) li.get(indexlast);

String newtone=li_lasttone+"5H";

li.remove(indexlast);

li.add(newtone);

continue;

}

}

 

return li;

}

}

 

1.5. 分析mid文件为txt

 

 

Player player = new Player();

//两只老虎Pattern pattern1 = new Pattern("I[40] C5q D5q E5q C5q");

//跑得快Pattern pattern2 = new Pattern("E5q F5q G5h");

//一只没有眼睛Pattern pattern3 = new Pattern("G5i A5i G5i F5i E5q C5q");

//真奇怪Pattern pattern4 = new Pattern("C5q G4q C5h");

// Put all of the patters together to form the songPattern song = new Pattern();song.add(pattern1, 2);

// Adds 'pattern1' to 'song' twicesong.add(pattern2, 2); // Adds 'pattern2' to 'song' twicesong.add(pattern3, 2);

// Adds 'pattern3' to 'song' twicesong.add(pattern4, 2);

 // Adds 'pattern4' to 'song' twice

// Play the song!player.play(song);

 类似资料: