DavidSFXModule.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:mochadoom 作者:
/** This one will only create datalines for common clip/audioline samples
 *  directly.
 * 
 * @param c
 * @param sfxid
 */
private final void  createDataLineForChannel(int c, int sfxid){

    // None? Make a new one.

    if (channels[c].auline == null) {
        try {
            DoomSound tmp=cachedSounds.get(sfxid);
            // Sorry, Charlie. Gotta make a new one.
            DataLine.Info info = new DataLine.Info(SourceDataLine.class, DoomSound.DEFAULT_SAMPLES_FORMAT);
            channels[c].auline = (SourceDataLine) AudioSystem.getLine(info);
            channels[c].auline.open(tmp.format);
        } catch (LineUnavailableException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
                boolean errors=false;
                // Add individual volume control.
                if (channels[c].auline.isControlSupported(Type.MASTER_GAIN))
                    channels[c].vc=(FloatControl) channels[c].auline
                    .getControl(Type.MASTER_GAIN);
                else {
                System.err.print("MASTER_GAIN, ");
                errors=true;
                if (channels[c].auline.isControlSupported(Type.VOLUME))
                        channels[c].vc=(FloatControl) channels[c].auline
                        .getControl(Type.VOLUME);
                else 
                    System.err.print("VOLUME, ");
                } 


                // Add individual pitch control.
                if (channels[c].auline.isControlSupported(Type.SAMPLE_RATE)){
                    channels[c].pc=(FloatControl) channels[c].auline
                    .getControl(Type.SAMPLE_RATE);
                } else {
                    errors=true;
                    System.err.print("SAMPLE_RATE, ");
                } 

                // Add individual pan control
                if (channels[c].auline.isControlSupported(Type.BALANCE)){
                    channels[c].bc=(FloatControl) channels[c].auline
                    .getControl(FloatControl.Type.BALANCE);
                } else {
                    System.err.print("BALANCE, ");
                    errors=true;
                    if (channels[c].auline.isControlSupported(Type.PAN)){                           
                    channels[c].bc=(FloatControl) channels[c].auline
                    .getControl(FloatControl.Type.PAN);
                } else {
                    System.err.print("PANNING ");
                    }
                }

                if (errors) System.err.printf("for channel %d NOT supported!\n",c);

                channels[c].auline.start();
            }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号