public MissleSystem2D(List<Collidable> collidableList, CollidableType type, float radius, SoundType soundType, Texture2D weaponTexture, float scale, GraphicsDevice device, int maxBullets, Vector3 weaponPositionRelative, float coolDownMS, float weaponSpeed, float bulletSpreadIntensity, int amountMissles, int life) : base(collidableList, type, radius, soundType, weaponTexture, scale, device, maxBullets, weaponPositionRelative, coolDownMS, weaponSpeed, bulletSpreadIntensity) { AmountMissles = amountMissles; _life = life; }
bool CheckSoundSolid( byte b ) { SoundType newType = game.BlockInfo.StepSounds[b]; if( newType != SoundType.None ) sndType = newType; if( b != 0 ) anyNonAir = true; return false; }
public static void Play(SoundType type) { if (Environment.OSVersion.Platform == PlatformID.Unix) return; if (type != SoundType.None) { Stream sound; switch (type) { case SoundType.Click: sound = Sounds.scificlick; break; case SoundType.Servo: sound = Sounds.panel_move; break; case SoundType.BigClick: sound = Sounds.button_click; break; default: sound = null; break; } if (sound != null) { var sp = new SoundPlayer(sound); sp.Play(); } } }
public void PlayEffect(SoundType id) { // plays an audio clip after its id switch(id){ case SoundType.onClick: if( onButtonPress != null) audio.PlayOneShot(onButtonPress,effectVolume); break; case SoundType.error: if( onError != null) audio.PlayOneShot(onError, effectVolume); break; case SoundType.undo: if( onUndo != null) audio.PlayOneShot(onUndo, effectVolume); break; case SoundType.build: if( onBuild != null) audio.PlayOneShot(onBuild, effectVolume); break; case SoundType.shoot: if( onShoot != null) audio.PlayOneShot(onShoot, effectVolume); break; case SoundType.silence: if( onSilence != null) audio.PlayOneShot(onSilence, effectVolume); break; case SoundType.newTower: if( onNewTower != null) audio.PlayOneShot(onNewTower,effectVolume); break; case SoundType.victory: if( onVictory != null) audio.PlayOneShot(onVictory, effectVolume); break; case SoundType.defeat: if( onDefeat != null) audio.PlayOneShot(onDefeat, effectVolume); break; } }
public void PlaySound(SoundType type, Transform position) { switch (type) { case SoundType.Rustle: rustleManager.PlaySound(position); break; case SoundType.ShortRustle: shortRustleManager.PlaySound(position); break; case SoundType.Creak: creakManager.PlaySound(position); longRustleManager.PlaySound(position); break; case SoundType.Whale: whaleManager.PlaySound(position); break; case SoundType.Bird: birdManager.PlaySound(position); break; case SoundType.BirdSqueak: birdSqueakManager.PlaySound(position); break; default: Debug.LogError("Unexpected sound type: " + type); break; } }
public SoundInstance(ScriptEngine parent, string filename) : base(parent) { PopulateFunctions(); string[] sounds = { ".wav", ".flac" }; string[] music = { ".ogg" }; if (!System.IO.File.Exists(filename)) { _soundType = SoundType.None; return; } _filename = filename; string ending = System.IO.Path.GetExtension(filename); if (Array.Exists(sounds, x => x == ending)) { _sound = new Sound(new SoundBuffer(filename)); _soundType = SoundType.Sound; } else if (Array.Exists(music, x => x == ending)) { _music = new Music(filename); _soundType = SoundType.Music; } }
public static void playSFX(SoundType type) { //Thread soundThread = new Thread(playSound); switch (type) { case SoundType.Click: playSound("GUI/Sounds/click.wav"); //soundThread.Start(@"C:\Users\Team7\Documents\crash.wav"); break; case SoundType.MouseOver: playSound("GUI/Sounds/swish.wav"); //soundThread.Start(@"C:\Users\Team7\Documents\swish.wav"); break; case SoundType.Move: // Play move sound break; case SoundType.KeyDown: playSound("GUI/Sounds/typewriter.wav"); break; case SoundType.Rotate: playSound("GUI/Sounds/swish.wav"); break; default: //playSound(@"C:\Users\Team7\Documents\Windows Notify.wav"); break; } }
public WeaponSystem2D(List<Collidable> collidableRef, CollidableType type, float radius, SoundType soundType, Texture2D weaponTexture, float scale, GraphicsDevice device, int maxBullets, Vector3 weaponPositionRelative, float coolDownMS, float weaponSpeed, float bulletSpreadIntensity) { CollidableReference = collidableRef; _projectileList = new List<Projectile>(); _weaponPositionRelative = weaponPositionRelative; _coolDownMS = coolDownMS; _weaponSpeed = weaponSpeed; _timer = 0; _randomVar = new Random(); _device = device; _textureQuad = new TextureQuad(_device, weaponTexture, scale, scale); _weaponTexture = weaponTexture; _scale = scale; _spriteBatch = new SpriteBatch(_device); _basicEffect = new BasicEffect(_device); _bulletSpreadIntensity = bulletSpreadIntensity; _maxBullets = maxBullets; _type = type; _boundingRadius = radius; _soundDump = new List<Sound>(); _soundType = soundType; }
public SmackerAudioTrack(IMixer mixer, AudioInfo audioInfo, SoundType soundType) { Mixer = mixer; _audioInfo = audioInfo; SoundType = soundType; _audioStream = new QueuingAudioStream((int)_audioInfo.sampleRate, _audioInfo.isStereo); }
/// <summary> /// Instantiate a new fighter controller /// </summary> /// <param name="state">The fighter state (enemy, player, wingman...)</param> /// <param name="trailPositions">List of trails position</param> /// <param name="engineAudio">Engine audio type</param> /// <param name="shootAudio">Gun shoot audio type</param> public FighterController(FighterState state, List<Vector3> trailPositions, SoundType engineAudio, SoundType shootAudio) { this.state = state; this.trailPositions = trailPositions; this.engineAudio = engineAudio; this.shootAudio = shootAudio; }
public override void PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { soundInstance = sound.CreateInstance(); soundInstance.Volume = volume * .5f; soundInstance.Pan = pan; soundInstance.Pitch = -1.0f; Main.PlaySoundInstance(soundInstance); }
void SetSound( int count, SoundType digType, SoundType stepType ) { for( int i = 0; i < count; i++ ) { StepSounds[i + curSoundBlock] = stepType; DigSounds[i + curSoundBlock] = digType; } curSoundBlock += count; }
public SoundProcess(Resource resource, SoundType type, int volume, bool looping) { _soundResource = resource; _volume = volume; _isLooping = looping; AudioType = type; InitializeVolume(); }
/// <summary> /// Gets sound path by its sound type /// </summary> /// <param name="sound"></param> /// <returns></returns> public string GetSoundPath(SoundType sound) { var list = this.soundDictionary[sound]; int id = this.random.NextInt() % list.Length; var soundInfo = list[id]; return soundInfo.Path; }
public void PlayEffect(SoundType Type) { SoundEffect sound = GetSoundEffect(Type); if (sound != null) { sound.Play(); } }
public AudioClip GetAudioClip(SoundType type){ switch(type){ case SoundType.NormalBtnSound: return normalBtnClick; } Debug.LogError("[SoundManager] cannot get the audioclip by the type"); return null; }
/// <summary> /// Play a sound and return its instance /// </summary> /// <param name="sound">The sound type</param> /// <param name="loop">Indicate if the sound must be looped</param> /// <returns>The associated sound instance</returns> public SoundInstance Play(SoundType sound, bool loop = false) { var list = this.soundDictionary[sound]; int id = this.random.NextInt() % list.Length; var soundInfo = list[id]; return this.soundPlayer.Play(soundInfo, 0, loop); }
public override void PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { if (soundInstance.State == SoundState.Playing) return; soundInstance.Volume = volume * .5f; soundInstance.Pan = pan; soundInstance.Pitch = (float)Main.rand.Next(-5, 6) * .05f; Main.PlaySoundInstance(soundInstance); }
public Sound PickRandomSound( SoundType type ) { if( type == SoundType.None ) return null; string name = soundNames[(int)type]; List<Sound> sounds; if( !allSounds.TryGetValue( name, out sounds ) ) return null; return sounds[rnd.Next( sounds.Count )]; }
bool CheckSoundNonSolid( byte b ) { SoundType newType = game.BlockInfo.StepSounds[b]; CollideType collide = game.BlockInfo.Collide[b]; if( newType != SoundType.None && collide != CollideType.Solid ) sndType = newType; if( b != 0 ) anyNonAir = true; return false; }
public Sound (AudioClip clip, SoundType type) { this.id = System.Guid.NewGuid ().GetHashCode (); this.instanceLimit = 3; this.audioClip = clip; this.type = type; this.name = clip.name; this.loop = type == SoundType.Music; }
private SoundEffect GetSoundEffect(SoundType Type) { if (!_effects.ContainsKey(Type)) using (FileStream fs = File.Open((string.Format("Content\\{0}.wav", Type)), FileMode.Open)) { _effects.Add(Type, SoundEffect.FromStream(fs)); } return _effects[Type]; }
public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { // By creating a new instance, this ModSound allows for overlapping sounds. Non-ModSound behavior is to restart the sound, only permitting 1 instance. soundInstance = sound.CreateInstance(); soundInstance.Volume = volume * .5f; soundInstance.Pan = pan; soundInstance.Pitch = -1.0f; return soundInstance; }
/// <summary> /// Initializes new instance of SoundFormat class /// </summary> /// <param name="soundType"></param> /// <param name="rate"></param> /// <param name="channels"></param> public SoundFormat(SoundType soundType, int rate, int channels) { SoundType = soundType; Format = soundType.ToString(); Rate = rate; Channels = channels; Init(); BlockSize = BitsPerSample / 8 * Channels; UseCustomAudioRendering = true; }
public Sound(SoundType type, Vector3 pos, float pitch, bool isLooped) { _randomVar = new Random(); SoundType = type; Position = pos; Volume = 0; IsLooped = isLooped; IsCreated = true; //This Sound was just created. Pitch = pitch; }
public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { // By checking if the input soundInstance is playing, we can prevent the sound from fireing while the sound is still playing, allowing the sound to play out completely. Non-ModSound behavior is to restart the sound, only permitting 1 instance. if (soundInstance.State == SoundState.Playing) return null; soundInstance.Volume = volume * .5f; soundInstance.Pan = pan; soundInstance.Pitch = (float)Main.rand.Next(-5, 6) * .05f; return soundInstance; }
public AudioClip GetSound(int id, SoundType type) { SoundConfig sound = sounds.Find (s => s.Id == id && s.Type == type); if (sound == null) { Debug.LogWarning ("The sound ["+id+"] and type = "+type+", was not found, please verify the config in settings. You got default sound."); return defaultSound; } else return sound.Audio; }
public void SetVolume (SoundType _soundType) { Sound[] soundObs = FindObjectsOfType (typeof (Sound)) as Sound[]; foreach (Sound soundOb in soundObs) { if (soundOb.soundType == _soundType) { soundOb.AfterLoading (); } } }
public static int GetSoundSlot(SoundType type, string sound) { if (sounds[type].ContainsKey(sound)) { return sounds[type][sound]; } else { return 0; } }
public PlaySoundAction(SoundID soundId, SoundType soundType, float delay) { // Set sound ID _soundId = soundId; // Set sound type _soundType = soundType; // Set delay time _delay = delay; }
/// <summary>Creates a new sound source.</summary> /// <param name="buffer">The sound buffer.</param> /// <param name="radius">The effective sound radius.</param> /// <param name="pitch">The pitch change factor.</param> /// <param name="volume">The volume change factor.</param> /// <param name="position">The position. If a train and car are specified, the position is relative to the car, otherwise absolute.</param> /// <param name="train">The train this sound source is attached to, or a null reference.</param> /// <param name="type">The type of sound</param> /// <param name="car">The car this sound source is attached to, or a null reference.</param> /// <param name="looped">Whether this sound source plays in a loop.</param> internal SoundSource(SoundBuffer buffer, double radius, double pitch, double volume, OpenBveApi.Math.Vector3 position, TrainManager.Train train, SoundType type, int car, bool looped) { this.Buffer = buffer; this.Radius = radius; this.Pitch = pitch; this.Volume = volume; this.Position = position; this.Parent = train; this.Car = car; this.Looped = looped; this.State = SoundSourceState.PlayPending; this.OpenAlSourceName = 0; //Set sound type manually this.Type = type; }
public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { if (soundInstance.State == SoundState.Playing) { return(null); } return(soundInstance); }
public UISound(string sName, AudioClip aClip, SoundType sType = SoundType.All) { soundName = sName; audioClip = aClip; soundType = sType; }
public AudioClip GetClip(SoundType soundType) { return(soundEntities.Find(x => x.soundType == soundType).clip); }
public Sound(Uri filePath, string soundName, string fileName, SoundContext soundContext, SoundType soundType, byte[] resource) { FilePath = filePath; SoundName = soundName; FileName = fileName; SoundContext = soundContext; SoundType = soundType; Resource = resource; }
public CustomSoundStyle(SoundEffect[] soundEffects, SoundType type = SoundType.Sound, float volume = 1f, float pitchVariance = 0.0f) : base(volume, pitchVariance, type) { this._soundEffects = soundEffects; }
private AudioSound Find(SoundType type) { return(Array.Find(sounds, sound => sound.type == type)); }
/// <summary> /// 停止播放音乐 /// </summary> /// <param name="type">停止播放背景音乐还是游戏音效</param> /// <param name="sound">停止的声音</param> public void StopMusic(Sound sound = Sound.Max, SoundType type = SoundType.GameEffectsMusic) { //停止背景音乐,只传第一个参数就够了 if (type == SoundType.BackgroundMusic) { if (BGMusicSource == null) { BGMusicSource = gameObject.AddComponent <AudioSource>(); } BGMusicSource.Stop(); currentPlayingBGMusic = Sound.Max; } else if (type == SoundType.GameEffectsMusic) { //停止所有的游戏音效 if (sound == Sound.Max) { for (int i = 0; i < gameEffectSourceList.Count; i++) { AudioSource item = gameEffectSourceList[i]; item.Stop(); } return; } //停止指定的游戏音效 if (dicSound.ContainsKey(sound)) { AudioClip audioClip = dicSound[sound]; if (audioClip != null) { if (gameEffectSourceList != null && gameEffectSourceList.Count > 0) { for (int i = 0; i < gameEffectSourceList.Count; i++) { AudioSource item = gameEffectSourceList[i]; if (item.isPlaying && item.clip == audioClip) { item.Stop(); return; } } } if (gameEffectSourceList_3D != null && gameEffectSourceList_3D.Count > 0) { for (int i = 0; i < gameEffectSourceList_3D.Count; ++i) { AudioSource item = gameEffectSourceList_3D[i]; if (item == null) { //gameEffectSourceList_3D.Remove(item); } else if (item.isPlaying && item.clip == audioClip) { item.Stop(); return; } } } } } } }
public override void PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { soundInstance = sound.CreateInstance(); soundInstance.Volume = volume; soundInstance.Pan = pan; soundInstance.Pitch = 0.8f; Main.PlaySoundInstance(soundInstance); }
public void SetMusicState(SoundType type, bool isOpen) // 设置声音状态 { }
public static int AddSound(string path, SoundType type = SoundType.Custom, ModSound modSound = null) { instance.AddSound(type, "Origins/" + path, modSound); return(SoundLoader.GetSoundSlot(type, "Origins/" + path)); }
public void PlaySound(SoundType which) { SoundHolder sound = sounds[(int)which]; source.PlayOneShot(sound.clips[Random.Range(0, sound.clips.Length)], sound.volume > 0f? sound.volume : 1f); }
public int GetSoundSlot(SoundType type, string name) { return(SoundLoader.GetSoundSlot(type, FileName(name))); }
public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { if (soundInstance.State == SoundState.Playing) { soundInstance.Stop(true); } soundInstance = sound.CreateInstance(); soundInstance.IsLooped = true; return(soundInstance); }
public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { soundInstance = sound.CreateInstance(); type = SoundType.Music; return(soundInstance); }
public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { // By checking if the input soundInstance is playing, we can prevent the sound from firing while the sound is still playing, allowing the sound to play out completely. Non-ModSound behavior is to restart the sound, only permitting 1 instance. soundInstance.Volume = volume * .7f; soundInstance.Pan = pan; return(soundInstance); }
public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { soundInstance = sound.CreateInstance(); soundInstance.Pitch = MusicMaker.isHigh?1:(MusicMaker.isLow?-1:0); return(soundInstance); }
public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { // By creating a new instance, this ModSound allows for overlapping sounds. Non-ModSound behavior is to restart the sound, only permitting 1 instance. soundInstance = sound.CreateInstance(); soundInstance.Volume = volume * .5f; soundInstance.Pan = pan; soundInstance.Pitch = -0f; return(soundInstance); }
public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { //if (soundInstance.State == SoundState.Playing) // return null; soundInstance = sound.CreateInstance(); soundInstance.Volume = volume * 1f; soundInstance.Pan = pan; soundInstance.Pitch = Main.rand.Next(-4, 4) * .05f; return(soundInstance); }
private void LoadSound(SoundType soundType) { SoundEffect sound = null; switch (soundType) { case SoundType.Car_Accelerate: sound = content.Load <SoundEffect>("sounds/Car_Accelerate"); break; case SoundType.Car_Background: sound = content.Load <SoundEffect>("sounds/Car_Background"); break; case SoundType.Car_Boost: sound = content.Load <SoundEffect>("sounds/Car_Boost"); break; case SoundType.Car_Horn: sound = content.Load <SoundEffect>("sounds/Car_Horn"); break; case SoundType.Car_Horn2: sound = content.Load <SoundEffect>("sounds/Car_Horn2"); break; case SoundType.Car_Horn3: sound = content.Load <SoundEffect>("sounds/Car_Horn3"); break; case SoundType.Enemy_Hit: sound = content.Load <SoundEffect>("sounds/Enemy_Monster_Hit"); break; case SoundType.Enemy_Growl: sound = content.Load <SoundEffect>("sounds/Enemy_Growl"); break; case SoundType.FlameThrower: sound = content.Load <SoundEffect>("sounds/FlameThrower"); break; case SoundType.RocketLauncher_Launch: sound = content.Load <SoundEffect>("sounds/RocketLauncher_Launch"); break; case SoundType.RocketLauncher_Explosion: sound = content.Load <SoundEffect>("sounds/RocketLauncher_EXPLOSION!!!"); break; case SoundType.Shockwave: sound = content.Load <SoundEffect>("sounds/Shockwave"); break; case SoundType.Trap_Launch: sound = content.Load <SoundEffect>("sounds/Trap_Launch"); break; case SoundType.Menu_Music: sound = content.Load <SoundEffect>("sounds/Lone_Wolf"); break; } if (!soundEffect.ContainsKey(soundType)) { soundEffect.Add(soundType, sound); } }
public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { // By checking if the input soundInstance is playing, we can prevent the sound from firing while the sound is still playing, allowing the sound to play out completely. Non-ModSound behavior is to restart the sound, only permitting 1 instance. if (soundInstance.State == SoundState.Playing) { return(null); } soundInstance = sound.CreateInstance(); soundInstance.Volume = volume * 0.8f; return(soundInstance); }
private char[] GetControlCode(ControlCode code, EndianBinaryReader reader, Dictionary <ControlCode, string> codeDict) { List <char> codeBank = new List <char>(); if (codeDict.First(x => x.Key == code).Value.Count() == 1) { codeBank.AddRange(codeDict[code].ToCharArray()); return(codeBank.ToArray()); } string codeInsides = ""; switch (code) { case ControlCode.Color: Color col = (Color)reader.ReadByte(); codeInsides = col.ToString(); break; case ControlCode.Icon: byte iconID = reader.ReadByte(); codeInsides = string.Format("{0}:{1}", "Icon", iconID); break; case ControlCode.Line_Break: return("\n".ToCharArray()); case ControlCode.Spaces: byte numSpaces = reader.ReadByte(); codeInsides = string.Format("{0}:{1}", "Pixels Right", numSpaces); break; case ControlCode.Delay: byte numFrames = reader.ReadByte(); codeInsides = string.Format("{0}:{1}", "Delay", numFrames); break; case ControlCode.Fade: byte numFramesFade = reader.ReadByte(); codeInsides = string.Format("{0}:{1}", "Fade", numFramesFade); break; case ControlCode.Sound: SoundType soundID = (SoundType)reader.ReadInt16(); codeInsides = string.Format("{0}:{1}", "Sound", soundID.ToString().Replace("_", " ")); break; case ControlCode.Speed: byte speed = reader.ReadByte(); codeInsides = string.Format("{0}:{1}", "Speed", speed); break; case ControlCode.High_Score: HighScore scoreID = (HighScore)reader.ReadByte(); codeInsides = string.Format("{0}:{1}", "High Score", scoreID.ToString().Replace("_", " ")); break; case ControlCode.Jump: short msgID = reader.ReadInt16(); codeInsides = string.Format("{0}:{1:X4}", "Jump", msgID); break; case ControlCode.Box_Break: return("\n<New Box>\n".ToCharArray()); case ControlCode.No_Skip: codeInsides = "NS"; break; case ControlCode.Draw_Instant: codeInsides = "DI"; break; case ControlCode.Draw_Char: codeInsides = "DC"; break; case ControlCode.Background: int backgroundID; byte id1 = reader.ReadByte(); byte id2 = reader.ReadByte(); byte id3 = reader.ReadByte(); backgroundID = BitConverter.ToInt32(new byte[] { id3, id2, id1, 0 }, 0); codeInsides = string.Format("{0}:{1}", "Background", backgroundID); break; default: codeInsides = code.ToString().Replace("_", " "); break; } codeBank.AddRange(string.Format("<{0}>", codeInsides).ToCharArray()); return(codeBank.ToArray()); }
public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { if (soundInstance.State == SoundState.Playing) { return(null); } soundInstance.Volume = volume; soundInstance.Pan = pan; soundInstance.Pitch = 0f; Main.PlaySoundInstance(soundInstance); return(soundInstance); }
public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { soundInstance = sound.CreateInstance(); soundInstance.Volume = volume * .5f; soundInstance.Pan = pan; soundInstance.Pitch = 0f; return(soundInstance); }
public void PlayClip(SoundType type, AudioClip clip, OnSoundPlayEnd playEndCB = null, bool loop = false, float channelvolume = 1, float currentFadeOutTime = 0, float delay = 0) { PlayClips(type, new AudioClip[] { clip }, playEndCB, loop, channelvolume, currentFadeOutTime, delay); }
public static bool UISoundNameExists(string soundName, SoundType soundType = SoundType.All) { return(GetUISoundNames(soundType).Contains(soundName)); }
/// <summary> /// Play one of supported sounds. /// </summary> /// /// <param name="type">Sound type to play.</param> /// /// <returns>Returns <b>true</b> if command was executed successfully or <b>false</b> otherwise.</returns> /// public bool PlaySound(SoundType type) { return(SendCommand(new byte[] { (byte)RCXCommand.PlaySound, (byte)type }, new byte[1], 1));; }
unsafe public OpenALSampleSound(VirtualFileStream stream, SoundType soundType, string name, SoundMode mode, out bool initialized) { initialized = false; byte[] samples; int sizeInBytes; float timeLength; if (string.Compare(Path.GetExtension(name), ".ogg", true) == 0) { //ogg VorbisFileReader vorbisFileReader = new VorbisFileReader(stream, false); VorbisFile.File vorbisFile = new VorbisFile.File(); if (!vorbisFileReader.OpenVorbisFile(vorbisFile)) { vorbisFile.Dispose(); vorbisFileReader.Dispose(); Log.Warning("OpenALSoundSystem: Creating sound failed \"{0}\" (Reading failed).", name); return; } int numSamples = (int)vorbisFile.pcm_total(-1); vorbisFile.get_info(-1, out channels, out frequency); timeLength = (float)vorbisFile.time_total(-1); sizeInBytes = numSamples * channels * 2; samples = new byte[sizeInBytes]; fixed(byte *pSamples = samples) { int samplePos = 0; while (samplePos < sizeInBytes) { int readBytes = vorbisFile.read((IntPtr)(pSamples + samplePos), sizeInBytes - samplePos, 0, 2, 1, IntPtr.Zero); if (readBytes <= 0) { break; } samplePos += readBytes; } } vorbisFile.Dispose(); vorbisFileReader.Dispose(); } else if (string.Compare(Path.GetExtension(name), ".wav", true) == 0) { //wav string error; if (!WavLoader.Load(stream, out channels, out frequency, out samples, out sizeInBytes, out error)) { Log.Warning("OpenALSoundSystem: Creating sound failed \"{0}\" ({1}).", name, error); return; } timeLength = (float)(samples.Length / channels / 2) / (float)frequency; } else { Log.Warning("OpenALSoundSystem: Creating sound failed \"{0}\" (Unknown file type).", name); return; } //create buffer Al.alGenBuffers(1, out alBuffer); int alFormat = (channels == 1) ? Al.AL_FORMAT_MONO16 : Al.AL_FORMAT_STEREO16; //bug fix: half volume mono 2D sounds //convert to stereo if ((mode & SoundMode.Mode3D) == 0 && alFormat == Al.AL_FORMAT_MONO16) { byte[] stereoSamples = new byte[sizeInBytes * 2]; for (int n = 0; n < sizeInBytes; n += 2) { stereoSamples[n * 2 + 0] = samples[n]; stereoSamples[n * 2 + 1] = samples[n + 1]; stereoSamples[n * 2 + 2] = samples[n]; stereoSamples[n * 2 + 3] = samples[n + 1]; } samples = stereoSamples; alFormat = Al.AL_FORMAT_STEREO16; sizeInBytes *= 2; } //convert to mono for 3D if ((mode & SoundMode.Mode3D) != 0 && channels == 2) { byte[] oldSamples = samples; samples = new byte[oldSamples.Length / 2]; for (int n = 0; n < samples.Length; n += 2) { samples[n + 0] = oldSamples[n * 2 + 0]; samples[n + 1] = oldSamples[n * 2 + 1]; } alFormat = Al.AL_FORMAT_MONO16; sizeInBytes /= 2; } fixed(byte *pSamples = samples) { Al.alBufferData(alBuffer, alFormat, pSamples, sizeInBytes, frequency); } if (OpenALSoundWorld.CheckError()) { Log.Warning("OpenALSoundSystem: Creating sound failed \"{0}\".", name); return; } Init(name, mode, timeLength, channels, frequency); initialized = true; }
internal void UpdateCalculations(bool force, double multiplier) { if (force || taikoMiddle == null) { //slider endpoint is not hittable when the next hitobject has //a starttime before the slider's endtime. List <HitObject> hitobjects = hitObjectManager.hitObjects; int ind = hitobjects.IndexOf(this); if (ind < hitobjects.Count - 1 && hitobjects[ind + 1].HittableStartTime - (EndTime + (int)MinHitDelay) <= (int)MinHitDelay) { endpointHittable = false; } float scalefactor = !SoundType.IsType(HitObjectSoundType.Finish) ? 0.65f : 1; SpatialLength *= SegmentCount; double v = hitObjectManager.SliderScoringPointDistance * hitObjectManager.Beatmap.DifficultySliderTickRate; double b = hitObjectManager.Beatmap.BeatLengthAt(StartTime); EndTime = StartTime + (int)(SpatialLength / v * b); SpatialLength *= multiplier; taikoMiddle = new pSprite(TextureManager.Load(@"taiko-roll-middle"), Fields.GamefieldWide, Origins.TopLeft, Clocks.Audio, new Vector2(Position.X, Position.Y - hitObjectManager.HitObjectRadius * scalefactor), SpriteManager.drawOrderBwd(EndTime + 10), false, new Color(252, 184, 6)); taikoMiddle.VectorScale = new Vector2((float)SpatialLength * GameBase.WindowManager.Ratio / hitObjectManager.SpriteRatio * (1 / scalefactor), 1); taikoMiddle.Transformations.Add(new Transformation(TransformationType.Fade, 0, 1, StartTime - hitObjectManager.PreEmpt, StartTime)); taikoMiddle.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0, EndTime, EndTime + hitObjectManager.PreEmptSliderComplete)); spriteManager.Add(taikoMiddle); SpriteCollection.Add(taikoMiddle); DimCollection.Add(taikoMiddle); taikoEnd = new pSprite(TextureManager.Load(@"taiko-roll-end"), Fields.GamefieldWide, Origins.TopLeft, Clocks.Audio, new Vector2(Position.X, Position.Y - hitObjectManager.HitObjectRadius * scalefactor), SpriteManager.drawOrderBwd(EndTime + 8), false, new Color(252, 184, 6)); taikoEnd.OriginPosition = new Vector2( (float)-SpatialLength * GameBase.WindowManager.Ratio / hitObjectManager.SpriteRatio * (1 / scalefactor), 0); taikoEnd.Transformations.Add(new Transformation(TransformationType.Fade, 0, 1, StartTime - hitObjectManager.PreEmpt, StartTime)); taikoEnd.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0, EndTime, EndTime + hitObjectManager.PreEmptSliderComplete)); spriteManager.Add(taikoEnd); SpriteCollection.Add(taikoEnd); DimCollection.Add(taikoEnd); sliderBall.Transformations.Add(new Transformation(sliderStartCircle.Position, sliderStartCircle.Position, StartTime - 500, EndTime)); sliderFollower.Transformations.Add(new Transformation(sliderStartCircle.Position, sliderStartCircle.Position, StartTime, EndTime)); counter = new pSpriteText("", SkinManager.Current.FontScore, SkinManager.Current.FontScoreOverlap, Fields.GamefieldWide, Origins.Centre, Clocks.Audio, HitObjectManagerTaiko.HIT_LOCATION, 0.9f, false, Color.White); counter.Scale = 0.8f; counter.Transformations.Add(new Transformation(TransformationType.Fade, 0, 1, StartTime, StartTime)); counter.Transformations.Add(new Transformation(TransformationType.Fade, 0.6f, 0, EndTime, EndTime + 300)); spriteManager.Add(counter); int index = 0; for (double i = StartTime; i < HittableEndTime; i += MinHitDelay) { if (i == StartTime) { hittablePoints.Add(new HitPoint((int)i, null)); index++; continue; } bool major = ((hitObjectManager.Beatmap.DifficultySliderTickRate == 3) || (hitObjectManager.Beatmap.DifficultySliderTickRate == 6) || (hitObjectManager.Beatmap.DifficultySliderTickRate == 1.5d)) ? (index % 3) == 0 : (index % 4) == 0; pSprite scoringDot = new pSprite(TextureManager.Load(@"sliderscorepoint"), Fields.GamefieldWide, Origins.Centre, Clocks.Audio, new Vector2(Position.X, Position.Y), SpriteManager.drawOrderBwd(StartTime + 1), false, major ? Color.Yellow : Color.White, this); if (!major) { scoringDot.Scale *= 0.8f; } scoringDot.OriginPosition.X -= (float)(SpatialLength * (float)(i - StartTime) / Length) * GameBase.WindowManager.Ratio / hitObjectManager.SpriteRatio / scoringDot.Scale * (1 / scalefactor); scoringDot.Transformations.Add(new Transformation(TransformationType.Fade, 0, 1, StartTime - hitObjectManager.PreEmpt, StartTime)); scoringDot.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0, EndTime, EndTime + hitObjectManager.PreEmptSliderComplete)); hittablePoints.Add(new HitPoint((int)i, scoringDot)); spriteManager.Add(scoringDot); SpriteCollection.Add(scoringDot); DimCollection.Add(scoringDot); index++; } if (scalefactor != 1) { foreach (pSprite p in SpriteCollection) { p.Scale *= scalefactor; } } for (int i = 0; i < sliderStartCircle.SpriteCollection.Count; i++) { pSprite s = sliderStartCircle.SpriteCollection[i]; foreach (Transformation t in s.Transformations) { if (t.Type == TransformationType.Fade && t.StartFloat == 1) { t.Time1 = EndTime; t.Time2 = EndTime; } } SpriteCollection.Add(s); DimCollection.Add(s); spriteManager.Add(s); } } }
public void PlaySound(SoundType type) { var foundEntry = _entries.First(entry => entry.Type == type); _soundEntryToPlay.OnNext(foundEntry); }