public static void Initialize() { sounds = new Cache<string, ISoundSource>(LoadSound); music = null; currentMusic = null; video = null; }
public Demo() { this.graphics = new GraphicsDeviceManager(this); this.sound = new SoundBASS(); Content.RootDirectory = "Content"; }
public Sound2D(string soundName, bool looped, bool paused) { this.loop = looped; this.paused = paused; SoundEffect soundEffect = ResourceManager.Inst.GetSoundEffect(soundName); this.sound = SoundEngine.Device.Play2D(soundEffect.Sound, loop, paused, false); }
public void Play(ISound Sound) { #if DEBUG_VERBOSE if (Debugger.IsAttached) Debug.WriteLine("Play(Sound) called from NullAudioService"); #endif }
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 EntityWalker(string unique_name) : base(unique_name) { IsGhost = false; StepSounds = new List<string>(); active_step_sound = null; step_sound_index = 0; }
Result IFModSystem.PlaySound(ChannelIndex channelIndex, ISound sound, bool paused, ref IChannel channel) { CheckMemberOnlyCall(); var result = NativeFModSystem.PlaySound(Self, channelIndex, sound, paused, ref channel); return result; }
Result IFModSystem.CreateStream(String nameOrData, Mode mode, IntPtr extInfo, ref ISound sound) { CheckMemberOnlyCall(); var result = NativeFModSystem.CreateStream(Self, nameOrData, mode, extInfo, ref sound); return result; }
public void Play(ISound sound) { lock (_lock) { sounds.Add(sound); } }
public void PlayLooped() { if (_sound == null) _sound = AudioProvider.SoundEngine.Play2D(_source, true, false, false); else { _sound.Looped = true; _sound.Paused = false; } }
public void LoadFile(string filePath) { if(internalSound != null) { internalSound.Stop(); internalSound.Dispose(); } internalSound = soundFactory.GetSoundForFile(filePath); }
void ISoundStopEventReceiver.OnSoundStopped(ISound sound, StopEventCause reason, object userData) { _soundPlaying = null; if (PlayFinished != null) { PlayFinished(_audioClip); _audioClip = null; } }
public void Dispose() { if(m_Sound != null) { m_Sound.Dispose(); m_Sound = null; m_Filename = null; } }
public void Stop() { if (_soundPlaying != null) { _soundPlaying.Stop(); _soundPlaying = null; _soundEngine.RemoveAllSoundSources(); _soundEngine.StopAllSounds(); } }
public void Stop() { if (Sound != null) { if (!Sound.Finished) Sound.Stop(); Sound.Dispose(); Sound = null; } }
SoundManager() { Sound = new SoundXACT() { SettingsFile = @"Content\Sound\ccm.xgs", EffectWaveBankFile = @"Content\Sound\SE Bank.xwb", StreamWaveBankFile = @"Content\Sound\BGM Bank.xwb", SoundBankFile = @"Content\Sound\Sound Bank.xsb", }; }
public IntroScreen(Game Game) : base(Game, GeneralManager.ScreenX, GeneralManager.ScreenY) { BSS = new BlackScreenSwitch(); BSS.SwitchState = SceneSwitchEffect.State.SwitchOn; BSS.MaxTime = 1f; m = SoundEngine.PlaySound(Vector2.Zero,"Content/Sounds/Logos jingle.mp3"); Renderer.AddPostProcess(BSS, "Switch"); }
/// <summary> /// Runs whenever a new level is loaded. We create the background music now so it loads, then pause it until we need to play it. /// </summary> void OnLevelLoad(LevelChangedEventArgs eventArgs) { // only want to load this on nonempty levels if (eventArgs.NewLevel.Type != LevelType.EmptyLevel) { // get the property from the .muffin file, if it has one string musicFile = eventArgs.NewLevel.Definition.GetStringProperty("Music", string.Empty); if (musicFile != string.Empty) { // if it's a race level, don't play the music until we need it bgMusic = LKernel.GetG<SoundMain>().PlayMusic(musicFile, eventArgs.NewLevel.Type == LevelType.Race); } } }
public void Play(ISound Sound) { var sound = (XNASound)Sound; if (AllowedToPlay) { var inst = sound.Sound.CreateInstance(); inst.Volume = sound.Volume; inst.Pitch = sound.Pitch; inst.Pan = sound.Pan; inst.Play(); } }
/// <summary> /// Make sure the volumes are "finished", then detach from the frame event /// </summary> public void Detach() { if (soundToFadeOut != null) soundToFadeOut.Volume = 0f; if (soundToFadeIn != null) soundToFadeIn.Volume = targetFadeInVolume; LKernel.GetG<Root>().FrameEnded -= FrameEnded; soundToFadeOut = null; soundToFadeIn = null; }
/// <summary> /// 再生が停止した時に呼ばれます。 /// </summary> void ISoundStopEventReceiver.OnSoundStopped(ISound sound, StopEventCause cause, object userData) { var handler = Interlocked.Exchange(ref Stopped, null); if (handler != null) { var reason = ConvertReason(cause); handler(null, new SoundStopEventArgs(reason)); } }
/// <summary> /// Creates a crossfader that will crossfade two sounds over the specified duration. /// </summary> /// <param name="toFadeOut">The sound you want to fade out.</param> /// <param name="toFadeIn">The sound you want to fade in.</param> /// <param name="duration">How long you want the crossfade to take, in seconds.</param> /// <param name="toFadeInVolume">What volume you want the "fade in" sound to have when it is completed</param> public SoundCrossfader(ISound toFadeOut, ISound toFadeIn, float duration, float toFadeInVolume = 1f) { // NOTE: Sounds will not exist when we're using the null sound driver! // Make sure that the sound is not null before touching it. this.duration = duration; this.soundToFadeIn = toFadeIn; this.soundToFadeOut = toFadeOut; this.initialFadeOutVolume = toFadeOut == null ? 0.0f : toFadeOut.Volume; this.targetFadeInVolume = toFadeIn == null ? 1.0f : toFadeInVolume; LKernel.GetG<Root>().FrameEnded += FrameEnded; }
public TwiCutlass(ThingBlock block, ThingDefinition def) : base(block, def) { // sounds soundMain = LKernel.GetG<SoundMain>(); idleSound = SoundComponents[0].Sound; fullSound = SoundComponents[1].Sound; // convert from linear velocity to KPH topSpeedKmHour = DefaultMaxSpeed * 3.6f; LKernel.GetG<Root>().FrameStarted += FrameStarted; }
public void Play(string filename = null) { if (filename == null) { playerStopWatch.Start(); engine.SetAllSoundsPaused(false); } else { playerStopWatch.Restart(); engine.StopAllSounds(); currentSound = engine.Play2D(filename); } IsPlaying = true; }
public bool Play(string soundName, bool loop) { if (ActiveScene == null) return false; if (Sound != null) { if (!Sound.Finished) Sound.Stop(); Sound.Dispose(); Sound = null; } return ActiveScene.Jukebox.Play3D(soundName, (Vector3D)Position, loop, false, false, out Sound); }
private void btnChooseFile_Click(object sender, EventArgs e) { eng.StopAllSounds(); OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { path = ofd.FileName; name = ofd.SafeFileName; tbFileName.Text = name; S = eng.Play2D(path, false, false, StreamMode.AutoDetect, true); int length = Convert.ToInt32(S.PlayLength / 1000); tbarProgress.Maximum = length; superflag = 1; } }
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 Play(Song song) { try { Stop(); Current = Engine.Play2D(song.Path); CurrentSong = song; IsPlaying = true; song.IsPlaying = true; song.Style = Text.Styles.Bold; } catch { return false; } return true; }
public DeployerContext(ISimultaneousKeys keys, IProjectSelector projectSelect, ICharDisplay lcd, IIndicators indicatorRefresh, ISound sound, IWebUtility netio, INetwork network, IWebRequestFactory webFactory, IGarbage garbage, IConfigurationService configurationService) { _keys = keys; _projectSelect = projectSelect; _lcd = lcd; _indicatorRefresh = indicatorRefresh; _sound = sound; _netio = netio; _network = network; _webFactory = webFactory; _garbage = garbage; _configurationService = configurationService; }
public bool Play(AudioClip clip) { if (!File.Exists(clip.CacheFileName)) { return false; } // 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); ISoundSource source = _soundEngine.AddSoundSourceFromMemory(audioData, clip.CacheFileName); _soundPlaying = _soundEngine.Play2D(source, false, false, false); if (_soundPlaying == null) { return false; } _audioClip = clip; _soundPlaying.setSoundStopEventReceiver(this); return true; }
public ScoreManager(PPDDevice device, PPDFramework.Resource.ResourceManager resourceManager, DxTextBox textBox, ISound sound, SongSelectFilter filter) : base(device) { this.sound = sound; this.textBox = textBox; this.filter = filter; back = new PictureObject(device, resourceManager, Utility.Path.Combine("scoremanager", "back.png")); folder = new PictureObject(device, resourceManager, Utility.Path.Combine("scoremanager", "folder.png")); score = new PictureObject(device, resourceManager, Utility.Path.Combine("scoremanager", "score.png")); Lw = new PictureObject(device, resourceManager, Utility.Path.Combine("scoremanager", "lw.png")) { Position = new Vector2(34, 57) }; Lb = new PictureObject(device, resourceManager, Utility.Path.Combine("scoremanager", "lb.png")) { Position = new Vector2(34, 57) }; Rw = new PictureObject(device, resourceManager, Utility.Path.Combine("scoremanager", "rw.png")) { Position = new Vector2(720, 57) }; Rb = new PictureObject(device, resourceManager, Utility.Path.Combine("scoremanager", "rb.png")) { Position = new Vector2(720, 57) }; songInfoSelection = new RectangleComponent(device, resourceManager, PPDColors.White); logicInfoSelection = new RectangleComponent(device, resourceManager, PPDColors.White); black = new RectangleComponent(device, resourceManager, PPDColors.Black) { RectangleHeight = 450, RectangleWidth = 800, Alpha = 0.65f }; this.AddChild(new TextureString(device, Utility.Language["ScoreManager"], 24, PPDColors.White) { Position = new Vector2(32, 25) }); this.AddChild(new TextureString(device, Utility.Language["Move"], 16, PPDColors.White) { Position = new Vector2(70, 406) }); this.AddChild(new TextureString(device, Utility.Language["SortInHolding"], 16, PPDColors.White) { Position = new Vector2(190, 406) }); this.AddChild(new TextureString(device, Utility.Language["Menu"], 16, PPDColors.White) { Position = new Vector2(430, 406) }); this.AddChild(new TextureString(device, Utility.Language["FolderExpandCollapse"], 16, PPDColors.White) { Position = new Vector2(545, 406) }); this.AddChild(new TextureString(device, Utility.Language["Back"], 16, PPDColors.White) { Position = new Vector2(707, 406) }); this.AddChild(back); this.AddChild(black); createlinkmenu = Utility.Language["CreateLink"]; createfoldermenu = Utility.Language["CreateFolder"]; cutmenu = Utility.Language["Cut"]; copymenu = Utility.Language["Copy"]; pastemenu = Utility.Language["Paste"]; deletemenu = Utility.Language["Delete"]; renamemenu = Utility.Language["Rename"]; cm = new ContextMenu(device, resourceManager, sound); cm.Selected += cm_Selected; Inputed += ScoreManager_Inputed; SongInformation.Updated += SongInformation_Updated; }
public static void Play(ISound wave) { var player = new WavePlayer(); player.PlayWave(wave, false); }
public void RemoveSound(ISound sound) { }
public Sound() { // soundEngine = null; music = new Silent(); video = new Silent(); }
public void StopSound(ISound sound) { }
public static void PlayVideo(byte[] raw) { rawSource = LoadSoundRaw(raw); video = soundEngine.Play2D(rawSource, false, true, float2.Zero, InternalSoundVolume, false); }
protected BaseBird(IFlying flying, ISound sound, ISwimming swimming) { _fly = flying ?? throw new ArgumentNullException(); _sound = sound ?? throw new ArgumentNullException(); _swim = swimming ?? throw new ArgumentNullException(); }
public LeftMenu(PPDDevice device, IGameHost gameHost, PPDFramework.Resource.ResourceManager resourceManager, DxTextBox textBox, SelectSongManager ssm, ISound sound) : base(device) { this.gameHost = gameHost; this.resourceManager = resourceManager; this.sound = sound; this.textBox = textBox; this.ssm = ssm; scoreUpdateCountBack = new PictureObject(device, resourceManager, Utility.Path.Combine("update_count_back.png")) { Position = new Vector2(20, 90), Hidden = true, Alpha = 0.75f }; scoreUpdateCountBack.AddChild(scoreUpdateCount = new NumberPictureObject(device, resourceManager, Utility.Path.Combine("result", "scoresmall.png")) { Position = new Vector2(17, 5), Alignment = PPDFramework.Alignment.Center, MaxDigit = -1, Scale = new Vector2(0.75f) }); modUpdateCountBack = new PictureObject(device, resourceManager, Utility.Path.Combine("update_count_back.png")) { Position = new Vector2(20, 330), Hidden = true, Alpha = 0.75f }; modUpdateCountBack.AddChild(modUpdateCount = new NumberPictureObject(device, resourceManager, Utility.Path.Combine("result", "scoresmall.png")) { Position = new Vector2(17, 5), Alignment = PPDFramework.Alignment.Center, MaxDigit = -1, Scale = new Vector2(0.75f) }); WebSongInformationManager.Instance.Updated += Instance_Updated; WebSongInformationManager.Instance.Update(true); this.Inputed += LeftMenu_Inputed; this.GotFocused += LeftMenu_GotFocused; }
public ExSound(ISound sound) { this.sound = sound; }
/// <summary> /// Remove the sound reference from playing queue. /// </summary> /// <param name="sound"></param> public void RemoveSoundReference(ISound sound) { sounds.Remove(sound); }
public async Task SayAsync(string text, PointF?textPosition = null, PointF?portraitPosition = null) { var outfit = _outfit; var walkComponent = _walkComponent; var previousAnimation = _faceDirection?.CurrentDirectionalAnimation; var speakAnimation = outfit == null ? null : outfit.Outfit[AGSOutfit.Speak]; bool wasWalking = false; if (walkComponent?.IsWalking ?? false) { if (outfit?.Outfit[AGSOutfit.SpeakAndWalk] == null) { await walkComponent.StopWalkingAsync(); previousAnimation = _outfit.Outfit[AGSOutfit.Idle]; } else { wasWalking = true; speakAnimation = outfit.Outfit[AGSOutfit.SpeakAndWalk]; } } if (_state.Cutscene.IsSkipping) { if (outfit != null) { await setAnimation(previousAnimation); } return; } if (speakAnimation != null) { await setAnimation(speakAnimation); } await Task.Delay(1); var speech = await _speechCache.GetSpeechLineAsync(_characterName, text); text = speech.Text; ISayLocation location = getLocation(text); var textLocation = textPosition ?? location.TextLocation; portraitPosition = portraitPosition ?? location.PortraitLocation; IObject portrait = showPortrait(portraitPosition); ILabel label = _factory.UI.GetLabel($"Say: {text} {Guid.NewGuid().ToString()}", text, SpeechConfig.LabelSize.Width, SpeechConfig.LabelSize.Height, textLocation.X, textLocation.Y, config: SpeechConfig.TextConfig, addToUi: false); label.RenderLayer = AGSLayers.Speech; label.Border = SpeechConfig.Border; label.Tint = SpeechConfig.BackgroundColor; TaskCompletionSource <object> externalSkipToken = new TaskCompletionSource <object> (null); BeforeSayEventArgs args = new BeforeSayEventArgs(label, () => externalSkipToken.TrySetResult(null)); OnBeforeSay.Invoke(args); label = args.Label; _state.UI.Add(label); ISound sound = null; if (speech.AudioClip != null) { _emitter.AudioClip = speech.AudioClip; sound = _emitter.Play(); } await waitForText(text, externalSkipToken.Task, sound); _state.UI.Remove(label); label.Dispose(); if (portrait != null) { portrait.Visible = false; } if (outfit != null && _faceDirection?.CurrentDirectionalAnimation == speakAnimation) //if the animation is not speakAnimation, somebody switched the animations during speak (perhaps the character is now walking), so we shouldn't revert the animation to what it was before { if (wasWalking && !walkComponent.IsWalking) { previousAnimation = outfit.Outfit[AGSOutfit.Idle]; //If we were in the middle of a walk but walk was completed before speech, then instead of revert to the previous animation (walk) we need to go to idle. } await setAnimation(previousAnimation); } }
private void FetchSound(ISound sound) { Microphone.FetchSound(sound); }
public IRiffContainer Encode(ISound sound) { var sampleRate = sound[NumericData.Rate]; if (sampleRate == null) { var sampleRates = sound .Samples .Select(s => s[NumericData.Rate]) .Where(r => r != null) .Distinct() .ToArray(); sampleRate = sampleRates.SingleOrDefault(); } if (sampleRate == null) { sampleRate = 44100; } var channels = sound.Samples.Count; var byteRate = sampleRate * channels * 2; var container = new RiffContainer { Format = "WAVE", Chunks = new List <IRiffChunk>() }; var format = new RiffFormat { Format = 1, SampleRate = (int)sampleRate, Channels = channels, ByteRate = (int)byteRate, BitsPerSample = 16, BlockAlign = channels * 2, ExtraData = new byte[0] }; container.Chunks.Add(_formatEncoder.Encode(format)); var totalSamples = sound.Samples.Max(s => s.Data.Count); using (var stream = new MemoryStream()) using (var writer = new BinaryWriter(stream)) { for (var i = 0; i < totalSamples; i++) { for (var j = 0; j < sound.Samples.Count; j++) { var sample = sound.Samples[j]; var source = sample.Data; var sourceValue = i < source.Count ? source[i] : 0f; var value = Math.Round(sourceValue * 32767f); if (value > 32767f) { value = 32767f; } else if (value < -32767f) { value = -32767f; } writer.Write((short)value); } } container.Chunks.Add(new RiffChunk { Id = "data", Data = stream.ToArray() }); } return(container); }
public static void PlayVideo(byte[] raw, int channels, int sampleBits, int sampleRate) { rawSource = LoadSoundRaw(raw, channels, sampleBits, sampleRate); video = soundEngine.Play2D(rawSource, false, true, WPos.Zero, InternalSoundVolume, false); }
public override void FetchSound(ISound sound) { ///code that fetch sound }
public UserSelectComponent(PPDDevice device, PPDFramework.Resource.ResourceManager resourceManager, ISound sound, ChangableList <User> users) : base(device) { this.resourceManager = resourceManager; this.sound = sound; this.AddChild(back = new PictureObject(device, resourceManager, Utility.Path.Combine("dialog_back.png"))); back.AddChild(new TextureString(device, Utility.Language["PlayerManager"], 30, PPDColors.White) { Position = new Vector2(35, 30) }); back.AddChild(userSprite = new SpriteObject(device) { Position = new Vector2(40, 80) }); this.AddChild(new RectangleComponent(device, resourceManager, PPDColors.Black) { RectangleHeight = 450, RectangleWidth = 800, Alpha = 0.75f }); Inputed += ItemSettingComponent_Inputed; GotFocused += ItemSettingComponent_GotFocused; foreach (var user in users) { if (user.IsSelf) { continue; } userSprite.AddChild(new UserComponent(device, resourceManager, user)); } AdjustPosition(); users.ItemChanged += users_ItemChanged; }
public void PauseSound(ISound sound, bool paused) { }
public void PlayVideo(byte[] raw, int channels, int sampleBits, int sampleRate) { StopVideo(); videoSource = soundEngine.AddSoundSourceFromMemory(raw, channels, sampleBits, sampleRate); video = soundEngine.Play2D(videoSource, false, true, WPos.Zero, InternalSoundVolume, false); }
public void SetSoundVolume(float volume, ISound music, ISound video) { }
public SoundStoppedEventArgs(ISound sound) { Sound = sound; }
public static ISound New(AudioTypes audioType, IDisposableResource parent, string filename, int instanceCount, bool looped, Loader.LoadedCallbackMethod loadedCallback) { ISound api = null; var soundFormat = SoundFormats.None; string ext = Streams.GetFileExt(filename); switch (ext.ToLower()) { case ".wav": soundFormat = SoundFormats.WAV; break; default: Debug.ThrowError("SoundAPI", string.Format("File 'ext' {0} not supported.", ext)); return(null); } #if WIN32 || WINRT if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.XAudio) { api = new XAudio.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif #if XNA if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.XNA) { api = new XNA.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif #if OSX || iOS if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.Cocoa) { api = new Cocoa.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif #if LINUX if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.OpenAL) { api = new OpenAL.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif #if ANDROID if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.Android) { api = new Android.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif if (audioType == AudioTypes.Dumby) { api = new Dumby.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } if (api == null) { Debug.ThrowError("SoundAPI", "Unsuported InputType: " + audioType); } return(api); }
public GameEngine(MessageBus bus, GameObjectFactory factory, WidgetFactory widgetFactory, IGraphicsLoader graphicsLoader, ISound sound) { _currentState = new IdleState(this); Timer = new AsyncObservableTimer(); Bus = bus; Factory = factory; _graphicsLoader = graphicsLoader; Sound = sound; WidgetFactory = widgetFactory; Bus.OfType <GraphicsLoadedMessage>().Subscribe(m => { Graphics = m.Graphics; WidgetFactory.Initialise(Graphics); Bus.Add(new GameStartMessage(Timer.LastTickTime)); }); IsRunning = false; Timer.Subscribe(Update); Timer.SubSample(5).Subscribe(t => Bus.SendAll()); //Timer.Subscribe(t => Bus.Add(new GraphicsDirtyMessage(t))); }
public static void PlaySync(ISound wave) { var player = new WavePlayer(); player.PlayWave(wave, true); }
public EmittedSound(ISound sound) { Sound = sound; ID = runningId; runningId++; }
public abstract string MakeSound(ISound sound);
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(@"C:\Development\irrTech\irrKlang\media\speech.wav", 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 = 0.5f; } // 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; float x = 20; 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(x, 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:f} {1:f} {2:f} ", x, 0.0f, 0.0f); 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(); bool playasound = false; if (key == 27) { break; // user pressed ESCAPE key } else if (key == 'a') { x -= 1; playasound = true; } else if (key == 's') { x = 0; playasound = true; } else if (key == 'd') { x += 1; playasound = true; } 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 = @"C:\Development\irrTech\irrKlang\media\bell.wav"; } else { filename = @"C:\Development\irrTech\irrKlang\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); } if (playasound) { engine.SetListenerPosition(x, 0, 0, 0, 0, 1); engine.Play3D(@"C:\Development\irrTech\irrKlang\media\impact.wav", x, 0, 0, false); } } } }
public BasicAlarm(ISound alarmSound) { _alarmSound = alarmSound; }
public VSound(ISound s) { Src = s; StarSoundSys.SL.Add(this); }
public void PlayAndWait(float volume) { ISound sound = playSound(volume, Pitch, Panning, Tags); Task.Run(async() => await sound.Completed).Wait(); }
public void Load(ISound sound) { reader = sound; }