Page 1 of 5
[WIP] Forge Sound System

Posted:
09 Nov 2012, 08:48
by Agetian
As I'm getting closer and closer to implementing the ChooseSource AF for Circles of Protection (which is my current dev target), I'm thinking about my next developer goals and I have an idea in mind that I'd like to discuss with you before I decide to either go for it or not go for it.
I'm not sure if anyone was ever interested in implementing sound in Forge (by the presence of a file "tap.mp3" I assume that such attempts have been made in the past), but it's something that I might be interested in and something I believe I may be able to tackle. If I decide to go for it, my priorities will be:
1. The sound system must be cross-platform and must not impose a serious overhead in the department of referenced libraries, so I'll try to stick to the standard sound API which is a part of JDK.
2. The sound system must be non-blocking, so that the interface must not wait for the sound events to finish etc. In a sense (the way I see it) it might be somewhat similar to the system of sound effects employed e.g. in Microprose's MTG Shandalar.
This, however, raises a couple potential questions:
1. Is there any base for the custom sound effects that may be utilized for Forge? We'll need to either find someone who can come up with sound effects, or use some royalty free sound effect package that will work for us and that may be legitimately used as a part of Forge without any licensing issues.
2. Is there any principal reason why the previous efforts in the sound department, assuming that they were undertaken before, were either canceled or failed? I mean, if the architecture of Forge does not play well (pun unintended) with the JDK sound API, then it's best to know it now and see if these problems can potentially be resolved or are too difficult to tackle.
Your opinions are more than welcome.
Remember, at this moment it's more of an idea than an exact declaration of a developer target. However, once I finish my current Forge plans, I'll officially notify everyone if I'm taking this project or not.
- Agetian
Re: Possible Project: Sound in Forge

Posted:
09 Nov 2012, 09:39
by Hellfish
IIRC, sound was removed because of heap space problems. Could be wrong though, it was a LONG time ago.
Public domain sound effects should be available for our needs.
Re: Possible Project: Sound in Forge

Posted:
09 Nov 2012, 11:25
by Chris H.
Hellfish wrote:IIRC, sound was removed because of heap space problems. Could be wrong though, it was a LONG time ago.
The library used would create a new sound object each time that the sound was played and this in turn caused the java heap space problems. I seem to remember Dennis commenting on this a few years ago.
Re: Possible Project: Sound in Forge

Posted:
09 Nov 2012, 12:41
by Agetian
Oh I see, I'll probably do a little research on whether it's possible to do it in a more optimal way so that it won't cause heap issues.
- Agetian
Re: Possible Project: Sound in Forge

Posted:
09 Nov 2012, 13:36
by sollecus11
Just dropped in to say this is a fantastic idea! It'd bring an even deeper level of immersion to the game as a whole. Many regular users, like myself, would be much appreciated if such an accomplishment was made.I hope you manage to sort it out and eventually undertake it.

Best wishes.
Re: Possible Project: Sound in Forge

Posted:
09 Nov 2012, 13:51
by Agetian
sollecus11 wrote:Just dropped in to say this is a fantastic idea! It'd bring an even deeper level of immersion to the game as a whole. Many regular users, like myself, would be much appreciated if such an accomplishment was made.I hope you manage to sort it out and eventually undertake it.

Best wishes.
Thanks for the kind words, I appreciate your interest! I'll definitely look into this problem.
- Agetian
Re: Possible Project: Sound in Forge

Posted:
09 Nov 2012, 15:28
by Diogenes
Heh, I got carried away and just kept writing. My opinion is that Forge is better off without sound, but it's always awesome to see you guys wanting to make it better and willing to work at it. I'm sure if you go for it you'll figure it out.

Anyway, my long sleep-deprived rant is preserved below for anyone who's curious. It was fun writing it (although I got a bit carried away) so I'd feel bad deleting it outright.
- My Long Rant About Sound | Open
- Sorry for jumping in here. It seems like sound hasn't been a top priority for any of the developers, or it would have been added somehow by now, but I haven't really seen a discussion over the costs and benefits (both technical and aesthetic) to adding audio. It's my opinion that Forge is actually much better off with no sound at all, but I really don't want to discourage or clash with anyone who feels the opposite way. I'll just make the case briefly, and if it doesn't sway anyone that's fine. All I'd ask for as a user is that audio (including system sounds) remains entirely optional.
First off, I don't see Forge as a video game per se, and while there might be some shared territory (the interface and menu selections, Quest Mode, etc.), bringing it closer in line to video game conventions might be an impulse worth resisting.
On a practical level, there are several Magic engines that are very game-like (DotP, the Microprose engine that's currently fan-supported, even the official online client in a lot of ways with its leaderboards and events.) One thing I like about Forge is that it's distinct from these in that it simulates the rules (and wonkishness) of the card game first and foremost, and it doesn't have a lavish "multimedia experience" through which it wants to channel the user. I like the purity, and I don't think Forge has to (or should) compete with every other program out there. I'm not really claiming that sound effects are the edge of a slippery slope, but lacking sound firmly and effectively plants Forge into the "enthusiast simulator" category.
As a simulator, sound is unnecessary. First, it adds a non-canon element to the experience. Second, there is no need for audio cues to impart information to the user, and in fact the current visual and textual system does a better job than audio events could anyway. Little clicks announcing UI selections are omnipresent both in games and applications, so I wouldn't exactly call it cruft or feature-creep, but I don't think playing towards this familiarity would benefit the user experience enough to add an aural element to an otherwise silent game. I appreciate how most backgammon engines provide the rattle of rolling dice and men clacking solidly onto the board. A "ding" confirming that you've played a creature is not a part of the paper card game experience.
Aesthetically, I don't view it as "building immersion" but rather intruding on the silent, cerebral layer of a game of Magic. It would annoy me if a chess engine played the sound of clashing swords for every capture, and (granted this is not the direction anyone probably intends) I found it very grating in Wagic that every time one of my creatures attacked there was a generic goblinoid battle-hiss. The only diegetic sound around a game of Magic is the conversation and exclamations of the players (I guess you could count the sound of shuffling, and the little slap of an energetically layed-down card, but if those were the only inclusions I'd find them superficial and turn them off as well.)
I also think that the silence of the cards underneath the table-talk is what makes the art and flavor satisfying. Magic is a very visual experience, and the concept of closure is what makes it all work. With a card like Giant Growth, you get the impression of a creature suddenly ballooned to ridiculous proportions and the havoc it's about to impart. With Murder or Assassinate, you see the immediate aftermath of a gruesome killing. The stillness of it is what lets your mind anchor to that one moment and fill in the gaps before and after. Even something relatively abstract, like a trumpet-flare when an attack is declared, would to me seem a weird and generic intrusion on the mental images I get to enjoy when I send my rag-tag coalition of little robotic men and broad-winged angels barreling into a world-eating monstrosity (and just imagine it the other way around.)
Anyway, I got a little pumped up there and I don't have the time to edit this down right now. Sorry.
In short, I don't think system sounds would offend anyone, but I also don't think they'd really add much. I feel the same way about in-game sounds that are simply meant to attract notice that something has happened (a card has been played, or a phase has changed, etc. - I'm already paying attention.) Representative sounds, though, I'm very much against (explosions and death-rattles and the like) because I think they ruin the feel of the game. At the moment, I very much like putting on some music and enjoying the combat of little mental abstractions in my imagination, and that's probably how I'd keep using Forge after sound effects made their way in.
That said, it's quite likely if someone did add sounds that built on Forge's UI identity, I'd probably grow to love them (as long as I can turn off the screaming of a 1000 elf tokens incinerated by an Electrickery.) 
Re: Possible Project: Sound in Forge

Posted:
09 Nov 2012, 15:31
by Agetian
Well, personally I think that as long as it's optional (as in "you can turn it off if you want to"), it can be a good thing for both worlds - those people who like sound can keep it on, those who don't like it can turn it off and forget that it exists.

- Agetian
Re: Possible Project: Sound in Forge

Posted:
09 Nov 2012, 15:39
by Diogenes
Agetian wrote:Well, personally I think that as long as it's optional (as in "you can turn it off if you want to"), it can be a good thing for both worlds - those people who like sound can keep it on, those who don't like it can turn it off and forget that it exists.

- Agetian
I'd be happy with that. I just hope I didn't come across as too pushy, I can get a bit carried away in my "argumentative" mode.

