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


Java UnsupportedAudioFileException类代码示例

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


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

示例1: attack

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
/**
 * Attack the player
 */
public void attack()
{
	for (Entity e : getLevel().getEntities()){
		if (e.isActive() && e instanceof Player)
			
			if (!getLevel().isThroughWall(getLocation(), e.getLocation()) && getLocation().dist(((Player) e).getLocation()) < 4)
			{
				Player p = (Player) e;
				p.takeDamage(80);
			}
	try
	{
		SoundStuff cam = new SoundStuff();
		cam.AWP();
	}
	catch (UnsupportedAudioFileException | IOException | LineUnavailableException e1)
	{
		e1.printStackTrace();
	}
	}
}
 
开发者ID:Chroniaro,项目名称:What-Happened-to-Station-7,代码行数:25,代码来源:Shotgun_Enemy.java

示例2: main

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
/**
 * @param args the command line arguments
 * @throws java.io.IOException
 */
public static void main(String[] args) throws IOException, InterruptedException, PropertyVetoException, UnsupportedAudioFileException, LineUnavailableException {
   File file = new File("CADASTRADOS.txt");
   
   if(!file.exists()){
    file.createNewFile();// TODO code application logic here
   }
   File dir = new File("CadastroRemedios");
   if(!dir.exists()){
       dir.mkdir();
   }
   
   LoginInterface inFrame = new LoginInterface();
   CadastroInterface inCadas = new CadastroInterface();
   TelaInicial tl = new TelaInicial(inFrame);
   tl.setVisible(true);
    System.out.println("Permitir Alteração");
   inFrame.setVisible(true);

}
 
开发者ID:knowrafa,项目名称:lembredio,代码行数:24,代码来源:Lembredio.java

