Looking plugin or behavior to access audio tags.

Post your work in progress addons and get feedback

Post » Tue Nov 01, 2016 9:03 pm

Hi, is there any plugin or audio behavior that allows access to all tags of the sounds being played at that time ?.

Suppose that X point in the game, I need to know the labels of the sounds in reproduction at that time, is there anything that allows this ?.

I have a sound that always being played in loop mode, sometimes other sounds are also played and then several sounds are heard at once.
Ok, I need to know when that sound is playing without any other sound more.
I mean, i need to know when the sound is unique sound playing without all others sounds.

So I think a plugin or a behavior that allows access to the labels of the sounds being played at that time could help this issue.
B
29
S
12
G
20
Posts: 756
Reputation: 13,855

Post » Wed Nov 02, 2016 5:03 am

Taken from the manual: https://www.scirra.com/manual/109/audio

Audio tags
Some actions affect audio parameters such as the volume for sounds which are already playing. However there can often be many sounds playing at once in a game. In order to identify which sounds you want to affect, sounds are played with an associated tag. This is any string that identifies the sound. For example, the player's weapon sound effect could be played with the tag "PlayerWeapon" and an enemy's weapon with the tag "EnemyWeapon". Then, the tag can be used in the Set Volume action to specify which sound to set the volume for. Tags are case insensitive.

Multiple sounds can also play at once using the same tag. In this case actions like Set Volume affect all the sounds playing with that tag.

A tag which is an empty string ("") has a special meaning: it refers only to the last sound played with the Play action. This is convenient for playing a sound and immediately setting its volume and other parameters

AUDIO CONDITION:
Is tag playing
True if any audio with a given tag is currently playing.
B
59
S
20
G
14
Posts: 779
Reputation: 13,857

Post » Wed Nov 02, 2016 6:38 am

Savvy001 wrote:Taken from the manual: https://www.scirra.com/manual/109/audio

Audio tags
Some actions affect audio parameters such as the volume for sounds which are already playing. However there can often be many sounds playing at once in a game. In order to identify which sounds you want to affect, sounds are played with an associated tag. This is any string that identifies the sound. For example, the player's weapon sound effect could be played with the tag "PlayerWeapon" and an enemy's weapon with the tag "EnemyWeapon". Then, the tag can be used in the Set Volume action to specify which sound to set the volume for. Tags are case insensitive.

Multiple sounds can also play at once using the same tag. In this case actions like Set Volume affect all the sounds playing with that tag.

A tag which is an empty string ("") has a special meaning: it refers only to the last sound played with the Play action. This is convenient for playing a sound and immediately setting its volume and other parameters

AUDIO CONDITION:
Is tag playing
True if any audio with a given tag is currently playing.


I read the manual, how do you think could solve my problem with that ?.
B
29
S
12
G
20
Posts: 756
Reputation: 13,855

Post » Wed Nov 02, 2016 7:09 am

You want to know which audio files are playing.. correct?

So when adding a "play audio" event you can set a tag for that specific audio file.
Then you can find out if that audio tag is playing using the condition: audio "tag" is playing.

Imagine using 1 tag for all audio files.
Than you can access all these audio files using that specific tag.
Set their volume.
Make stop playing.
Setting effects etc.

Example.
2 audio files playing use tag "gunshot".
1 audio file playing uses tag "bomb".

You can check audio: is "gunshot" playing-->set playback rate to 1.2

Etc.

Does this answer your question?
B
59
S
20
G
14
Posts: 779
Reputation: 13,857

Post » Wed Nov 02, 2016 8:16 am

Savvy001 wrote:You want to know which audio files are playing.. correct?

So when adding a "play audio" event you can set a tag for that specific audio file.
Then you can find out if that audio tag is playing using the condition: audio "tag" is playing.

Imagine using 1 tag for all audio files.
Than you can access all these audio files using that specific tag.
Set their volume.
Make stop playing.
Setting effects etc.

Example.
2 audio files playing use tag "gunshot".
1 audio file playing uses tag "bomb".

You can check audio: is "gunshot" playing-->set playback rate to 1.2

Etc.

Does this answer your question?


I understand but my problem is not that.

My sounds are played with a different label each, the name of the label is its file name.

File -> shotPlayer.ogg
tag -> "shotPlayer"

File -> enemyKilled.ogg
tag -> "enemyKilled"

etc...

I have a sound played in a loop throughout the game.
I need to know when you're playing that sound only and no more.

For what?.
When other sounds playing, then I must turn down the volume of the sound played in loop.
When no sound except the sound playing loop, then I must increase its volume.
B
29
S
12
G
20
Posts: 756
Reputation: 13,855

Post » Wed Nov 02, 2016 1:01 pm

Ah thats should be simple.
Make a variable, call it "allsounds".

Then add to each event where you play a sound other than loop.
On play: set variable to 1.
Else: set variable to 0.

Put the play "loop" event all the way at the bottom of the event sheet.
Let it check: If variable allsounds = 1
Set volume to low.
If variable allsounds = 0
Set volume to high.

Because the event sheet works from top to bottom you can do it this way.

All sounds are checked playing and if they dont play.
Then for each sound the "Else" event is triggered.
So it will be set to either 1 or 0.
Reaching the bottom of your event list then it checks if that variable is 0 or 1.

I hope i explained it simple.
B
59
S
20
G
14
Posts: 779
Reputation: 13,857

Post » Fri Nov 04, 2016 10:44 am

Savvy001 wrote:Ah thats should be simple.
Make a variable, call it "allsounds".

Then add to each event where you play a sound other than loop.
On play: set variable to 1.
Else: set variable to 0.

Put the play "loop" event all the way at the bottom of the event sheet.
Let it check: If variable allsounds = 1
Set volume to low.
If variable allsounds = 0
Set volume to high.

Because the event sheet works from top to bottom you can do it this way.

All sounds are checked playing and if they dont play.
Then for each sound the "Else" event is triggered.
So it will be set to either 1 or 0.
Reaching the bottom of your event list then it checks if that variable is 0 or 1.

I hope i explained it simple.


I have doubts about this system.
Could you make an example in this capx ?.

Maybe this that helps me understand if you system is valid for me.

https://dl.dropboxusercontent.com/u/60803633/testSound.capx

How to lower the volume of sound "bucleSound" when another sound is ringing ?.
Then, when there is no other sound reproduction, you must turn up the volume to "bucleSound".
B
29
S
12
G
20
Posts: 756
Reputation: 13,855

Post » Fri Nov 04, 2016 4:37 pm

I will take a look at it after work tonight.
B
59
S
20
G
14
Posts: 779
Reputation: 13,857

Post » Sat Nov 05, 2016 12:11 am

B
59
S
20
G
14
Posts: 779
Reputation: 13,857

Post » Mon Nov 07, 2016 2:09 am

@Mirlas
So have you checked it?
B
59
S
20
G
14
Posts: 779
Reputation: 13,857

Next

Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 0 guests