That said, if you give it a go, good luck! I can't do much more to help than report bugs, but if you do give it a try and want someone to do some targeted testing, just let me know.
Re: Possible Project: Sound in Forge

Posted:
09 Nov 2012, 15:41
by Agetian
Not at all, don't worry, constructive criticism is always welcome! Also, it's important to know what opinions exist about different potential features. Thanks for offering to help, too, we'll see if anything works out of this project!

- Agetian
Re: Possible Project: Sound in Forge

Posted:
09 Nov 2012, 15:44
by friarsol
While we're having some fun on the topic...
Diogenes wrote:As a simulator, sound is unnecessary. First, it adds a non-canon element to the experience.
You don't play against people who make spaceship attack noises when the attack. "I attack with my
Shivan Dragon, *pew pew*"
But seriously, as Agetian says, this is definitely an "Enable Sounds Preference" scenario, where people who don't want it, don't have to have it.
Re: Possible Project: Sound in Forge

Posted:
09 Nov 2012, 15:58
by Diogenes
friarsol wrote:While we're having some fun on the topic...
Diogenes wrote:As a simulator, sound is unnecessary. First, it adds a non-canon element to the experience.
You don't play against people who make spaceship attack noises when the attack. "I attack with my
Shivan Dragon, *pew pew*"
In my defense, your honor, I added this further on:
My Long Rant About Sound wrote:The only diegetic sound around a game of Magic is the conversation and exclamations of the players
I submit that, as a player, I am including my
own pew-pews as already being an integral component of Forge's soundtrack!
friarsol wrote:But seriously, as Agetian says, this is definitely an "Enable Sounds Preference" scenario, where people who don't want it, don't have to have it.
I'm starting to feel a little worried that I'll be remembered for this as "the guy who hates the people who put sound into Forge". It's not on my own personal wishlist, but I really am totally cool if Agetian (or anyone else) finds a way to put it in.
PS - if there is a sound clip for a declared attack, it really should be stored as pewpew.wav.
Re: Possible Project: Sound in Forge

Posted:
09 Nov 2012, 16:15
by Max mtg
Will that sound effects be similiar to what we have seen in Magic online?
Re: Possible Project: Sound in Forge

Posted:
09 Nov 2012, 16:59
by Agetian
Yeah, basically yes. Or MTG Shandalar.

- Agetian
Re: [WIP] Forge Sound System

Posted:
11 Nov 2012, 15:00
by Agetian
OK, I just committed the initial implementation of the sound playback system to SVN. Currently, it's not linked to anything else in the code, so no sounds will play yet. However, the sound system is fully tested and confirmed to be working as desired. In particular:
1) It is non-blocking, so you don't need to wait for the sound playback to finish for the UI to respond. Multiple sounds are allowed in quick succession, even before the first sound has finished.
2) It does not leak memory in any fashion - the sounds are only preloaded once when Forge starts, and then they can be played at any time via a public enum Sounds interface. That reuses the same sound loaded into memory, so no new objects are created upon playback.
3) It is cross-platform, it only uses javax.sound.sampled.* (the standard JDK API) and no third party libraries.
4) It supports WAV and AU file formats.
5) Not having a listed file in the directory is not considered a fatal error (in that case, no sound will be played, and Forge won't crash, a message will be generated on the debug console though), this is done in the interest of people who may not be interested in downloading separate sound packs for Forge (who like Forge with no sounds, as it is) - yep, it means that those of you who don't like the idea of sound in Forge won't have to notice any change whatsoever, you don't need to download the sound files and there won't be any other increase in size because all the code is 100% standard JDK stuff.
There's a little problem (almost non-noticeable) with a possibility of a sound "dropping off" in case many instances of the same sound are played in a very quick succession before each of them has a chance of finishing playback, I'm looking into it but even the way it is it's hardly noticeable (probably not noticeable, actually) under normal playing conditions.
I have several questions:
1) If I were to link the sound system to the code, where would I look for the best locations in code for, for instance, linking a sound to tapping/untapping cards, playing different types of cards, etc.?
2) If I were to create an easily changeable property which would allow the end user to enable or disable sound effects, how would I go about that?
Your help with the last two points is highly welcome! Hope you like this idea!
- Agetian