Search in sources :

Example 1 with AudioFile

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);
        }
    }
}
Also used : AudioFile(blue.soundObject.AudioFile) SoundObject(blue.soundObject.SoundObject) PolyObject(blue.soundObject.PolyObject)

Example 2 with AudioFile

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;
    }
}
Also used : AudioFormat(javax.sound.sampled.AudioFormat) AudioFile(blue.soundObject.AudioFile) File(java.io.File) AudioFileFormat(javax.sound.sampled.AudioFileFormat)

Example 3 with AudioFile

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());
}
Also used : AudioFile(blue.soundObject.AudioFile) AudioFile(blue.soundObject.AudioFile) File(java.io.File)

Example 4 with 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);
        }
    }
}
Also used : AudioFile(blue.soundObject.AudioFile) SoundObject(blue.soundObject.SoundObject) PolyObject(blue.soundObject.PolyObject)

Example 5 with AudioFile

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);
}
Also used : AudioFile(blue.soundObject.AudioFile) AudioWaveformData(blue.ui.utilities.audio.AudioWaveformData) AudioWaveformListener(blue.ui.utilities.audio.AudioWaveformListener)

Aggregations

AudioFile (blue.soundObject.AudioFile)6 PolyObject (blue.soundObject.PolyObject)3 File (java.io.File)3 SoundObject (blue.soundObject.SoundObject)2 AudioWaveformData (blue.ui.utilities.audio.AudioWaveformData)1 AudioWaveformListener (blue.ui.utilities.audio.AudioWaveformListener)1 Point (java.awt.Point)1 Transferable (java.awt.datatransfer.Transferable)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 IOException (java.io.IOException)1 List (java.util.List)1 AudioFileFormat (javax.sound.sampled.AudioFileFormat)1 AudioFormat (javax.sound.sampled.AudioFormat)1 UnsupportedAudioFileException (javax.sound.sampled.UnsupportedAudioFileException)1