• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AudioAttributes类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



AudioAttributes类属于it.sauronsoftware.jave包,在下文中一共展示了AudioAttributes类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例5: toMp3

import it.sauronsoftware.jave.AudioAttributes; //导入依赖的package包/类
public byte[] toMp3(byte[] midi, String wavPath) throws Exception {
        //allowing a maximum number users to generate tracks at the same time so that the system remains stable (midi->wav->mp3 is heavy)
        semaphore.acquire();
        try {
            File wav;
            if (wavPath == null) {
                wav = File.createTempFile("gen", ".wav");
            } else {
                wav = new File(wavPath + "/gen.wav");
            }
            
            long start = System.currentTimeMillis();
            try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(wav))) {
                Midi2WavRenderer.midi2wav(new ByteArrayInputStream(midi), fos);
                IOUtils.write(midi, fos);
            }
            logger.info("midi2wav conversion took: " + (System.currentTimeMillis() - start) + " millis");
            start = System.currentTimeMillis();
            EncodingAttributes attrs = new EncodingAttributes();
            attrs.setFormat("mp3");
            AudioAttributes audio = new AudioAttributes();
//            audio.setBitRate(36000);
//            audio.setSamplingRate(20000);
            attrs.setAudioAttributes(audio);
            attrs.setThreads(1);
            File mp3 = File.createTempFile("gen", ".mp3");
            encoder.encode(wav, mp3, attrs);
            logger.info("wav2mp3 conversion took: " + (System.currentTimeMillis() - start) + " millis");
            if (wavPath == null) {
                wav.delete(); //cleanup the big wav file
            }
            byte[] mp3Bytes = FileUtils.readFileToByteArray(mp3);
            mp3.delete();
            return mp3Bytes;
        } finally {
            semaphore.release();
        }
    }
 
开发者ID:Glamdring,项目名称:computoser,代码行数:39,代码来源:Generator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ByteBufferInputStream类代码示例发布时间:2022-05-22
下一篇:
Java IMovableRegistry类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap