From 02db1bcc5b8cd53705877349d341684d406676e0 Mon Sep 17 00:00:00 2001 From: Murat Suri Date: Sat, 25 Jun 2011 23:34:10 +0000 Subject: [PATCH] * Update demo --- .../CSharpTutorial1_2DSound/Program.cs | 55 +++++++------------ .../Properties/Resources.Designer.cs | 42 ++++++-------- 2 files changed, 36 insertions(+), 61 deletions(-) diff --git a/Samples/CSharpAudioPlayer/CSharpTutorial1_2DSound/Program.cs b/Samples/CSharpAudioPlayer/CSharpTutorial1_2DSound/Program.cs index 472b4d8..1c7b5cc 100644 --- a/Samples/CSharpAudioPlayer/CSharpTutorial1_2DSound/Program.cs +++ b/Samples/CSharpAudioPlayer/CSharpTutorial1_2DSound/Program.cs @@ -16,29 +16,24 @@ namespace CSharpTutorial1_2DSound { //Some fancy text Console.WriteLine("cAudio 2.2.0 Tutorial 1: Basic 2D Audio. C# \n \n"); - Console.WriteLine("\nAvailable Playback Devices: \n"); - //Create an uninitialized Audio Manager - IAudioManager mAudioMgr = cAudioCSharpWrapper.createAudioManager(false); - //Grab a list of avalible devices + //Grab a list of available devices IAudioDeviceList pDeviceList = cAudioCSharpWrapper.createAudioDeviceList(); - //Get the number of avalible devices. - uint deviceCount = pDeviceList.getDeviceCount(); - //Get the defualt device name. - string defaultDeviceName = pDeviceList.getDefaultDeviceName().ToString(); + //Get the default device name. + string defaultDeviceName = pDeviceList.getDefaultDeviceName(); - for(uint i=0; i< deviceCount; ++i) + for(uint i=0; i< pDeviceList.getDeviceCount(); i++) { - string deviceName = pDeviceList.getDeviceName(i).ToString(); + string deviceName = pDeviceList.getDeviceName(i); if(deviceName.Equals(defaultDeviceName)) - Console.WriteLine(" "+ i + "): " + deviceName.ToString() + " [DEFAULT] \n"); + Console.WriteLine(" "+ i + "): " + deviceName + " [DEFAULT]"); else - Console.WriteLine(" "+ i + "): " + deviceName.ToString() + " \n"); + Console.WriteLine(" "+ i + "): " + deviceName); } Console.WriteLine("\n"); @@ -46,37 +41,25 @@ namespace CSharpTutorial1_2DSound string deviceSelection = Console.ReadLine(); uint deviceSelect = Convert.ToUInt32(deviceSelection); Console.WriteLine("\n"); - mAudioMgr.initialize(pDeviceList.getDeviceName(deviceSelect).ToString()); - if (mAudioMgr != null) + //Create an uninitialized Audio Manager + IAudioManager audioMgr = cAudioCSharpWrapper.createAudioManager(false); + audioMgr.initialize(pDeviceList.getDeviceName(deviceSelect)); + + IAudioSource currentSource = audioMgr.create("bing", "../../../Media/cAudioTheme1.ogg"); + if (currentSource != null) { + currentSource.setVolume(0.5f); + currentSource.play2d(false); - IAudioSource mCurrentSource; - - mCurrentSource = mAudioMgr.create("bing", "../../../../Media/cAudioTheme1.ogg"); - - if (mCurrentSource != null) + while (currentSource.isPlaying()) { - - mCurrentSource.setVolume(0.5f); - mCurrentSource.play2d(false); - - - while (mCurrentSource.isPlaying()) - { - cAudioCSharpWrapper.cAudioSleep(10); - } + cAudioCSharpWrapper.cAudioSleep(10); } - - mAudioMgr.shutDown(); - cAudioCSharpWrapper.destroyAudioManager(mAudioMgr); } - else - { - Console.WriteLine("Failed to create audio playback manager. \n"); - } + audioMgr.Dispose(); - Console.WriteLine("Press any key to quit \n"); + Console.WriteLine(@"Press any key to quit "); Console.ReadLine(); } } diff --git a/Samples/CSharpAudioPlayer/cAudioPlayer/Properties/Resources.Designer.cs b/Samples/CSharpAudioPlayer/cAudioPlayer/Properties/Resources.Designer.cs index 0e62f5c..0bb04b3 100644 --- a/Samples/CSharpAudioPlayer/cAudioPlayer/Properties/Resources.Designer.cs +++ b/Samples/CSharpAudioPlayer/cAudioPlayer/Properties/Resources.Designer.cs @@ -8,10 +8,10 @@ // //------------------------------------------------------------------------------ -namespace cAudioPlayer.Properties -{ - - +namespace cAudioPlayer.Properties { + using System; + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -22,48 +22,40 @@ namespace cAudioPlayer.Properties [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("cAudioPlayer.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } }