mercredi 11 mars 2015

Get Volume of Arbirtrary frame in Clip (Java)?



I've been trying to get the volume of a specific frame of a Clip in Java. If it matters, it's in the WAV file format. I tried the following, assuming clip is a Clip object and i is an arbitrary int. All I get is -1.0, which is equivalent to AudioSystem.NOT_SPECIFICED



if(clip.isOpen())
{
clip.setFramePosition(i);
System.out.println(clip.getLevel());
}


I checked the clip has been loaded by playing it, which worked. Can anyone help me figure this out? The code this snippet is from:



AudioInputStream ais;
Clip clip;
int i = 6; //Arbitrary value
ais = AudioSystem.getAudioInputStream(new File("C:\Arbitrary\Path\File.wav"));
clip = AudioSystem.getClip();
clip.open(ais);
if(clip.isOpen())
{
clip.setFramePosition(i);
float level = clip.getLevel();
System.out.println(level);
}



Aucun commentaire:

Enregistrer un commentaire