Light Style© by Fisana

Jump to content


Photo

New Sound Manager svn patch


  • Please log in to reply
295 replies to this topic

#1 stwf

stwf

    Sesquiplicarius

  • WFG Retired
  • 179 posts

Posted 27 April 2012 - 12:01 PM

Hello,



I have attached patches that were generated from by git branch. Sorry there are 5 (the command I used treats each commit separately). They should work with svn although you may need to apply them with the command 'patch -p1 -i 0001-new-soundmanager-code-release-1.patch', etc. Let me know if they don't work......

As mentioned in this blog post:
http://codeprairie.n...s-with-git.aspx

So while the underlying code has been completely rewritten, the only changes to the javascript side were the additions of the classes MusicSound, and AmbientSound to the previous Sound. MusicSound and AmbientSound each play in their own tracks, at their own volumes, and only one can play at a time. When you set a new one it will automatically fade out and release the old one. Regular Sounds, as well as the SoundGroups support for the SoundGroup xml remain the same.

So it seems like a good place to do some testing and firm up the new underlying SoundManager code. There are alot of numbers for things like buffer sizes that can be tweaked for better performance if need be. I can say it works perfectly on my blazingly fast iMac with lots of RAM and an SSD.....

I've tried to keep to the projects coding conventions where I could, any hints to improve the code more than welcome! Good Luck!

PS, still missing a lot of functionality. Position isn't set for the action sounds, many of the parameters in the SoundGroup files are currently ignored, fading throuigh the javascript side is currently ignored as well as setting many of the parameters from javascript (gain is supported however) but in my examples most of these aren't used yet. Anyway there are other things too I'm sure. Enjoy,

Attached Files


Edited by stwf, 27 April 2012 - 12:05 PM.

  • 0

#2 k776

k776

    Centurio

  • WFG Retired
  • 724 posts

Posted 27 April 2012 - 07:39 PM

Thanks stwf. I'm giving this a go now.

For those with git repos of the project, here is stwf's work: https://github.com/s...w-sound-manager
  • 1

Kieran P [ aka k776 ]


#3 feneur

feneur

    Cartographer of imaginary worlds

  • 0 A.D. Project Leader
  • 7,776 posts

Posted 28 April 2012 - 04:32 PM

I'll leave it to the programmers to comment on the programming related stuff, but I'll say as a general comment that this sounds very promising (y) Thanks for working on this!
  • 0

Erik Johansson [ aka feneur ]

Wildfire Games
Contact me: feneur@wildfiregames.com



Support Wildfire Games!


#4 stwf

stwf

    Sesquiplicarius

  • WFG Retired
  • 179 posts

Posted 28 April 2012 - 06:44 PM

No problem, its been fun!

I do have a new release should be pushed to github, the url is:

https://github.com/s...w-sound-manager

Also there are these svn patches that git created. I attached them here. I'm interested to see if they now work.

This version cleans up the logs, fixes the crash on exit, and a few minor tweaks. Also the parameters for sound buffer size, and the number of buffers to keep in memory per item can now be set through the config file. So we can start to tweak these things if the values I'm using don't work out in the wild... Enjoy.

Attached Files


  • 0

#5 k776

k776

    Centurio

  • WFG Retired
  • 724 posts

Posted 28 April 2012 - 08:04 PM

Excellent work. Your latest changes work flawlessly. It looks like this commit (https://github.com/s...d9f43077#diff-0) stopped actionGain from being set though.

Other than that, it's working great on Mac. Have you been able to try this on Linux and Windows?

If it works on all 3 operating systems, then we can start moving ahead to include it into Alpha 10 hopefully :-)

Anything I've missed from the TODO list?
* Sounds intensity based on position
* Sounds intensity based on zoom level
  • 0

Kieran P [ aka k776 ]


#6 feneur

feneur

    Cartographer of imaginary worlds

  • 0 A.D. Project Leader
  • 7,776 posts

Posted 28 April 2012 - 08:16 PM

