public async Task <ActionResult <Speakers> > PostSpeakers(Speakers speakers) { _context.Speakers.Add(speakers); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSpeakers", new { id = speakers.Id }, speakers)); }
internal void __MarshalFrom(ref WaveFormatExtensible.__Native @ref) { base.__MarshalFrom(ref @ref.waveFormat); this.wValidBitsPerSample = @ref.wValidBitsPerSample; this.ChannelMask = @ref.dwChannelMask; this.GuidSubFormat = @ref.subFormat; }
public async Task <IActionResult> PutSpeakers(int id, Speakers speakers) { if (id != speakers.Id) { return(BadRequest()); } _context.Entry(speakers).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpeakersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Edit(int id, [Bind("SpeakerId,FirstName,LastName,Subject,MeetingId")] Speakers speakers) { if (id != speakers.SpeakerId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(speakers); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpeakersExists(speakers.SpeakerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MeetingId"] = new SelectList(_context.Meeting, "MeetingId", "ClosingPrayer", speakers.MeetingId); return(View(speakers)); }
async Task GetSpeakers() { if (IsBusy) { return; } try { IsBusy = true; var service = DependencyService.Get <AzureService>(); var items = await service.GetSpeakers(); Speakers.Clear(); foreach (var item in items) { Speakers.Add(item); } } catch (Exception e) { Debug.WriteLine("Error: " + e.Message); await Application.Current.MainPage.DisplayAlert("Error!", e.Message, "OK"); } finally { IsBusy = false; } }
public CollectionViewController (UICollectionViewLayout layout) : base (layout) { Speakers = new Speakers (); CollectionView.ContentSize = UIScreen.MainScreen.Bounds.Size; CollectionView.BackgroundColor = UIColor.White; }
public Speakers Udf_GetResourceVersionStringListener(int resourceVersionId, int stringId) { Speakers result = new Speakers(); using SqlConnection con = new SqlConnection(m_connectionString); using SqlCommand cmd = new SqlCommand("select * from [dbo].[udf_GetResourceVersionStringListener] (@resourceVersionID, @stringID)", con) { CommandType = CommandType.Text }; cmd.Parameters.AddWithValue("@resourceVersionID", resourceVersionId); cmd.Parameters.AddWithValue("@stringID", stringId); con.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { result.Age = (string)reader["Age"]; result.Name = (string)reader["Name"]; result.Gender = (string)reader["Gender"]; result.IsPlayer = (bool)reader["IsPlayer"]; } } con.Close(); return(result); }
public MySqlContext(DbContextOptions options) : base(options) { //Database.EnsureDeleted(); Database.EnsureCreated(); if (Articles.Count() == 0) { PutData data = new PutData(); Articles.AddRange(data.articles); Comments.AddRange(data.comments); SuperUsers.Add(data.super); TeacherUsers.AddRange(data.teacher); StudentUsers.AddRange(data.studentUser); TestStudents.AddRange(data.testStudents); QuestionAnswers.AddRange(data.questionAnswers); Tests.AddRange(data.tests); Themes.AddRange(data.themes); TestThemes.AddRange(data.TestThemas); Questions.AddRange(data.questions1); Questions.AddRange(data.questions2); Questions.AddRange(data.questions3); Marks.AddRange(data.Marks1); Marks.AddRange(data.Marks2); EventProfileUsers.AddRange(data.EventProfileUsers); Meetups.AddRange(data.Meetups); Speakers.AddRange(data.Speakers); SaveChanges(); } }
public Speakers Update(Speakers speakerToUpdate) { var updatedSpeaker = conferenceContext.Update(speakerToUpdate); conferenceContext.SaveChanges(); return(updatedSpeaker.Entity); }
public void LoadVoiceSample(string speakerName, byte[] sample) { if (string.IsNullOrEmpty(speakerName)) { throw new ArgumentException(nameof(speakerName)); } if (sample == null || sample.Length == 0) { throw new ArgumentException(nameof(sample)); } var speakerToUpdate = Speakers.FirstOrDefault(x => x.Name == speakerName); var voiceSample = new VoiceSample(sample, _sampleRate); if (speakerToUpdate != null) { for (int i = 0; i < speakerToUpdate.Samples[0].MelFrequency.Length; i++) { speakerToUpdate.Samples[0].MelFrequency[i] = (speakerToUpdate.Samples[0].MelFrequency[i] + voiceSample.MelFrequency[i]) / 2; } } else { var speaker = new Speaker(speakerName); speaker.Id = Guid.NewGuid().ToString(); speaker.Samples.Add(voiceSample); Speakers.Add(speaker); } }
public SpeakersViewModel(AzureService azureService = null) { var service = azureService ?? DependencyService.Get <AzureService>(); GetSpeakers = ReactiveCommand.CreateFromObservable(() => service.GetSpeakers()); GetSpeakers .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(speakers => { Speakers.Clear(); Speakers.AddRange(speakers); }); GetSpeakers.IsExecuting .ToProperty(this, vm => vm.IsBusy, out busy); GetSpeakers.ThrownExceptions .SelectMany(error => ConnectionError.Handle(error)) .Subscribe(); // go to details page when Speaker is set this.WhenAnyValue(vm => vm.Speaker) .Where(speaker => speaker != null) .Subscribe(speaker => this.PushPageFromCacheAsync <Details.DetailsViewModel>(vm => vm.Speaker = speaker)); this.ThrownExceptions .Subscribe(ex => { Debug.WriteLine(ex.Message); }); }
public Speakers AddSpeaker(Speakers speakerToBeAdded) { var addedSpeaker = conferenceContext.Add(speakerToBeAdded); conferenceContext.SaveChanges(); return(addedSpeaker.Entity); }
public async void OnNavigatingTo(INavigationParameters parameters) { var data = await SpeakerService.GetAsync(); Speakers.Clear(); foreach (var item in data) { Speakers.Add(new Speaker { Name = item.Name, Bio = item.Bio, HeadshotImage = item.PhotoLink, Sessions = item.Sessions.Select(x => new Session { Title = x.Title, Description = x.Description, IsFavorite = false, Room = x.Room, TimeSlot = x.TimeSlot, TimeSlotName = x.TimeSlotName, Track = x.Category.ToSessionTrack(), Speaker = new Speaker { Name = item.Name, HeadshotImage = item.PhotoLink } }) }); } }
public ActionResult Edit(Speakers speakers) { if (ModelState.IsValid) { Speakers speakers1 = context.Speakers.Find(speakers.Id); if (speakers.ImgFile != null) { string imgName = DateTime.Now.ToString("ddMMyyyyHHmmssfff") + speakers.ImgFile.FileName; string imgPath = Path.Combine(Server.MapPath("~/Uploads/"), imgName); string oldPath = Path.Combine(Server.MapPath("~/Uploads"), speakers1.Image); System.IO.File.Delete(oldPath); speakers.ImgFile.SaveAs(imgPath); speakers1.Image = imgName; } speakers1.Name = speakers.Name; speakers1.Profession = speakers.Profession; context.Entry(speakers1).State = EntityState.Modified; context.SaveChanges(); return(RedirectToAction("Index")); } return(View(speakers)); }
public Speakers Update(Speakers speakers) { var up = conferenceContext.Speakers.Update(speakers); conferenceContext.SaveChanges(); return(up.Entity); }
public async Task <IActionResult> Edit(int id, [Bind("ID,SpeakerID,Topic,SMPID")] Speakers speakers) { if (id != speakers.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(speakers); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpeakersExists(speakers.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SpeakerID"] = new SelectList(_context.Member, "ID", "ID", speakers.SpeakerID); ViewData["SMPID"] = new SelectList(_context.SMP, "ID", "ID", speakers.SMPID); return(View(speakers)); }
// Method to marshal from native to managed struct internal unsafe void __MarshalFrom(ref __Native @ref) { this.__MarshalFrom(ref @ref.waveFormat); this.wValidBitsPerSample = @ref.wValidBitsPerSample; this.ChannelMask = @ref.dwChannelMask; this.GuidSubFormat = @ref.subFormat; }
/// <summary> /// Handles data from network connected to specific client id /// </summary> /// <param name="id">unique id of a remote client</param> /// <param name="bytes">array of received data (samples)</param> private void HandleRawData(int id, string name, byte[] bytes) { if (!_listening) { return; } lock (_lock) { Speaker speaker; if (!Speakers.ContainsKey(id)) { speaker = new Speaker(id, name, transform); speaker.IsMute = IsSpeakersMuted; Speakers.Add(id, speaker); SpeakersUpdatedEvent?.Invoke(); } else { speaker = Speakers[id]; } speaker.HandleRawData(bytes); } }
public void Speak(Transform speaker, string dialogue, Speakers speakerType) { Move(speaker); text.text = dialogue; StartCoroutine(DialogueTime(speakerType)); }
public HeroCard ToCard() { var hero = new HeroCard( title: Title, subtitle: Room, text: string.Join("\n", Description)); if (Speakers?.Any() ?? false) { hero.Subtitle = string.Empty; hero.Images = new List <CardImage>(); foreach (var speaker in Speakers) { if (!string.IsNullOrEmpty(hero.Subtitle)) { hero.Subtitle += " - "; } hero.Subtitle += $"{speaker.FirstName} {speaker.LastName}"; hero.Images.Add(new CardImage() { Url = speaker.ProfilePicture, Alt = speaker.TagLine }); } } return(hero); }
public static IEnumerable <Session> FindSessions(string[] speakerNames = null, string[] topics = null, string companyName = null, LevelTypes level = LevelTypes.Any) { var localSpeakerNames = speakerNames; if (!String.IsNullOrWhiteSpace(companyName)) { localSpeakerNames = Speakers.Where(k => k.Company.ContainsIgnoreCase(companyName)).Select(k => k.Name).ToArray(); } var topicsRegex = topics?.GetWholeWordsRegex(); return(CodeCamp.Sessions .Where(s => localSpeakerNames == null || localSpeakerNames.Length == 0 || s.Speakers.ContainIgnoreCase(localSpeakerNames)) .Where(s => topics == null || (topics.ContainIgnoreCase("misc") && s.AllTracks == true) || s.Title.RegexMatch(topicsRegex) || s.Description.RegexMatch(topicsRegex)) .Where(s => level == LevelTypes.None || level == LevelTypes.Any || s.Level.ContainsIgnoreCase(level.ToString())) .OrderBy(s => s.StartTime) .Take(10)); }
public async Task <IActionResult> Edit(int id, [Bind("id,Image,Name,Position,IsDeleted")] Speakers speakers) { if (id != speakers.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(speakers); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpeakersExists(speakers.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(speakers)); }
public Speakers CreateSpeakers(Speakers speakers) { var create = conferenceContext.Speakers.Add(speakers); conferenceContext.SaveChanges(); return(create.Entity); }
private async Task GetSpeakers() { if (IsBusy) { return; } Exception error = null; try { IsBusy = true; var items = await _speakersService.GetAllSpeakersAsync(); Speakers.Clear(); foreach (var item in items) { Speakers.Add(item); } } catch (Exception ex) { error = ex; } finally { IsBusy = false; } if (error != null) { await Application.Current.MainPage.DisplayAlert("Error!", error.Message, "OK"); } }
// Method to marshal from native to managed struct internal void __MarshalFrom(ref __Native @ref) { __MarshalFrom(ref @ref.waveFormat); wValidBitsPerSample = @ref.wValidBitsPerSample; ChannelMask = @ref.dwChannelMask; GuidSubFormat = @ref.subFormat; }
internal static void PlatformShutdown() { if (_reverbVoice != null) { _reverbVoice.DestroyVoice(); _reverbVoice.Dispose(); _reverbVoice = null; } if (MasterVoice != null) { MasterVoice.Dispose(); MasterVoice = null; } if (Device != null) { Device.StopEngine(); Device.Dispose(); Device = null; } _device3DDirty = true; _speakers = Speakers.Stereo; }
private IEnumerator DialogueTime(Speakers speakerType) { Debug.Log("wait"); yield return(new WaitForSeconds(2f)); Debug.Log("ienum"); switch (speakerType) { case Speakers.Alarm: if (AlarmSpeakEnded != null) { Debug.Log("alarm"); AlarmSpeakEnded(); } break; case Speakers.PersonLeaving: if (LeavingSpeakEnded != null) { Debug.Log("leave"); LeavingSpeakEnded(); } break; } Destroy(gameObject); }
public async Task <IActionResult> CreateSpeaker(SpeakersDTO model) { var newSpeaker = new Speakers { SpeakerId = model.SpeakerId, SpeakerName = model.SpeakerName, Email = model.Email, Country = model.Country, Phone = model.Phone, Duration = model.Duration }; _context.Speakers.Add(newSpeaker); try { await _context.SaveChangesAsync(); } catch (Exception) { return(BadRequest("No se pudo insertar el dato")); //throw; } return(Ok(new SpeakersDTO { SpeakerId = model.SpeakerId, SpeakerName = model.SpeakerName, Email = model.Email, Country = model.Country, Phone = model.Phone, Duration = model.Duration })); }
private void SetSpeakerContext(EventDb eventToModifier) { var speakersSelected = Speakers.Where(x => x.IsSpeaker).ToList(); var speakersToAddToDb = speakersSelected.Where(x => !_context.Speakers.Any(s => x.Id == s.Id)).ToList(); speakersToAddToDb?.ForEach(x => { _context.Speakers.Add(new Speaker { Id = x.Id }); }); var speakerToAddFromEvent = speakersSelected.Where(x => !eventToModifier.Speakers.Any(s => s.SpeakerId == x.Id)) .ToList(); speakerToAddFromEvent?.ForEach(x => { eventToModifier.Speakers.Add(new SpeakerEvent { SpeakerId = x.Id, Event = eventToModifier }); }); eventToModifier.Speakers.Where(x => !speakersSelected.Any(s => s.Id == x.SpeakerId)) .ToList() ?.ForEach(x => eventToModifier.Speakers.Remove(x)); }
private async Task GenerateDataToShow(string id) { var eventDetail = await _meetupService.GetEventDetail(id); var eventDb = _context.Events.Include(x => x.Speakers) .Include(x => x.Sponsors) .ThenInclude(s => s.Sponsor) .FirstOrDefault(x => x.Id == id); Event = new EventViewModel(eventDetail); Speakers = (await _meetupService.GetAttendance(id, 20))?.Select(x => new MemberViewModel(x)).ToList(); Sponsors = (await _meetupService.GroupDetail()).results[0].sponsors?.Select(x => new SponsorViewModel(x)) .ToList(); if (eventDb != null) { Speakers.Where(x => eventDb.Speakers.Any(s => s.SpeakerId == x.Id))?.ToList() .ForEach(s => s.IsSpeaker = true); Speakers.Where(x => eventDb.Speakers.Any(s => s.SpeakerId == x.Id))?.ToList() .ForEach(s => s.IsSpeaker = true); Sponsors.Where(x => eventDb.Sponsors.Any(s => s.SponsorId == x.Name))?.ToList() .ForEach(s => s.Selected = true); } }
public async Task LoadSpeakersAsync(RadListView lv) { if (lv == null) { IsBusy = true; } try { Speakers.Clear(); var items = await DependencyService.Get <IDataStore <Speaker> >().GetItemsAsync(true); foreach (var item in items) { Speakers.Add(item); } } catch (Exception ex) { bool wasManualRefresh = lv != null; Crashes.TrackError(ex, new Dictionary <string, string> { { "Location", "SpeakersViewModel" }, { "Method", "LoadSpeakersAsync" }, { "WasManualRefresh", wasManualRefresh.ToString() }, }); } finally { lv?.EndRefresh(true); IsBusy = false; } }
public CollectionViewController (UICollectionViewLayout layout) : base (layout) { Speakers = new Speakers (); // TODO: Step 1b: set size and color of the UICollectionView CollectionView.ContentSize = UIScreen.MainScreen.Bounds.Size; CollectionView.BackgroundColor = UIColor.White; }
public MyX3DAudio(Speakers speakerMask, float speedOfSound = 343.5f) { unsafe { X3DAudioHandle result; X3DAudioInitialize_((int)speakerMask, speedOfSound, &result); m_x3dAudioHandle = result; } }
/// <summary> /// Initializes a new instance of the <see cref="X3DAudio"/> class. /// </summary> /// <param name="speakers">The speakers config.</param> /// <param name="speedOfSound">The speed of sound.</param> /// <param name="requestVersion">The request requestVersion.</param> /// /// <msdn-id>microsoft.directx_sdk.x3daudio.x3daudioinitialize</msdn-id> /// /// <unmanaged>void X3DAudioInitialize([In] SPEAKER_FLAGS SpeakerChannelMask,[In] float SpeedOfSound,[Out] X3DAUDIOHANDLE* Instance)</unmanaged> /// /// <unmanaged-short>X3DAudioInitialize</unmanaged-short> public X3DAudio(Speakers speakers, float speedOfSound, X3DAudioVersion requestVersion = X3DAudioVersion.Default) { var tryVersions = requestVersion == X3DAudioVersion.Default ? new [] {X3DAudioVersion.Version29, X3DAudioVersion.Version28, X3DAudioVersion.Version17} : new[] {requestVersion}; foreach(var tryVersion in tryVersions) { switch(tryVersion) { #if DESKTOP_APP case X3DAudioVersion.Version17: try { X3DAudio17.X3DAudioInitialize(speakers, speedOfSound, out handle); version = X3DAudioVersion.Version17; calculateDelegate = X3DAudio17.X3DAudioCalculate; } catch (DllNotFoundException) {} break; #endif case X3DAudioVersion.Version28: try { X3DAudio28.X3DAudioInitialize(speakers, speedOfSound, out handle); version = X3DAudioVersion.Version28; calculateDelegate = X3DAudio28.X3DAudioCalculate; } catch (DllNotFoundException) { } break; #if STORE_APP_10 case X3DAudioVersion.Version29: try { X3DAudio29.X3DAudioInitialize(speakers, speedOfSound, out handle); version = X3DAudioVersion.Version29; calculateDelegate = X3DAudio29.X3DAudioCalculate; } catch (DllNotFoundException) { } break; #endif } if(version != X3DAudioVersion.Default) { break; } } if(version == X3DAudioVersion.Default) { throw new DllNotFoundException(string.Format("Unable to find X3DAudio dlls for the following requested version [{0}]", string.Join(",", tryVersions))); } }
/// <summary> /// Counts the channels from a speaker mask. /// </summary> /// <param name="speakers">The speakers mask.</param> /// <returns></returns> public static int ToChannelCount(Speakers speakers) { var channelsMask = (int)speakers; int channelCount = 0; while (channelsMask != 0) { if ((channelsMask & 1) != 0) channelCount++; channelsMask >>= 1; } return channelCount; }
public static int ToChannelCount(Speakers speakers) { int num1 = (int) speakers; int num2 = 0; while (num1 != 0) { if ((num1 & 1) != 0) ++num2; num1 >>= 1; } return num2; }
public WaveFormatExtensible(int rate, int bits, int channels) : base(rate, bits, channels) { this.waveFormatTag = WaveFormatEncoding.Extensible; this.extraSize = (short) 22; this.wValidBitsPerSample = (short) bits; int num = 0; for (int index = 0; index < channels; ++index) num |= 1 << index; this.ChannelMask = (Speakers) num; this.GuidSubFormat = bits == 32 ? new Guid("00000003-0000-0010-8000-00aa00389b71") : new Guid("00000001-0000-0010-8000-00aa00389b71"); }
public Speakers FindAll() { var speakers = GetAllSpeakers(this); Func<Speakers> findAll = () => { var speakerList = new Speakers(); speakerList.AddRange(speakers); return speakerList; }; return findAll(); }
public Speaker Find(int id) { var speakers = GetAllSpeakers(this); Func<Speaker> findSingle = () => { var speakerList = new Speakers(); return speakers.Where(s => s.Id == id).FirstOrDefault(); }; return findSingle(); }
/// <summary> /// Creates a new WaveFormatExtensible for PCM or IEEE /// </summary> public WaveFormatExtensible(int rate, int bits, int channels) : base(rate, bits, channels) { waveFormatTag = WaveFormatEncoding.Extensible; extraSize = 22; wValidBitsPerSample = (short)bits; int dwChannelMask = 0; for (int n = 0; n < channels; n++) dwChannelMask |= (1 << n); ChannelMask = (Speakers)dwChannelMask; // KSDATAFORMAT_SUBTYPE_IEEE_FLOAT // AudioMediaSubtypes.MEDIASUBTYPE_IEEE_FLOAT // KSDATAFORMAT_SUBTYPE_PCM // AudioMediaSubtypes.MEDIASUBTYPE_PCM; GuidSubFormat = bits == 32 ? new Guid("00000003-0000-0010-8000-00aa00389b71") : new Guid("00000001-0000-0010-8000-00aa00389b71"); }
/// <summary> /// Parses <see cref="WaveFormatExtensible"/> object from <paramref name="binaryImage"/>. /// </summary> /// <param name="binaryImage">Binary image to be used for initialization.</param> /// <param name="startIndex">0-based starting index in the <paramref name="binaryImage"/> to be used for initialization.</param> /// <param name="length">Valid number of bytes within binary image.</param> /// <returns>The number of bytes used for initialization in the <paramref name="binaryImage"/> (i.e., the number of bytes parsed).</returns> /// <exception cref="InvalidOperationException">Not enough length in binary image to parse WaveFormatExtensible object.</exception> public int Initialize(byte[] binaryImage, int startIndex, int length) { if (length < BinaryLength) throw new InvalidOperationException("Not enough length in binary image to parse WaveFormatExtensible object"); m_sampleValue = EndianOrder.LittleEndian.ToUInt16(binaryImage, startIndex); m_channelMask = (Speakers)EndianOrder.LittleEndian.ToInt32(binaryImage, startIndex + 2); m_subFormat = EndianOrder.LittleEndian.ToGuid(binaryImage, startIndex + 6); return BinaryLength; }
/// <summary> /// Initializes a new instance of the <see cref="X3DAudio"/> class. /// </summary> /// <param name="speakers">The speakers config.</param> /// <param name="speedOfSound">The speed of sound.</param> /// <msdn-id>microsoft.directx_sdk.x3daudio.x3daudioinitialize</msdn-id> /// <unmanaged>void X3DAudioInitialize([In] SPEAKER_FLAGS SpeakerChannelMask,[In] float SpeedOfSound,[Out] X3DAUDIOHANDLE* Instance)</unmanaged> /// <unmanaged-short>X3DAudioInitialize</unmanaged-short> public X3DAudio(Speakers speakers, float speedOfSound) { X3DAudioInitialize(speakers, speedOfSound, out handle); }
/// <summary> /// Initializes a new instance of the <see cref="X3DAudio"/> class. /// </summary> /// <param name="speakers">The speakers config.</param> /// <msdn-id>microsoft.directx_sdk.x3daudio.x3daudioinitialize</msdn-id> /// <unmanaged>void X3DAudioInitialize([In] SPEAKER_FLAGS SpeakerChannelMask,[In] float SpeedOfSound,[Out] X3DAUDIOHANDLE* Instance)</unmanaged> /// <unmanaged-short>X3DAudioInitialize</unmanaged-short> public X3DAudio(Speakers speakers) : this(speakers, SpeedOfSound) { }
public WaveFormatExtensible(WaveFormatChunk waveFormat, ushort sampleValue, Speakers channelMask, Guid subFormat) { m_sampleValue = sampleValue; m_channelMask = channelMask; m_subFormat = subFormat; }
/// <summary> /// Generate a basic extensible object based on the <see cref="WaveFormatChunk"/> settings. /// </summary> public WaveFormatExtensible(WaveFormatChunk waveFormat) { m_waveFormat = waveFormat; m_sampleValue = (ushort)m_waveFormat.BitsPerSample; m_channelMask = Speakers.All; m_subFormat = DataFormatSubType.PCM; }
// Does someone actually need to call this if it only happens when the whole // game closes? And if so, who would make the call? internal static void Shutdown() { if (MasterVoice != null) { MasterVoice.DestroyVoice(); MasterVoice.Dispose(); MasterVoice = null; } if (Device != null) { Device.StopEngine(); Device.Dispose(); Device = null; } _device3DDirty = true; _speakers = Speakers.Stereo; }
/// <summary> /// /// </summary> internal void Initialize() { try { if (Device == null) { Device = new XAudio2(XAudio2Flags.None, ProcessorSpecifier.DefaultProcessor); Device.StartEngine(); } var DeviceFormat = Device.GetDeviceDetails(0).OutputFormat; // Just use the default device. const int deviceId = 0; if (MasterVoice == null) { // Let windows autodetect number of channels and sample rate. MasterVoice = new MasteringVoice(Device, XAudio2.DefaultChannels, XAudio2.DefaultSampleRate, deviceId); MasterVoice.SetVolume(_masterVolume, 0); } // The autodetected value of MasterVoice.ChannelMask corresponds to the speaker layout. var deviceDetails = Device.GetDeviceDetails(deviceId); Speakers = deviceDetails.OutputFormat.ChannelMask; var dev3d = Device3D; Log.Debug("Audio devices :"); for ( int devId = 0; devId < Device.DeviceCount; devId++ ) { var device = Device.GetDeviceDetails( devId ); Log.Debug( "[{1}] {0}", device.DisplayName, devId ); Log.Debug( " role : {0}", device.Role ); Log.Debug( " id : {0}", device.DeviceID ); } } catch { // Release the device and null it as // we have no audio support. if (Device != null) { Device.Dispose(); Device = null; } MasterVoice = null; } }
internal static void PlatformShutdown() { SoundEffectInstancePool.Shutdown(); if (MasterVoice != null) { MasterVoice.DestroyVoice(); MasterVoice.Dispose(); MasterVoice = null; } if (Device != null) { Device.StopEngine(); Device.Dispose(); Device = null; } _device3DDirty = true; _speakers = Speakers.Stereo; }
/// <summary> /// Parses <see cref="WaveFormatExtensible"/> object by parsing the specified <paramref name="buffer"/> containing a binary image. /// </summary> /// <param name="buffer">Buffer containing binary image to parse.</param> /// <param name="startIndex">0-based starting index in the <paramref name="buffer"/> to start parsing.</param> /// <param name="length">Valid number of bytes within <paramref name="buffer"/> from <paramref name="startIndex"/>.</param> /// <returns>The number of bytes used for initialization in the <paramref name="buffer"/> (i.e., the number of bytes parsed).</returns> /// <exception cref="ArgumentNullException"><paramref name="buffer"/> is null.</exception> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="startIndex"/> or <paramref name="length"/> is less than 0 -or- /// <paramref name="startIndex"/> and <paramref name="length"/> will exceed <paramref name="buffer"/> length. /// </exception> public int ParseBinaryImage(byte[] buffer, int startIndex, int length) { buffer.ValidateParameters(startIndex, length); m_sampleValue = EndianOrder.LittleEndian.ToUInt16(buffer, startIndex); m_channelMask = (Speakers)EndianOrder.LittleEndian.ToInt32(buffer, startIndex + 2); m_subFormat = EndianOrder.LittleEndian.ToGuid(buffer, startIndex + 6); return BinaryLength; }
/// <summary> /// Initializes a new instance of the <see cref="X3DAudio" /> class. /// </summary> /// <param name="speakers">The speakers config.</param> /// <param name="requestVersion">The requestVersion.</param> /// <msdn-id>microsoft.directx_sdk.x3daudio.x3daudioinitialize</msdn-id> /// <unmanaged>void X3DAudioInitialize([In] SPEAKER_FLAGS SpeakerChannelMask,[In] float SpeedOfSound,[Out] X3DAUDIOHANDLE* Instance)</unmanaged> /// <unmanaged-short>X3DAudioInitialize</unmanaged-short> public X3DAudio(Speakers speakers, X3DAudioVersion requestVersion) : this(speakers, SpeedOfSound, requestVersion) { }
/// <summary> /// /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { if (disposing) { if (MasterVoice != null) { MasterVoice.DestroyVoice(); MasterVoice.Dispose(); MasterVoice = null; } if (Device != null) { Device.StopEngine(); Device.Dispose(); Device = null; } _device3DDirty = true; _speakers = Speakers.Stereo; } }
/// <summary> /// Initializes a new instance of the <see cref="X3DAudio" /> class. /// </summary> /// <param name="speakers">The speakers config.</param> /// <msdn-id>microsoft.directx_sdk.x3daudio.x3daudioinitialize</msdn-id> /// <unmanaged>void X3DAudioInitialize([In] SPEAKER_FLAGS SpeakerChannelMask,[In] float SpeedOfSound,[Out] X3DAUDIOHANDLE* Instance)</unmanaged> /// <unmanaged-short>X3DAudioInitialize</unmanaged-short> public X3DAudio(Speakers speakers) : this(speakers, X3DAudioVersion.Default) { }