private void Action(delAction action, eCmd cmd) //cmd note used? //if (P.F == null || AutoSync == null) return; { if (clsAudioSync.StaticMP3Playing) { return; } //int topindex = clbEla.TopIndex; if (cmd != eCmd.Undo && cmd != eCmd.Redo && cmd != eCmd.Merge) { AudioSync.UpdateUndo(); } action(cmd); //AutoSync.indSave = true; ShowList(); //clbEla.TopIndex = topindex; PlayableForms.CmdState_Stopped(); //possible Play.IsEmpty changed cmdSave.Enabled = (P.F.AudioSync != null && !P.F.AudioSync.IsEmpty()); //P.frmSC.mnuSaveAutoSyncFile.Enabled = cmdSave.Enabled; //* update Elapsed.Play display in bars panes if (P.F?.frmTrackMap != null) { P.F.frmTrackMap.picBars.Refresh(); } if (P.F?.frmChordMap != null) { P.F.frmChordMap.picBars.Refresh(); } clsAudioSync.SetPlayAudioText(P.F?.AudioSync); }
private void cmdConnectAll_Click(object sender, EventArgs e) { using (new clsWaitCursor()) { clsBASSOutDev.Disconnected = false; CloseAllStreams(); Interface.Apply(); OpenAllStreams(); try { MidiPlay.OpenMidiDevs(bassonly: true); } catch (AudioIOException exc) { MessageBox.Show("Audio IO Exception: " + exc.Message); return; } catch (MidiIOException exc) { MessageBox.Show("Midi IO Exception: " + exc.Message); return; } SetStates(); ShowCurrentConnection(); PlayableForms.CmdState_Set(); } }
internal bool LoadChordFileAndMidi() { if (!P.F.CloseCancellableForms()) { return(false); } clsFileStream fs; try { if (!File.Exists(P.F.Project.CHPPath)) { return(false); } fs = LoadMidiFileHeaderFromCF(); //may not exist P.frmSC.NewEmpty(); //* load chpfile before sections and notes if (!P.frmSC.InitShowChordsTxt()) { clsF.NewEmpty(); return(false); } //* load midifile tracks if (fs != null) { P.F.FSTrackMap = new clsFileStream(P.F.Project.MidiPath, null, false, false, false); PlayableForms.CmdState_Set(); } //* load chpfile sections and notes P.F.CF.PostInit(); //if (P.F.CF.Lines_Notes.Count == 0) MessageBox.Show("Warning - no chords in .chp file"); if (fs != null) { //P.F.indCalcKeys = true; //P.frmSC.cmbPlayStyle_SelectedIndexChanged(null, null); if (chkLoadMM.Checked) { Forms.frmSC.ShowMultiMap(); } //P.frmSC.cmbPlayStyle_SelectedIndexChanged(null, null); } P.F.CurrentBBT = new clsMTime.clsBBT(0); P.frmSC.SetProps(); P.frmSC.Play?.NewReset(); RefreshBBT(P.F.CurrentBBT); //P.frmSC.ResizeForm(); } catch (Exception exc) { clsF.NewEmpty(); MessageBox.Show("Load Project failed: " + exc.Message); return(false); } //P.frmStart.lblChpLoad.Text = "loaded"; return(true); }
internal void StreamPlayOnAll() //stream { if (MidiPlay.Sync.indPlayActive != clsSync.ePlay.None) { return; } MidiPlay.Sync.indPlayActive = (clsAudioSync.ActiveStatic) ? clsSync.ePlay.AudioStream : clsSync.ePlay.MidiStream; PlayableForms.CmdState_Playing(); }
internal void StreamPlayOffAll() { MidiPlay.Sync.indPlayActive = clsSync.ePlay.None; PlayableForms.CmdState_Stopped(); //if (P.frmSC != null && P.F.FSTrackMap != null) P.F.FSTrackMap.SaveRecord(); FormsStreamOnOff(false); if (P.F?.frmTrackMap != null) { P.F.frmTrackMap.PlayOff(); } }
private void cmdApply_Click(object sender, EventArgs e) { using (new clsWaitCursor()) { clsBASSOutDev.Disconnected = false; CloseAllStreams(); Interface.Apply(); OpenAllStreams(); SetStates(); ShowCurrentConnection(); PlayableForms.CmdState_Set(); } }
internal void ShowCurrentConnections() { if (P.BASSOutDev == null) { lblCurrentAudio.Text = "None"; } else { lblCurrentAudio.Text = P.BASSOutDev.GetDeviceDesc(); } HideShowFontFXControls(); CheckConnectStates(); PlayableForms.CmdState_Set(); }
private void cmdDisconnect_Click(object sender, EventArgs e) { using (new clsWaitCursor()) { clsBASSOutDev.Disconnected = true; CloseAllStreams(); //Interface = null; SetStates(); ShowCurrentConnection(); if (P.frmMidiDevs != null) { P.frmMidiDevs.ShowCurrentConnections(); } PlayableForms.CmdState_Set(); } }
private void mnuSelCopy_Click(object sender, EventArgs e) { //if (P.F == null || AutoSync == null) return; if (clsAudioSync.StaticMP3Playing) { return; } if (clbEla.SelectedIndices.Count == 0) { return; } //int topindex = clbEla.TopIndex; clsAudioSync.clsElapsed elapsed = AudioSync.Elapsed.Copy(); foreach (int beat in clbEla.SelectedIndices) { if (beat >= elapsed.Record.Count) { continue; } elapsed.Play[beat] = Math.Max(0, elapsed.Record[beat]); } int b = elapsed.ValidatePlay(prompt: false); if (b >= 0) { MessageBox.Show("Copy failed - invalid output at beat " + (b + 1)); } else { AudioSync.UpdateUndo(); AudioSync.Elapsed = elapsed; //AutoSync.indSave = true; } ShowList(); //clbEla.TopIndex = topindex; PlayableForms.CmdState_Stopped(); //possible Play.IsEmpty changed clsAudioSync.SetPlayAudioText(P.F?.AudioSync); }
private void cmdResetPlay_Click(object sender, EventArgs e) { PlayableForms.CmdState_Stopped(); }
internal bool LoadProject(string filename, bool updaterecent) { //* filename = "" (button) or DragDrop file MidiPlay.Sync.Stop(); P.F.StartBar = 0; //else Stop will set CurrentBBT to old StartBar!!! //if (!P.F.CloseCancellableForms()) return false; string chpext; if (filename == "") //Button { filename = GetFileNameFromOFD(ofd, "Project Files|*.chp*;*.mid;*.chl;*.chtc;*.mp3|ChordFiles|*.chp*|All Files|*.*", "Load Project", Cfg.ProjectDir); if (filename == "***") { return(false); } } if (!P.F.CloseCancellableForms()) { return(false); } using (new clsWaitCursor()) { using (new clsLoadingProject()) { //P.frmStart.nudMaxBarsNoMidiFile.Value = clsF.DefaultSongLength; if (Path.GetExtension(filename).StartsWith(".chp")) { chpext = Path.GetExtension(filename); } else //get all .chp<n> files in folder { string[] dirs = Directory.GetFiles( Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename) + ".chp?"); //? = zero or one char if (dirs.Length > 1) //multiple .chp files { dlgCHP dialogfrm = new dlgCHP(dirs, true); if (dialogfrm.CHPDescs == null || dialogfrm.CHPDescs.Length == 0) { return(false); } if (dialogfrm.ShowDialog(P.frmSC) == DialogResult.Cancel) { return(true); } chpext = dialogfrm.OK_Ext; } else if (dirs.Length == 1) //one .chp file only { chpext = Path.GetExtension(dirs[0]); } else //no .chp files { chpext = ".chp0"; //new file } } P.frmSC.panTrkAudio.Enabled = false; if (!clsF.NewF(ref P.F)) { return(false); //should not happen - already checked earlier } P.F.Project = new clsProject(filename, chpext); if (!LoadChordFileAndMidi()) //clsF.NewEmpty() if false { if (File.Exists(P.F.Project.MidiPath)) { if (!LoadMidiFile()) { return(false); //no .chp file - load .mid } } else { P.F.SetEmpty(clsCF.DefaultSongLength); } } P.F.AudioSync = clsAudioSync.New(); LoadLyricsFile(); P.frmSC.NewMidiOrCF(); //P.frmSC.cmbPlayStyle_SelectedIndexChanged(null, null); PlayableForms.CmdState_Stopped(); //if (updaterecent) P.frmSC.UpdateRecentProjects(); if (updaterecent) { P.frmSC.UpdateRecentProjects(); } P.frmSC.Play = (P.frmSC.optModeChords.Checked) ? clsPlay.NewPlay(frmSC.ePlayMode.Chords) : clsPlay.NewPlay(frmSC.ePlayMode.KB); //if (P.F.CF != null) P.F.CF.indSave = false; if (P.F.frmTrackMap != null) { P.F.frmTrackMap.Refresh(); } if (P.F.frmChordMap != null) { P.F.frmChordMap.Refresh(); } return(true); } } }
private void cmdOK_Click(object sender, EventArgs e) { try { if (!P.F.CloseCancellableForms()) { return; } //* check if midifile and audiofile exists if (!CheckFileToCopy(txtMidiFilePath.Text)) { return; } if (!CheckFileToCopy(txtAudioFilePath.Text)) { return; } //* create project dir string fulldir = CreateProjectDir(txtProjectLocation, txtProjectName, chkAddNameToLocation); if (fulldir == "") { return; } //* copy files string mididest = CopyFile(txtMidiFilePath.Text, fulldir, txtProjectName.Text); if (mididest == "***") { return; //copy failed } string audiodest = CopyFile(txtAudioFilePath.Text, fulldir, txtProjectName.Text); if (audiodest == "***") { return; //copy failed } if (!clsF.NewF(ref P.F)) { return; //should not happen - already checked earlier } //* error checking complete P.F.Project = new clsProject(fulldir, txtProjectName.Text, true); //* load midifile if (mididest != "") { //P.F.Project.MidiExists = true; if (!P.frmStart.LoadMidiFile()) { return; } PlayableForms.CmdState_Stopped(); } else { clsF.InitNullMidiFile(clsCF.DefaultSongLength, 192, 4, 4); } //* load audiofile if (audiodest != "") { P.F.AudioSync = clsAudioSync.New(); PlayableForms.CmdState_Stopped(); if (mididest == "") { //P.F.ProjectPathAndName = fulldir + "\\" + txtProjectName.Text; //P.frmSC.cmbPlayStyle_SelectedIndexChanged(null, null); } } //* set up and save chordfile { P.F.CF = new clsCFPC(0); if (P.frmSC != null) { P.frmSC.NewEmpty(); } string msg = P.frmSC.SaveChordFile(); if (msg != "") { MessageBox.Show("Error saving ChordFile: " + msg); } else { //MessageBox.Show("Null ChordFile (" + P.F.MaxBBT.Bar + " Bars): " + P.F.Project.CHPPath + " created"); P.frmSC.UpdateRecentProjects(); } } DialogResult = DialogResult.OK; } catch { return; } }