Excellent work. Your latest changes work flawlessly. It looks like this commit (https://github.com/s...d9f43077#diff-0) stopped actionGain from being set though.

Other than that, it's working great on Mac. Have you been able to try this on Linux and Windows?

If it works on all 3 operating systems, then we can start moving ahead to include it into Alpha 10 hopefully :-)

Anything I've missed from the TODO list?
* Sounds intensity based on position
* Sounds intensity based on zoom level

Please be very sure there are no issues before including it. Unless it's extremely stable I would wait until after Alpha 10 is released, it is after all just over a week until the feature freeze, so while it sure would be nice to have sound on Mac as well I definitely don't think we should do anything that would lessen the experience on the other platforms. Even if everything works at least as well on Win/linux I'm still a bit wary about including something as significant this close to a release. Better to include it right after the release and make sure everything works well for Alpha 11 imho.
  • 0

Erik Johansson [ aka feneur ]

Wildfire Games
Contact me: feneur@wildfiregames.com



Support Wildfire Games!


#7 stwf

stwf

    Sesquiplicarius

  • WFG Retired
  • 179 posts

Posted 29 April 2012 - 04:17 AM

Thanks! You are right about this commit, my mistake SoundGroups have their own volume, so once that is supported(soon) ths won't be used.but I. Didn't mean to leave it out of this build... My mistake... I will fix that tomorrow...
I don't have a windows build nvironmentnalthough i can run win and Linux under VMware. Is it easy to set one up? Anyone have a good link explaining it?


  • 0

#8 historic_bruno

historic_bruno

    Primus Pilus

  • WFG Programming Team
  • 2,388 posts

Posted 29 April 2012 - 09:59 PM

VMWare is really easy to setup (or you can use VirtualBox as a free alternative, but VMWare is slightly more polished), you just create a new virtual machine, insert the CD or ISO of the install disc, it will normally detect the OS automatically, then you create a virtual hard drive of whatever size you want, then it will boot the installer disc and away you go :) Afterwards you'll want to install the guest support tools if available, that gives you copy/paste between guest and host, 3D acceleration, etc.
  • 0
Ben Brian [ aka historic_bruno ]

Wildfire Games Programmer
Contact me: ben [at] wildfiregames [dot] com

#9 WhiteTreePaladin

WhiteTreePaladin

    Primus Pilus

  • WFG Retired
  • 1,637 posts

Posted 29 April 2012 - 10:02 PM

Virtualbox is pretty easy to work with. I'd recommend it. Free is always nice :)
  • 0

Brian [aka WhiteTreePaladin]

0 A.D. Gameplay and UI Developer


#10 stwf

stwf

    Sesquiplicarius

  • WFG Retired
  • 179 posts

Posted 02 May 2012 - 05:16 PM

Hello all,
Thanks for the help, I got Ubuntu running in VMWare, not too bad! Why is Copy/Paste different in different apps? lol

I posted a diff file to trac:

http://trac.wildfiregames.com/ticket/1223

This version builds on mac and linux
Fully supports the SoundGroup.xml as well as allowing for control of the Sound item from Javascript.

The missing feature is for position. It seems like the implementation of this merits some discussions here.

Bugs carried over from the previous code include the playing of sounds that aren't on the screen and special intensity levels which also probably needs some discussion. I think the code is pretty solid, but probably wouldn't recommend Alpha 10 unless you plan on holding it off a bit. Of course its up to you either way.







  • 0

#11 Pureon

Pureon

    Primus Pilus

  • 0 A.D. Art Team
  • 3,571 posts

Posted 13 May 2012 - 12:42 PM

Do you need us to decide on how the camera position affects sound before you can progress further?

Excellent work (y)
  • 0

Pureon
0 A.D. Part time Designer / Texturer / 3D Artist
Contact email:
pureon{@}wildfiregames.com


#12 stwf

stwf

    Sesquiplicarius

  • WFG Retired
  • 179 posts

Posted 14 May 2012 - 01:26 PM

Thanks... After much thought I think i have an idea, but any feedback is appreciated. Time spent discussing now can save a lot of coding time later!

I was thinking that the real 3d is very tricky and probably not of much help to the player. Since the only representation they have is the 2D screen. My idea was to map the location of the sounds to the location of the image on the screen. Just ignore everything about the location except for its right<-> left positioning (screenwise), assume the left side of the screen is 45 degrees left of center, the right side of the screen 45 degrees to the right, and place the various sounds along that range. Then put offscreen sounds that are set to play anyway a bit further out than that than that. This would put everything at the same distance from the listener. It could be a nice touch to have far distant sounds be quieter (in a low shot), but in most game situations the distances aren't different enough to convey useful information to the player.

Even if someone has a full surround sound system I don't think that playing a sound behind them would prompt them to scroll to the bottom of the screen. But a sound full in the left ear might get them to look to the left hand side of the screen.

Feel free to tell me if this is totally off-base. Between learning the system and writing the code I've actually played very few games :-(...
  • 0

#13 Pureon

Pureon

    Primus Pilus

  • 0 A.D. Art Team
  • 3,571 posts

Posted 14 May 2012 - 08:21 PM

I'd be interested to hear what others think, but I don't see a problem with sound working on a 2d plane as you describe. I haven't tried your upload because I don't know how that all works, but I know a lot of Mac users are looking forward to hearing in-game sounds :)
  • 0

Pureon
0 A.D. Part time Designer / Texturer / 3D Artist
Contact email:
pureon{@}wildfiregames.com


#14 stwf

stwf

    Sesquiplicarius

  • WFG Retired
  • 179 posts

Posted 18 May 2012 - 11:25 AM

Hello Gang, I have a new version of the sound code. Mostly just adds the 0AD boilerplate at the top of each file and some minor code cleanup. I've started working on the code for locating sounds and should have that soon...

BTW the new forum wouldn't let me upload a .diff file. I had to add a .txt suffix to get it to go...

Attached Files


  • 0

#15 WhiteTreePaladin

WhiteTreePaladin

    Primus Pilus

  • WFG Retired
  • 1,637 posts

Posted 18 May 2012 - 03:25 PM

Good to hear you're still working on this. :)
  • 0

Brian [aka WhiteTreePaladin]

0 A.D. Gameplay and UI Developer


#16 feneur

feneur

    Cartographer of imaginary worlds

  • 0 A.D. Project Leader
  • 7,776 posts

Posted 18 May 2012 - 04:52 PM

The forum didn't allow .diff before either, previously you've either been attaching .zips or at Trac :) I've added the .diff attachment type now though, so you should be able to do things either way :) And again, thanks for working on this, it's greatly needed (y)
  • 0

Erik Johansson [ aka feneur ]

Wildfire Games
Contact me: feneur@wildfiregames.com



Support Wildfire Games!


#17 quantumstate

quantumstate

    Primus Pilus

  • WFG Retired
  • 1,150 posts

Posted 19 May 2012 - 08:12 AM

I was thinking that the real 3d is very tricky and probably not of much help to the player. Since the only representation they have is the 2D screen. My idea was to map the location of the sounds to the location of the image on the screen. Just ignore everything about the location except for its right<-> left positioning (screenwise), assume the left side of the screen is 45 degrees left of center, the right side of the screen 45 degrees to the right, and place the various sounds along that range. Then put offscreen sounds that are set to play anyway a bit further out than that than that. This would put everything at the same distance from the listener. It could be a nice touch to have far distant sounds be quieter (in a low shot), but in most game situations the distances aren't different enough to convey useful information to the player.


The idea that I have had is to first take the 2D positions of all the units and then do the following transforms:

1. The visible area on screen is distorted by perspective, first make it nice and rectangular. The player is positioned so that the left and right sides of the screen are at about 45 degrees as you said. The green dot shows where I think the player should be in terms of height.

