SunBurn Game Engine: Audio System, Drag-Drop, and More!

Hello SunBurn community!

As you know the SunBurn Game Engine early adopter is going very well.  SunBurn is more feature rich than ever and we’ve nearly completed the early adopter roadmap.

To top it off, this week we’ve completed two of the remaining five engine features on the roadmap - one of which I’ll cover today.

Of course if you’re following me on Twitter you’ve probably already heard (literally ;) some of the details...


Audio System

Player, environmental, ui, and other sounds (especially 3D) add an enormous amount of depth to games.  Until now adding audio to SunBurn games involved different code for ambient, ui, and 3D audio sources  (using the XNA api), and while relatively easy to setup it still required more work than necessary.

Now SunBurn includes an audio system that handles all of the details for you.  Simply create an AudioSource object in the editor (or in code and submit it to the AudioManager), and enjoy lots of beautiful audio goodness. :)

The audio system supports:

  • Point / location based 3D sounds (with control of the audible distance)
  • Ambient and UI non-3D sounds
  • Continuous looping sounds
  • Single-shot sounds
  • Playing / stopping
  • Automatically handles maximum platform audio sources (on Xbox and WP7, Windows has no limit)

And all using the AudioSource class – no audio playback or device code is required.


Creating Audio Sources

Audio sources can be created in the SunBurn editor by importing a sound file into the game’s content repository, then dragging the sound into the scene.


Sources can also be created in code by passing an XNA SoundEffect into the AudioSource constructor, and submitting the source to the AudioManager:


SoundEffect
sound = Content.Load<SoundEffect>(“sound_file_name”);
AudioSource source = new AudioSource(sound);
sceneInterface.AudioManager.Submit(source);
source.Play();


Drag-and-Drop Assets

In the SunBurn editor you can change the sound used by an audio source by drag-and-dropping an imported sound from the game’s content repository onto the source’s Sound Effect property (similar to changing the model assigned to a scene object).

However, what if you create a component that assigns audio to an object?  Or an object that uses multiple sounds?  Wouldn’t it be cool to use the same drag-and-drop control in your own objects and components?

Now you can!  We’ve introduced two classes, which are used by the editor as drag-and-drop targets for content repository assets:

  • SoundEffectAsset – add a property of this type to your class and the editor will automatically support drag-and-dropping sound files onto the property
  • ModelAsset – add a property of this type to your class and the editor will automatically support drag-and-dropping models onto the property

The classes also provide direct access to the contained asset, without the need to load the asset manually.  This provides a ton of benefits, but the most significant are:

  • Add assets to classes and components without needing access to the game’s content manager
  • Receive events (via the property setter) when new assets are dropped onto the property in-editor (or set on the property in-code)
  • Game code also has direct access to the assets (using SoundEffectAsset.Asset and ModelAsset.Asset)

To expand on the last point: developers frequently ask how to retrieve a scene object’s source model.  In the past you’d need to ask the content repository for the model - while this is relatively easy, it’s not obvious when browsing the SceneObject class.

Now, however, it is – the source model can be retrieved using the ModelAsset:


Model
model = sceneObject.ModelAsset.Asset;
// do something cool with the scene object’s model...


So how do you use this feature in your own classes and components?  Here’s an example:


[Serializable]
[EditorCreatedObject]
public class CustomModel : SceneEntity
{
    public ModelAsset ModelAsset
    {
        get { return _ModelAsset; }
        set
        {
            // This setter is called whenever the model is changed.

            _ModelAsset = value;
            Model model = value.Asset;
            // do something cool with the model...
        }
    }

    private ModelAsset _ModelAsset = ModelAsset.Empty;
}


More on the Way

And of course there’s still another awesome roadmap feature we haven’t covered... but I’ll save that for my next blog. :)

If you have any questions, comments, or thoughts let us know!

-John Kabus

 

Other SunBurn 2.0 Blogs:

  1. Announcing the SunBurn 2.0 Game Engine - free upgrade, new editions, and updated features
  2. SunBurn 2.0 Collisions, Scenegraph, and Components - new collision system, components, and more
  3. SunBurn 2.0 upgrade for our Torque customers - upgrade path for all of our previous TLK technology customers
  4. SunBurn 2.0 goes Mobile on Windows Phone 7! - full Windows Phone 7 support, light mapping, and more
  5. Holiday, Components, and more! - read about the new components and more
  6. SunBurn 2.0: components, perfabs, and more! - more details about SunBurn's new component system
  7. Festive SunBurn 2.0 Starter Kits, yum, yum! - first release of the new SunBurn Starter kit
  8. SunBurn 2.0.10 update available - streamlined user experience and integrated starter kits
  9. SunBurn Dev Journal: Scenegraph Optimizations - faster scenegraph and City Demo with 10,000 buildings
  10. SunBurn 2.0.12 Update Now Available! - edit components and custom scene object types in editor
  11. SunBurn Update: Windows Redistributable - ship Windows games using only the XNA Redistributable
  12. SunBurn Dev Journal: Workflow Enhancements - background importing, shared materials, Visual Studio templates, and more
  13. SunBurn 2.0.13 Update: Get it Now! - the latest goodies are now available
  14. SunBurn 2.0.14 Update Available! - extended materials and sprite rendering on Windows Phone 7
  15. SunBurn Dev Journal: Reflections and Clipping Planes - the return of the Reflection / Refraction example!

 

 


Posted 05-11-2011 9:37 PM by JohnK "bobthecbuilder"
Attachment: blog-audio.jpg

Comments

Alex "Turbosmooth Operator" wrote re: SunBurn Game Engine: Audio System, Drag-Drop, and More!
on 05-11-2011 9:54 PM

Awesome work guys!

UjenT wrote re: SunBurn Game Engine: Audio System, Drag-Drop, and More!
on 05-12-2011 1:16 AM

Very nice! Truly awesome. Keep it up.

pat cook wrote re: SunBurn Game Engine: Audio System, Drag-Drop, and More!
on 05-12-2011 1:37 AM

very nice!  

Tom wrote re: SunBurn Game Engine: Audio System, Drag-Drop, and More!
on 05-12-2011 2:50 AM

Awesome stuff - Two great new additions, is there a possibility to expand the audio system beyond XACT's features? I think neither SoundEffect nor XACT provide the proper feature-set / workflow (XACT is especially horrible) for really intense sounds.

CJ Bailey wrote re: SunBurn Game Engine: Audio System, Drag-Drop, and More!
on 05-12-2011 3:42 AM

Wow!  Sunburn just gets better and better.  I've not been able to work on my project for a few months now (something called work just keeps getting in the way... boooo!), but I'm really looking forward to getting back to it and using all these new features.

dirtysteve wrote re: SunBurn Game Engine: Audio System, Drag-Drop, and More!
on 05-12-2011 10:30 AM

I'm getting quite excited for the next big update :)

Filip wrote re: SunBurn Game Engine: Audio System, Drag-Drop, and More!
on 05-12-2011 11:30 AM

looks good john :)

JohnK "bobthecbuilder" wrote re: SunBurn Game Engine: Audio System, Drag-Drop, and More!
on 05-12-2011 2:42 PM

Thanks guys!

@Tom, the system uses SoundEffect for both ambient and 3D audio.

We agree, XACT is not so user-friendly.  It's also not supported on WP7 and no longer being updated.  So we are definitely focusing on SoundEffect.

diegoleao wrote re: SunBurn Game Engine: Audio System, Drag-Drop, and More!
on 05-13-2011 2:35 AM

Are you interested in making Sunburn into a Unity-like editor? Is this the overall direction for Sunburn?

I would really like if that was the case! I think you are prioritizing very well your new features.

The reason I don't use Sunburn for some time now is that I don't feel very productive in it. I wish I could just focus on the game, like I do in Unity. Sunburn is "almost there", but we still need some productivity tools for many areas of game development. It is still too much about the graphics, not the game.

The work you are doing lately is giving me a lot of hope. When Kinect support arrives to the Indie channel, Sunburn is going to be my home XD Keep up!

Pérsio Flexa wrote re: SunBurn Game Engine: Audio System, Drag-Drop, and More!
on 05-13-2011 11:38 AM

Show, this was a step I would implement it but fortunately you did first. =D

Congratulations

JohnK "bobthecbuilder" wrote re: SunBurn Game Engine: Audio System, Drag-Drop, and More!
on 05-13-2011 2:17 PM

Hi guys, yes we're definitely focusing a lot on workflow, tools, and rapid game development.

And we expose these new features in the SunBurn API, so SunBurn will continue to be highly modular and provide very deep access to the engine via code.

Václav Antošík wrote re: SunBurn Game Engine: Audio System, Drag-Drop, and More!
on 05-22-2011 2:58 PM

It looks AWESOME! Good idea!

JohnK Blog wrote SunBurn Game Engine: Transparencies, Player Controller, and More!
on 08-17-2011 1:15 AM

Hello SunBurn community! If you follow my blogs you know we’re adding a number of unannounced features

JohnK Blog wrote SunBurn Launches Powerful new Community Plugin System
on 10-16-2011 3:16 PM

Hello SunBurn community! Last night we rolled out a development preview of the SunBurn Game Engine’s

JohnK Blog wrote New SunBurn Community Resources Portal!
on 11-01-2011 5:45 PM

Hello SunBurn community! Two weeks ago we rolled out a powerful new resource system for the SunBurn Game

JohnK Blog wrote SunBurn Game Engine: A Whole New Level of Flexibility!
on 11-16-2011 5:06 PM

Hello SunBurn community! Today we’re announcing the last couple of features in the upcoming SunBurn

JohnK Blog wrote Orbitron: Revolution blasts onto Xbox LIVE Marketplace!
on 12-05-2011 9:52 PM

Hello SunBurn community! Talk about an exciting weekend! The awesome team at Firebase Industries just

JohnK Blog wrote SunBurn 2.0.17 Released – Advanced Lighting, Transparencies, and tons of Enhancements!
on 12-09-2011 4:45 PM

Hello SunBurn community! It’s here! Today we released the SunBurn Game Engine 2.0.17 update –

JohnK Blog wrote New SunBurn Documentation and Silverlight WP7 Example!
on 12-12-2011 9:09 PM

Hello SunBurn community! We’ve just updated the SunBurn Getting Started documentation to ensure

JohnK Blog wrote Starting 2012 with style: SunBurn Game Engine 2.0.18 Preview!
on 01-27-2012 2:01 PM

Hello SunBurn community! We're kicking the year off with a huge new update to the SunBurn Game Engine

JohnK Blog wrote SunBurn Game Engine 2.0.18: Built-in Character Controller!
on 02-04-2012 4:50 PM

Hello SunBurn community! Last night we delivered a feature-complete preview of SunBurn Game Engine 2

JohnK Blog wrote SunBurn 2.0.18 Released - Physics, Char Controller, More!
on 02-14-2012 3:46 PM

Hello SunBurn community! This morning we launched the much anticipated SunBurn Game Engine 2.0.18! The

JohnK Blog wrote New sgMotion Plugin and the SunBurn 2.0.18 Refresh!
on 02-23-2012 4:50 PM

Hello SunBurn community! We just rolled out two exciting new updates for the SunBurn Game Engine ! The

JohnK Blog wrote Latest SunBurn 2.0.18 Update Available!
on 06-06-2012 4:54 PM

Hello SunBurn Community! Today we launched the latest SunBurn Game Engine 2.0.18 refresh! Just in time

JohnK Blog wrote New SunBurn Examples - Learn to Create Scenes in Code!
on 06-12-2012 3:39 PM

Hello SunBurn community! This afternoon we released two new examples for the SunBurn Game Engine - as

JohnK Blog wrote SunBurn 2.0 goes Gold! Framework Edition Ships Too!
on 06-29-2012 8:05 PM

Hello SunBurn community! We're very excited to announce we've shipped the official gold release

JohnK Blog wrote Awesome new SunBurn and Community Updates!
on 07-25-2012 6:54 PM

Hello SunBurn community! Today we posted two new updates! The first is to the community site, which makes

menfou wrote re: SunBurn Game Engine: Audio System, Drag-Drop, and More!
on 12-20-2012 2:03 AM

Hello,

I have a problem with mp3 file, I have a exception when I load a mp3 file, but that works with a wav file.

That says the file is a Microsoft.Xna.Framework.Media.Song, and I need a Microsoft.Xna.Framework.Audio.SoundEffect

Content.Load<SoundEffect>("mp3file")



Please login to post comments.