public Engine() { GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Lequal); GL.Enable(EnableCap.PointSmooth); GL.Hint(HintTarget.PointSmoothHint, HintMode.Nicest); GL.Enable(EnableCap.LineSmooth); GL.Hint(HintTarget.LineSmoothHint, HintMode.Nicest); //GL.Enable(EnableCap.PolygonSmooth); //GL.Hint(HintTarget.PolygonSmoothHint, HintMode.Nicest); sound = new ISoundEngine(SoundOutputDriver.AutoDetect, SoundEngineOptionFlag.DefaultOptions); world = new World(new FarseerPhysics.Common.Vector2(0, 9.82f)); viewport = new int[4]; sz = new int[MAX_OBJECTS * 4]; shaders = new Shaders(); }
static void Main(string[] args) { // start the sound engine with default parameters ISoundEngine engine = new ISoundEngine(); // create an instance of the file factory and let // irrKlang know about it. MyIrrKlangFileFactory myfactory = new MyIrrKlangFileFactory(); engine.AddFileFactory(myfactory); // that's it, play some sounds with our overriden // file access methods: // now play some sounds until user presses 'q' Console.Out.WriteLine("\nDemonstrating file access overriding."); Console.Out.WriteLine("Press any key to play some sound, press ESCAPE to quit."); _getch(); engine.Play2D("../../media/getout.ogg", true); do { // play some wave sound engine.Play2D("../../media/bell.wav"); }while(_getch() != 27); // user pressed eskape key to cancel }
public void Start() { try { // start up the engine engine = new ISoundEngine(); if (!File.Exists("./ikpMP3.dll")) { throw new Exception("No mp3 plugin for irrKlang found!"); } engine.LoadPlugins("./ikpMP3.dll"); } catch (Exception e) { System.Windows.Forms.MessageBox.Show("Exception thrown! {" + e.Message + "}. Halting!"); if (System.Windows.Forms.Application.MessageLoop) { System.Windows.Forms.Application.Exit(); } else { System.Environment.Exit(1); } } }
//=========================================================================== public void DoSoundEffects(ESoundEffects fx) { effectsEngine = new ISoundEngine(); // boolean args are 1) looped 2) start paused 3) enable sound effects ISound effectTester = effectsEngine.Play2D("curlew.wav", true, false, StreamMode.AutoDetect, true); ISoundEffectControl effectsControl = effectTester.SoundEffectControl; switch (fx) { case ESoundEffects.DISTORTION: effectsControl.EnableDistortionSoundEffect(); break; case ESoundEffects.ECHO: effectsControl.EnableEchoSoundEffect(); break; case ESoundEffects.REVERB: effectsControl.EnableWavesReverbSoundEffect(); break; case ESoundEffects.GARGLE: effectsControl.EnableGargleSoundEffect(); break; } } // end DoSoundEffects
public TheStory( ) { graphics = new GraphicsDeviceManager( this ); Content.RootDirectory = "Content"; SOUND = new ISoundEngine( ); }
private void btnPlay_Click_1(object sender, EventArgs e) { openFileDialog1.InitialDirectory = Application.StartupPath + "\\musicas\\"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { btnPause.Enabled = true; btnPlay.Enabled = false; btnStop.Enabled = true; ISoundEngine engine = new ISoundEngine(); StreamReader rd = new StreamReader(openFileDialog1.FileName, true); List <String> arquivo = new List <string>(); while (!rd.EndOfStream) { arquivo.Add(rd.ReadLine()); } String nomeMusica = arquivo[0]; String caminhoMusica = Path.Combine(Application.StartupPath + "\\media", arquivo[1]); frases = new List <Frase>(); arquivo.RemoveRange(0, 2); foreach (String frase in arquivo) { String[] componentes = frase.Split('#'); frases.Add(new Frase(componentes[0], uint.Parse(componentes[1]), uint.Parse(componentes[2]))); } rd.Close(); lblNomeMusica.Text = nomeMusica; musica = engine.Play2D(caminhoMusica); timer1.Start(); frasesParaExibir = getFrasesParaExibicao(frases, musica.PlayPosition); renderizarFrases(frasesParaExibir); musica.Volume = 1; } }
public bool Initiliase() { this.soundEngine = new ISoundEngine(); this.soundEngine.SoundVolume = 1.0f; this.SetListenerPosition(Vector3.ZERO, Vector3.UNIT_Z); return true; }
public SFX(byte[] song, string name) { ISoundEngine sfx = new ISoundEngine(); ISoundSource source = sfx.AddSoundSourceFromMemory(song, name); sfx.Play2D(source, false, false, true); }
public Engine() { GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Lequal); GL.Enable(EnableCap.PointSmooth); GL.Hint(HintTarget.PointSmoothHint, HintMode.Nicest); GL.Enable(EnableCap.LineSmooth); GL.Hint(HintTarget.LineSmoothHint, HintMode.Nicest); //GL.Enable(EnableCap.PolygonSmooth); //GL.Hint(HintTarget.PolygonSmoothHint, HintMode.Nicest); sound = new ISoundEngine(SoundOutputDriver.AutoDetect, SoundEngineOptionFlag.DefaultOptions); world = new World(new FarseerPhysics.Common.Vector2(0, 9.82f)); viewport = new int[4]; sz = new int[MAX_OBJECTS * 4]; shaders = new Shaders(); }
private void LineReceived(string line) { // richTextBox1.Text = line; switch (line) { case "1": ISoundEngine engine1 = new ISoundEngine(); engine1.Play2D(@"C:\Users\Gregster\Documents\Visual Studio 2012\Projects\Bateria_virtual\Bateria_virtual\HiHat.wav"); break; case "2": ISoundEngine engine2 = new ISoundEngine(); engine2.Play2D(@"C:\Users\Gregster\Documents\Visual Studio 2012\Projects\Bateria_virtual\Bateria_virtual\Snare.wav"); break; case "3": ISoundEngine engine3 = new ISoundEngine(); engine3.Play2D(@"C:\Users\Gregster\Documents\Visual Studio 2012\Projects\Bateria_virtual\Bateria_virtual\Tom.wav"); break; case "4": ISoundEngine engine4 = new ISoundEngine(); engine4.Play2D(@"C:\Users\Gregster\Documents\Visual Studio 2012\Projects\Bateria_virtual\Bateria_virtual\Crash.wav"); break; } }
public override void OnUpdate(Input input, ISoundEngine soundEngine, float deltaTime) { HandleInput(input, deltaTime); ai.Update(gameFrame, deltaTime); physics.Step(gameFrame, deltaTime); int player = physics.CheckForScore(gameFrame); if (player != -1) { scores[player]++; if (scores[player] >= 7) { if (player == 0) { stateManager.Push(StateId.Winner); } else if (player == 1) { stateManager.Push(StateId.Loser); } scores[0] = 0; scores[1] = 0; } else { gameFrame.DropPuck(); stateManager.Push(StateId.BeginPlay); } } }
public override void Initialize() { soundEngine = new ISoundEngine(); // Register object in Lua. ScriptManager.SetGlobal("Sound", this); }
public MainWindow() { InitializeComponent(); Debug.WriteLine("Starting up!"); /* set up audio stuff */ engine = new ISoundEngine(); /* Set up scene */ agSetupScene(); /* add building */ agAddBuilding(); /* Demo Dots */ //agAddDemoPoints(); /* Start twitter stream */ twitter_hose(); /* Grab the plane data */ plane_data(); /* Grab the bikeshare data */ bike_data(); /* Grab the metro data */ metro_data(); }
public SFX(byte[] song, string name) { ISoundEngine sfx = new ISoundEngine(); ISoundSource source = sfx.AddSoundSourceFromMemory(song, name); sfx.Play2D(source, false, false, true); }
public Player() { this._engine = new ISoundEngine(); this._playUpdater = new Timer(500); this._playUpdater.Elapsed += _playUpdater_Elapsed; }
public SoundManager(Engine engine) { _engine = engine; _soundEngine = new ISoundEngine(); _loadedSounds = new Dictionary<string, ISoundSource>(); }
public AudioIrrKlangSession(string filePath) { _engine = new ISoundEngine(); _recorder = new IAudioRecorder(_engine); _path = filePath; _irrklangEventProxy = new ProxyForIrrklangEvents(this); }
private void btnPlay_Click_1(object sender, EventArgs e) { openFileDialog1.InitialDirectory = Application.StartupPath + "\\musicas\\"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { btnPause.Enabled = true; btnPlay.Enabled = false; btnStop.Enabled = true; ISoundEngine engine = new ISoundEngine(); StreamReader rd = new StreamReader(openFileDialog1.FileName, true); List<String> arquivo = new List<string>(); while (!rd.EndOfStream) { arquivo.Add(rd.ReadLine()); } String nomeMusica = arquivo[0]; String caminhoMusica = Path.Combine(Application.StartupPath + "\\media", arquivo[1]); frases = new List<Frase>(); arquivo.RemoveRange(0, 2); foreach (String frase in arquivo) { String[] componentes = frase.Split('#'); frases.Add(new Frase(componentes[0], uint.Parse(componentes[1]), uint.Parse(componentes[2]))); } rd.Close(); lblNomeMusica.Text = nomeMusica; musica = engine.Play2D(caminhoMusica); timer1.Start(); frasesParaExibir = getFrasesParaExibicao(frases, musica.PlayPosition); renderizarFrases(frasesParaExibir); musica.Volume = 1; } }
static void Main(string[] args) { // start the sound engine with default parameters ISoundEngine engine = new ISoundEngine(); // create an instance of the file factory and let // irrKlang know about it. MyIrrKlangFileFactory myfactory = new MyIrrKlangFileFactory(); engine.AddFileFactory(myfactory); // that's it, play some sounds with our overriden // file access methods: // now play some sounds until user presses 'q' Console.Out.WriteLine("\nDemonstrating file access overriding."); Console.Out.WriteLine("Press any key to play some sound, press ESCAPE to quit."); _getch(); engine.Play2D("../../media/getout.ogg", true); do { // play some wave sound engine.Play2D("../../media/bell.wav"); } while(_getch() != 27); // user pressed eskape key to cancel }
public void LoadMusic(ISoundEngine engine) { Stream stream = Application.GetResourceStream(GetFileUri()).Stream; int lenght = (int)stream.Length; byte[] buffer = new byte[lenght]; try { int count; int sum = 0; while ((count = stream.Read(buffer, sum, lenght - sum)) > 0) { sum += count; } } finally { stream.Close(); } engine.AddSoundSourceFromMemory(buffer, SoundName); }
public RadioPlayer(IDisplayEngine displayEngine, ISoundEngine soundEngine) { _displayEngine = displayEngine; _soundEngine = soundEngine; StationManager = ApplicationDataHandler.Load(); StationManager.PlayingStationDeleted += StationManager_PlayingStationDeleted; }
public void Load(string file) { Stop(); if (_engine == null) { _engine = new ISoundEngine(); } _currentPlayback = _engine.Play2D(file, false, false); if (_currentPlayback != null) { _currentPlayback.Volume = Volume; _currentPlayback.setSoundStopEventReceiver(this); TrackDuration = TimeSpan.FromMilliseconds(_currentPlayback.PlayLength); OnPlaybackPositionChanged(TimeSpan.FromSeconds(0)); var info = _engine.GetSoundSource(file).AudioFormat; Channels = info.ChannelCount; BytesPerSecond = info.BytesPerSecond; SampleRate = info.SampleRate; NotifyPlayBackStateChanged(); } else { NotifyPlayBackStateChanged(); throw new Exception(string.Format("Error loading file '{0}' for playback", file)); } }
public SoundManager([NotNull] ISoundsLibrary soundsLibrary, ISoundEngine soundEngine, ILogger logger, IProcessStarter processStarter) { if (soundsLibrary == null) { throw new ArgumentNullException("soundsLibrary"); } if (soundEngine == null) { throw new ArgumentNullException("soundEngine"); } if (logger == null) { throw new ArgumentNullException("logger"); } if (processStarter == null) { throw new ArgumentNullException("processStarter"); } this.soundsLibrary = soundsLibrary; this.logger = logger; engine = soundEngine; globalVolume = 0.5f; form = new SoundManagerForm(this, soundsLibrary, processStarter); }
public IrrKlangEngine() { this._engine = new ISoundEngine // startup IrrKlang's internal sound engine. { SoundVolume = GlobalSettings.Instance.NotificationSoundVolume // set the master volume. }; }
public InGameMenuState(GameStatesManager stateManager, IKernel iocContainer, ISoundEngine soundEngine) : base(stateManager) { _ioc = iocContainer; AllowMouseCaptureChange = false; _soundEngine = soundEngine; }
public AudioIrrKlangSession(string filePath) { _engine = new ISoundEngine(); _recorder = new IAudioRecorder(_engine); _path = filePath; _irrklangEventProxy = new ProxyForIrrklangEvents(this); }
/// <summary> /// The sound manager class. /// </summary> public SoundMain() { Launch.Log("[Loading] Creating IrrKlang and SoundMain..."); musics = new List<ISound>(); sounds = new List<ISound>(); components = new HashSet<SoundComponent>(); enableMusic = Options.GetBool("Music"); enableSounds = Options.GetBool("Sounds"); playerManager = LKernel.GetG<PlayerManager>(); cameraManager = LKernel.GetG<CameraManager>(); playerManager.OnPostPlayerCreation += new PlayerEvent(OnPostPlayerCreation); LevelManager.OnLevelUnload += new LevelEvent(OnLevelUnload); LevelManager.OnLevelLoad += new LevelEvent(OnLevelLoad); LKernel.GetG<Pauser>().PauseEvent += new PauseEvent(PauseEvent); SoundEngineOptionFlag flags = SoundEngineOptionFlag.DefaultOptions | SoundEngineOptionFlag.MuteIfNotFocused | SoundEngineOptionFlag.MultiThreaded; try { Engine = new ISoundEngine(SoundOutputDriver.AutoDetect, flags); } catch (System.Exception) { Launch.Log("[Loading] Cannot initialize real SoundOutputDriver!"); Engine = new ISoundEngine(SoundOutputDriver.NullDriver, flags); } Engine.Default3DSoundMinDistance = 50f; Launch.Log("[Loading] IrrKlang and SoundMain initialised!"); }
public AmbientSoundControl(ISoundEngine engine, string internalName, string friendlyName) : this() { this.Engine = engine; this.InternalName = internalName; this.FriendlyName = friendlyName; }
public IrrklangPlayer(AudioClip clip) { if (!File.Exists(clip.CacheFileName)) { throw new AGSEditorException("AudioClip file is missing from the audio cache"); } if (Utilities.IsMonoRunning()) { _soundEngine = new ISoundEngine(SoundOutputDriver.AutoDetect); } else { // explicitly ask for the software driver as there seem to // be issues with ISound returning bad data when re-using // the same source and certain audio drivers _soundEngine = new ISoundEngine(SoundOutputDriver.WinMM); } // we have to read it into memory and then play from memory, // because the built-in Irrklang play from file function keeps // the file open and locked byte[] audioData = File.ReadAllBytes(clip.CacheFileName); _source = _soundEngine.AddSoundSourceFromMemory(audioData, clip.CacheFileName); _audioClip = clip; }
static void Main(string[] args) { // start the sound engine with default parameters ISoundEngine engine = new ISoundEngine(); // To make irrKlang know about the memory we want to play, we register // the memory chunk as a sound source. We specify the name "testsound.wav", so // we can use the name later for playing back the sound. Note that you // could also specify a better fitting name like "ok.wav". // The method AddSoundSourceFromMemory() also returns a pointer to the created sound source, // it can be used as parameter for play2D() later, if you don't want to // play sounds via string names. ISoundSource source = engine.AddSoundSourceFromMemory(SoundDataArray, "testsound.wav"); // now play the sound until user presses 'q' Console.Out.WriteLine("\nPlaying sounds directly from memory"); Console.Out.WriteLine("Press any key to play some sound, press 'q' to quit."); do { // play the sound we added to memory engine.Play2D("testsound.wav"); }while(_getch() != 'q'); // user pressed 'q' key, cancel }
public bool Initiliase() { this.soundEngine = new ISoundEngine(); this.soundEngine.SoundVolume = 1.0f; this.SetListenerPosition(Vector3.ZERO, Vector3.UNIT_Z); return(true); }
//[DllImport("winmm.dll")] // private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback); public Mediaplayer(Info info,string filepath) { InitializeComponent(); this.info = info; //player = new SoundPlayer(filepath); this.filepath = filepath; soundPlayer = new ISoundEngine(); }
//[DllImport("winmm.dll")] // private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback); public Mediaplayer(Info info, string filepath) { InitializeComponent(); this.info = info; //player = new SoundPlayer(filepath); this.filepath = filepath; soundPlayer = new ISoundEngine(); }
public MainForm() { InitializeComponent(); _player = new ISoundEngine(); _timer.Tick += UpdateRemainingTime; _timer.Interval = 1000; _timer.Start(); }
public static void PlayEffect(string effect) { var se = new ISoundEngine(); var sound = se.Play2D(effect, false, true); sound.Volume = SoundOn ? EffectVolume : 0; EffectList.Add(sound); sound.Paused = false; }
public Sound(SoundSettings soundSettings) { soundEngine = OpenALSoundController.GetInstance; if (soundSettings.Mute) { MuteAudio(); } }
public Lobby(Main main, ISoundEngine soundengine) { InitializeComponent(); Main = main; soundEngine = soundengine; PCards = new List <Card>(); OCards = new List <Card>(); Cardtexts = new List <string>(); }
public GeneralSoundManager(ISoundEngine soundEngine) { _soundEngine = soundEngine; //Get Global sound value from configuration _soundEngine.GlobalFXVolume = (ClientSettings.Current.Settings.SoundParameters.GlobalFXVolume / 100.0f); _soundEngine.GlobalMusicVolume = (ClientSettings.Current.Settings.SoundParameters.GlobalMusicVolume / 100.0f); this.IsSystemComponent = true; }
public Sound(IPlatform platform, SoundSettings soundSettings) { soundEngine = platform.CreateSound(soundSettings.Device); if (soundSettings.Mute) { MuteAudio(); } }
ISoundEngine death; //create sound engine for death sound public AsteroidForm() { InitializeComponent(); //play theme music music = new ISoundEngine(); music.SoundVolume = 0.5f; music.Play2D("../../../MACINTOSH_PLUS_-_------420_-_--------.wav", true); }
public void Dispose() { if (FEngine != null) { FEngine.StopAllSounds(); FEngine.RemoveAllSoundSources(); FEngine = null; } }
public SFX(string effect) { if (effect == null) return; ISoundEngine sfx = new ISoundEngine(); sfx.Play2D(effect); }
public irrKlangClass(String fileName, int tracksCount) { engine = new ISoundEngine(); this.fileName = fileName; isPlaying = false; trackCurrentlyPlaying = 0; this.tracksCount = tracksCount; }
public Player() { Instance = this; Engine = new ISoundEngine(SoundOutputDriver.AutoDetect, SoundEngineOptionFlag.DefaultOptions, Config.GetInstance().DeviceId); Playlist = new Playlist(); //Playlist.Tracks.CollectionChanged += OnPlaylistChanged; new Thread(() => { while (true) { PlayerThread(); Thread.Sleep(250); } }).Start(); }
public Jukebox(ResourceManager resmgr) { res_manager = resmgr; soundEngine = new ISoundEngine(); listenerViewDir = new Vector3D(0, 0, 1); listenerPosition = new Vector3D(); soundEngine.SetListenerPosition( listenerPosition, listenerViewDir); sounds = new Dictionary<string, ISoundSource>(); }
/// <summary> /// Creates an instance of the sound engine /// Removes any sound source that may exist /// Keeps all sounds in memory /// </summary> public void InitializeSoundEngine() { this.engine = new ISoundEngine(); this.engine.RemoveAllSoundSources(); //Initializing the test sound this.test_sound = new Audio("TEST", TEST_SOUND_NAME); this.engine.Play2D(this.test_sound.getUrl(), false, true); }
private void button2_Click(object sender, EventArgs e) { button1.Enabled = true; button2.Enabled = false; if (engine != null) { engine.StopAllSounds(); engine.Dispose(); engine = null; } }
public KlangPlayer() { try { Engine = new ISoundEngine(); } catch (Exception) { Engine = null; } TmProgressionFlux = new Timer(500); }
internal static void CreateSoundBank() { Logger.LogInfo("Initializing", THIS); SoundEngine = new ISoundEngine(); SoundBankCreated = true; if (!Directory.Exists(SoundsDirectory)) { Directory.CreateDirectory(SoundsDirectory); } InitDefVolumesDict(); BuildSoundBank(); Logger.LogInfo("Init completed", THIS); }
private void addsource(ISoundEngine e, string path, string name) { using (FileStream s = new FileStream(path, FileMode.Open)) { byte[] SBuffer = new byte[s.Length]; s.Read(SBuffer, 0, (int)s.Length); // ISoundSource iss = e.AddSoundSourceFromMemory(SBuffer, name); // sourceKick = e.AddSoundSourceFromMemory(SBuffer, name); // so = e.AddSoundSourceFromMemory(SBuffer, name); sounds.Add(name); } }
public static bool Init() { try { soundEngine = new ISoundEngine(); return true; } catch { return false; } }
static void Main(string[] args) { if (File.Exists("Updater.exe")) { try { File.Delete("Updater.exe"); } catch { } } SoundEngine = new ISoundEngine(SoundOutputDriver.AutoDetect, SoundEngineOptionFlag.DefaultOptions | SoundEngineOptionFlag.PrintDebugInfoIntoDebugger); Settings = Settings.Load(); new MainMenu().Open(); }
private void buttonTestSound_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxSoundFile.Text)) { MessageBox.Show("Please select a sound clip","No Sound Clip",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); textBoxSoundFile.Focus(); return; } ISoundEngine engine = new ISoundEngine(); engine.Default3DSoundMinDistance = 0; engine.Default3DSoundMaxDistance = 1; engine.SetListenerPosition(0, 0, 0, 0, 0, 1); engine.SoundVolume = ((float)trackBarVolume.Value) / 100; Vector3D vector = new Vector3D(); ISound music = engine.Play3D(textBoxSoundFile.Text, (float)soundClipPlacement1.Balance,0, (float)soundClipPlacement1.Fade, false); }
private void button1_Click(object sender, EventArgs e) { string path = @"..\..\..\irrKlang-1.3.0\media\ophelia.mp3"; if (File.Exists(path)) { button1.Enabled = false; button2.Enabled = true; engine = new ISoundEngine(); ISound music = engine.Play2D(path, false); MessageBox.Show("Lengte fragment (msec): " + music.PlayLength.ToString()); } else { MessageBox.Show("File does noet exist!"); } }
private ISound sound; // Current playing song #endregion Fields #region Constructors /// <summary> /// Initializes music player and randomizer. After that plays first song /// from file and sets event receiver. /// </summary> /// <param name="mWindow">The RenderWindow instance for making overlays</param> public SoundPlayer( Mogre.RenderWindow mWindow) { engine = new ISoundEngine(); songs = Directory.GetFiles(songPath); r = new Random(); this.mWindow = mWindow; sound = engine.Play2D(songs[0]); sound.setSoundStopEventReceiver(this); ShowCurrentPlaying(songs[current]); effects = new Dictionary<string, string>(); var tempEff = Directory.GetFiles(effectPath); foreach (var effName in tempEff) { var splited = effName.Split('\\'); effects.Add(splited[splited.Length - 1], effName); } }
static void Main(string[] args) { // start the sound engine with default parameters ISoundEngine engine = new ISoundEngine(); // To play a sound, we only to call play2D(). The second parameter // tells the engine to play it looped. engine.Play2D("../../media/getout.ogg", true); Console.Out.WriteLine("\nHello World"); do { Console.Out.WriteLine("Press any key to play some sound, press 'q' to quit."); // play a single sound engine.Play2D("../../media/bell.wav"); } while(_getch() != 'q'); }
public static bool PlayMusic(string fileLocation) { fileLocation = FileSystem.DirectoryPath + "\\" + FileSystem.Directory + "\\music\\" + fileLocation; try { if (System.IO.File.Exists(fileLocation)) { soundEngine = new ISoundEngine(); soundEngine.SoundVolume = GameManager.Volume; sound = soundEngine.Play2D(fileLocation, false, false, StreamMode.Streaming, false); } else return false; return true; } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); return false; } }
private void btnPlay_Click(object sender, EventArgs e) { if (btnPlay.Text.Equals("Stop")) { musica.Stop(); btnPlay.Text = "Play"; btnFrase.Enabled = false; btnSpace.Enabled = false; } else { openFileDialog1.InitialDirectory = Application.StartupPath + "\\musicas\\"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { btnFrase.Enabled = true; btnSpace.Enabled = true; btnPlay.Text = "Stop"; ISoundEngine engine = new ISoundEngine(); musica = engine.Play2D(openFileDialog1.FileName); this.Focus(); } } }
public static void Create(string engine) { soundEngine = CreateEngine(engine); }
static void Main(string[] args) { // start the sound engine with default parameters ISoundEngine engine = new ISoundEngine(); // Now play some sound stream as music in 3d space, looped. // We play it at position (0,0,0) in 3d space ISound music = engine.Play3D("../../media/ophelia.mp3", 0,0,0, true); // the following step isn't necessary, but to adjust the distance where // the 3D sound can be heard, we set some nicer minimum distance // (the default min distance is 1, for a small object). The minimum // distance simply is the distance in which the sound gets played // at maximum volume. if (music != null) music.MinDistance = 5.0f; // Print some help text and start the display loop Console.Out.Write("\nPlaying streamed sound in 3D."); Console.Out.Write("\nPress ESCAPE to quit, any other key to play sound at random position.\n\n"); Console.Out.Write("+ = Listener position\n"); Console.Out.Write("o = Playing sound\n"); Random rand = new Random(); // we need random 3d positions const float radius = 5; float posOnCircle = 0; while(true) // endless loop until user exits { // Each step we calculate the position of the 3D music. // For this example, we let the // music position rotate on a circle: posOnCircle += 0.04f; Vector3D pos3d = new Vector3D(radius * (float)Math.Cos(posOnCircle), 0, radius * (float)Math.Sin(posOnCircle * 0.5f)); // After we know the positions, we need to let irrKlang know about the // listener position (always position (0,0,0), facing forward in this example) // and let irrKlang know about our calculated 3D music position engine.SetListenerPosition(0,0,0, 0,0,1); if (music != null) music.Position = pos3d; // Now print the position of the sound in a nice way to the console // and also print the play position string stringForDisplay = " + "; int charpos = (int)((pos3d.X + radius) / radius * 10.0f); if (charpos >= 0 && charpos < 20) { stringForDisplay = stringForDisplay.Remove(charpos, 1); stringForDisplay = stringForDisplay.Insert(charpos, "o"); } uint playPos = 0; if (music != null) playPos = music.PlayPosition; string output = String.Format("\rx:({0}) 3dpos: {1:f} {2:f} {3:f}, playpos:{4}:{5:00} ", stringForDisplay, pos3d.X, pos3d.Y, pos3d.Z, playPos/60000, (playPos%60000)/1000); Console.Write(output); System.Threading.Thread.Sleep(100); // Handle user input: Every time the user presses a key in the console, // play a random sound or exit the application if he pressed ESCAPE. if (_kbhit()!=0) { int key = _getch(); if (key == 27) break; // user pressed ESCAPE key else { // Play random sound at some random position. Vector3D pos = new Vector3D(((float)rand.NextDouble() % radius*2.0f) - radius, 0, 0); string filename; if (rand.Next()%2 != 0) filename = "../../media/bell.wav"; else filename = "../../media/explosion.wav"; engine.Play3D(filename, pos.X, pos.Y, pos.Z); Console.Write("\nplaying {0} at {1:f} {2:f} {3:f}\n", filename, pos.X, pos.Y, pos.Z); } } } }