It is currently 07 May 2025, 00:32
   
Text Size

[WIP] Forge Sound System

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Re: [WIP] Forge Sound System

Postby RumbleBBU » 13 Nov 2012, 12:01

Stupid question time.

Would it be possible to make the sound system eat MP3s? Non-lossy wav files are largely a waste of disk space and memory for non-hifi use like this.
User avatar
RumbleBBU
 
Posts: 394
Joined: 18 Aug 2012, 04:24
Has thanked: 29 times
Been thanked: 66 times

Re: [WIP] Forge Sound System

Postby Chris H. » 13 Nov 2012, 14:59

I found the original tap sound from several years ago. I raised the pitch, shortened the sound somewhat and converted to wav format.
 
Attachments
tap.wav.zip
attribute: this is the original tap sound that came with the first sound effects system from several years ago
(9.84 KiB) Downloaded 858 times
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: [WIP] Forge Sound System

Postby Agetian » 13 Nov 2012, 15:37

Max Mtg wrote:I think you may proceed as you did for the next few days until beta, but be ready to change (or to discover how your code has changed) when someone (probably me) makes that bus implementation (after beta of course)
Yep, I see your point, and like I said, I'd rather not jump into that especially since there's already a prospect of how it should work in the future and I don't know the details of it and have little experience with it. That being said, I'm flexible and I'll certainly adapt to the new implementation when you transform the code - feel free to change my calls into whatever form would be appropriate to transmit them properly via your event bus implementation, and I'll be sure to utilize that form from that point on when adding new sounds to the sound system.

RumbleBBU wrote:Would it be possible to make the sound system eat MP3s? Non-lossy wav files are largely a waste of disk space and memory for non-hifi use like this.
Sadly, JDK itself doesn't support MP3 out of the box, potentially because it's a proprietary format, it only supports WAV and AU. If we decide to try to go for the MP3 format (or OGG, or some other compressed format), it's probably not a big problem to use some third party library for that, but that might increase the size of the Forge jar file as well as create potential issues with cross-platform compatibility (if that library is going to make any native calls, it might be difficult to ascertain that it's universally available on all platforms, plus, it might turn into an end-user problem). So, we definitely need to decide on the following: 1) is MP3 support really mandatory, or is maybe .WAV actually enough? (yes, I know it's typically much larger in size, but our sounds are short enough, and all things considered, collectively all the WAV files together are unlikely to exceed 20-25 MB, probably maybe even twice less than that amount - Shandalar has a ton of duel sounds in WAV format and they all combined together have the total size of about 16 MB - that doesn't include music and other stuff like that of course; two sounds submitted by Chris are under 50 kb in size together); 2) if it is mandatory, how OK would it be to utilize a third party library for the playback, and are there any criteria as to what to look for when looking for a third party library?

Chris H. wrote:I found the original tap sound from several years ago. I raised the pitch, shortened the sound somewhat and converted to wav format.
Thanks a lot for the sounds so far! I tried them out and liked them very much! How do we go about putting them on cardforge.org and stuff? Maybe it's worth collecting them somewhere in one place at first and then, when we have a more or less complete set, I'm going to add a downloader to Forge that will be able to fetch those from cardforge.org?
P.S. I think we should decide on something for the file format too before we actually put the collection up and link it to Forge.

- Agetian
Agetian
Programmer
 
Posts: 3486
Joined: 14 Mar 2011, 05:58
Has thanked: 683 times
Been thanked: 568 times

Re: [WIP] Forge Sound System

Postby Chris H. » 13 Nov 2012, 16:16

Agetian wrote:Thanks a lot for the sounds so far! I tried them out and liked them very much! How do we go about putting them on cardforge.org and stuff? Maybe it's worth collecting them somewhere in one place at first and then, when we have a more or less complete set, I'm going to add a downloader to Forge that will be able to fetch those from cardforge.org?
P.S. I think we should decide on something for the file format too before we actually put the collection up and link it to Forge.
 
I think that we should continue to use the .wav format. I have had some success in shrinking the size of the sound files and I do not think that they will take up too much heap space with the launchers that we are using.

I will keep a folder on my computer with the sound files, although I could use a helping hand from other people finding some good sounds. :)

Marc has offered to move the files to cardforge when we get to that point.

And I have another file ready:
 
Attachments
lose_duel.wav.zip
attribute: www.freesound.org
(11.11 KiB) Downloaded 663 times
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: [WIP] Forge Sound System

