public override void RapidUpdate() { base.RapidUpdate(); if (XAudio != null) { XAudio.CommitChanges(XAudio2.CommitAll); } }
private void DisposeXAudio() { if (XAudio != null) { XAudio.Dispose(); } XAudio = null; }
public void getAudioProperties(XAudio audio) { AudioProperties property = AudioInFrameProps.Find(prop => prop.Frame == currentFrame && prop.Audio == audio); fadeinTextBox.Text = property.FadeIn.ToString(); fadeoutTextBox.Text = property.FadeOut.ToString(); //queueCheckBox.IsChecked = property.Queue; loopCheckBox.IsChecked = property.Loop; imagePropsPanel.Visibility = Visibility.Hidden; }
private void audioMouseActions(XAudio newaudio) { newaudio.Selected += content_Selected; newaudio.MouseUp += content_Selected; newaudio.MouseLeave += audio_MouseLeave; newaudio.MouseEnter += audiomovie_Enter; newaudio.Checkbox.Checked += audio_Checked; newaudio.Checkbox.Unchecked += audio_Unchecked; newaudio.Checkbox.Indeterminate += audio_Indeterminate; }
private void selectOnlyCurrentaudio(XAudio previous, XAudio current) { if (previous != null && previous != current) { if (addorselect) { AudioInFrameProps.Last(prop => prop.Audio == previous && previousFrames.Contains(prop.Frame)).StopFrame = currentFrame; } previous.IsChecked = false; } }
/// <summary> /// Used to notify when audio processing stops (so that the timing calculator can be reset). /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Event_PlaybackStopped(object sender, StoppedEventArgs e) { isRunning = isPaused = false; if (xAudio == null) { ResetBufferToZero(); return; } XAudio.Dispose(); xAudio = null; ResetBufferToZero(); }
public void Pause() { XAudio.Pause(); if (isPaused) { Resume(); } else { isPaused = true; } }
public void Stop() { // turn off effects/instruments if (effect != null) { effect.Off(); } if (instrument != null) { instrument.Off(); } // event handler respondes and shuts down memory. XAudio.Stop(); }
private void audioImport_Click(object sender, RoutedEventArgs e) { OpenFileDialog musDialog = new OpenFileDialog() { Filter = audioextensions, Multiselect = true }; if (musDialog.ShowDialog() == true) { for (int file = 0; file < musDialog.FileNames.Length; file++) { try { string name = musDialog.SafeFileNames[file]; if (!(tabControlResources.SelectedContent as ListView).Items.OfType <XAudio>().Any(item => item.Header == name)) { XAudio audio = new XAudio() { Header = name }; audioMouseActions(audio); if (tabControlResources.SelectedContent == musicListView) { audio.Type = "music "; musicListView.Items.Add(audio); audio.Path = projectFolder + musicFolder + name; } else if (tabControlResources.SelectedContent == soundListView) { audio.Type = "sound "; soundListView.Items.Add(audio); audio.Path = projectFolder + soundsFolder + name; } else { audio.Type = "voice "; voiceListView.Items.Add(audio); audio.Path = projectFolder + voicesFolder + name; } contentCollector(musDialog.FileNames[file], audio.Path); } else { MessageBox.Show("Audio is already in use!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception) { MessageBox.Show("Please choose the audio!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } }
public void Play(double SampleStartPosition) { this.SampleOffset = SampleStartPosition; if (instrument != null) { instrument.On(); } if (effect != null) { effect.On(); } this.CurrentChannel.Volume = Volume; XAudio.Play(); isRunning = true; }
private void audio_Unchecked(object sender, RoutedEventArgs e) { XAudio selectedAudio = (sender as CheckBox).Tag as XAudio; if (waschecked) { if (removeorunselect) { AudioInFrameProps.Remove(AudioInFrameProps.Find(i => i.Frame == currentFrame && i.Audio == selectedAudio)); } waschecked = false; } else { AudioProperties audio = AudioInFrameProps.Last(i => previousFrames.Contains(i.Frame) && i.Audio == selectedAudio); if (removeorunselect) { if (audio.Frame.MenuOptions == null) { audio.StopFrame = currentFrame; } else { audio.StopFrames.Add(currentFrame); } } } if (selectedAudio.Type == "music ") { hideAudioLayer(music, panelMusic, labelMusic); } else if (selectedAudio.Type == "sound ") { hideAudioLayer(sound, panelSound, labelSound); } else { hideAudioLayer(voice, panelVoice, labelVoice); } audioPropsPanel.Visibility = Visibility.Hidden; show = false; }
private void audio_Indeterminate(object sender, RoutedEventArgs e) { if (waschecked && addorselect) { (sender as CheckBox).IsChecked = false; } else { XAudio selectedAudio = (sender as CheckBox).Tag as XAudio; if (selectedAudio.Type == "music ") { addAudioToLayer(selectedAudio.Path, music, panelMusic, labelMusic); } else if (selectedAudio.Type == "sound ") { addAudioToLayer(selectedAudio.Path, sound, panelSound, labelSound); } else { addAudioToLayer(selectedAudio.Path, voice, panelVoice, labelVoice); } }; }
private void audiomovie_Enter(object sender, RoutedEventArgs e) { if (File.Exists((sender as XContent).Path)) { (sender as XContent).TextColor = Brushes.Black; (sender as XContent).Checkbox.IsEnabled = true; if (sender.GetType() == typeof(XAudio)) { XAudio audioUnderCursor = sender as XAudio; coverartShow(audioUnderCursor.Path); if (audioUnderCursor.IsChecked != true) { audioPropsPanel.Visibility = Visibility.Hidden; } else { audioPropsPanel.Visibility = Visibility.Visible; getAudioProperties(audioUnderCursor); } } movieplayer.Source = new Uri((sender as XContent).Path, UriKind.Absolute); mediaNameLabel.Content = (sender as XContent).Header; imageViewer.Visibility = Visibility.Hidden; audiomovie.Visibility = Visibility.Visible; media.Visibility = Visibility.Visible; media.IsExpanded = true; } else { (sender as XContent).TextColor = Brushes.Red; (sender as XContent).Checkbox.IsEnabled = false; } }
public AudioItemViewModel(XAudio audio) { Audio = audio; IsSelected = false; }
public void Dispose() { MasteringVoice.Dispose(); XAudio.Dispose(); }
private void loadScript() { //код для загрузки script.rpy FileStream fs = new FileStream(projectFolder + "script.rpy", FileMode.Open); StreamReader readerlabels = new StreamReader(fs); while (!readerlabels.EndOfStream) { string label = readerlabels.ReadLine().TrimStart(' '); if (label.StartsWith("label")) { ListView newLabel = createLabel(label.Substring(6, label.Length - 7)); } } readerlabels.Dispose(); fs.Dispose(); fs = new FileStream(projectFolder + "script.rpy", FileMode.Open); StreamReader reader = new StreamReader(fs); //контент ОЧЕНЬ неоднозначен, потому для его правильного распознания нужен код и в init, и в метках string singleLine; while (!reader.EndOfStream) { singleLine = reader.ReadLine().TrimStart(' '); if (singleLine.StartsWith("define")) { if (singleLine.Contains("Character")) { XCharacter character = loadCharacter(singleLine); characterList.Add(character); } else if (singleLine.Contains("audio.")) { XAudio audio = new XAudio(); audio.loadAudio(singleLine, projectFolder + game); audioMouseActions(audio); musicListView.Items.Add(audio); } } else if (singleLine.StartsWith("image")) { if (!singleLine.Contains("Movie")) { XImage image = new XImage(); image.loadImage(singleLine, projectFolder + "images\\"); imageMouseActions(image); if (!singleLine.StartsWith("image side")) { backImageListView.Items.Add(image); } else { image.Checkbox.Visibility = Visibility.Hidden; sideListView.Items.Add(image); } } else { XMovie movie = new XMovie(); movie.loadMovie(singleLine, projectFolder + "movies\\"); movieMouseActions(movie); movieListView.Items.Add(movie); } } else if (singleLine.StartsWith("label")) { XLabel selectedLabel = tabControlStruct.Items.OfType <XLabel>().First(label => label.Text == singleLine.Substring(6, singleLine.Length - 7)); selectedLabel.IsSelected = true; XFrame frame; bool buildmenu = false; bool firstframe = true; singleLine = reader.ReadLine().Trim(' '); while (singleLine != "return" && !reader.EndOfStream) { frame = createFrame(); currentFrame = frame; (selectedLabel.Content as ListView).Items.Add(frame); if (firstframe) { setPreviousFrames(); firstframe = false; } else { previousFrames.Add(frame); } List <string> framebody = new List <string> { }; while (singleLine != "return" && !reader.EndOfStream) { if (singleLine.StartsWith("menu")) { buildmenu = true; frame.MenuOptions = new ObservableCollection <XMenuOption> { }; } else if (Regex.IsMatch(singleLine, @"[\S\s]*""[\S\s]*"":$")) { XMenuOption newmenuoption = createMenuOption(frame.MenuOptions.Count == 0); newmenuoption.Choice = value(singleLine); singleLine = reader.ReadLine().Trim(' '); if (singleLine.StartsWith("jump")) { newmenuoption.MenuAction.SelectedItem = jumpAction; newmenuoption.ActionLabel.SelectedIndex = menuLabelList.IndexOf(menuLabelList.First(label => label.Content.ToString() == singleLine.Substring(singleLine.IndexOf(' ') + 1))); (tabControlStruct.Items[newmenuoption.ActionLabel.SelectedIndex] as XLabel).MenuChoice = frame; } else if (singleLine.StartsWith("call")) { newmenuoption.MenuAction.SelectedItem = callAction; newmenuoption.ActionLabel.SelectedIndex = menuLabelList.IndexOf(menuLabelList.First(label => label.Content.ToString() == singleLine.Substring(singleLine.IndexOf(' ') + 1))); (tabControlStruct.Items[newmenuoption.ActionLabel.SelectedIndex] as XLabel).MenuChoice = frame; } else { newmenuoption.MenuAction.SelectedItem = passAction; } frame.MenuOptions.Add(newmenuoption); } else if (Regex.IsMatch(singleLine, @"[\S\s]*""[\S\s]*""$")) { if (buildmenu && frame.MenuOptions.Count != 0) { break; } loadText(frame, singleLine); if (!buildmenu) { break; } } else { if (!buildmenu) { framebody.Add(singleLine); } else { break; } } singleLine = reader.ReadLine().Trim(' '); } for (int line = 0; line < framebody.Count; line++) { if (framebody[line].StartsWith("scene")) { string[] all = framebody[line].Split(' '); XImage selectedImage = backImageListView.Items.OfType <XImage>().First(item => item.Alias == all[1]); ImageBackProperties BackProp = new ImageBackProperties() { Frame = frame, Image = selectedImage }; if (all.Length > 2) { if (all[2] == "with") { BackProp.AnimationInType = (byte)animationInTypeComboBox.Items.IndexOf(animationInTypeComboBox.Items.OfType <string>().First(item => item == all[3])); } } //секция поиска if (BackInFrameProps.Any(prop => previousFrames.Contains(prop.Frame) && !previousFrames.Contains(prop.StopFrame))) { ImageBackProperties previous = BackInFrameProps.Last(prop => previousFrames.Contains(prop.Frame) && !previousFrames.Contains(prop.StopFrame)); //а вдруг меню, а мы неподготовлены? надо расставить все нужные метки if (previous.Frame.MenuOptions == null) { previous.StopFrame = frame; } else { if (previous.StopFrames == null) { previous.StopFrames = new List <XFrame> { } } ; previous.StopFrames.Add(frame); }; } //усьо BackInFrameProps.Add(BackProp); } else if (framebody[line].StartsWith("show")) { string[] all = framebody[line].Split(' '); XImage selectedImage; if (backImageListView.Items.OfType <XImage>().Any(item => item.Alias == all[1])) { selectedImage = backImageListView.Items.OfType <XImage>().First(item => item.Alias == all[1]); backImageListView.Items.Remove(selectedImage); imageListView.Items.Add(selectedImage); } else { selectedImage = imageListView.Items.OfType <XImage>().First(item => item.Alias == all[1]); } ImageCharProperties props = new ImageCharProperties() { Frame = frame, Image = selectedImage, Displayable = newDisplayable() }; props.Displayable.Source = imageShow(selectedImage.Path); for (int i = 2; i < all.Length; i++) { if (all[i] == "with") { props.AnimationInType = (byte)animationInTypeComboBox.Items.IndexOf(animationInTypeComboBox.Items.OfType <string>().First(item => item == all[i + 1])); } else if (all[i] == "at") { props.Align = (byte)alignComboBox.Items.IndexOf(alignComboBox.Items.OfType <string>().First(item => item == all[i + 1])); } } ImageInFrameProps.Add(props); } else if (framebody[line].StartsWith("hide")) { string[] all = framebody[line].Split(' '); if (backImageListView.Items.OfType <XImage>().Any(prop => prop.Alias == all[1])) { ImageBackProperties previous = BackInFrameProps.Last(prop => previousFrames.Contains(prop.Frame) && prop.Image.Alias == all[1]); if (all.Length > 2) { if (all[2] == "with") { previous.AnimationOutType = (byte)animationOutTypeComboBox.Items.IndexOf(animationOutTypeComboBox.Items.OfType <string>().First(item => item == all[3])); } } if (previous.Frame.MenuOptions == null) { previous.StopFrame = frame; } else { if (previous.StopFrames == null) { previous.StopFrames = new List <XFrame> { } } ; previous.StopFrames.Add(frame); }; } else { ImageCharProperties previous = ImageInFrameProps.Last(prop => previousFrames.Contains(prop.Frame) && prop.Image.Alias == all[1]); if (all.Length > 2) { if (all[2] == "with") { previous.AnimationOutType = (byte)animationOutTypeComboBox.Items.IndexOf(animationOutTypeComboBox.Items.OfType <string>().First(item => item == all[3])); } } if (previous.Frame.MenuOptions == null) { previous.StopFrame = frame; } else { if (previous.StopFrames == null) { previous.StopFrames = new List <XFrame> { } } ; previous.StopFrames.Add(frame); }; } } else if (framebody[line].StartsWith("stop")) { string type = framebody[line].Substring(5) + " "; AudioProperties previous = AudioInFrameProps.Last(prop => previousFrames.Contains(prop.Frame) && prop.Audio.Type == type); if (previous.Frame.MenuOptions == null) { previous.StopFrame = frame; } else { if (previous.StopFrames == null) { previous.StopFrames = new List <XFrame> { } } ; previous.StopFrames.Add(frame); }; } else if (framebody[line].StartsWith("play")) { string[] all = framebody[line].Split(' '); XAudio audio = musicListView.Items.OfType <XAudio>().First(item => item.Alias == all[2]); if (all[1] != "music") { musicListView.Items.Remove(audio); if (all[1] == "sound") { soundListView.Items.Add(audio); } else { voiceListView.Items.Add(audio); } } AudioProperties props = new AudioProperties() { Frame = frame, Audio = audio }; for (int i = 2; i < all.Length; i++) { if (all[i] == "fadein") { props.FadeIn = float.Parse(all[i + 1]); } else if (all[i] == "fadeout") { props.FadeOut = float.Parse(all[i + 1]); } else if (all[i] == "noloop") { props.Loop = false; } } AudioInFrameProps.Add(props); } } if (singleLine != "return") { if (buildmenu) { buildmenu = false; } else { frame.IsSelected = true; singleLine = reader.ReadLine().TrimStart(' '); } } } } } previousFrames.Clear(); fs.Close(); }
void Resume() { XAudio.Play(); isPaused = false; }