[WIP] Forge Sound System
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Re: [WIP] Forge Sound System
by Agetian » 23 Nov 2012, 15:40
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

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

- Agetian
- Agetian
- Programmer
- Posts: 3486
- Joined: 14 Mar 2011, 05:58
- Has thanked: 683 times
- Been thanked: 568 times
Re: [WIP] Forge Sound System
by Max mtg » 23 Nov 2012, 19:53
I think you did a great job!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.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: [WIP] Forge Sound System
by Agetian » 24 Nov 2012, 02:14
Thanks a lot, I appreciate your feedback!
- Agetian
- Agetian
- Agetian
- Programmer
- Posts: 3486
- Joined: 14 Mar 2011, 05:58
- Has thanked: 683 times
- Been thanked: 568 times
Re: [WIP] Forge Sound System
by Agetian » 24 Nov 2012, 15:10
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
- Agetian
- Agetian
- Programmer
- Posts: 3486
- Joined: 14 Mar 2011, 05:58
- Has thanked: 683 times
- Been thanked: 568 times
Re: [WIP] Forge Sound System
by Agetian » 10 Dec 2012, 07:15
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:
I'm ready to listen to your suggestions, because, honestly, I'm out of any good ones.
- Agetian
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;
}
- 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;
}
I'm ready to listen to your suggestions, because, honestly, I'm out of any good ones.
- Agetian
- Agetian
- Programmer
- Posts: 3486
- Joined: 14 Mar 2011, 05:58
- Has thanked: 683 times
- Been thanked: 568 times
Re: [WIP] Forge Sound System
by Agetian » 10 Dec 2012, 09:27
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:
If the SVar:SoundEffect is not specified in a card script, the default sound will be played as usual.
- Agetian
- Code: Select all
SVar:SoundEffect:my_sound.wav
If the SVar:SoundEffect is not specified in a card script, the default sound will be played as usual.
- Agetian
- Agetian
- Programmer
- Posts: 3486
- Joined: 14 Mar 2011, 05:58
- Has thanked: 683 times
- Been thanked: 568 times
Re: [WIP] Forge Sound System
by Max mtg » 10 Dec 2012, 11:51
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
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
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: [WIP] Forge Sound System
by Agetian » 10 Dec 2012, 15:32
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
- Agetian
- Agetian
- Programmer
- Posts: 3486
- Joined: 14 Mar 2011, 05:58
- Has thanked: 683 times
- Been thanked: 568 times
Re: [WIP] Forge Sound System
by Rob Cashwalker » 26 Jan 2013, 21:39
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.
Edit - built a jar instead of playing from eclipse, and it worked OK.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
69 posts
• Page 5 of 5 • 1, 2, 3, 4, 5
Who is online
Users browsing this forum: No registered users and 42 guests