Postby Agetian » 13 Nov 2012, 16:18

@ Chris: Nice! Yes, I agree about the .wav format. And sure thing, once I finish hooking up the sound system or at least get a complete starting list of sounds, I'll try to join in in seach of good sound samples! ;)

- Agetian
Agetian
Programmer
 
Posts: 3486
Joined: 14 Mar 2011, 05:58
Has thanked: 683 times
Been thanked: 568 times

Re: [WIP] Forge Sound System

Postby Agetian » 13 Nov 2012, 17:56

Ok, I added support for some of the remaining sounds that were pending support, currently I added them the old-fashioned way. I think I'd better stop here for the time being until the beta is released (there are many enough direct calls to the sound system already, I don't want to overpollute the code base with those since they'll all have to be converted). So, I'll test for a while and wait until Max implements the event pool and converts the code so that I can adapt to the upcoming changes in the model, and then I'll add support for more sounds using the new event-based model.

- Agetian
Agetian
Programmer
 
Posts: 3486
Joined: 14 Mar 2011, 05:58
Has thanked: 683 times
Been thanked: 568 times

Re: [WIP] Forge Sound System

Postby Agetian » 14 Nov 2012, 03:53

To recap, here's the current state of the Sound System, with the associated file name and a quick description specified:

Code: Select all
AddCounter - add_counter.wav - triggered when a counter is added to a permanent.
Artifact - artifact.wav - triggered when an artifact is played.
ArtifactCreature - artifact_creature.wav - triggered when an artifact creature is played.
BlackLand - black_land.wav - triggered when a land with the "B" mana ability is played.
BlueLand - blue_land.wav - triggered when a land with the "U" mana ability is played.
Creature - creature.wav - triggered when a creature is played.
Damage - damage.wav - triggered when a creature is damaged.
Destroy - destroy.wav - triggered when a permanent is destroyed.
Discard - discard.wav - triggered when a player discards a card.
Draw - draw.wav - triggered when a player draws a card.
Enchantment - enchant.wav - triggered when an enchantment is played.
EndOfTurn - end_of_turn.wav - triggered at the end of turn.
Equip - equip.wav - triggered when an equipment is equipped.
FlipCoin - flip_coin.wav - triggered when a coin is flipped.
GreenLand - green_land.wav - triggered when a land with the "G" mana ability is played.
Instant - instant.wav - triggered when an instant is played.
LifeLoss - life_loss.wav - triggered when a player loses life.
LoseDuel[*] - lose_duel.wav - triggered when a player loses a duel.
ManaBurn - mana_burn.wav - triggered during a mana burn if the appropriate rule is enabled.
OtherLand - other_land.wav - triggered when a land with non-color mana abilities or any other land is played.
Planeswalker - planeswalker.wav - triggered when a planeswalker is played.
Poison - poison.wav - triggered when a player receives a poison counter.
RedLand - red_land.wav - triggered when a land with the "R" mana ability is played.
Regen - regeneration.wav - triggered when a creature is regenerated.
RemoveCounter - remove_counter.wav - triggered when a counter is removed from a permanent.
Sacrifice - sacrifice.wav - triggered when a permanent is sacrificed.
Sorcery - sorcery.wav - triggered when a sorcery is played.
Shuffle[*] - shuffle.wav - triggered when a player shuffles his deck.
Tap[*] - tap.wav - triggered when a permanent is tapped.
Untap - untap.wav - triggered when a permanent is untapped.
WhiteLand - white_land.wav - triggered when a land with the "W" mana ability is played.
WinDuel - win_duel.wav - triggered when a player wins the duel.
The files must go into the "res/sound" folder of Forge.

The sounds for which we already have our own custom sound files are marked with [*]. There are currently very few of them, so if anyone has time to look for appropriate royalty-free sounds that we can use in Forge for one of the effects listed above, please post your findings in this thread: http://www.slightlymagic.net/forum/viewtopic.php?f=26&t=8570 Every single little contribution is appreciated!

Like I said, right now I'm unlikely to add new sounds to the list of supported sounds (with maybe a very few standalone exceptions, we'll see) until the event bus system is implemented, because there are many sounds on the list already as it is and I don't want to overcomplicate the conversion process in this department.

