Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 2 of 2 FirstFirst 12
Results 26 to 32 of 32

Thread: thread/timer/sound interaction

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: thread/timer/sound interaction

    That loop takes 13 seconds to execute. Why do you use that loop? What will the sound method do when called 54 times, one time immediately after the other?

    What happens if you remove the for loop and have a single call to the sound method in the run method?
    If you don't understand my answer, don't ignore it, ask a question.

  2. #27
    Junior Member
    Join Date
    May 2013
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: thread/timer/sound interaction

    How can do single call ?

  3. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: thread/timer/sound interaction

    Remove the for loop and replace the i in [i] with a valid value.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #29
    Junior Member
    Join Date
    May 2013
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: thread/timer/sound interaction

    I did like this and it removes problem this.sound60(freq[44],100,0.5);
    but i need to place into sound60 value of each element of array
    how can i do it ?

  5. #30
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: thread/timer/sound interaction

    i need to place into sound60 value of each element of array
    When do you want to use the other values in the array?
    The originally posted code used them all at once.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #31
    Junior Member
    Join Date
    May 2013
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: thread/timer/sound interaction

    thats what i want : use different frequency every n seconds , at least every 5 seconds (ideally every second )

  7. #32
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: thread/timer/sound interaction

    Put some logic in the loop in the run method to choose the next time to call the sound method so it is called at the desired times.
    Use class variables to hold information about it and to control it and be the index to the array.
    If you don't understand my answer, don't ignore it, ask a question.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. replacing thread with timer
    By hwoarang69 in forum What's Wrong With My Code?
    Replies: 11
    Last Post: December 3rd, 2012, 08:49 AM
  2. How to convert thread.sleep() into a timer in an Applet
    By all_pro in forum Java Theory & Questions
    Replies: 2
    Last Post: April 14th, 2011, 07:45 AM
  3. Thread Sleep, Timer, Button Question
    By tabutcher in forum Java Theory & Questions
    Replies: 1
    Last Post: May 1st, 2010, 02:54 AM
  4. Thread/timer problem
    By korbal in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 18th, 2010, 05:59 PM
  5. need help with Timer and sound
    By amahara in forum AWT / Java Swing
    Replies: 4
    Last Post: February 18th, 2010, 12:22 PM

Tags for this Thread