Playing a Song

Won't work for some reason

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

41 Replies - 18130 Views - Last Post: 26 June 2010 - 05:15 PM

#31 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: Playing a Song

Posted 25 June 2010 - 01:16 PM

Believe that would audioEngine.
Was This Post Helpful? 0
  • +
  • -

#32 lesPaul456   User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: Playing a Song

Posted 25 June 2010 - 01:32 PM

:oops:

Yes, it's supposed to be audioEngine, not soundEngine. :D
Was This Post Helpful? 0
  • +
  • -

#33 eZACKe   User is offline

  • Garbage Collector

Reputation: 120
  • View blog
  • Posts: 1,278
  • Joined: 01-June 09

Re: Playing a Song

Posted 25 June 2010 - 02:25 PM

Well lesPaul, I can't get yours working. I have no doubt in your abilities or that your code is 100% correct, but I'm either implementing it wrong or it's just not working in my game for some reason.

I have some questions about what I've done:

 public static class AudioManager
    {
        static AudioEngine audioEngine;//the main sound engine
        static WaveBank waveBank;//from the wavebank in our XACT project
        static SoundBank soundBank;//from the soundbank in our XACT project



        public static void Initialize()
        {
            audioEngine = new AudioEngine("Content/Sounds/MenuSonud.xgs");
            waveBank = new WaveBank(audioEngine, "Content/Sounds/Wave Bank.xwb", 0, 4);
            soundBank = new SoundBank(audioEngine, "Content/Sounds/Sound Bank.xsb");

            audioEngine.Update();
        }


        public static void Update()
        {
            audioEngine.Update();
        }

        public static void PlaySound(string cue)
        {
            soundBank.PlayCue(cue);
        }

    }



^^Okay there should be no problems there. The name of my sound file that I made in XACT is MenuSound and I have it in my Solution Explorer under a Sounds Folder, which is within Content. There it is save as MenuSound.xap. No problem?


Game1 Class:
 protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            AudioManager.Initialize();

            base.Initialize();
        }





 protected override void Update(GameTime gameTime)
        {

            AudioManager.Update(); 



^^No problem?


StartScreen(where I want music to play) Class:
 protected override void LoadContent()
        {
           

            AudioManager.PlaySound("Sounds\\MenuSound");




^^Is that what I should have between quotations? Any problem here?


I just feel like I've done everything you said.





@SixOfEleven: I will be trying your implementation too, but I haven't done that yet. :bigsmile:

This post has been edited by eZACKe: 25 June 2010 - 02:27 PM

Was This Post Helpful? 1
  • +
  • -

#34 lesPaul456   User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: Playing a Song

Posted 25 June 2010 - 03:18 PM

I'm at home now, and I was able to test the code I posted. It works fine for me.

Have you set the wave bank for streaming? Here's a link that shows how (a little towards the end).

Also, try playing the sound like this:

AudioManager.PlaySound("MenuSound"); // Try dropping the "Sounds\\"


Was This Post Helpful? 1
  • +
  • -

#35 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: Playing a Song

Posted 25 June 2010 - 03:26 PM

I took my Screen Manager Part 2 as a starting point and have made a project using my method. Hope to have a tutorial written up on it before the night is through. It is for XNA 3.1, not XNA 3.0, but I don't see that as much of a problem.

I will just mention that XACT isn't available for the Zune. If anybody is wanting to use music in their games on the Zune they do have to find an alternative. I believe my way will work for Zune but since I don't have a Zune or Zune HD to test it on, can't be sure.
Was This Post Helpful? 0
  • +
  • -

#36 eZACKe   User is offline

  • Garbage Collector

Reputation: 120
  • View blog
  • Posts: 1,278
  • Joined: 01-June 09

Re: Playing a Song

Posted 25 June 2010 - 03:52 PM

Yes, I do have it on Streaming and changed the name but still not working. Thanks for the tutorial though!


Alright SixOfEleven, I'll be sure to read it!
Was This Post Helpful? 0
  • +
  • -

#37 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: Playing a Song

Posted 26 June 2010 - 06:35 AM

The tutorial is now in the Game Programming tutorial section. It takes place after part 2 of the screen manager series. Hope that it is helpful.
Was This Post Helpful? 0
  • +
  • -

#38 eZACKe   User is offline

  • Garbage Collector

Reputation: 120
  • View blog
  • Posts: 1,278
  • Joined: 01-June 09

Re: Playing a Song

Posted 26 June 2010 - 11:49 AM

Is there a quick way to upgrade to xna 3.1? I have 3.0 right now and would like to upgrade it so I can use your tutorial.

I'm just worried that I'll lose what I have saved now. So is there a way to simply upgrade or should I just download 3.1 and not worry about it?

Thanks!
Was This Post Helpful? 0
  • +
  • -

#39 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: Playing a Song

Posted 26 June 2010 - 01:15 PM

Very easy to upgrade to XNA 3.1. Unistall XNA 3.0. Install XNA 3.1. Right click your solution in the solution explorer and there will be an Upgrade to XNA 3.1 option. All there is to it. With XNA 3.1 installed, you still have the option to create XNA 3.0 projects as well. You can't mix the two in the same solution though.
Was This Post Helpful? 0
  • +
  • -

#40 eZACKe   User is offline

  • Garbage Collector

Reputation: 120
  • View blog
  • Posts: 1,278
  • Joined: 01-June 09

Re: Playing a Song

Posted 26 June 2010 - 03:24 PM

Oh alright thanks!

Was just a little concerned I'd lose my project. Thank you for clarifying that for me though.
Was This Post Helpful? 0
  • +
  • -

#41 eZACKe   User is offline

  • Garbage Collector

Reputation: 120
  • View blog
  • Posts: 1,278
  • Joined: 01-June 09

Re: Playing a Song

Posted 26 June 2010 - 04:56 PM

Posted this in the tutorial itself, but figured I'd post it over here too:

Something is going wrong with this line:
public static event EventHandler<MusicChangeEventArgs> OnMusicChange;





It is giving me an error that says:
"Inconsistent accessibility: field type 'System.EventHandler<fullGame1.MusicChangeEventArgs>' is less accessible than field 'fullGame1.GameScreen.OnMusicCahnge'


Not sure why I'm getting this.

This post has been edited by eZACKe: 26 June 2010 - 05:02 PM

Was This Post Helpful? 0
  • +
  • -

#42 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: Playing a Song

Posted 26 June 2010 - 05:15 PM

I posted a reply in the tutorial, but will post it here as well. You have inconsitent access somewhere. It is probably the MusicChangeEventArgs class. It needs to be public for your code to compile. If it isn't that class, then it is another class. Setting all classes to public, not necessarily the best object-oriented idea, should solve this problem.
Was This Post Helpful? 1
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3