The caveats of the current implementation are:
1. Sometimes when there are many cards on the battlefield, with targeting overlay enabled, etc. etc., some sounds may "skip" a bit - hopefully it will be easier to remedy this when the event bus system comes into play, with the possible scheduling and filtering of sound events accomplished on the sound system end. Perhaps this might also require moving the sound playback into its own thread, but I'm not sure at this moment. EDIT: Hopefully with the latest commit which increased the responsiveness of the sound system, this problem should either go away or at least be far less noticeable.
2. Multiple sounds of the same type will be played at the same time if the same event happens multiple times for different cards on the battlefield at the same time. While practically not noticeable under normal conditions, this may be related to [1] and is likely to be remedied the same way as [1] either.

Otherwise, the basic implementation can be considered complete until the event bus upgrade, after which more coding may and most likely will follow in this department.

- Agetian
Agetian
Programmer
 
Posts: 3486
Joined: 14 Mar 2011, 05:58
Has thanked: 683 times
Been thanked: 568 times

Re: [WIP] Forge Sound System

Postby Max mtg » 22 Nov 2012, 08:09

Luckily Google has already made an EventBus class!

Attached is my idea on how events-based sound would work.

The patch results in a lot of compile errors (because direct calls to sound system have to be converted into events) yet it shows the common idea on a poison counter added event
Attachments
event-based-sound.patch.txt
(40.99 KiB) Downloaded 353 times
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

Postby Agetian » 22 Nov 2012, 16:50

Good developments, Max! Unfortunately, for some reason I'm unable to apply the patch, trying to apply it both in Netbeans and just using a console patch utility leads to patch errors (some files patch OK and some report chunk errors)... If you'd like me to join in on this conversion (which I'm all for, I just need to get a bit more spare time and take care of some business-related issues before I get back to major coding), can you please help me with how to properly patch the files?

- Agetian
Agetian
Programmer
 
Posts: 3486
Joined: 14 Mar 2011, 05:58
Has thanked: 683 times
Been thanked: 568 times

Re: [WIP] Forge Sound System

Postby Max mtg » 22 Nov 2012, 17:40

Thanks!

I made this patch from the \src\main\java directory. Maybe NetBeans expects the patch to be relative to project root?

I'll commit my developments to SVN once compile errors are eliminated (that is I make the whole system work somehow). At that moment everyone will be able to convert the rest.
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

Postby Max mtg » 22 Nov 2012, 18:08

it's there in 18317
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

Postby Agetian » 22 Nov 2012, 18:29

Nice, I'll work on converting some calls in the nearest future then! Thanks!

- Agetian
Agetian
Programmer
 
Posts: 3486
Joined: 14 Mar 2011, 05:58
Has thanked: 683 times
Been thanked: 568 times

Re: [WIP] Forge Sound System

Postby Agetian » 23 Nov 2012, 03:51

I'm looking through the event system code - great job overall, very transparent and clean, I'll definitely get to converting ASAP. I can't understand one thing though... e.g. when the Poison event is passed, for some reason, a constant value "3" is passed in the event... is that an oversight (and it should have been the "num" parameter) or was it intended and I just don't understand what's supposed to happen there with the number?

- Agetian
Agetian
Programmer
 
Posts: 3486
Joined: 14 Mar 2011, 05:58
Has thanked: 683 times
Been thanked: 568 times

Re: [WIP] Forge Sound System

Postby Max mtg » 23 Nov 2012, 08:33

That "3" was copied from a line that adds gamelog entry. In that context '3' is 'error level' or some kind of priority log uses.

The correct amount of counters is 'num' parameter, and I've already fixed that call.
Thanks for pointing at my mistake.

When you'll be desiging your own events, it's pretty OK to pack only the needed data into an event. In this example 'number of counters' is insignificant for sound system, so the sound programmer doesn't need to add it. The one who will use events for other activities should add the fields he is going to consume.
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

Postby Agetian » 23 Nov 2012, 15:01

Ok, awesome, thanks for your advice, Max! I've started the process of conversion and will try to finish over the next few days. I think I've got it all covered, so you don't need to participate in conversion and you can dedicate your time to other stuff. :)

- Agetian
Agetian
Programmer
 
Posts: 3486
Joined: 14 Mar 2011, 05:58
Has thanked: 683 times
Been thanked: 568 times

PreviousNext

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 37 guests


Who is online

In total there are 37 users online :: 0 registered, 0 hidden and 37 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 37 guests

Login Form