private static void DrawDebugWindow() { //ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(5, 0)); if (ImGui.Begin("MIDIBARD DEBUG", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.AlwaysAutoResize)) { try { ImGui.TextUnformatted($"AgentModule: {AgentManager.AgentModule.ToInt64():X}"); ImGui.SameLine(); if (ImGui.SmallButton("C##AgentModule")) ImGui.SetClipboardText($"{AgentManager.AgentModule.ToInt64():X}"); ImGui.TextUnformatted($"UiModule: {AgentManager.UiModule.ToInt64():X}"); ImGui.SameLine(); if (ImGui.SmallButton("C##4")) ImGui.SetClipboardText($"{AgentManager.UiModule.ToInt64():X}"); ImGui.TextUnformatted($"AgentCount:{AgentManager.Agents.Count}"); } catch (Exception e) { ImGui.TextUnformatted(e.ToString()); } ImGui.Separator(); try { ImGui.TextUnformatted($"AgentPerformance: {PerformanceAgent.Pointer.ToInt64():X}"); ImGui.SameLine(); if (ImGui.SmallButton("C##AgentPerformance")) ImGui.SetClipboardText($"{PerformanceAgent.Pointer.ToInt64():X}"); ImGui.TextUnformatted($"AgentID: {PerformanceAgent.Id}"); ImGui.TextUnformatted($"notePressed: {notePressed}"); ImGui.TextUnformatted($"noteNumber: {noteNumber}"); ImGui.TextUnformatted($"InPerformanceMode: {InPerformanceMode}"); ImGui.TextUnformatted($"Timer1: {TimeSpan.FromMilliseconds(PerformanceTimer1)}"); ImGui.TextUnformatted($"Timer2: {TimeSpan.FromTicks(PerformanceTimer2 * 10)}"); } catch (Exception e) { ImGui.TextUnformatted(e.ToString()); } ImGui.Separator(); try { ImGui.TextUnformatted($"AgentMetronome: {MetronomeAgent.Pointer.ToInt64():X}"); ImGui.SameLine(); if (ImGui.SmallButton("C##AgentMetronome")) ImGui.SetClipboardText($"{MetronomeAgent.Pointer.ToInt64():X}"); ImGui.TextUnformatted($"AgentID: {MetronomeAgent.Id}"); ImGui.TextUnformatted($"Running: {MetronomeRunning}"); ImGui.TextUnformatted($"Ensemble: {EnsembleModeRunning}"); ImGui.TextUnformatted($"BeatsElapsed: {MetronomeBeatsElapsed}"); ImGui.TextUnformatted($"PPQN: {MetronomePPQN} ({60_000_000 / (double)MetronomePPQN:F3}bpm)"); ImGui.TextUnformatted($"BeatsPerBar: {MetronomeBeatsperBar}"); ImGui.TextUnformatted($"Timer1: {TimeSpan.FromMilliseconds(MetronomeTimer1)}"); ImGui.TextUnformatted($"Timer2: {TimeSpan.FromTicks(MetronomeTimer2 * 10)}"); } catch (Exception e) { ImGui.TextUnformatted(e.ToString()); } ImGui.Separator(); try { ImGui.TextUnformatted($"PerformInfos: {PerformInfos.ToInt64() + 3:X}"); ImGui.SameLine(); if (ImGui.SmallButton("C##PerformInfos")) ImGui.SetClipboardText($"{PerformInfos.ToInt64() + 3:X}"); ImGui.TextUnformatted($"CurrentInstrumentKey: {CurrentInstrument}"); ImGui.TextUnformatted($"Instrument: {InstrumentSheet.GetRow(CurrentInstrument).Instrument}"); ImGui.TextUnformatted($"Name: {InstrumentSheet.GetRow(CurrentInstrument).Name.RawString}"); ImGui.TextUnformatted($"Tone: {CurrentGroupTone}"); //ImGui.Text($"unkFloat: {UnkFloat}"); ////ImGui.Text($"unkByte: {UnkByte1}"); } catch (Exception e) { ImGui.TextUnformatted(e.ToString()); } ImGui.Separator(); ImGui.TextUnformatted($"currentPlaying: {PlaylistManager.CurrentPlaying}"); ImGui.TextUnformatted($"currentSelected: {PlaylistManager.CurrentSelected}"); ImGui.TextUnformatted($"FilelistCount: {PlaylistManager.Filelist.Count}"); ImGui.TextUnformatted($"currentUILanguage: {pluginInterface.UiLanguage}"); ImGui.Separator(); try { //var devicesList = DeviceManager.Devices.Select(i => i.ToDeviceString()).ToArray(); //var inputDevices = DeviceManager.Devices; ////ImGui.BeginListBox("##auofhiao", new Vector2(-1, ImGui.GetTextLineHeightWithSpacing()* (inputDevices.Length + 1))); //if (ImGui.BeginCombo("Input Device", DeviceManager.CurrentInputDevice.ToDeviceString())) //{ // if (ImGui.Selectable("None##device", DeviceManager.CurrentInputDevice is null)) // { // DeviceManager.DisposeDevice(); // } // for (int i = 0; i < inputDevices.Length; i++) // { // var device = inputDevices[i]; // if (ImGui.Selectable($"{device.Name}##{i}", device.Id == DeviceManager.CurrentInputDevice?.Id)) // { // DeviceManager.SetDevice(device); // } // } // ImGui.EndCombo(); //} //ImGui.EndListBox(); //if (ImGui.ListBox("##????", ref InputDeviceID, devicesList, devicesList.Length)) //{ // if (InputDeviceID == 0) // { // DeviceManager.DisposeDevice(); // } // else // { // DeviceManager.SetDevice(InputDevice.GetByName(devicesList[InputDeviceID])); // } //} if (ImGui.SmallButton("Start Event Listening")) { DeviceManager.CurrentInputDevice?.StartEventsListening(); } ImGui.SameLine(); if (ImGui.SmallButton("Stop Event Listening")) { DeviceManager.CurrentInputDevice?.StopEventsListening(); } ImGui.TextUnformatted($"InputDevices: {InputDevice.GetDevicesCount()}\n{string.Join("\n", InputDevice.GetAll().Select(i => $"[{i.Id}] {i.Name}"))}"); ImGui.TextUnformatted($"OutputDevices: {OutputDevice.GetDevicesCount()}\n{string.Join("\n", OutputDevice.GetAll().Select(i => $"[{i.Id}] {i.Name}({i.DeviceType})"))}"); ImGui.TextUnformatted($"CurrentInputDevice: \n{DeviceManager.CurrentInputDevice} Listening: {DeviceManager.CurrentInputDevice?.IsListeningForEvents}"); ImGui.TextUnformatted($"CurrentOutputDevice: \n{CurrentOutputDevice}"); } catch (Exception e) { PluginLog.Error(e.ToString()); } #region Generator //ImGui.Separator(); //if (ImGui.BeginChild("Generate", new Vector2(size - 5, 150), false, ImGuiWindowFlags.NoDecoration)) //{ // ImGui.DragInt("length##keyboard", ref config.testLength, 0.05f); // ImGui.DragInt("interval##keyboard", ref config.testInterval, 0.05f); // ImGui.DragInt("repeat##keyboard", ref config.testRepeat, 0.05f); // if (config.testLength < 0) // { // config.testLength = 0; // } // if (config.testInterval < 0) // { // config.testInterval = 0; // } // if (config.testRepeat < 0) // { // config.testRepeat = 0; // } // if (ImGui.Button("generate##keyboard")) // { // try // { // testplayback?.Dispose(); // } // catch (Exception e) // { // // // } // static Pattern GetSequence(int octave) // { // return new PatternBuilder() // .SetRootNote(Note.Get(NoteName.C, octave)) // .SetNoteLength(new MetricTimeSpan(0, 0, 0, config.testLength)) // .SetStep(new MetricTimeSpan(0, 0, 0, config.testInterval)) // .Note(Interval.Zero) // .StepForward() // .Note(Interval.One) // .StepForward() // .Note(Interval.Two) // .StepForward() // .Note(Interval.Three) // .StepForward() // .Note(Interval.Four) // .StepForward() // .Note(Interval.Five) // .StepForward() // .Note(Interval.Six) // .StepForward() // .Note(Interval.Seven) // .StepForward() // .Note(Interval.Eight) // .StepForward() // .Note(Interval.Nine) // .StepForward() // .Note(Interval.Ten) // .StepForward() // .Note(Interval.Eleven) // .StepForward().Build(); // } // static Pattern GetSequenceDown(int octave) // { // return new PatternBuilder() // .SetRootNote(Note.Get(NoteName.C, octave)) // .SetNoteLength(new MetricTimeSpan(0, 0, 0, config.testLength)) // .SetStep(new MetricTimeSpan(0, 0, 0, config.testInterval)) // .Note(Interval.Eleven) // .StepForward() // .Note(Interval.Ten) // .StepForward() // .Note(Interval.Nine) // .StepForward() // .Note(Interval.Eight) // .StepForward() // .Note(Interval.Seven) // .StepForward() // .Note(Interval.Six) // .StepForward() // .Note(Interval.Five) // .StepForward() // .Note(Interval.Four) // .StepForward() // .Note(Interval.Three) // .StepForward() // .Note(Interval.Two) // .StepForward() // .Note(Interval.One) // .StepForward() // .Note(Interval.Zero) // .StepForward() // .Build(); // } // Pattern pattern = new PatternBuilder() // .SetNoteLength(new MetricTimeSpan(0, 0, 0, config.testLength)) // .SetStep(new MetricTimeSpan(0, 0, 0, config.testInterval)) // .Pattern(GetSequence(3)) // .Pattern(GetSequence(4)) // .Pattern(GetSequence(5)) // .SetRootNote(Note.Get(NoteName.C, 5)) // .StepForward() // .Note(Interval.Twelve) // .Pattern(GetSequenceDown(5)) // .Pattern(GetSequenceDown(4)) // .Pattern(GetSequenceDown(3)) // // Get pattern // .Build(); // var repeat = new PatternBuilder().Pattern(pattern).Repeat(config.testRepeat).Build(); // testplayback = repeat.ToTrackChunk(TempoMap.Default).GetPlayback(TempoMap.Default, Plugin.CurrentOutputDevice, // new MidiClockSettings() { CreateTickGeneratorCallback = () => new HighPrecisionTickGenerator() }); // } // ImGui.SameLine(); // if (ImGui.Button("chord##keyboard")) // { // try // { // testplayback?.Dispose(); // } // catch (Exception e) // { // // // } // var pattern = new PatternBuilder() // //.SetRootNote(Note.Get(NoteName.C, 3)) // //C-G-Am-(G,Em,C/G)-F-(C,Em)-(F,Dm)-G // .SetOctave(Octave.Get(3)) // .SetStep(new MetricTimeSpan(0, 0, 0, config.testInterval)) // .Chord(Chord.GetByTriad(NoteName.C, ChordQuality.Major)).Repeat(config.testRepeat) // .Chord(Chord.GetByTriad(NoteName.G, ChordQuality.Major)).Repeat(config.testRepeat) // .Chord(Chord.GetByTriad(NoteName.A, ChordQuality.Minor)).Repeat(config.testRepeat) // .Chord(Chord.GetByTriad(NoteName.G, ChordQuality.Major)).Repeat(config.testRepeat) // .Chord(Chord.GetByTriad(NoteName.F, ChordQuality.Major)).Repeat(config.testRepeat) // .Chord(Chord.GetByTriad(NoteName.C, ChordQuality.Major)).Repeat(config.testRepeat) // .Chord(Chord.GetByTriad(NoteName.F, ChordQuality.Major)).Repeat(config.testRepeat) // .Chord(Chord.GetByTriad(NoteName.G, ChordQuality.Major)).Repeat(config.testRepeat) // .Build(); // testplayback = pattern.ToTrackChunk(TempoMap.Default).GetPlayback(TempoMap.Default, Plugin.CurrentOutputDevice, // new MidiClockSettings() { CreateTickGeneratorCallback = () => new HighPrecisionTickGenerator() }); // } // ImGui.Spacing(); // if (ImGui.Button("play##keyboard")) // { // try // { // testplayback?.MoveToStart(); // testplayback?.Start(); // } // catch (Exception e) // { // PluginLog.Error(e.ToString()); // } // } // ImGui.SameLine(); // if (ImGui.Button("dispose##keyboard")) // { // try // { // testplayback?.Dispose(); // } // catch (Exception e) // { // PluginLog.Error(e.ToString()); // } // } // try // { // ImGui.TextUnformatted($"{testplayback.GetDuration(TimeSpanType.Metric)}"); // } // catch (Exception e) // { // ImGui.TextUnformatted("null"); // } // //ImGui.SetNextItemWidth(120); // //UIcurrentInstrument = Plugin.CurrentInstrument; // //if (ImGui.ListBox("##instrumentSwitch", ref UIcurrentInstrument, InstrumentSheet.Select(i => i.Instrument.ToString()).ToArray(), (int)InstrumentSheet.RowCount, (int)InstrumentSheet.RowCount)) // //{ // // Task.Run(() => SwitchInstrument.SwitchTo((uint)UIcurrentInstrument)); // //} // //if (ImGui.Button("Quit")) // //{ // // Task.Run(() => SwitchInstrument.SwitchTo(0)); // //} // ImGui.EndChild(); //} #endregion ImGui.End(); } //ImGui.PopStyleVar(); }
private static void DrawDebugWindow() { ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(5, 0)); //ImGui.SetNextWindowSize(new Vector2(500, 800)); ImGui.Begin("MIDIBARD DEBUG", ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoTitleBar); ImGui.Columns(2); ImGui.SetColumnWidth(0, ImGui.GetWindowContentRegionWidth() - 130); ImGui.BeginChild("childleft", ImGui.GetContentRegionAvail(), false); try { ImGui.Text($"AgentModule: {AgentManager.AgentModule.ToInt64():X}"); ImGui.SameLine(); if (ImGui.Button("C##3")) { ImGui.SetClipboardText($"{AgentManager.AgentModule.ToInt64():X}"); } ImGui.Text($"UiModule: {AgentManager.UiModule.ToInt64():X}"); ImGui.SameLine(); if (ImGui.Button("C##4")) { ImGui.SetClipboardText($"{AgentManager.UiModule.ToInt64():X}"); } ImGui.Text($"AgentCount:{AgentManager.Agents.Count}"); } catch (Exception e) { ImGui.Text(e.ToString()); } ImGui.Separator(); try { ImGui.Text($"AgentMetronome: {MetronomeAgent.Pointer.ToInt64():X}"); ImGui.SameLine(); if (ImGui.Button("C##1")) { ImGui.SetClipboardText($"{MetronomeAgent.Pointer.ToInt64():X}"); } ImGui.Text($"AgentID: {MetronomeAgent.Id}"); ImGui.Text($"Running: {MetronomeRunning}"); ImGui.Text($"Ensemble: {EnsembleModeRunning}"); ImGui.Text($"BeatsElapsed: {MetronomeBeatsElapsed}"); ImGui.Text($"TickRate: {MetronomeTickRate} ({60_000_000 / (double)MetronomeTickRate:F3})"); ImGui.Text($"BeatsPerBar: {MetronomeBeatsperBar}"); ImGui.Text($"Timer1: {TimeSpan.FromMilliseconds(MetronomeTimer1)}"); ImGui.Text($"Timer2: {TimeSpan.FromTicks(MetronomeTimer2 * 10)}"); } catch (Exception e) { ImGui.Text(e.ToString()); } ImGui.Separator(); try { ImGui.Text($"AgentPerformance: {PerformanceAgent.Pointer.ToInt64():X}"); ImGui.SameLine(); if (ImGui.Button("C##2")) { ImGui.SetClipboardText($"{PerformanceAgent.Pointer.ToInt64():X}"); } ImGui.Text($"AgentID: {PerformanceAgent.Id}"); ImGui.Text($"notePressed: {notePressed}"); ImGui.Text($"noteNumber: {noteNumber}"); ImGui.Text($"InPerformanceMode: {InPerformanceMode}"); ImGui.Text($"Timer1: {TimeSpan.FromMilliseconds(PerformanceTimer1)}"); ImGui.Text($"Timer2: {TimeSpan.FromTicks(PerformanceTimer2 * 10)}"); } catch (Exception e) { ImGui.Text(e.ToString()); } ImGui.Separator(); ImGui.Text($"currentPlaying: {PlaylistManager.CurrentPlaying}"); ImGui.Text($"currentSelected: {PlaylistManager.CurrentSelected}"); ImGui.Text($"FilelistCount: {PlaylistManager.Filelist.Count}"); ImGui.Text($"currentUILanguage: {pluginInterface.UiLanguage}"); ImGui.Separator(); try { ImGui.Text($"CurrentInstrumentKey: {CurrentInstrument}"); //if (CurrentInstrument != 0) { ImGui.Text($"Instrument: {InstrumentSheet.GetRow(CurrentInstrument).Instrument}"); ImGui.Text($"Name: {InstrumentSheet.GetRow(CurrentInstrument).Name.RawString}"); } //ImGui.Text($"unkFloat: {UnkFloat}"); //ImGui.Text($"unkByte: {UnkByte1}"); } catch (Exception e) { ImGui.Text(e.ToString()); } ImGui.EndChild(); ImGui.NextColumn(); ImGui.BeginChild("childright", ImGui.GetContentRegionAvail(), false); //ImGui.SetNextItemWidth(120); //UIcurrentInstrument = Plugin.CurrentInstrument; //if (ImGui.ListBox("##instrumentSwitch", ref UIcurrentInstrument, InstrumentSheet.Select(i => i.Instrument.ToString()).ToArray(), (int)InstrumentSheet.RowCount, (int)InstrumentSheet.RowCount)) //{ // Task.Run(() => SwitchInstrument.SwitchTo((uint)UIcurrentInstrument)); //} //if (ImGui.Button("Quit")) //{ // Task.Run(() => SwitchInstrument.SwitchTo(0)); //} ImGui.EndChild(); ImGui.End(); ImGui.PopStyleVar(); }
private static unsafe void DrawProgressBar() { ImGui.PushStyleColor(ImGuiCol.PlotHistogram, 0x9C60FF8E); //ImGui.PushStyleColor(ImGuiCol.FrameBg, 0x800000A0); MetricTimeSpan currentTime = new MetricTimeSpan(0); MetricTimeSpan duration = new MetricTimeSpan(0); float progress = 0; if (currentPlayback != null) { currentTime = currentPlayback.GetCurrentTime<MetricTimeSpan>(); duration = currentPlayback.GetDuration<MetricTimeSpan>(); try { progress = (float)currentTime.Divide(duration); } catch (Exception e) { // } ImGui.PushStyleColor(ImGuiCol.FrameBg, 0xAC104020); ImGui.ProgressBar(progress, new Vector2(-1, 3)); ImGui.PopStyleColor(); } else { ImGui.ProgressBar(progress, new Vector2(-1, 3)); } ImGui.TextUnformatted($"{currentTime.Hours}:{currentTime.Minutes:00}:{currentTime.Seconds:00}"); var durationText = $"{duration.Hours}:{duration.Minutes:00}:{duration.Seconds:00}"; ImGui.SameLine(ImGui.GetWindowContentRegionWidth() - ImGui.CalcTextSize(durationText).X); ImGui.TextUnformatted(durationText); try { var currentInstrument = PlayingGuitar && !config.OverrideGuitarTones ? (uint)(24 + CurrentGroupTone) : CurrentInstrument; string currentInstrumentText; if (currentInstrument != 0) { currentInstrumentText = InstrumentSheet.GetRow(currentInstrument).Instrument; if (PlayingGuitar && config.OverrideGuitarTones) { currentInstrumentText = currentInstrumentText.Split(':', ':').First()+": Auto"; } } else { currentInstrumentText = string.Empty; } ImGui.SameLine((ImGui.GetWindowContentRegionWidth() - ImGui.CalcTextSize(currentInstrumentText).X) / 2); ImGui.TextUnformatted(currentInstrumentText); } catch (Exception e) { // } ImGui.PopStyleColor(); }
private static unsafe void DrawProgressBar() { ImGui.PushStyleColor(ImGuiCol.PlotHistogram, 0x9C60FF8E); //ImGui.PushStyleColor(ImGuiCol.FrameBg, 0x800000A0); if (currentPlayback != null) { var currentTime = currentPlayback.GetCurrentTime <MetricTimeSpan>(); var duration = currentPlayback.GetDuration <MetricTimeSpan>(); float progress; try { progress = (float)currentTime.Divide(duration); } catch (Exception e) { progress = 0; } ImGui.PushStyleColor(ImGuiCol.FrameBg, 0xAC104020); ImGui.ProgressBar(progress, new Vector2(-1, 3)); ImGui.PopStyleColor(); ImGui.Text($"{currentTime.Hours}:{currentTime.Minutes:00}:{currentTime.Seconds:00}"); var fmt = $"{duration.Hours}:{duration.Minutes:00}:{duration.Seconds:00}"; ImGui.SameLine(ImGui.GetWindowContentRegionWidth() - ImGui.CalcTextSize(fmt).X); ImGui.Text(fmt); try { var text = CurrentInstrument != 0 ? InstrumentSheet.GetRow(CurrentInstrument).Instrument : string.Empty; var size = ImGui.CalcTextSize(text); ImGui.SameLine((ImGui.GetWindowContentRegionWidth() - size.X) / 2); ImGui.Text(text); } catch (Exception e) { // } } else { ImGui.ProgressBar(0, new Vector2(-1, 3)); ImGui.Text("0:00:00"); ImGui.SameLine(ImGui.GetWindowContentRegionWidth() - ImGui.GetItemRectSize().X); ImGui.Text("0:00:00"); try { var text = CurrentInstrument != 0 ? InstrumentSheet.GetRow(CurrentInstrument).Instrument : string.Empty; var size = ImGui.CalcTextSize(text); ImGui.SameLine((ImGui.GetWindowContentRegionWidth() - size.X) / 2); ImGui.Text(text); } catch (Exception e) { // } } ImGui.PopStyleColor(); }