User Tag List

Results 1 to 5 of 5

Thread: Requst: Audio Channel Index Pointer

  1. #1
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Requst: Audio Channel Index Pointer

    Hi

    WHAT I WANT TO DO

    I have been trying to create some cool audio Panning effects for a game im working on.
    It would work by setting the Pan of a sample to -100 or 100 ( as it plays ) depending on how far it is from the center of the screen, like this:

    If Bomb collides with Ground
    - Play Sample BOOM
    - Set Pan of BOOM to BombX - ( FrameXright - FrameXleft )/2
    - Bomb destroy

    ...
    THE PROBLEM

    Problem is if multiple Bombs hit Ground making the BOOM Samples overlap, the 'Set Pan' action only ever referrs to the first Sample it finds in the Channel list ( 'Set Sample Volume' also works like this, maybe 'Set Sample Position' too ).

    So for example, if i drop 3 bombs across the screen ( 1 at the left side, 1 in the middle, 1 at the right side ), i would expect something like this:

    C#1: BOOM, Pan -100
    C#2: BOOM, Pan 0
    C#3: BOOM, Pan 100

    But istead, since the Set Pan of BOOM allways only referrs to the first BOOM Sample it can find, i end up with this:

    C#1: BOOM, Pan 100
    C#2: BOOM, Pan 0
    C#3: BOOM, Pan 0

    ...
    THE PROBLEM IN DETAIL

    In detail what happens is:

    FIRST BOMB
    If Bomb collides with Ground
    - Play Sample BOOM ( plays in first empty Channel, Channel#1 )
    - Set Pan of BOOM ( Sets Pan of first BOOM sample it finds in Channel list, sets pan of Channel#1 ), -100
    - Bomb destroy

    SECOND BOMB
    If Bomb collides with Ground
    - Play Sample BOOM ( plays in first empty Channel, Channel#2 )
    - Set Pan of BOOM ( Sets Pan of first BOOM sample it finds in Channel list, sets pan of Channel#1 ), 0
    - Bomb destroy

    THIRD BOMB
    If Bomb collides with Ground
    - Play Sample BOOM ( plays in first empty Channel, Channel#3 )
    - Set Pan of BOOM ( Sets Pan of first BOOM sample it finds in Channel list, sets pan of Channel#1 ), 100
    - Bomb destroy

    ...
    THE SOLUTION

    The solution for this is very simple in theory.
    What is needed is a 'Channel Index Pointer' which, as soon as a Sample plays, changes to the Channel# the Sample is played on.

    EXAMPLE A
    Lets take the Bomb example from above and see if this solution will get the job done:
    So for example, if i drop 3 bombs across the screen ( 1 at the left side, 1 in the middle, 1 at the right side )

    FIRST BOMB
    If Bomb collides with Ground
    - Play Sample BOOM ( plays in first empty Channel, Channel#1. 'Channel Index Pointer' is set to 1 )
    - Set Pan of Channel#<Channel Index Pointer value> ( Sets Pan of Channel#1 ), -100
    - Bomb destroy

    SECOND BOMB
    If Bomb collides with Ground
    - Play Sample BOOM ( plays in first empty Channel, Channel#2. 'Channel Index Pointer' is set to 2 )
    - Set Pan of Channel#<Channel Index Pointer value> ( Sets Pan of Channel#2 ), -100
    - Bomb destroy

    SECOND BOMB
    If Bomb collides with Ground
    - Play Sample BOOM ( plays in first empty Channel, Channel#3. 'Channel Index Pointer' is set to 3 )
    - Set Pan of Channel#<Channel Index Pointer value> ( Sets Pan of Channel#3 ), -100
    - Bomb destroy

    RESULTS
    C#1: BOOM, Pan -100
    C#2: BOOM, Pan 0
    C#3: BOOM, Pan 100

    Amazing , it works!

    ...
    EXAMPLE B
    With this 'Channel Index Pointer' solution, i can create 3 different Samples and Pan them correctly according to their origins in a single event

    Start of frame
    - Set Origin to -100
    - Play Sample BOOM
    - Set Pan of Channel#<Channel Index Pointer value> to Origin
    - Set Origin to 0
    - Play Sample BOOM
    - Set Pan of Channel#<Channel Index Pointer value> to Origin
    - Set Origin to 100
    - Play Sample BOOM
    - Set Pan of Channel#<Channel Index Pointer value> to Origin

    With a 'Channel Index Pointer' you are allways able to referr to the Sample being played, regradless of there being other Instances of the Smaple in play at the time.
    Remember, this also applies to and fixes same issues with 'Set Sample Volume' and 'Set Sample Position'.

    So what do you think?
    Im not expecting or demanding anything, but this cant be that hard to do right?

    As it is right now its impossible for me, and you, to create flawless consisten stereo panning in Apps or Games ( that is, if your design allows for multiple Sample Instances to play at the same time ) without going out of your way by creating your own or using alternative audio Objects/ Extencions/ Engines.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    King_Cool - I've not looked into stereo panning of sounds, but one solution might be to have multiple samples of Boom.wav, called Boom1.wav, Boom2.wav, Boom3.wav, etc and play them on the different channels. Obviously you'd need to cap how many sounds could be played.

  3. #3
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AyreGuitar View Post
    King_Cool - I've not looked into stereo panning of sounds, but one solution might be to have multiple samples of Boom.wav, called Boom1.wav, Boom2.wav, Boom3.wav, etc and play them on the different channels. Obviously you'd need to cap how many sounds could be played.
    I understand, but its still not very convenient

    DRAWBACKS
    - I need multiple identical Samples which take up unessesary space
    - In many situation this method is not a very good solution

    For example:
    Player has a rappid fire machinegun.
    There are 10 Enemies in the playfield.
    When Bullet hits Enemy, a IMPACT Sample is played.

    How many Bullets can potentially hit Enemies within a short time frame?
    How many different ( identical ) IMPACT Samples do i need?
    And what about other Samples which overlap, like Enemy Bullet Hits Player, or different ammunition types?

    I would need an arsenal of different ( identical ) Samples depending on the complexity of the Game.

  4. #4
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Francois's Avatar
    Join Date
    Jul 2006
    Location
    Montpellier, France
    Posts
    6,920
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    I agree the solution for now is to play the sounds on different channels, and set the pan to the channel, and you have what you want.

  5. #5
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I created the ACP consept using simple MMF2 code, its in the File Archive.
    http://community.clickteam.com/showthread.php?t=74037&p=545764#post545764

Similar Threads

  1. Replies: 3
    Last Post: 11th November 2012, 06:46 AM
  2. Multi-channel audio
    By Keith in forum XNA Export Module Version 2.0
    Replies: 2
    Last Post: 19th August 2012, 06:05 PM
  3. Replies: 2
    Last Post: 1st April 2010, 12:07 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
  •