using Jacobi.Vst.Core; using NAudio.Midi; using static QuikDawEditor.EDITING.ShorcutKeys; namespace QuikDawEditor.EDITING; public class StaticProperties { public static AsioOut playAsioOut; public static bool ISPROJECTLOADED = false; public static bool HotKeysDisabled = false; public static bool IsUndoing = false; public static bool TrackContentControlChildBeingModified = false; public static double BeatsPerMinute = 100; internal static double oldBPMvalue = 0; internal static double minLyricLineWidthMs = MillisecondsPerBeat * 2; public static ObservableCollection GeneralMidiPrograms; public static List userCommandKeyPairs { get; set; } = new List(); public static ObservableCollection undoActions { get; set; } = new ObservableCollection(); private static string _InfoText; public static string InfoText { get { return _InfoText; } set { _InfoText = value; Application.Current.Dispatcher.Invoke(() => { ((EditorWindow)App.Current.MainWindow).DisplayInfoText = value; }); } } public static int SelectedAudioOutIndex; public static int SelectedAudioInIndex; public static bool SetupWindowInitializing; public static Project editingProject = new Project(); public static ClipControl normalizingClipControl = null; public static ClipControl mixingdownClipControl = null; public static WaveFormat DefaultPlayWaveFormat = WaveFormat.CreateIeeeFloatWaveFormat(44100, 2); public static ProjectPlayer projPlayer; public static readonly double PixelsPerSecond = 10; public static double TracksViewingWidthPixels = 300; public static double TracksContentSVHorizontalScrollOffset = 0; public static bool IsMixingDown = false; public static string GlobalSettingsDirectory { get { return Settings.Default.DataDirectory + "\\GlobalSettings"; } } public static string CompPresetsFile; public static string ProjectsDirectory { get { return Settings.Default.DataDirectory + "\\Projects"; } } public static string EditingProjectPath { get { return editingProject.ProjectDirectory; } } public static string EditingProjectDataFileName { get { return EditingProjectPath + "\\" + editingProject.ProjectName + ".qdd"; } } public static string EditingProjectClipsDirectory { get { return EditingProjectPath + "\\AudioClips"; } } public static string ProjectMixdownDirectory { get { return EditingProjectPath + "\\Mixdowns"; } } public static string ProjectBackupsDirectory { get { return EditingProjectPath + "\\Backups"; } } public static string ProjectRecordingDirectory { get { return EditingProjectPath + "\\Recordings"; } } public static string ProjectWaveformImagesDirectory { get { return EditingProjectPath + "\\WaveformImages"; } } public static string VSTLoadLogFileName { get { return Settings.Default.DataDirectory + "\\VstLoadLog.txt"; } } public static string VstiFavoritesFilePath { get { return GlobalSettingsDirectory + "\\VstiFavorites.txt"; } } public static string VstFxFavoritesFilePath { get { return GlobalSettingsDirectory + "\\VstFxFavorites.txt"; } } public static string EQPresetsFile { get { return GlobalSettingsDirectory + "\\EQPresets.txt"; } } public static int MOD_CONTROLLER_CODE = 1; public static int SUSTAIN_CONTROLLER_CODE = 64; public static int PITCHWHEEL_OFF_VALUE = 8192; public static List movingClips = new List(); public static SolidColorBrush ClipBackgroundBrush = new SolidColorBrush(Color.FromArgb(255, 130, 130, 115)); //public static Pen waveBorderDrawPen = new Pen(Brushes.Black, 0.15); public static SolidColorBrush WavePaintBrush = Brushes.ForestGreen; public static SolidColorBrush MidiNotePaintBrush = Brushes.DarkTurquoise; public static Pen midiNoteBorderPen = null; internal static SolidColorBrush SelectedMidiNoteBrush = new SolidColorBrush(Colors.LawnGreen) { Opacity = 0.8 }; internal static LinearGradientBrush NormalMidiNoteBrush = new LinearGradientBrush(new GradientStopCollection(new[] { new GradientStop(Colors.White, 0), new GradientStop(Colors.CadetBlue, 1) }), new Point(0, 0), new Point(0, 1)) { Opacity = 0.8 }; public static double MsecToPixels(double msec) { return msec / 1000D * PixelsPerSecond; } public static double PixelsToMsec(double pixels) { return Math.Truncate(pixels / PixelsPerSecond * 1000D); } public static double MsecToPixelsZoomed(double msec) { return msec / 1000D * PixelsPerSecond * editingProject.ViewXZoomFac; } public static double PixelsToMsecZoomed(double pixels) { return Math.Truncate(pixels / editingProject.ViewXZoomFac / PixelsPerSecond * 1000D); } public static double BaseGridMagnificationFactor = 40; public static double MsecToPixelsGrid(double msec) { return MsecToPixels(msec) * BaseGridMagnificationFactor; } public static double PixelsToMsecGrid(double pixels) { return PixelsToMsec(pixels / BaseGridMagnificationFactor); } public static double UnitHeight = 60; public static double PianoRollNoteHeight = 10; public static int NumMidiNotesVertical = 116;//in Midi, C0 starts at 12, goes to 127 public static int GetNoteFromYLocation(double locY, double height) { return Math.Min(116, Math.Max(0, (int)((height - locY) / PianoRollNoteHeight))); } public static double GetMsFromXLocationRounded(double locX, double snapToMs) { return snapToMs == -1 ? PixelsToMsecGrid(locX) : Math.Max(0, Math.Round(PixelsToMsecGrid(locX) / snapToMs) * snapToMs); } public static double GetMsFromXLocationTruncated(double locX, double snapToMs) { return snapToMs == -1 ? PixelsToMsecGrid(locX) : Math.Max(0, Math.Truncate(PixelsToMsecGrid(locX) / snapToMs) * snapToMs); } private static ObservableCollection _EQPresets = new ObservableCollection(); public static ObservableCollection EQPresets { get { return _EQPresets; } set { _EQPresets = value; OnEQPresetChanged(EventArgs.Empty); } } public static event EventHandler EQPresetChanged; protected static void OnEQPresetChanged(EventArgs e) { EventHandler handler = EQPresetChanged; if (handler != null) { handler(null, e); } } public static ObservableCollection VstiFavorites { get; set; } = new ObservableCollection(); public static ObservableCollection VstFxFavorites { get; set; } = new ObservableCollection(); public static List waveBitmapSources = new List(); public static Cursor RedHandCursor = new Cursor(new MemoryStream(Resources.RedHand)); public static Cursor RedArrowCursor = new Cursor(new MemoryStream(Resources.RedArrow)); internal static VstTimeInfoFlags playingFlags = VstTimeInfoFlags.ClockValid | VstTimeInfoFlags.TempoValid | VstTimeInfoFlags.PpqPositionValid | VstTimeInfoFlags.BarStartPositionValid | VstTimeInfoFlags.CyclePositionValid | VstTimeInfoFlags.TimeSignatureValid | VstTimeInfoFlags.SmpteValid | VstTimeInfoFlags.TransportPlaying | VstTimeInfoFlags.TransportChanged; internal static VstTimeInfoFlags nonPlayingFlags = VstTimeInfoFlags.ClockValid | VstTimeInfoFlags.TempoValid | VstTimeInfoFlags.PpqPositionValid | VstTimeInfoFlags.BarStartPositionValid | VstTimeInfoFlags.CyclePositionValid | VstTimeInfoFlags.TimeSignatureValid | VstTimeInfoFlags.SmpteValid; public static List AllNotesOffMidiEvents = new List(); static StaticProperties() { EQPresetChanged += (sender, e) => { return; }; //Create list of all notes once, to use for note stopping for (int noteno = 0; noteno < 128; noteno++) { MemoryStream noteOffStream = new MemoryStream(); BinaryWriter noteOffDatax = new BinaryWriter(noteOffStream); noteOffDatax.Write(MidiMessage.StopNote(noteno, 0, 1).RawData); VstMidiEvent newvstMEvent = new VstMidiEvent(0, 0, 0, noteOffStream.ToArray(), 0, 0, true); AllNotesOffMidiEvents.Add(newvstMEvent); noteOffDatax.Close(); noteOffStream.Close(); } } public static JsonSerializerOptions standardJSO = new JsonSerializerOptions() { IgnoreReadOnlyFields = true, IgnoreReadOnlyProperties = true, }; }