2. Take everything that falls outside of the box and scale it by some large factor, the factor should be determined by what type of sound it is (defined in some config files) So for woodcutters it would be really big so sound falls off really fast. For battle noise it should lower so I can hear a battle in the distance.

Hopefully these diagrams will help show what I mean.

Posted Image
  • 0

Jonathan Waller [ aka quantumstate ]

Wildfire Games Programmer
Contact me: jonathanmarkwaller at gmail dot com


Support Wildfire Games!


#18 khegarty

khegarty

    Discens

  • WFG Retired
  • 27 posts

Posted 19 May 2012 - 06:23 PM

Thanks... After much thought I think i have an idea, but any feedback is appreciated. Time spent discussing now can save a lot of coding time later!

I was thinking that the real 3d is very tricky and probably not of much help to the player. Since the only representation they have is the 2D screen. My idea was to map the location of the sounds to the location of the image on the screen. Just ignore everything about the location except for its right<-> left positioning (screenwise), assume the left side of the screen is 45 degrees left of center, the right side of the screen 45 degrees to the right, and place the various sounds along that range. Then put offscreen sounds that are set to play anyway a bit further out than that than that. This would put everything at the same distance from the listener. It could be a nice touch to have far distant sounds be quieter (in a low shot), but in most game situations the distances aren't different enough to convey useful information to the player.

Even if someone has a full surround sound system I don't think that playing a sound behind them would prompt them to scroll to the bottom of the screen. But a sound full in the left ear might get them to look to the left hand side of the screen.

Feel free to tell me if this is totally off-base. Between learning the system and writing the code I've actually played very few games :-(...


I agree stwf on the 45 degree thing for the sounds, but have one thing to add. To keep consistent with how audio panning is usually set up I would suggest we have hard left/right be at 60 degrees left and right of center. (For audio usually -63, +63 are used, but I don't think 126 wouldn't be a simple number to work with coding wise so 120 instead)? If this doesn't make sense in coding then 45 will work fine.

I also agree that putting a sound behind someone will not make them look down, using left/right and increasing/descreasing volume I feel could solve the up down issue. We could make distant sounds quieter and I don't know what the options are in coding, but possibly have a little more reverb on a sound the farther away it is, to help a player preceive distance. I understand this may not be possible in code.

quantumstate, I am still a little confused by what you mean, could you describe this again? Sorry!
  • 0
Wildfire Games Sound Designer
Contact me: Kaitlynn@wildfiregames.com

#19 historic_bruno

historic_bruno

    Primus Pilus

  • WFG Programming Team
  • 2,388 posts

Posted 19 May 2012 - 10:26 PM

Surely it won't be hard to tweak the exact behavior? Compared to say, the challenge of rewriting the entire sound system :) Honestly I have no idea how the above suggestions would sound in practice, I would rather hear them for myself.
  • 0
Ben Brian [ aka historic_bruno ]

Wildfire Games Programmer
Contact me: ben [at] wildfiregames [dot] com

#20 stwf

stwf

    Sesquiplicarius

  • WFG Retired
  • 179 posts

Posted 20 May 2012 - 01:13 PM

Surely it won't be hard to tweak the exact behavior? Compared to say, the challenge of rewriting the entire sound system :) Honestly I have no idea how the above suggestions would sound in practice, I would rather hear them for myself.

This is actually the correct answer OpenAL is pretty flexible, so things like custom volume rolloff, doppler effect, and applying reverb to single sources is straightforward. So getting these details right can be an iterative process.

The current system only provides a flag, eOmnipresent that is defined as playing a sound at the listeners location. It does make sense to add one for a sounds with direction that should be played even when off screen. All of the sounds are specified in xml files. So a custom rolloff for each could be added to that pretty easily.

I do wonder how much you want to hear things that are offscreen. Of course you want to be notified of attacks as they start, but actually hearing all of the sounds of battle while you are trying to do something on the other side of the screen could be distracting.
  • 0