我用了很多办法就是无法改变midi的音量,请问有什么可行方法吗?谢谢!

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【cloudffx】截止到2008-07-21 11:39:00的历史汇总数据(不包括此帖):
    发帖的总数量:1                        发帖的总分数:0                        每贴平均分数:0                        
    回帖的总数量:0                        得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:1                        结贴的总分数:0                        
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:100.00%               结分的百分比:---------------------
    无满意结贴率:0.00  %               无满意结分率:---------------------
    敬礼!
      

  2.   

    用Java调用VC音量控制程序
    2008年02月27日  湖南经济网  点击次数: 133          【字体:大 中 小】   前言  本文通过Java的Runtime接口来实现调用其他语言实现的应用程序,进而来实现对计算机硬件信息的监控和控制.本文是多媒体信息系统的一个部分,就是调整计算机音量。  使用VC编写音量控制程序  本控制示例使用VC6.0编写,主要是调用系统的API来实现,  mixerGetLineInfo 获取Master Volume Control.  mixerGetControlDetails 获取 Volume Control 信息  mixerSetControlDetails 设置 Volume Control 信息  最终编译成Console类型的Dos执行的程序VolumeControl.exe。这个程序实现三个功能:  1.获取音量 VolumeControl.exe 0  2.增加音量 VolumeControl.exe 1  3.减少音量 VolumeControl.exe 2  下面我们用Java设计创建一个Panel用于显示音量并调用应用程序实现对音量的实际控制,本例中使用自定义Progress显示VolumeTracker.java  实现原理如下:  使用一个线程动态刷新页面,主线程用来实现对音量的控制.其实现代码如下:import java.awt.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    import java.text.AttributedString;
    import java.text.AttributedCharacterIterator;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    import java.io.*;
    public class VolumeTracker extends JPanel implements Runnable
    {
     String welcomeStr = "Welcome to Java Sound";
     Thread pbThread;
     Color background = Color.white;
     //new Color(20, 20, 20);
     Color jfcBlue = Color.blue;
     //new Color(204, 204, 255);
     Color jfcDarkBlue = jfcBlue.darker();
     Font font24 = new Font("serif", Font.BOLD, 24);
     Font font28 = new Font("serif", Font.BOLD, 28);
     Font font42 = new Font("serif", Font.BOLD, 42);
     FontMetrics fm28, fm42;
     String errStr=null;
     String currentName=null;
     double duration = 100.0;
     double seconds = 82.0;
     boolean midiEOM, audioEOM;
     public VolumeTracker()
     {
      fm28 = getFontMetrics(font28);
      fm42 = getFontMetrics(font42);
      initVolume();
      start();
     }
     private void initVolume()
     {
      try
       {
        //这一段小程序实现对VC创建程序的调用
         Runtime rt = Runtime.getRuntime(); //Time and Date.
        //mngPathTool类,提供了一个获取当前路径的方法
        mngPathTool tool = new mngPathTool();
        String sexec = tool.getCurPath()+ "\binex\VolumeControl.exe 0";
        Process child = rt.exec(sexec);
        //获取控制台输出的内容,进而获得音量的大小
        InputStreamReader reader = new InputStreamReader(child.getInputStream());
        char[] chr = new char[5];
        reader.read(chr) ;
        String s="";
        for(int i=0;i<5;i++)
        {
         if(chr[i]>='0' && chr[i]<='9') s+=chr[i];
        }
        //System.out.println(s);
        Integer nVolume = new Integer(s);
        seconds = nVolume.intValue();
        child.waitFor();
        //这一段小程序实现对VC创建程序的调用
       }
      catch(Exception e1)
       {
        e1.printStackTrace();
       }
     }
     public void paint(Graphics g)
     {
      //画图来实现百分比Tracker
      Graphics2D g2 = (Graphics2D) g;
      Dimension d = getSize();
      g2.setBackground(background);
      g2.clearRect(0, 0, d.width, d.height);
      g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g2.setColor(jfcBlue);
      double tseconds = duration-seconds;
      if (tseconds > 0.0)
      {
       int num = 20;
       int progress = (int) (tseconds / duration * num);
       double hh = ((double) (d.height - 4) / (double) num);
       double ww = (int)(d.width-4);
       double x = 0.0;
       for ( ; x < progress; x+=1.0)
       {
        g2.fill(new Rectangle2D.Double(d.width-ww-2, x*hh+2, ww, hh));
        g2.fill3DRect((int)(d.width-ww-2),(int) (x*hh+2),(int) ww, (int)hh,true);
       }
       g2.setColor(jfcDarkBlue);
       for ( ; x < num; x+=1.0)
       {
        g2.fill(new Rectangle2D.Double(d.width-ww-2, x*hh+2, ww, hh));
        g2.fill3DRect((int)(d.width-ww-2),(int) (x*hh+2),(int) ww, (int)hh,true);
       }
      }
     }
     public void start()
     {
      pbThread = new Thread(this);
      pbThread.setName("PlaybackMonitor");
      pbThread.start();
     }
     public void stop()
     {
      if (pbThread != null)
      {
       pbThread.interrupt();
      }
      pbThread = null;
     }
     public void run()
     {
      while (pbThread != null)
      {
       try
       {
        pbThread.sleep(99);
       }
       catch (Exception e)
       {
        break;
       }
       repaint();
      }
      pbThread = null;
     }
     public void addVolume()
     {
      changeVolume(false);
      initVolume();
     }
     public void minusVolume()
     {
      changeVolume(true);
      initVolume();
     }
     //control sound volume.
     private void changeVolume(boolean bIsMinus)
     {
      try
      {
       Runtime rt = Runtime.getRuntime();
       //Sound Control mngPathTool
       tool = new mngPathTool();
       String sexec;
       if(bIsMinus)
        sexec= tool.getCurPath()+ "\binex\VolumeControl.exe 2";
       else
        sexec= tool.getCurPath()+ "\binex\VolumeControl.exe 1";
        rt.exec(sexec);
      }catch(Exception e1){e1.printStackTrace(); }
     }
    }
    // End VolumeTracker
      创建一个JFrame用于显示 VolumeControl.java