Jibble

Author Topic: [FEATURE REQUEST]:More than 16 sound channels.  (Read 637 times)

Pajama Sam

  • Sam's The name
[FEATURE REQUEST]:More than 16 sound channels.
« on: 31 Dec 2021, 00:55 »
I kind of feel a little weird saying this since I already talked to Crimson Wizard about this but I didnt know where to ask him this. I noticed some music based game ideas never happen or are just not fully functional when made in ags.
For an example of why more than 16 channels are needed. I will give a story idea.
Supposing  a  game had a virtual piano that was controlled by keyboard input for every note.
If the user was to make a chord or play too fast before the channels freed up the game would crash.
I know the reason it isnt needed that much is because many channels at once would be an incoherent mess.
but with music this is different.Notes merge through channels to create music.
I dont know if there could be any other reason than this but you know the more room for creativity could make more room for new ideas.I know that this is a bit ridiculous to think about 20 or 30 channels but im just suggesting it. Even if not to be built into ags just a module or plugin would be plenty.
This may or may not have much of a use but I leave it up to you to think about it.

         
             -Pajama Sam
 
« Last Edit: 31 Dec 2021, 00:59 by Pajama Sam »

Crimson Wizard

  • Local Moderator
    • Lifetime Achievement Award Winner
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Crimson Wizard worked on one or more games that won an AGS Award!
    •  
    • Crimson Wizard worked on one or more games that was nominated for an AGS Award!
Re: [FEATURE REQUEST]:More than 16 sound channels.
« Reply #1 on: 31 Dec 2021, 01:13 »
I think that the number of channels is an issue in the first place because of how AGS system works: right now is made so that the channel always have a one individual clip bound to it, and also the script channel directly corresponds to the sound source object in the sound library we're using.

If this system was changed to something different, e.g. allowing multiple clip playbacks going into the same channel, then the channel number would be much less of an issue (or not at all). For example, the above case of piano simulation could be rather solved if there was a Sound Mixer API, where you could merge multiple sounds on the same output channel (guess the meaning of a "channel" would change also in such case).

So I believe that instead of keeping increasing sound channels in its current form, it might be more optimal to redesign the system into something that allows more flexibility with the sound.

There has been a topic opened couple of years back, but unfortunately everything is postponed:
https://www.adventuregamestudio.co.uk/forums/index.php?topic=56079.0


If the user was to make a chord or play too fast before the channels freed up the game would crash.

It should not crash, unless there's some mistake either in script or in the engine. Could you post an example of the game that crashes?
« Last Edit: 31 Dec 2021, 01:16 by Crimson Wizard »

Pajama Sam

  • Sam's The name
Re: [FEATURE REQUEST]:More than 16 sound channels.
« Reply #2 on: 31 Dec 2021, 01:31 »
How would I do that I dont have cloud storage or anything I dont even have a place like facebook.
also I cant get to the files right at this moment.
So all I can do is try to make up the script here since it is the very basic playing a sound when a key is pressed.

Code: Adventure Game Studio
  1.  
  2. if(IsKeyPressed(eKeyC))
  3. {
  4.     anoteC.Play();
  5. }
  6. if(IsKeyPressed(eKeyD))
  7. {
  8.     anoteD.Play();
  9. }
  10. if(IsKeyPressed(eKeyE))
  11. {
  12.     anoteE.Play();
  13. }
  14. And so on... in repeatedly execute
  15.  
I could very much be wrong in my thinking.
I didnt attempt this much because I could never get past the crashing when simply tapping the key faster than super slow.
The error assosiated with this is the invalid channel id error.
I could be very much wrong in my thinking.
It just seems that this should not crash the game.Unless if it was taking up the channels.
Do you know what this could be?

If this would take something major to fix it. Then I would be fine with just forgetting about it.

Quote
So I believe that instead of keeping increasing sound channels in its current form, it might be more optimal to redesign the system into something that allows more flexibility with the sound.

There has been a topic opened couple of years back, but unfortunately everything is postponed:
https://www.adventuregamestudio.co.uk/forums/index.php?topic=56079.0


Oh sorry I didnt see the rest of your post. I kind of thought that there must be a better sound system.
« Last Edit: 31 Dec 2021, 01:39 by Pajama Sam »

Crimson Wizard

  • Local Moderator
    • Lifetime Achievement Award Winner
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Crimson Wizard worked on one or more games that won an AGS Award!
    •  
    • Crimson Wizard worked on one or more games that was nominated for an AGS Award!
Re: [FEATURE REQUEST]:More than 16 sound channels.
« Reply #3 on: 31 Dec 2021, 01:40 »
Normally, if the audio type runs out of channels, then it either replaces one of the active sounds with the new one, or does not play a new one at all (this depends on clip priority setting).
Game crash would mean that something is wrong.

