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

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);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值