public void update(GameTime gt) { if (this.firstCall) { this.IsInDialog = true; Tolk.Speak(this.parts[index], true); engine.Play2D("sounds/UI/menuconfirm.mp3"); this.firstCall = false; } if (Input.WasKeyPressed(Keys.E)) { Tolk.Speak(this.parts[index], true); } if (Input.WasKeyPressed(Keys.Enter)) { if (index < parts.Length - 1) { index += 1; Tolk.Speak(parts[index], true); engine.Play2D("sounds/UI/menumove.mp3"); } else { Tolk.Speak("dieron enter"); engine.Play2D("sounds/UI/menuback.mp3"); this.IsInDialog = false; } } }
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 playstep() { string stx = player.me.X.ToString("R"); string sty = player.me.Y.ToString("R"); if (gmw().IndexOf("wall", 0) > -1) { engine.Play2D("sounds/walls/" + gmw() + ".wav"); bounce(); } if (stx.Contains(",1") && stx != oldEaredX) { engine.Play2D("sounds/steps/" + get_tile_at((int)player.me.X, (int)player.me.Y, (int)player.me.Z) + "/" + random.Next(1, Directory.GetFiles("sounds/steps/" + get_tile_at((int)player.me.X, (int)player.me.Y, (int)player.me.Z)).Length + 1) + ".ogg"); oldEaredX = stx; } else if (stx.Contains(",5") && stx != oldEaredX) { engine.Play2D("sounds/Movement/stepback" + random.Next(1, 7) + ".wav"); oldEaredX = stx; } else if (sty.Contains(",1") && sty != oldEaredY) { engine.Play2D("sounds/steps/" + get_tile_at((int)player.me.X, (int)player.me.Y, (int)player.me.Z) + "/" + random.Next(1, Directory.GetFiles("sounds/steps/" + get_tile_at((int)player.me.X, (int)player.me.Y, (int)player.me.Z) + "/").Length + 1) + ".ogg"); oldEaredY = sty; } else if (sty.Contains(",5") && sty != oldEaredY) { engine.Play2D("sounds/Movement/move" + random.Next(1, 12) + ".ogg"); oldEaredY = sty; } }
//takes file name as a string parameter and activates the corresponding mp3 file private void activator(string file) { if (PlayingSound == null) { PlayingSound = sound.Play2D(file, false); currentFile = soundfile; } if (PlayingSound != null && PlayingSound.Paused == false && currentFile == soundfile) { PlayingSound.Paused = true; } else if (PlayingSound != null && PlayingSound.Paused == true) { if (currentFile == soundfile) { PlayingSound.Paused = false; } else { PlayingSound = sound.Play2D(file, false); currentFile = soundfile; } } if (PlayingSound.Finished == true) { PlayingSound = sound.Play2D(file, false); } }
void pictureBox2_Click(object sender, EventArgs e) { if (GetPictureBoxImageIsPlay()) { SetPictureBoxPause(true); if (mediaType == MediaType.Video) { MediaControl.Run(); } else if (mediaType == MediaType.Audio) { currentSound.Paused = false; if (currentSound.Finished) { currentSound = soundengine.Play2D(filepath); timer1.Start(); } } } else { SetPictureBoxPause(false); if (mediaType == MediaType.Video) { MediaControl.Pause(); } else if (mediaType == MediaType.Audio) { currentSound.Paused = true; } } }
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 static void PlayBGM() { if (currentBGM != 3) { IBGM.Play2D(Directory + BGM[currentBGM], true); } }
public static VSound PlaySource(VSoundSource src, bool loop = false) { var snd = engine.Play2D(src.Src, loop, false, false); var vs = new VSound(); vs.Snd = snd; return(vs); }
private static void playVaried(string soundPath) { ISound sound = engine.Play2D(soundPath); Random r = new Random(); float speed = 1.0f + ((float)r.NextDouble() - 0.5f) * 0.5f; sound.PlaybackSpeed = speed; engine.Update(); }
static public void play(string mp3) { if (mp3 == null) { return; } stop(); bgm.Play2D(mp3, true); }
public FileSound StartPlayingOnce(FileSound sound) { if (!Enabled) { return(null); } sound.Sound = soundEngine.Play2D(sound.SoundName); return(sound); }
public void Play(bool stopPrevious = false) { if (SourceEntity == null) { return; } if (stopPrevious && SoundInstances.Count > 0) { SoundInstances.ForEach(x => x.Stop()); } ISound iSound; if (Flags.HasFlag(AudioFlags.No3D)) { if (_soundSource == default) { iSound = _soundEngine.Play2D(FilePath, Flags.HasFlag(AudioFlags.Loop), true, StreamMode.AutoDetect); } else { iSound = _soundEngine.Play2D(_soundSource, Flags.HasFlag(AudioFlags.Loop), true, false); } } else { if (_soundSource == default) { iSound = _soundEngine.Play3D(FilePath, MathUtils.Vector3ToVector3D(Vector3.Zero), Flags.HasFlag(AudioFlags.Loop), true, StreamMode.AutoDetect); } else { iSound = _soundEngine.Play3D(_soundSource, 0, 0, 0, Flags.HasFlag(AudioFlags.Loop), true, false); } } if (iSound == null) { throw new Exception($"KRAL Engine init failed. File Path: {FilePath}"); } SoundInstances.Add(iSound); Last = iSound; if (StartFadeIn) { Last.Volume = 0; IsDoingFadeIn = true; } Last.Paused = false; }
private ISound getEffect() { if (sound == null) { //ISoundSource src = engine.AddSoundSourceFromFile("media/" + FilePath); sound = engine.Play2D("media/" + FilePath, false, true); } //sound.SoundEffectControl.EnableEchoSoundEffect() return(sound); }
/// <summary> /// Plays the effect from the file with game effects by the given name. /// </summary> /// <param name="name">The name of the effect.</param> public void PlayEffect(string name) { // Controls if sound is in media/music/effect if (effects.ContainsKey(name)) { sound = engine.Play2D(effects[name]); } else { Console.WriteLine("Sound " + name + " missing"); } }
public Rooms(Map map, int rminx, int rmaxx, int rminy, int rmaxy, int rminz, int rmaxz, string rsound) { this.map = map; this.minx = rminx; this.maxx = rmaxx; this.miny = rminy; this.maxy = rmaxy; this.minz = rminz; this.maxz = rmaxz; this.sound = rsound; engine.Play2D("sounds/rooms/" + rsound + ".mp3", true); }
public void click() { bar.currentFrame = 0; _active = true; if (_mirrored) { engine.Play2D("sounds/clap.ogg"); } else { engine.Play2D("sounds/kick.ogg"); } }
/// <summary> /// /// </summary> /// <param name="type"></param> /// <param name="player"></param> /// <param name="name"></param> /// <param name="headRelative"></param> /// <param name="pos"></param> /// <param name="volumeModifier"></param> /// <param name="loop"></param> /// <returns></returns> ISound Play(SoundType type, Player player, string name, bool headRelative, Vector3 pos, float volumeModifier = 1f, bool loop = false) { if (string.IsNullOrEmpty(name) || (DisableWorldSounds && type == SoundType.World)) { return(null); } if (player != null && player != player.World.LocalPlayer) { return(null); } return(soundEngine.Play2D(sounds[name], loop, headRelative, pos, InternalSoundVolume * volumeModifier, true)); }
static ISound Play(Player player, string name, bool headRelative, float2 pos, float volumeModifier) { if (player != null && player != player.World.LocalPlayer) { return(null); } if (name == "" || name == null) { return(null); } return(soundEngine.Play2D(sounds[name], false, headRelative, pos, InternalSoundVolume * volumeModifier)); }
static ISound Play(Player player, string name, bool headRelative, WPos pos, float volumeModifier) { if (string.IsNullOrEmpty(name)) { return(null); } if (player != null && player != player.World.LocalPlayer) { return(null); } return(soundEngine.Play2D(sounds[name], false, headRelative, pos, InternalSoundVolume * volumeModifier, true)); }
private bool Evenement(Event e) { if (Vies <= 0) { return(false); } if (e.Type == EventType.Key) { switch (e.Key.Key) { case KeyCode.KeyZ: K_Avant = e.Key.PressedDown; break; case KeyCode.KeyS: K_Arriere = e.Key.PressedDown; break; case KeyCode.KeyQ: K_Gauche = e.Key.PressedDown; break; case KeyCode.KeyD: K_Droite = e.Key.PressedDown; break; } } else if (e.Type == EventType.Mouse) { if ((e.Mouse.Type == MouseEventType.LeftDown) && (FramePistolet == 0)) { Audio.Play2D(@"Sound\pistolet.wav"); Tirer(); FramePistolet = 1; ProchaineFramePistolet = 0.1f; } } return(false); }
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 }
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 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 SFX(byte[] song, string name) { ISoundEngine sfx = new ISoundEngine(); ISoundSource source = sfx.AddSoundSourceFromMemory(song, name); sfx.Play2D(source, false, false, true); }
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; } }
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 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)); } }
/// <summary> /// SEを再生します。 /// </summary> public ISoundObjectBackend Play(string filename, double volume) { if (engine == null) { return(null); } if (string.IsNullOrEmpty(filename)) { return(null); } var source = GetSoundSource(filename); if (source == null) { throw new InvalidDataException( "音声ファイルの読み込みに失敗しました。"); } // 再生 var sound = engine.Play2D(source, false, true, false); if (sound == null) { throw new InvalidOperationException( "音声ファイルの再生に失敗しました。"); } // 音量を設定します。 sound.Volume = MathEx.Between(0.0f, 1.0f, (float)(engine.SoundVolume * volume)); sound.Paused = false; return(new SoundObjectBackend_IrrKlang(sound)); }
public static void PlaySound(Sounds SonidoATocar) { if (sounds_on) { ISounds.Play2D(Directory + Sonido[(int)SonidoATocar], false); } }
public static void playBgm(string soundName, float volumenn) { try { volumen = volumenn; mediaPlayerControl.SoundVolume = volumen; musica = mediaPlayerControl.Play2D(soundName, true); //mainOutput = new DirectSoundOut(); //mainOutput = new DirectSoundOut(); BgmAdress = soundName; // WaveMixerStream32 mixerer = new WaveMixerStream32(); //mixerer.AutoStop = true; //mixerer.AddInputStream(CreateInputStreamReturnable(BgmAdress)); //mainOutput.Init(mixerer); //mixerin = mixerer; //mainOutput.Volume = volumen; //mainOutput.Play(); //mainOutput.PlaybackStopped += new EventHandler(mainOutput_PlaybackStopped); } catch (Exception e) { onError(e.Message); } }
public static void PlayMusic(string sound, bool loop = true) { var music = SoundEngine.Play2D(sound, loop, true); music.Volume = SoundOn ? MusicVolume : 0; MusicList.Add(music); music.Paused = false; }
public void Load(Sound sound) { sound.iSourceSource = soundEngine.GetSoundSource(sound.FileName, true); switch (sound.Is3D) { case true: sound.iSound = soundEngine.Play3D(sound.iSourceSource, sound.Position.x, sound.Position.y, sound.Position.z, sound.Loop, sound.Stopped, false); break; default: sound.iSound = soundEngine.Play2D(sound.iSourceSource, sound.Loop, sound.Stopped, false); break; } StopAllSounds(); }
public SFX(string effect) { if (effect == null) return; ISoundEngine sfx = new ISoundEngine(); sfx.Play2D(effect); }
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'); }
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); } }
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(); } } }
static void Main(string[] args) { // start the sound engine with default parameters ISoundEngine engine = new ISoundEngine(); // we play a .xm file as music here. Note that the last parameter // named 'enableSoundEffects' has been set to 'true' here. If this // is not done, sound effects cannot be used with this sound. // After this, we print some help text and start a loop which reads // user keyboard input. ISound music = engine.Play2D("../../media/MF-W-90.XM", false, false, StreamMode.AutoDetect, true); // Print some help text and start the display loop Console.Out.Write("\nSound effects example. Keys:\n"); Console.Out.Write("\nESCAPE: quit\n"); Console.Out.Write("w: enable/disable waves reverb\n"); Console.Out.Write("d: enable/disable distortion\n"); Console.Out.Write("e: enable/disable echo\n"); Console.Out.Write("a: disable all effects\n"); while(true) // endless loop until user exits { int key = _getch(); // 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 (key == 27) break; // user pressed ESCAPE key else { ISoundEffectControl fx = null; if (music != null) fx = music.SoundEffectControl; if (fx == null) { // some sound devices do not support sound effects. Console.Out.Write("This device or sound does not support sound effects.\n"); continue; } // here we disable or enable the sound effects of the music depending // on what key the user pressed. Note that every enableXXXSoundEffect() // method also accepts a lot of parameters, so it is easily possible // to influence the details of the effect. If the sound effect is // already active, it is also possible to simply call the // enableXXXSoundEffect() method again to just change the effect parameters, // although we aren't doing this here. if (key < 'a') // make key lower key += 'a' - 'A'; switch(key) { case 'd': if (fx.IsDistortionSoundEffectEnabled) fx.DisableDistortionSoundEffect(); else fx.EnableDistortionSoundEffect(); break; case 'e': if (fx.IsEchoSoundEffectEnabled) fx.DisableEchoSoundEffect(); else fx.EnableEchoSoundEffect(); break; case 'w': if (fx.IsWavesReverbSoundEffectEnabled) fx.DisableWavesReverbSoundEffect(); else fx.EnableWavesReverbSoundEffect(); break; case 'a': fx.DisableAllEffects(); break; } } } }
private void btnPlay_Click(object sender, EventArgs e) { openFileDialog3.InitialDirectory = Application.StartupPath + "\\musicas\\"; if (openFileDialog3.ShowDialog() == DialogResult.OK) { ISoundEngine engine = new ISoundEngine(); musica = engine.Play2D(openFileDialog3.FileName); timer1.Start(); btnPlay.Enabled = false; btnStop.Enabled = true; btnPause.Enabled = true; } }
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 void Play(ISoundEngine engine) { Byte[] data = new Byte[this.length * 2]; // signed 16-bit for (Int32 i = 0; i < this.length; i++) { Int16 sample = (Int16)values[i]; data[i * 2] += (byte)(sample >> 8); data[(i * 2) + 1] += (byte)(sample & 0xFF); //writer.Write(sample); } engine.RemoveSoundSource(name); this.source = engine.AddSoundSourceFromPCMData(data, name, fmt); engine.Play2D(name, true); }
public void Play(ISoundEngine soundEngine) { if (!Stopped && !IsPlaying /*!soundEngine.IsCurrentlyPlaying(Source.Name)*/) { IsPlaying = true; switch (Is3D) { case true: soundEngine.Play3D(Source, Position.X, Position.Y, Position.Z, Loop, false, false); break; default: soundEngine.Play2D(Source, Loop, false, false); break; } } }
public void SPEAK(object st) { int internal_preceding_vowel = 0, internal_character = 0; //var h=0x50; char ch = 'আ'; int integer = 2437; ch = (char)integer; //MessageBox.Show(h.ToString()); //float f=0; //////////////////////////////////////IrrKlang object start ISoundEngine engine = new ISoundEngine(); ISound music = null; ISoundEffectControl fx = null; /////////////////////////////////IrrKlang object finished Detect_Convert det_con_obj = new Detecting_Converting_String.Detect_Convert(); string str = (string)st + " END", play_string = " "; for (char_no = play_position.Value; char_no < str.Length - 5; char_no++) { play_position.Value = char_no; if (str[play_position.Value] == ' ') { int i = play_position.Value + 1; current_string = Editor.Text + " "; current_string = current_string.Substring(i, 15); current_string = current_string.Substring(0, current_string.IndexOf(" ")); this.label1.Text = "বর্তমান শব্দ : " + current_string; } if (btnReset.Text == "STOP") { if (str[char_no].ToString() == " " || str[char_no].ToString() == "।" || str[char_no].ToString() == "!" || str[char_no].ToString() == "," || str[char_no].ToString() == "?" || str[char_no] == 0x9CD)//SPACE { internal_character = 0; internal_preceding_vowel = 0; music = engine.Play2D("SOUND//SPACE.wav", false, false, StreamMode.AutoDetect, true); music.Volume = .01f * volume.Value; music.PlaybackSpeed = 0.2f * tempo.Value; while (music.Finished == false) ; } else if (str[char_no] >= 0x985 && str[char_no] <= 0x994)//START WITH VOWEL start/// A O OU AT AM AM { if ((str[char_no + 2] < 0x9BE && str[char_no + 1] >= 0X995) || (str[char_no + 2] > 0x9CC))//AT AM AM/ { play_string = str.Substring(char_no, 2); char_no += 1; play_string = det_con_obj.convert(play_string); play_string = play_string + ".mp3"; // play a sound file // MessageBox.Show(play_string); music = engine.Play2D("SOUND//" + play_string, false, false, StreamMode.AutoDetect, true); music.Volume = .1f * volume.Value; music.PlaybackSpeed = 0.2f * tempo.Value; while (music.Finished == false) ;// while(music.Finished==false); internal_character = 1; } else //A O { play_string = str[char_no].ToString(); play_string = det_con_obj.convert(play_string); play_string = play_string + ".mp3"; // play a sound file music = engine.Play2D("SOUND//" + play_string, false, false, StreamMode.AutoDetect, true); //music.Volume = .1f * volume.Value; music.PlaybackSpeed = 0.2f * tempo.Value; while (music.Finished == false) ; internal_character = 1; } }//////////////////////////////////START WITH VOWEL END else if (str[char_no] >= 0x995 || str[char_no] <= 0x9B9)/// KO to HO KA TO HA START WITH CONSONANT { if (str[char_no + 1] >= 0x9BE && str[char_no + 1] <= 0x9CC)////KA PA HA { play_string = str.Substring(char_no, 2); char_no++; play_string = det_con_obj.convert(play_string); play_string = play_string + ".mp3"; // play a sound file music = engine.Play2D("SOUND//" + play_string, false, false, StreamMode.AutoDetect, true); fx = music.SoundEffectControl; music.Volume = .1f * volume.Value; music.PlaybackSpeed = 0.2f * tempo.Value; while (music.Finished == false) ; internal_character = 1; }////KA PA HA end else //KO HO MO { if (char_no != 0 && str[char_no - 1] >= 0x9BE && str[char_no - 1] <= 0x9CC)//AK OK KAK { fx = music.SoundEffectControl; ch = str[char_no - 1]; integer = ch - 0x38; ch = (char)integer; ch.ToString(); play_string = ch + str[char_no].ToString(); play_string = det_con_obj.convert(play_string); play_string = play_string + ".mp3"; music.Volume = .01f; music.PlaybackSpeed = 0.2f * tempo.Value; music.PlayPosition = (uint)180; music = engine.Play2D("SOUND//" + play_string, false, false, StreamMode.AutoDetect, true); music.Volume = .01f; Thread.Sleep(80); music.Volume = .03f; Thread.Sleep(50); music.Volume = .08f; Thread.Sleep(50); music.Volume = .09f; Thread.Sleep(50); music.Volume = .01f; while (music.Finished == false) ; } else //KO HO { play_string = str[char_no].ToString(); play_string = det_con_obj.convert(play_string); play_string = play_string + ".mp3"; music = engine.Play2D("SOUND//" + play_string, false, false, StreamMode.AutoDetect, true); music.Volume = .1f * volume.Value; music.PlaybackSpeed = 0.2f * tempo.Value; while (music.Finished == false) ; } } } ////KO HO KA HA END } } play_position.Value = 0; play_position.Minimum = 0; // MessageBox.Show("END !"); btnReset.Text = "READ"; }