示例3: getAudioInputStream

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
@Override
public AudioInputStream getAudioInputStream(final InputStream stream)
        throws UnsupportedAudioFileException, IOException {
    stream.mark(200); // The biggest value which was historically used
    try {
        final StandardFileFormat format = getAudioFileFormatImpl(stream);
        // we've got everything, the stream is supported and it is at the
        // beginning of the audio data, so return an AudioInputStream
        return new AudioInputStream(stream, format.getFormat(),
                                    format.getLongFrameLength());
    } catch (UnsupportedAudioFileException | EOFException ignored) {
        // stream is unsupported or the header is less than was expected
        stream.reset();
        throw new UnsupportedAudioFileException();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:SunFileReader.java

示例4: getAudioInputStream

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
public AudioInputStream getAudioInputStream(InputStream stream)
        throws UnsupportedAudioFileException, IOException {

    AudioFileFormat format = getAudioFileFormat(stream);
    RIFFReader riffiterator = new RIFFReader(stream);
    if (!riffiterator.getFormat().equals("RIFF"))
        throw new UnsupportedAudioFileException();
    if (!riffiterator.getType().equals("WAVE"))
        throw new UnsupportedAudioFileException();
    while (riffiterator.hasNextChunk()) {
        RIFFReader chunk = riffiterator.nextChunk();
        if (chunk.getFormat().equals("data")) {
            return new AudioInputStream(chunk, format.getFormat(),
                    chunk.getSize());
        }
    }
    throw new UnsupportedAudioFileException();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:WaveFloatFileReader.java

示例5: getAudioInputStream

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
public AudioInputStream getAudioInputStream(InputStream stream)
        throws UnsupportedAudioFileException, IOException {

    AudioFileFormat format = getAudioFileFormat(stream);
    RIFFReader riffiterator = new RIFFReader(stream);
    if (!riffiterator.getFormat().equals("RIFF"))
        throw new UnsupportedAudioFileException();
    if (!riffiterator.getType().equals("WAVE"))
        throw new UnsupportedAudioFileException();
    while (riffiterator.hasNextChunk()) {
        RIFFReader chunk = riffiterator.nextChunk();
        if (chunk.getFormat().equals("data")) {
            return new AudioInputStream(chunk, format.getFormat(), chunk
                    .getSize());
        }
    }
    throw new UnsupportedAudioFileException();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:WaveExtensibleFileReader.java

示例6: extractFromInputStream

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
private void extractFromInputStream() throws IOException, PlatformAccessError, UnsupportedAudioFileException {
    if (inputType == InputType.WAV) {
        AudioInput wavFile = new AudioInput(inputStream, defaultChannelName);
        sampleSource = wavFile;
        configureSampleStreamInput();
    } else if (inputType == InputType.PULSES) {
        pulseSource = new PulseSourceFromInputStream(inputStream);
        connector = new DummySampleSource();
    } else if (inputType == InputType.COMMODORE_TAP) {
        intervalSource = new IntervalSourceFromTAPInputStream(inputStream);
        connector = new DummySampleSource();
    }

    linkSourceToPlatforms();
    runThroughSource();
}
 
开发者ID:eightbitjim,项目名称:cassette-nibbler,代码行数:17,代码来源:ExtractFile.java

示例7: getSoundbank

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
public Soundbank getSoundbank(File file)
        throws InvalidMidiDataException, IOException {
    try {
        AudioInputStream ais = AudioSystem.getAudioInputStream(file);
        ais.close();
        ModelByteBufferWavetable osc = new ModelByteBufferWavetable(
                new ModelByteBuffer(file, 0, file.length()), -4800);
        ModelPerformer performer = new ModelPerformer();
        performer.getOscillators().add(osc);
        SimpleSoundbank sbk = new SimpleSoundbank();
        SimpleInstrument ins = new SimpleInstrument();
        ins.add(performer);
        sbk.addInstrument(ins);
        return sbk;
    } catch (UnsupportedAudioFileException e1) {
        return null;
    } catch (IOException e) {
        return null;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:AudioFileSoundbankReader.java

示例8: processMonitorQuery

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
private void processMonitorQuery(float[] audioData,QueryResultHandler handler, double timeStamp,Set<Integer> avoid){
	int samplerate = Config.getInt(Key.RAFS_SAMPLE_RATE);
	int size = Config.getInt(Key.RAFS_FFT_SIZE);
	int overlap = size - Config.getInt(Key.RAFS_FFT_STEP_SIZE);
	
	AudioDispatcher d;
	try {
		d = AudioDispatcherFactory.fromFloatArray(audioData, samplerate, size, overlap);
		d.setZeroPadFirstBuffer(true);
		final RafsExtractor processor = new RafsExtractor(null,true);
		d.addAudioProcessor(processor);
		d.run();
		queryForMonitor(processor.fingerprints, processor.fingerprintProbabilities, 10 , avoid, handler);
	} catch (UnsupportedAudioFileException e) {
		LOG.severe("Unsupported audio");
	}
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:18,代码来源:RafsRepStrategy.java

示例9: processMonitorQueryToSerializeFingerprints

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
private void processMonitorQueryToSerializeFingerprints(float[] audioBuffer,SerializedFingerprintsHandler handler,double queryOffset){
	int samplerate = Config.getInt(Key.NFFT_SAMPLE_RATE);
	int size = Config.getInt(Key.NFFT_SIZE);
	int overlap = size - Config.getInt(Key.NFFT_STEP_SIZE);
	
	AudioDispatcher d;
	try {
		d = AudioDispatcherFactory.fromFloatArray(audioBuffer, samplerate, size, overlap);
		final NFFTEventPointProcessor minMaxProcessor = new NFFTEventPointProcessor(size,overlap,samplerate);
		d.addAudioProcessor(minMaxProcessor);
		d.run();
		double queryDuration = d.secondsProcessed();
		List<NFFTFingerprint> fingerprints = new ArrayList<NFFTFingerprint>(minMaxProcessor.getFingerprints());
		handler.handleSerializedFingerprints(PanakoWebserviceClient.serializeFingerprintsToJson(fingerprints),queryDuration,queryOffset);
	} catch (UnsupportedAudioFileException e) {
		LOG.severe("Unsupported audio");
	}
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:19,代码来源:NFFTStrategy.java

示例10: attack

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
/**
 * Picks a player to attack
 */
public void attack()
{
	Player weakest = null;

	for (Entity e : getLevel().getEntities())
		if (e.isActive() && e instanceof Player)
			if (!getLevel().isThroughWall(getLocation(), e.getLocation()))
			{
				Player p = (Player) e;
				if (weakest == null || p.getHealth() < weakest.getHealth())
					weakest = p;
			}

	weakest.takeDamage(75);

	try
	{
		SoundStuff cam = new SoundStuff();
		cam.AWP();
	}
	catch (UnsupportedAudioFileException | IOException | LineUnavailableException e1)
	{
		e1.printStackTrace();
	}
}
 
开发者ID:Chroniaro,项目名称:What-Happened-to-Station-7,代码行数:29,代码来源:EnemySniper.java

示例11: getAudioInputStream

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
@Override
public AudioInputStream getAudioInputStream(final InputStream stream)
        throws UnsupportedAudioFileException, IOException {

    final StandardFileFormat format = getAudioFileFormat(stream);
    final AudioFormat af = format.getFormat();
    final long length = format.getLongFrameLength();
    // we've got everything, the stream is supported and it is at the
    // beginning of the header, so find the data chunk again and return an
    // AudioInputStream
    final RIFFReader riffiterator = new RIFFReader(stream);
    while (riffiterator.hasNextChunk()) {
        RIFFReader chunk = riffiterator.nextChunk();
        if (chunk.getFormat().equals("data")) {
            return new AudioInputStream(chunk, af, length);
        }
    }
    throw new UnsupportedAudioFileException();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:WaveFloatFileReader.java

示例12: getAudioInputStream

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
/**
 * Obtains an audio stream from the File provided.  The File must
 * point to valid audio file data.
 * @param file the File for which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data pointed
 * to by the File
 * @throws UnsupportedAudioFileException if the File does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public AudioInputStream getAudioInputStream(File file)
    throws UnsupportedAudioFileException, IOException {

    FileInputStream fis = new FileInputStream(file); // throws IOException
    AudioFileFormat fileFormat = null;
    // part of fix for 4325421
    try {
        fileFormat = getCOMM(fis, false);
    } finally {
        if (fileFormat == null) {
            fis.close();
        }
    }
    return new AudioInputStream(fis, fileFormat.getFormat(), fileFormat.getFrameLength());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:AiffFileReader.java

示例13: testAfterSaveToFile

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
/**
 * Verifies the frame length after the stream was saved/read to/from file.
 */
private static void testAfterSaveToFile(final AudioFileWriter afw,
                                        final AudioFileFormat.Type type,
                                        AudioInputStream ais)
        throws IOException {
    final File temp = File.createTempFile("sound", ".tmp");
    try {
        afw.write(ais, type, temp);
        ais = AudioSystem.getAudioInputStream(temp);
        final long frameLength = ais.getFrameLength();
        ais.close();
        validate(frameLength);
    } catch (IllegalArgumentException | UnsupportedAudioFileException
            ignored) {
    } finally {
        Files.delete(Paths.get(temp.getAbsolutePath()));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:FrameLengthAfterConversion.java

示例14: play

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
/**
 * Plays an audio file (in .wav, .mid, or .au format) in a background
 * thread.
 *
 * @param filename
 *            the name of the audio file
 * @throws IllegalArgumentException
 *             if unable to play {@code filename}
 * @throws IllegalArgumentException
 *             if {@code filename} is {@code null}
 */
public static synchronized void play(final String filename) {
	if (filename == null)
		throw new IllegalArgumentException();

	InputStream is = StdAudio.class.getResourceAsStream(filename);
	if (is == null) {
		throw new IllegalArgumentException("could not read '" + filename + "'");
	}

	// code adapted from:
	// http://stackoverflow.com/questions/26305/how-can-i-play-sound-in-java
	try {
		// check if file format is supported
		// (if not, will throw an UnsupportedAudioFileException)
		@SuppressWarnings("unused")
		AudioInputStream ais = AudioSystem.getAudioInputStream(is);

		new Thread(new Runnable() {
			@Override
			public void run() {
				stream(filename);
			}
		}).start();
	}

	// let's try Applet.newAudioClip() instead
	catch (UnsupportedAudioFileException e) {
		playApplet(filename);
		return;
	}

	// something else went wrong
	catch (IOException ioe) {
		throw new IllegalArgumentException("could not play '" + filename + "'", ioe);
	}

}
 
开发者ID:Scoutdrago3,项目名称:MusicToGraph,代码行数:49,代码来源:StdAudio.java

示例15: playAudio

import javax.sound.sampled.UnsupportedAudioFileException; //导入依赖的package包/类
public void playAudio(int tempo, boolean flag) throws UnsupportedAudioFileException, LineUnavailableException, IOException, InterruptedException{
    Clip clip = AudioSystem.getClip();
    URL url = getClass().getResource("/audio/smb_die.wav");
    URL urlToHot = this.getClass().getResource("/audio/smb_die.wav");
    System.out.println(urlToHot);
    this.audio = Applet.newAudioClip(url);
    if(flag) audio.loop();
    else audio.stop();
    
}
 
开发者ID:knowrafa,项目名称:lembredio,代码行数:11,代码来源:Audio.java


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