Page 5 of 5

Re: [WIP] Forge Sound System

PostPosted: 23 Nov 2012, 15:40
by Agetian
Well, actually, I'm done. :) All sounds use the event bus model now and are not called directly. Many events came out to be empty for now, I mean, the sound system doesn't need any specifics... Feel free to expand/merge as necessary.

P.S. Seems to work as expected thus far, though I could have accidentally broken something. ;)

- Agetian

Re: [WIP] Forge Sound System

PostPosted: 23 Nov 2012, 19:53
by Max mtg
Agetian wrote:Well, actually, I'm done. :) All sounds use the event bus model now and are not called directly. Many events came out to be empty for now, I mean, the sound system doesn't need any specifics... Feel free to expand/merge as necessary.
I think you did a great job!

Re: [WIP] Forge Sound System

PostPosted: 24 Nov 2012, 02:14
by Agetian
Thanks a lot, I appreciate your feedback!

- Agetian

Re: [WIP] Forge Sound System

PostPosted: 24 Nov 2012, 15:10
by Agetian
I added two new sounds to the list of sounds supported by Forge: Block (when a blocker is assigned - "block.wav") and Token (when a token is created - "token.wav").

- Agetian

Re: [WIP] Forge Sound System

PostPosted: 10 Dec 2012, 07:15
by Agetian
OK, I have a question about implementation strategy... I'm working on implementing customizable sound effects via a card script SVar "SoundEffect". However, that brings up an important point because the enumeration SoundEffectType is a finite thing, so it's impossible to dynamically add a new enumeration element or to spawn any instances of SoundEffectType that are not elements of the enumeration.

I thought of using the getCardSpecialEffect method in EventVisualizer to play that back, but that's a part of EventVisualizer, not a part of SoundSystem, so I thought it might be a bad idea to play sounds directly from there. Anyhow, here's the code I currently have in mind:

Code: Select all
    private static boolean getSpecificCardEffect(final Card c) {
        if (null != c) {
            String effect = c.getSVar("SoundEffect");
            if (!effect.isEmpty()) {
                AudioClip specialClip = new AudioClip(effect);
                if (specialClip != null) {
                    specialClip.play();
                }
                return true;
            }
        }
        return false;
    }
I think this kind of breaks the purpose of EventVisualizer to abstract from direct calls to the sound system; however, just putting this code into SoundSystem as e.g.:

Code: Select all
    public boolean play(String resourceName) {
        if (!resourceName.isEmpty()) {
            AudioClip specialClip = new AudioClip(resourceName);
            if (specialClip != null) {
                specialClip.play();
                return true;
            }
        }
        return false;
    }
Also won't work because in that case, a dependency will have to be introduced between EventVisualizer and SoundSystem, which, once again, will defeat the original purpose of abstraction.

I'm ready to listen to your suggestions, because, honestly, I'm out of any good ones.

- Agetian

Re: [WIP] Forge Sound System

PostPosted: 10 Dec 2012, 09:27
by Agetian
UPDATE: found a (rather indirect) way of plugging in card-specific sounds without ruining the autonomous character of EventVisualizer and the event bus in general as independent entities from the SoundSystem class. Probably can be optimized in many ways, so suggestions are still highly welcome. Otherwise, the card-specific sound effects are now supported via the SoundEffect SVar. For example, if a card has a SVar specified like this:

Code: Select all
SVar:SoundEffect:my_sound.wav
then, when the card is played, the sound system will try to play back "res/sound/my_sound.wav" if it exists. If it doesn't exist, no sound will be played.
If the SVar:SoundEffect is not specified in a card script, the default sound will be played as usual.

- Agetian

Re: [WIP] Forge Sound System

PostPosted: 10 Dec 2012, 11:51
by Max mtg
Writing from a mobile phone,
Just to don't mix up the game with visualization, I suggest getting that svar value right in visualizer. It's the client - it recieved an event like "card Tezzeret has entered play" and decides how to show it to player.

Will review this thread from computer later

Re: [WIP] Forge Sound System

PostPosted: 10 Dec 2012, 15:32
by Agetian
Oh, OK. Yeah, that's where it's currently taken (the SVar is taken in the visualizer). It's just that my current implementation seems unnecessarily complex, I think there should be a simpler, more elegant and effective solution but it eludes me at the moment... Thanks for your suggestions so far!

- Agetian

Re: [WIP] Forge Sound System

PostPosted: 26 Jan 2013, 21:39
by Rob Cashwalker
I was just playing a couple rounds for the first time in a while. I only heard sound for the first time an event occurred, like playing a land, or artifact.. none afterwards.

Edit - built a jar instead of playing from eclipse, and it worked OK.