User Tag List

Results 1 to 8 of 8

Thread: Random sound

  1. #1
    No Products Registered

    Join Date
    Oct 2007
    Location
    Norway, Oslo
    Posts
    379
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Random sound

    Is it possible to get a random sound when I pick up an object? And how can I do it?

  2. #2
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export ModuleUnicode Add-on

    Join Date
    Jun 2006
    Location
    Australia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random sound

    One way of doing it is to use a random value for a counter or alterable value. Then have an event for each different value of the counter to play a different sample Eg:

    Play picks up an object > Set counter to random(3)+1

    If counter = 1
    Then
    Play sample 1, set counter to -1

    If counter = 2
    Then
    Play sample 2, set counter to -1

    If counter = 3
    Then
    Play sample 3, set counter to -1

  3. #3
    No Products Registered

    Join Date
    Oct 2007
    Location
    Norway, Oslo
    Posts
    379
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random sound

    Thank you!

    I can also set the event "Only one action when event loop" instead of set counter to -1

  4. #4
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random sound

    This is one of the areas where I'd really love to see MMF2 improve a bit; playing samples or creating objects using expressions.

    I can also set the event "Only one action when event loop" instead of set counter to -1 \:\)
    Nope, that won't work; you won't hear a sound if the same random number is generated again.

    Play picks up an object > Set counter to random(3)+1

    If counter = 1
    Then
    Play sample 1, set counter to -1

    If counter = 2
    Then
    Play sample 2, set counter to -1

    If counter = 3
    Then
    Play sample 3, set counter to -1
    If more sounds are involved I'd personally set it up like this instead (it's worth having an extra condition to save an extra action per each "play sample" event):

    Play picks up an object > Set counter to random(4)+1
    If counter = 1 then play sample 1
    If counter = 2 then play sample 2
    If counter = 3 then play sample 3
    If counter = 4 then play sample 4
    If counter > 0 then set counter to 0

  5. #5
    No Products Registered

    Join Date
    Oct 2007
    Location
    Norway, Oslo
    Posts
    379
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random sound

    I can also set the event "Only one action when event loop" instead of set counter to -1 \:\)
    Nope, that won't work; you won't hear a sound if the same random number is generated again.


    Ok. Try to do this.
    +Start of frame
    -Set counter to Random(3)+1

    +Counter=1
    +Only one action when event loop
    -Play sample 1


    +Counter=2
    +Only one action when event loop
    -Play sample 2


    +Counter=3
    +Only one action when event loop
    -Play sample 3

    This will for example play a random song at the start of frame.
    And it's working.

  6. #6
    No Products Registered

    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    1,141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random sound

    But it still won't work correctly if you trigger it more than once...

  7. #7
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random sound

    The emphasis in what I said was on the second part ("...if the same random number is generated again"). If you perform your events at start of frame, of course it will work. However, try to do it once every second or whenever you press space bar, and hear the silence the second time the same random number is generated.

  8. #8
    No Products Registered

    Join Date
    Oct 2007
    Location
    Norway, Oslo
    Posts
    379
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random sound

    Nifflas: I don't think I need to try it, because I know that it won't work. And both of you have right.

    I have had some problems with the sound when I pick up for example a coin. Or the sound when I'm falling.
    I fixed it with "Only one action when event loop" The problem is when I have a random sound on that coin or when I'm falling. Then I can't use "Only one action when event loop". I haven't tried this with random sound on an object I pick up yet. I will come back later if it's working or not working.

Similar Threads

  1. Random Active Spawn in Random Location in Frame
    By Top_of_the_Temple in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 20th October 2016, 03:33 AM
  2. Random Sound Player
    By FlinkGigitty in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 21st June 2013, 11:35 AM
  3. How can I pick a random sound???
    By Oliver in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 5th October 2011, 05:03 PM
  4. Random Speed + Ypos at random times
    By Keehan in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 14th May 2011, 05:25 PM
  5. Sound array? alternative to random sound?
    By gen in forum SWF/Flash Export Module Version 2.0
    Replies: 1
    Last Post: 28th April 2011, 06:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •