吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 852|回复: 1
收起左侧

[求助] 帮看一下怎么才能弄出

[复制链接]
星辰an 发表于 2021-5-19 21:31
这是代码,大佬们帮看一下,谢谢啦{:1_919:} {:1_919:}
[Java] 纯文本查看 复制代码
 package FirstHeadJava;

import javax.sound.midi.*;

public class MiniMusicCmdLine  {
    public static void main(String[] args) {
        MiniMusicCmdLine mini = new MiniMusicCmdLine();
        if(args.length<2){
            System.out.println("Don't forget the instrument and note args");
        }else {
             int instrument = Integer.parseInt(args[0]);
             int note = Integer.parseInt(args[1]);
             mini.play(instrument,note);

        }

    }
    public void play(int instrument ,int note ){
        try{
            Sequencer player = MidiSystem.getSequencer();
            player.open();
            Sequence seq = new Sequence(Sequence.PPQ, 4);
            Track track = seq.createTrack();

            MidiEvent event = null;

            ShortMessage first = new ShortMessage();
            first.setMessage(192,1,instrument,0);
            MidiEvent changeInstrument = new MidiEvent(first,1);
            track.add(changeInstrument);

            ShortMessage a = new ShortMessage();
            a.setMessage(144,1,note,100);
            MidiEvent noteOn = new MidiEvent(a,1);
            track.add(noteOn);

            ShortMessage b = new ShortMessage();
            b.setMessage(128,1,note,100);
            MidiEvent noteOff = new MidiEvent(b,16);
            track.add(noteOff);
            player.setSequence(seq);
            player.start();

        }catch (Exception ex){
            ex.printStackTrace();
        }
    }
}

Snipaste_2021-05-19_21-24-24.png

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

baolibu 发表于 2021-5-20 13:45
我去,我居然点进来了。然后啥都看不懂,只能灰溜溜的出去。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-16 12:22

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表