All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.lessvoid.nifty.sound.minim.SoundDeviceMinim Maven / Gradle / Ivy

There is a newer version: 1.4.3
Show newest version
package de.lessvoid.nifty.sound.minim;

import ddf.minim.Minim;
import de.lessvoid.nifty.sound.SoundSystem;
import de.lessvoid.nifty.spi.sound.SoundDevice;
import de.lessvoid.nifty.spi.sound.SoundHandle;
import de.lessvoid.nifty.tools.resourceloader.NiftyResourceLoader;

/**
 * Implementation of Nifty's SoundDevice for the Minim Java audio library.
 * Minim is an audio library primarily built for use with Processing.
 * @author Xuanming
 */
public class SoundDeviceMinim implements SoundDevice {
	
	Minim minim;
	NiftyResourceLoader resourceLoader;
	
	/**
	 * Create an instance of SoundDeviceMinim.
	 * @param minim Instance of Minim currently in use by Processing (or Java).
	 */
	public SoundDeviceMinim(Minim minim){
		this.minim = minim;
	}

	@Override
	public void setResourceLoader(NiftyResourceLoader niftyResourceLoader) {
		this.resourceLoader = niftyResourceLoader;
	}

	@Override
	public SoundHandle loadSound(SoundSystem soundSystem, String filename) {
		return new SoundHandleMinim(minim, resourceLoader.getResource(filename).getPath());
	}

	@Override
	public SoundHandle loadMusic(SoundSystem soundSystem, String filename) {
		return new SoundHandleMinim(minim, resourceLoader.getResource(filename).getPath());
	}

	@Override
	public void update(int delta) { // Do nothing.
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy