XNA Sound Effects. float volume, pitch, pan; SoundEffect boing1; SoundEffect boing2; boing1 = Content.Load ("boing1"); boing2 = Content.Load ("boing2");

Slides:



Advertisements
Similar presentations
Computer Science 320 Clumping in Parallel Java. Sequential vs Parallel Program Initial setup Execute the computation Clean up Initial setup Create a parallel.
Advertisements

08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Constructor and New Fields // Don't synch draw() with vertical retrace of monitor graphics.SynchronizeWithVerticalRetrace = false; IsFixedTimeStep = true;
Thomas Lövgren, Flash developer
11 Reaction Timer Game Session 8.1. Session Overview  Find out how an XNA program can measure the passage of time and trigger events at certain points.
Audio 靜宜大學資工系 蔡奇偉 副教授 © 內容大綱 簡介 Recording Playback Sample Rate and Sample Quality Mono & Stereo Sound Sound Formats, Compression, and Codecs XNA.
COMPUTER PROGRAMMING 2 Chapter 7 Sound. Objectives Find out how to prepare sounds for inclusion in Microsoft XNA projects. Incorporate sounds into XNA.
Loops We have been using loops since week 2, our void draw(){ } is a loop A few drawbacks of draw() –It is endless –There is only one draw() –It updates.
Lecture 3 IAT 800. Sept 15, Fall 2006IAT 8002 Suggestions on learning to program  Spend a lot of time fiddling around with code –Programming is something.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
Rob Miles Microsoft MVP University of Hull Fun Programming with Visual Studio.
COMPUTER PROGRAMMING 2 Timers. Game Idea: Mob Reaction Timer Use a timer variable to keep track of time and a variable for each player to measure the.
Getting Started. XNA Game Studio 4.0 To download XNA Game Studio 4.0 itself, go to XNA Game.
Using Namepsaces  This section lists the namespaces that the application will be using frequently. Saves the programmer from specifying a fully qualified.
Developing the Game User Interface (UI) Lesson 5.
1 Useful Tools for Making Video Games Part V An overview of.
11 Adding Sounds Session 7.1. Session Overview  Find out how to capture and manipulate sound on a Windows PC  Show how sound is managed as an item of.
Microsoft Tech Days 2012 Cheezia: Developing a Windows Phone XNA Game Rodrigo Barretto Software Engineer - MCPD on Windows Phone
Rob Miles. Creating a Working MoodLight We know that colours in XNA are stored as values which represent the amount of red, blue, green and transparency.
CHAPTER 10 Using C# Methods to Solve Problem XNA Game Studio 4.0.
Variables and Functions. Open your Encoder program Let’s begin by opening the “Labyrinth Auto Straight” code. Save this file as Labyrinth with variables.
CSC 107 – Programming For Science. Today’s Goal  When lecture over, start understanding pointers  What a pointer is and what it is not  Why pointers.
XNA An Introduction. What XNA is… Microsoft® XNA™ is composed of industry- leading software, services, resources, and communities focused on enabling.
XNA Game Studio 4.0 Keyboard and Mouse Controls + more on Animated Sprites.
11 Making a Sprite Session 4.2. Session Overview  Describe the principle of a game sprite, and see how to create a sprite in an XNA game  Learn more.
Rob Miles. How does an XNA game program work? Programs tell computers what to do A program is written in a programming language – C# is a programming.
CIS 3.5 Lecture 2.2 More programming with "Processing"
Aaron Yuen 1 Outline 9.1Storyboarding & Charting Method for Game Design 9.2Game State in Game Development 9.3Game State Management 9.4GUI Assets for Gameplay.
CHAPTER 3 Getting Player Input XNA Game Studio 4.0.
XNA Basic Displaying Image & Collision Detect. What’s format image that XNA support? XNA support only.bmp.png and.jpg image..PNG have transparent region.
CHAPTER 6 Multiplayer XNA Game Studio 4.0. Objectives Discover how to detect and use individual button-press events in a game. Learn how to create and.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Flash: ActionScript review & Controlling Sound Presentation by Mindy McAdams Edited for JOMC 187, UNC-Chapel Hill by Laura Ruel.
CHAPTER 2 The Game Loop - Variables, Types, Classes and Objects in XNA XNA Game Studio 4.0.
11 Writing Text Session 5.1. Session Overview  Show how fonts are managed in computers  Discover the difference between bitmap fonts and vector fonts.
Playing with Sprites. XNA Game Lifecycle In the faceBall demo program we bounced a smiley face around the graphical display against a background image.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Starting Out with Games & Graphics in C++ Tony Gaddis Chapter 8 The.
Review Expressions and operators Iteration – while-loop – for-loop.
XNA Tutorial 1 For CS134 Lecture. Overview Some of the hard work has already been done for you. If you build and run your game now, the GraphicsDeviceManager.
Rob Miles. Using data in an XNA game program An XNA game program Draw and Update methods that are called to run the game Colours are held in XNA as four.
11 Adding Vibration Effects Session Session Overview  Describe how the vibration feature of the gamepad works  Show how an XNA program can control.
Rob Miles. Creating a Broken MoodLight An XNA game contains game data which is used by the Draw and Update methods – Update updates the game data – Draw.
Consumer Windows Phone Emulator Phone Emulator SamplesDocumentation GuidesCommunity Packaging and Verification Tools Windows Phone Dev Tools AppHub.
Loops. About the Midterm Exam.. Exam on March 12 Monday (tentatively) Review on March 5.
Bryant Tober. Problem Description  View the sound wave produced from a wav file  Apply different modulations to the wave file  Hear the effect of the.
CHAPTER 5 Text XNA Game Studio 4.0. Objectives Discover how text is drawn using Microsoft XNA. Add some font resources to your XNA program. Draw some.
XNA 4.0 Side Scrolling.
Programming Environments
Lecture 4 Using SpriteFonts
Test 2 Review Outline.
CSC111 Quick Revision.
Sound Music & Sound Effects.
Assignment 2a Q&A Xu Wang.
Using and Creating Sprites
Programming Environments
For Loops October 12, 2017.
Collision Detection.
LRobot Game.
Hank Childs, University of Oregon
Side Scrolling Game Development.
Lecture 2 - Building a Monogame Windows Project
Local Variables, Global Variables and Variable Scope
More programming with "Processing"
Simple Classes in Java CSCI 392 Classes – Part 1.
Gameprogrammeren: Game states
MTA-4201 Game Programming Chapter 8 : Scrolling Background & Font
LCC 6310 Computation as an Expressive Medium
Repetition Statements (Loops) - 2
Collisions with Static Objects
Presentation transcript:

XNA Sound Effects

float volume, pitch, pan; SoundEffect boing1; SoundEffect boing2; boing1 = Content.Load ("boing1"); boing2 = Content.Load ("boing2"); pitch = (float)((double)(spritescale * )); pan = -(float)(((((double)maxX-(double)facePosition.X)/maxX)*2.0)-1.0); boing2.Play(volume,pitch,pan); Example Sound Effects in faceBall4.zip Sound effects variables declared as global Sound effects loaded in Content.Load( ) method (see Lecture 2 for how to associate.wav files with project (same procedure as used to associate bitmaps with project). Range of valid values for pitch are from -1.0 (down one octave) to +1.0 (up an octave). Normal pitch is at value 0.0 Value of pan sets relative volume in left (-1.0) and right(1.0) speakers. Center value 0.0. Example

protected override void Update(GameTime gameTime) { int i, j; pitch = (float)((double)(spritescale/ )); pan = -(float)(((((double)maxX - (double)facePosition.X) / maxX) * 2.0) - 1.0); spriterot -= (float)0.05; if (spriterot > 6.28) spriterot = (float)0.0; if (spriterot < 0.0) spriterot = (float)6.28; spritescale += delscale; if ((spritescale > (float)2.0) || (spritescale < (float)0.5)) delscale *= (float)-1.0; if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); Example Integrating Sound Effects into the Update( ) Method

facePosition.X += faceVx; if (facePosition.X > maxX - blit.Width / 2) { faceVx *= -1; boing1.Play(1, pitch, pan); } if (facePosition.X < minX + blit.Width / 2) { faceVx *= -1; boing1.Play(1,pitch, pan); } facePosition.Y += faceVy; if (facePosition.Y > maxY - blit.Height / 2) { faceVy *= -1; boing2.Play(1, pitch, pan); } if (facePosition.Y < minY + blit.Height / 2) { faceVy *= -1; boing2.Play(1,pitch,pan); } if (rnd.Next(1000)>990) { i = rnd.Next(4); j = rnd.Next(2); blit.X = i * 90; blit.Y = j * 85; } base.Update(gameTime); }

SoundEffect wind; SoundEffectInstance thewind; wind = Content.Load ("wind"); thewind = wind.CreateInstance(); thewind.IsLooped = true; thewind.Play(); thewind.Pause(); thewind.Resume(); thewind.Stop(); Looping a Sound Any SoundEffect can be looped or played repeatedly by creating an instance of the effect, settng its IsLooped boolean property to true and then playing the instance. Note that since the sound is being looped, thewind.Play( ) has to be called only once. In addition the looping sound can be paused, resumed, and stopped using the calls to methods of the same name. declare variables globally so that they are accessible anywhere in the project code instance is created in LoadContent( ) after associated soundeffect is loaded. state of instance can be changed in any methods in the project