use of blue.soundObject.AudioFile in project blue by kunstmusik.
the class OpenProjectAction method checkAudioFiles.
private static void checkAudioFiles(PolyObject pObj, ArrayList<String> filesList) {
for (Iterator<SoundObject> iter = pObj.getSoundObjects(true).iterator(); iter.hasNext(); ) {
SoundObject sObj = iter.next();
if (sObj instanceof AudioFile) {
AudioFile af = (AudioFile) sObj;
String soundFileName = af.getSoundFileName();
if (soundFileName == null) {
continue;
}
if (BlueSystem.findFile(soundFileName) == null) {
if (!filesList.contains(soundFileName)) {
filesList.add(soundFileName);
}
}
} else if (sObj instanceof PolyObject) {
checkAudioFiles((PolyObject) sObj, filesList);
}
}
}
use of blue.soundObject.AudioFile in project blue by kunstmusik.
the class AudioFileEditor method setAudioFileInfo.
private void setAudioFileInfo(String audioFile) {
if (audioFile == null || audioFile.equals("")) {
audioFileName.setText("Choose an Audio File");
clearAudioInfo();
return;
}
File soundFile = BlueSystem.findFile(audioFile);
if (soundFile == null || !soundFile.exists() || !soundFile.isFile()) {
audioFileName.setText("Could not find file: " + audioFile);
clearAudioInfo();
return;
}
audioFileName.setText(audioFile);
try {
AudioFileFormat aFormat = AudioSystem.getAudioFileFormat(soundFile);
AudioFormat format = aFormat.getFormat();
durationText.setText(getDuration(aFormat, format));
formatTypeText.setText(aFormat.getType().toString());
byteLengthText.setText(Integer.toString(aFormat.getByteLength()));
encodingTypeText.setText(format.getEncoding().toString());
sampleRateText.setText(Float.toString(format.getSampleRate()));
sampleSizeInBitsText.setText(Integer.toString(format.getSampleSizeInBits()));
int numChannels = format.getChannels();
channelsText.setText(Integer.toString(numChannels));
setChannelVariablesInfo(numChannels);
isBigEndianText.setText(getBooleanString(format.isBigEndian()));
} catch (java.io.IOException ioe) {
JOptionPane.showMessageDialog(null, BlueSystem.getString("soundfile.infoPanel.error.couldNotOpenFile") + " " + soundFile.getAbsolutePath());
clearAudioInfo();
return;
} catch (javax.sound.sampled.UnsupportedAudioFileException uae) {
JOptionPane.showMessageDialog(null, BlueSystem.getString("soundfile.infoPanel.error.unsupportedAudio") + " " + uae.getLocalizedMessage());
clearAudioInfo();
return;
}
}
use of blue.soundObject.AudioFile in project blue by kunstmusik.
the class AudioFileEditor method main.
public static void main(String[] args) {
GUI.setBlueLookAndFeel();
BlueSystem.setCurrentProjectDirectory(new File("/home/steven"));
AudioFileEditor afe = new AudioFileEditor();
GUI.showComponentAsStandalone(afe, "Audio File Editor Test", true);
afe.editScoreObject(new AudioFile());
}
use of blue.soundObject.AudioFile in project blue by kunstmusik.
the class OpenProjectAction method reconcileAudioFiles.
private static void reconcileAudioFiles(PolyObject pObj, Map<String, String> map) {
for (SoundObject sObj : pObj.getSoundObjects(true)) {
if (sObj instanceof AudioFile) {
AudioFile af = (AudioFile) sObj;
String soundFileName = af.getSoundFileName();
if (map.containsKey(soundFileName)) {
af.setSoundFileName(map.get(soundFileName));
}
} else if (sObj instanceof PolyObject) {
reconcileAudioFiles((PolyObject) sObj, map);
}
}
}
use of blue.soundObject.AudioFile in project blue by kunstmusik.
the class AudioFileRenderer method paintWaveform.
private void paintWaveform(Graphics2D g, SoundObjectView sObjView, int pixelSeconds) {
AudioFile audioFile = (AudioFile) sObjView.getSoundObject();
String audioFilename = audioFile.getSoundFileName();
int sObjVisibleHeight = sObjView.getHeight() - 4;
AudioWaveformData waveData = (AudioWaveformData) sObjView.getClientProperty(AUDIO_WAVEFORM_DATA);
if (waveData == null) {
waveData = waveCache.getAudioWaveformData(BlueSystem.getFullPath(audioFilename), pixelSeconds);
if (waveData.percentLoadingComplete < 1.0) {
waveCache.addAudioWaveformListener(new AudioWaveformListener(audioFilename, sObjView));
}
sObjView.putClientProperty(AUDIO_WAVEFORM_DATA, waveData);
} else if (waveData.pixelSeconds != pixelSeconds || !waveData.fileName.equals(audioFile.getSoundFileName())) {
waveData = waveCache.getAudioWaveformData(BlueSystem.getFullPath(audioFilename), pixelSeconds);
sObjView.putClientProperty(AUDIO_WAVEFORM_DATA, waveData);
if (waveData.percentLoadingComplete < 1.0) {
waveCache.addAudioWaveformListener(new AudioWaveformListener(audioFilename, sObjView));
}
}
g.translate(1, 2);
AudioWaveformUI.paintWaveForm(g, sObjVisibleHeight, waveData, 0);
g.translate(-1, -2);
}
Aggregations