Regarding game upload, there is a number of free file host services, personally I know Dropbox, Mediafire and Google drive, but there should be many more.

Pajama Sam

  • Sam's The name
Re: [FEATURE REQUEST]:More than 16 sound channels.
« Reply #4 on: 31 Dec 2021, 01:59 »
I'm suprised! I didn't know those places were free.I should use that to backup my game.
As for the music game, I made many different attempts at a music game using sound and it always was the same thing.
After all those new game attempts I just deleted them because it was stored on someone else's computer.
The script wasn't anything different than what I showed you.But i'm sorry to say I don't have these examples anymore.
I do have one example left but that one is so confusing from my attempting to vary the pitch of one sound.
There is no use in looking at that game because looking for the problem would be like looking for a needle in a haystack.

I want to suggest making ags able to vary the pitch of a sound.Should I start a new topic or ask you here?
« Last Edit: 31 Dec 2021, 04:14 by Pajama Sam »

Pajama Sam

  • Sam's The name
Re: [FEATURE REQUEST]:More than 16 sound channels.
« Reply #5 on: 31 Dec 2021, 16:37 »
Okay I just remade the entire music game I had and now it doesnt crash.I must have been using an apha version of ags.The game does what you said. It only plays a sound if it has channels.Which is more of a reason to have more.With this simple script I was unable to play more than one note before the channels were full.
if you would like to see for yourself the game is right here.

https://www.mediafire.com/file/x8qy6clvy6yuib3/VP.zip/file

this link last for only 14 days.

Im sure that more channels on the ags sound system would be a problem so whatever happens is fine with me.
« Last Edit: 31 Dec 2021, 16:41 by Pajama Sam »

Snarky

  • Global Moderator
  • Global Moderator
  • Mittens Lord
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: [FEATURE REQUEST]:More than 16 sound channels.
« Reply #6 on: 31 Dec 2021, 17:53 »
With this simple script I was unable to play more than one note before the channels were full.

That's because you have coded it wrong. You have the code in repeatedly_execute(), which means that it runs (by default) 40 times per second. So if you press one key and keep it pressed for two tenths of a second, it will start playing 8 copies of the same audio clip, using up all the audio channels (or I guess half of them in the newest version). To make it work cleanly, you have to check whether the clip is already playing (or whether the keyboard key was already pressed last game cycle) before you start playing it again.

Pajama Sam

  • Sam's The name
Re: [FEATURE REQUEST]:More settings for audioclip
« Reply #7 on: 31 Dec 2021, 18:40 »
Now I see-
so you cant play a sound in repeatedly execute.
Then this wouldnt require more channels but a different script.
I can see that in the newest version 16 channels is plenty for anything as long as it isnt in repeatedly execute.

Now that that's solved I wanted to suggest a script that can modify a sound as the game is running.
Such as-

Code: Adventure Game Studio
  1. function object_AnyClick()
  2. {
  3.    Sound.Pitch=-or+ number;
  4. }
  5.  

or
Code: Adventure Game Studio
  1. function object_AnyClick()
  2. {
  3.    Sound.FadeIn=-or+ number;
  4.    Sound.FadeOut=-or+ number;
  5. }
  6.  

or
Code: Adventure Game Studio
  1. function object_AnyClick()
  2. {
  3.    Sound.Reverse=true;
  4. }
  5.  

Do you think these things could be useful in some way. Or is this already a module or plugin?
« Last Edit: 31 Dec 2021, 20:48 by Pajama Sam »

Crimson Wizard

  • Local Moderator
    • Lifetime Achievement Award Winner
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Crimson Wizard worked on one or more games that won an AGS Award!
    •  
    • Crimson Wizard worked on one or more games that was nominated for an AGS Award!
Re: [FEATURE REQUEST]:More than 16 sound channels.
« Reply #8 on: 01 Jan 2022, 06:31 »
In AGS currently the sounds are modified by accessing the channel they are played on.
At the moment it is possible to change Volume and Speed.

Here's the related articles in the manual:
https://adventuregamestudio.github.io/ags-manual/AudioChannel.html



so you cant play a sound in repeatedly execute.

You can, but if you do that unconditionally, then it will start over every game frame.
What Snarky said is that your script logic should be fixed, for example to not replay same sound until the previous instance has stopped.

EDIT: or, alternatively, you may play looping sound as Sound.Play(eAudioPriorityNormal, eRepeat), and stop it when the player releases the key.
« Last Edit: 01 Jan 2022, 07:03 by Crimson Wizard »