|
|
Waveform Display Simulator Java code example - Click here to copy ->>>
Can't find what you're looking for? Try our search:
|
|
Really working examples categorized by API, package, class. You can compile and run our examples right away!
Not from source code for Java projects - only working examples! Copy, compile and run!
|
------------------
| Code: |
import javax.swing.*;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import java.awt.*;
import java.io.*;
public class WaveformDisplaySimulator {
public static void main(String[] args) {
try {
JFrame frame = new JFrame("Waveform Display Simulator");
frame.setBounds(200,200, 500, 350);
File file = new File(args[0]);
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new BufferedInputStream (new FileInputStream (file)));
WaveformPanelContainer container = new WaveformPanelContainer();
container.setAudioToDisplay(audioInputStream);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(container, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
frame.validate();
frame.repaint();
} catch (Exception e){
e.printStackTrace();
}
}
}
/* Swing Hacks
* Tips and Tools for Killer GUIs
* By Joshua Marinacci, Chris Adamson
* First Edition June 2005
* Series: Hacks
* ISBN: 0-596-00907-0
* http://www.oreilly.com/catalog/swinghks/
*/
|
| Code: |
import javax.swing.*;
import javax.sound.sampled.AudioInputStream;
import java.awt.*;
import java.util.ArrayList;
/**
* Created by IntelliJ IDEA.
* User: Jonathan Simon
* Date: Mar 20, 2005
* Time: 5:08:57 PM
* To change this template use File | Settings | File Templates.
*/
public class WaveformPanelContainer extends JPanel {
private ArrayList singleChannelWaveformPanels = new ArrayList();
private AudioInfo audioInfo = null;
public WaveformPanelContainer() {
setLayout(new GridLayout(0,1));
}
public void setAudioToDisplay(AudioInputStream audioInputStream){
singleChannelWaveformPanels = new ArrayList();
audioInfo = new AudioInfo(audioInputStream);
for (int t=0; t<audioInfo.getNumberOfChannels(); t++){
SingleWaveformPanel waveformPanel
= new SingleWaveformPanel(audioInfo, t);
singleChannelWaveformPanels.add(waveformPanel);
add(createChannelDisplay(waveformPanel, t));
}
}
private JComponent createChannelDisplay(SingleWaveformPanel waveformPanel, int index) {
JPanel panel = new JPanel(new BorderLayout());
panel.add(waveformPanel, BorderLayout.CENTER);
JLabel label = new JLabel("Channel " + ++index);
panel.add(label, BorderLayout.NORTH);
return panel;
}
}
/* Swing Hacks
* Tips and Tools for Killer GUIs
* By Joshua Marinacci, Chris Adamson
* First Edition June 2005
* Series: Hacks
* ISBN: 0-596-00907-0
* http://www.oreilly.com/catalog/swinghks/
*/
|
|
|
References.
The list of classes which were used on this page you can find below. The
links to Java API contain official SUN documentation about all used classes.
[ Go Back ]
|
|