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


Java MpegAudioFileReader类代码示例

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


MpegAudioFileReader类属于javazoom.spi.mpeg.sampled.file包,在下文中一共展示了MpegAudioFileReader类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculateSamples

import javazoom.spi.mpeg.sampled.file.MpegAudioFileReader; //导入依赖的package包/类
public static int calculateSamples() throws UnsupportedAudioFileException, IOException{
	File file = new File(fileDialogs.getInputPath());
	
    AudioFileFormat baseFileFormat = new MpegAudioFileReader().getAudioFileFormat(file);
    Map properties = baseFileFormat.properties();
    Long duration = (Long) properties.get("duration");
    int samples =  (int) (duration/1000/1000)*44100;
    return samples;
}
 
开发者ID:Ptrk25,项目名称:eshopMusicConverter,代码行数:10,代码来源:XMLCreator.java

示例2: decode

import javazoom.spi.mpeg.sampled.file.MpegAudioFileReader; //导入依赖的package包/类
@Override
public AudioInputStream decode(File inputFile) throws UnsupportedAudioFileException, IOException {

  MpegAudioFileReader mafr = new MpegAudioFileReader();
  AudioInputStream mp3Ais;
  // AudioInputStream mp3Dmais = null;
  AudioInputStream result;

  try {
    mp3Ais = mafr.getAudioInputStream(inputFile);
  } catch (Exception e) {

    /*
     * This is now a work around (aka hack) for files with stored images in them. The images have to be removed. We load the file as FileInputStream, check
     * the length of the header and skip it.
     */
    FileInputStream f_in = new FileInputStream(inputFile);
    Bitstream m = new Bitstream(f_in);
    long start = m.header_pos();

    try {
      m.close();
    } catch (BitstreamException be) {
      // nop
    }

    f_in = new FileInputStream(inputFile);

    // Skip the header
    f_in.skip(start);

    // Now try again with the 'truncated' sound stream
    mp3Ais = mafr.getAudioInputStream(f_in);
  }

  AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, mp3Ais.getFormat().getSampleRate(), 16, mp3Ais.getFormat().getChannels(),
      mp3Ais.getFormat().getChannels() * 2, mp3Ais.getFormat().getSampleRate(), false);

  result = new DecodedMpegAudioInputStream(decodedFormat, mp3Ais);

  // result = new PCMtoPCMCodec().getAudioInputStream(TARGET_ENCODING, mp3Dmais);
  // result = new MpegFormatConversionProvider().getAudioInputStream(TARGET_ENCODING, mp3Dmais);
  // result = AudioSystem.getAudioInputStream(TARGET_ENCODING, mp3Dmais);

  return tidyStream(result);
}
 
开发者ID:nwaldispuehl,项目名称:interval-music-compositor,代码行数:47,代码来源:Mp3AudioFileDecoder.java


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