Search in sources :

Example 1 with AudioWaveformData

use of blue.ui.utilities.audio.AudioWaveformData 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)1 AudioWaveformData (blue.ui.utilities.audio.AudioWaveformData)1 AudioWaveformListener (blue.ui.utilities.audio.AudioWaveformListener)1