当前位置: 首页>>代码示例>>Java>>正文


Java AudioAttributes.setChannels方法代码示例

本文整理汇总了Java中it.sauronsoftware.jave.AudioAttributes.setChannels方法的典型用法代码示例。如果您正苦于以下问题:Java AudioAttributes.setChannels方法的具体用法?Java AudioAttributes.setChannels怎么用?Java AudioAttributes.setChannels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在it.sauronsoftware.jave.AudioAttributes的用法示例。


在下文中一共展示了AudioAttributes.setChannels方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mp4ToMp3

import it.sauronsoftware.jave.AudioAttributes; //导入方法依赖的package包/类
/**
 * Converts Mp4 file to MP3
 *
 * @param fileMp4
 * @param fileMp3
 * @return true if it has been converted
 */
public static boolean mp4ToMp3(File fileMp4, File fileMp3)
{
	AudioAttributes audio = new AudioAttributes();
	audio.setCodec("libmp3lame");
	audio.setBitRate(new Integer(128000));
	audio.setChannels(new Integer(2));
	audio.setSamplingRate(new Integer(44100));
	EncodingAttributes attrs = new EncodingAttributes();
	attrs.setFormat("mp3");
	attrs.setAudioAttributes(audio);
	Encoder encoder = new Encoder();
	try
	{
		encoder.encode(fileMp4, fileMp3, attrs);
		Log.info("File MP4 convertito in MP3");
		return true;
	}
	catch (IllegalArgumentException | EncoderException e)
	{
		Log.error("File non convertito");
		Log.stackTrace(e.getStackTrace());
		return false;
	}
}
 
开发者ID:BITeam,项目名称:Telegram_Bot,代码行数:32,代码来源:EncoderVA.java

示例2: FileEncoder

import it.sauronsoftware.jave.AudioAttributes; //导入方法依赖的package包/类
public FileEncoder(String inFileName, String outFileName)
{
	encoder = new Encoder();
	AudioAttributes audio = new AudioAttributes();
	audio.setCodec("libmp3lame");
	audio.setBitRate(new Integer(320000));
	audio.setChannels(new Integer(2));
	audio.setSamplingRate(new Integer(44100));
	
	attrs = new EncodingAttributes();
	attrs.setFormat("mp3");
	attrs.setAudioAttributes(audio);
	
	inputFile = new File(inFileName);
	outputFile = new File(outFileName);
}
 
开发者ID:Armaxis,项目名称:jmg,代码行数:17,代码来源:FileEncoder.java

示例3: writeMP3

import it.sauronsoftware.jave.AudioAttributes; //导入方法依赖的package包/类
/**
 * Converts the given <code>sequence</code> to a wav file and then to a mp3 file.
 * The temporary wav file is deleted afterwards.
 *
 * @param sequence The sequence to write to the file
 * @param fileName The file to write to
 * @throws IOException Thrown if writing to file was not possible
 * @see MusicWriter#writeWav(Sequence, String)
 */
public static void writeMP3(Sequence sequence, String fileName) throws IOException {
    String file = fileNameWithoutEnding(fileName);
    File wav = new File(file + System.currentTimeMillis() + ".wav");
    File mp3 = new File(file + ".mp3");
    mp3.delete();

    writeWav(sequence, wav.getPath());

    //Convert wav to mp3
    AudioAttributes audio = new AudioAttributes();
    audio.setCodec("libmp3lame");
    audio.setBitRate(64000);
    audio.setChannels(2);
    audio.setSamplingRate(22050);
    EncodingAttributes attrs = new EncodingAttributes();
    attrs.setFormat("mp3");
    attrs.setAudioAttributes(audio);
    Encoder encoder = new Encoder();
    try {
        encoder.encode(wav, mp3, attrs);
        if (!fileName.equals(mp3.getName()))
            System.out.println("Wrote mp3 to \"" + mp3.getPath() + "\"");
    } catch (EncoderException e) {
        e.printStackTrace();
    } finally {
        if (!wav.delete())
            System.err.println("Could not delete temporary wav file");
    }
}
 
开发者ID:AudiophileDev,项目名称:T2M,代码行数:39,代码来源:MusicWriter.java

示例4: encodeMP3

import it.sauronsoftware.jave.AudioAttributes; //导入方法依赖的package包/类
public boolean encodeMP3() {
    try {
        File fileConvert = new File(System.getProperty("user.dir") + "/" + toConvert);
        File fileConversion = new File(System.getProperty("user.dir") + "/" + resultConversion);


        Encoder enc = new Encoder();
        EncodingAttributes att = new EncodingAttributes();
        InfoMusic inf = new InfoMusic(fileConvert);
        att.setDuration((float) inf.getFullTime());
        AudioAttributes audioAttributes = new AudioAttributes();

        audioAttributes.setBitRate(BITRATE);
        audioAttributes.setChannels(CHANNELS);
        audioAttributes.setSamplingRate((int) SAMPLE);

        att.setAudioAttributes(audioAttributes);
        att.setFormat("mp3");

        enc.encode(fileConvert, fileConversion, att);
    } catch (EncoderException e) {
        e.printStackTrace();
        return false;
    }

    return true;
}
 
开发者ID:dimamo5,项目名称:SDIS-SoundShare,代码行数:28,代码来源:Converter.java


注:本文中的it.sauronsoftware.jave.AudioAttributes.setChannels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。