Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: sound gets out of time

Reply
Thread Tools

Re: sound gets out of time

 
 
active_ksa@msn.com
Guest
Posts: n/a
 
      07-23-2003
"webster" <> wrote in message news:<aKmTa.9169$>...
> I have a program that plays drum samples. The problem is when i select 2
> check boxes close together it gets out of time a bit. I was just wondering
> if there is a way of overcoming this? Some body has told me that i cant fix
> it cos that's just what java does. I have included a sample of my program so
> you can see what I'm on about.
> thanks
> matt
>
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> import java.applet.*;
> import java.net.*;
> public class TBtest extends JFrame implements ActionListener{
> JCheckBox box1,box2,box3,box4;
> JButton play;
> public TBtest(){
> super("Test for sound using tickBox and button");
> setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> setSize(200,100);
> setVisible(true);
> Container contentArea = getContentPane();
> contentArea.setLayout(new FlowLayout());
> box1 = new JCheckBox();
> box2 = new JCheckBox();
> box3 = new JCheckBox();
> box4 = new JCheckBox();
> play = new JButton("play");
> play.addActionListener(this);
> contentArea.add(box1);
> contentArea.add(box2);
> contentArea.add(box3);
> contentArea.add(box4);
> contentArea.add(play);
> setContentPane(contentArea);
> }
> void pause(int duration) {
> try {
> Thread.sleep(duration);
> }catch (InterruptedException e) {}
> }
> public void actionPerformed(ActionEvent event) {
> String command = event.getActionCommand();
> if(event.getSource() == play)
> { try
> { URL Basefile = new URL("file:base.wav");
> AudioClip Base = JApplet.newAudioClip(Basefile);
> URL Snarefile = new URL("file:snare.wav");
> AudioClip Snare = JApplet.newAudioClip(Snarefile);
> if (box1.isSelected())
> Base.play();
> if (box2.isSelected())
> Snare.play();
> pause(800);
> if (box3.isSelected())
> Base.play();
> if (box4.isSelected())
> Snare.play();
> }
> catch (MalformedURLException error) {}
> }
> }
> public static void main(String[] args)
> {TBtest Drum = new TBtest();}
> }

it is easy
 
Reply With Quote
 
 
 
 
webster
Guest
Posts: n/a
 
      07-23-2003
what does "it is easy" mean does that mean you know the answer to my
problem?
<> wrote in message
news: om...
> "webster" <> wrote in message

news:<aKmTa.9169$>...
> > I have a program that plays drum samples. The problem is when i select 2
> > check boxes close together it gets out of time a bit. I was just

wondering
> > if there is a way of overcoming this? Some body has told me that i cant

fix
> > it cos that's just what java does. I have included a sample of my

program so
> > you can see what I'm on about.
> > thanks
> > matt
> >
> > import java.awt.*;
> > import java.awt.event.*;
> > import javax.swing.*;
> > import java.applet.*;
> > import java.net.*;
> > public class TBtest extends JFrame implements ActionListener{
> > JCheckBox box1,box2,box3,box4;
> > JButton play;
> > public TBtest(){
> > super("Test for sound using tickBox and button");
> > setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> > setSize(200,100);
> > setVisible(true);
> > Container contentArea = getContentPane();
> > contentArea.setLayout(new FlowLayout());
> > box1 = new JCheckBox();
> > box2 = new JCheckBox();
> > box3 = new JCheckBox();
> > box4 = new JCheckBox();
> > play = new JButton("play");
> > play.addActionListener(this);
> > contentArea.add(box1);
> > contentArea.add(box2);
> > contentArea.add(box3);
> > contentArea.add(box4);
> > contentArea.add(play);
> > setContentPane(contentArea);
> > }
> > void pause(int duration) {
> > try {
> > Thread.sleep(duration);
> > }catch (InterruptedException e) {}
> > }
> > public void actionPerformed(ActionEvent event) {
> > String command = event.getActionCommand();
> > if(event.getSource() == play)
> > { try
> > { URL Basefile = new URL("file:base.wav");
> > AudioClip Base = JApplet.newAudioClip(Basefile);
> > URL Snarefile = new URL("file:snare.wav");
> > AudioClip Snare = JApplet.newAudioClip(Snarefile);
> > if (box1.isSelected())
> > Base.play();
> > if (box2.isSelected())
> > Snare.play();
> > pause(800);
> > if (box3.isSelected())
> > Base.play();
> > if (box4.isSelected())
> > Snare.play();
> > }
> > catch (MalformedURLException error) {}
> > }
> > }
> > public static void main(String[] args)
> > {TBtest Drum = new TBtest();}
> > }

> it is easy



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return of gets gets John Joyce Ruby 0 04-23-2007 01:38 PM
gets gets John Joyce Ruby 2 03-26-2007 04:00 PM
XMLHttpRequest gets data to display in element but data gets appended not replaces previous! libsfan01 Javascript 5 12-20-2006 06:25 AM
Not only the selected HREF gets surrounded, but the whole row gets surrounded Stefan Mueller HTML 5 07-10-2006 11:53 AM
Incoming e mail gets time out John Goodliffe Computer Support 3 01-22-2004 01:15 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57