Adding audio - is there a better way?

scottwoodscottwood Member, PRO Posts: 68

I have a quiz game and want to add audio to the questions. At present, I have an image and some text that appear for each question. I'd also like a different audio clip to play for each question.
I believe there is currently no way to select audio with an expression.

To workaround this I am contemplating adding an actor for every audio to the scene. Each actor could potentially play their audio clip when clicked on. I can then adjust the position of the actor to show and be available to touch/play according to the value in a table on the same row as the table cell used to decide which question is being used.

Doing this won't be a problem, but it seems dreadfully inefficient. I'm concerned that every audio file will need to be loaded so the game will be very slow if there are a lot of questions. However, it may be that all the audio files are loaded into the client memory anyway, as soon as the game is started.

Do you have an insight into any of this or know of a better way of approaching the problem?

Comments

  • awesome_wellsawesome_wells Member, PRO Posts: 38

    Hi @scottwood,

    You could create a global real variable (e.g. Playsound) linked to the question number, and the create an actor that contains all the rules to play the desired sound. For example:

    If Playsound = 1 then Play Sound 'A'
    If Playsound = 2 then Play Sound 'B' ..etc.

    Paste that actor invisibly in to all Scenes and at least you only have to create the rules once.

    Hope that helps!

  • ArmellineArmelline Member, PRO Posts: 5,364

    I've recently been doing a project with a ton of audio. A slightly different problem to what you're facing, as I needed to find ways of efficiently playing a lot of audio files very quickly and as many as 5 or 6 at once. GS struggles with this, but it can be done. The two things I found most beneficial were:

    1. Convert all audio files to CAF files. This increases the project file size, but makes them load more quickly, both with the initial load and when each sound is played.

    2. Have only 1 audio file be played by a single actor at a time. I needed to play, for example, three audio files all at the same time, and having three actors each playing one file each gave me far better results than having one actor play all three. Each actor has dozens of nested rules to select which audio file plays, so I'm not using 1 actor per sound, but rather 1 actor per type of sound.

    However, working with lots of audio in GS is always inefficient. Not too much that can be done about that, though!

  • scottwoodscottwood Member, PRO Posts: 68

    Thanks for your help. @awesome_wells that’s such a good idea, I’ll definitely try it out. Far better than having loads of separate actors. Shame we can’t use tables for this like we can with images. Thanks for the tip about using CAF files @Armelline, I’d never heard of them.

Sign In or Register to comment.