示例#1
0
        public static void Load()
        {
            var ini = new IniFile();

            ini.Load(GetConfigFileName());

            DpiScaling           = ini.GetInt("UI", "DpiScaling", 0);
            TimeFormat           = ini.GetInt("UI", "TimeFormat", 0);
            CheckUpdates         = ini.GetBool("UI", "CheckUpdates", true);
            TrackPadControls     = ini.GetBool("UI", "TrackPadControls", false);
            ReverseTrackPad      = ini.GetBool("UI", "ReverseTrackPad", false);
            FollowSequencer      = ini.GetInt("UI", "FollowSequencer", 0);
            InstrumentStopTime   = ini.GetInt("Audio", "InstrumentStopTime", 2);
            MidiDevice           = ini.GetString("MIDI", "Device", "");
            SquareSmoothVibrato  = ini.GetBool("Audio", "SquareSmoothVibrato", true);
            LastFileFolder       = ini.GetString("Folders", "LastFileFolder", "");
            LastInstrumentFolder = ini.GetString("Folders", "LastInstrumentFolder", "");
            LastSampleFolder     = ini.GetString("Folders", "LastSampleFolder", "");

            if (DpiScaling != 100 && DpiScaling != 150 && DpiScaling != 200)
            {
                DpiScaling = 0;
            }

            InstrumentStopTime = Utils.Clamp(InstrumentStopTime, 0, 10);

            if (MidiDevice == null)
            {
                MidiDevice = "";
            }
            if (!Directory.Exists(LastFileFolder))
            {
                LastFileFolder = "";
            }
            if (!Directory.Exists(LastInstrumentFolder))
            {
                LastInstrumentFolder = "";
            }
            if (!Directory.Exists(LastSampleFolder))
            {
                LastSampleFolder = "";
            }
        }
示例#2
0
        public static void Load()
        {
            var ini = new IniFile();

            ini.Load(GetConfigFileName());

            Version                = ini.GetInt("General", "Version", 0);
            ShowTutorial           = ini.GetBool("UI", "ShowTutorial", true);
            DpiScaling             = ini.GetInt("UI", "DpiScaling", 0);
            TimeFormat             = ini.GetInt("UI", "TimeFormat", 0);
            FollowMode             = ini.GetInt("UI", "FollowMode", FollowModeContinuous);
            FollowSync             = ini.GetInt("UI", "FollowSync", FollowSyncBoth);
            CheckUpdates           = ini.GetBool("UI", "CheckUpdates", true);
            ShowPianoRollViewRange = ini.GetBool("UI", "ShowPianoRollViewRange", true);
            TrackPadControls       = ini.GetBool("UI", "TrackPadControls", false);
            ReverseTrackPad        = ini.GetBool("UI", "ReverseTrackPad", false);
            InstrumentStopTime     = ini.GetInt("Audio", "InstrumentStopTime", 2);
            MidiDevice             = ini.GetString("MIDI", "Device", "");
            SquareSmoothVibrato    = ini.GetBool("Audio", "SquareSmoothVibrato", true);
            NoDragSoungWhenPlaying = ini.GetBool("Audio", "NoDragSoungWhenPlaying", false);
            LastFileFolder         = ini.GetString("Folders", "LastFileFolder", "");
            LastInstrumentFolder   = ini.GetString("Folders", "LastInstrumentFolder", "");
            LastSampleFolder       = ini.GetString("Folders", "LastSampleFolder", "");
            LastExportFolder       = ini.GetString("Folders", "LastExportFolder", "");

            if (DpiScaling != 100 && DpiScaling != 150 && DpiScaling != 200)
            {
                DpiScaling = 0;
            }

            InstrumentStopTime = Utils.Clamp(InstrumentStopTime, 0, 10);

            if (MidiDevice == null)
            {
                MidiDevice = "";
            }
            if (!Directory.Exists(LastFileFolder))
            {
                LastFileFolder = "";
            }
            if (!Directory.Exists(LastInstrumentFolder))
            {
                LastInstrumentFolder = "";
            }
            if (!Directory.Exists(LastSampleFolder))
            {
                LastSampleFolder = "";
            }
            if (!Directory.Exists(LastExportFolder))
            {
                LastExportFolder = "";
            }

            // No deprecation at the moment.
            Version = SettingsVersion;
        }
示例#3
0
        public static void Load()
        {
            var ini = new IniFile();

            ini.Load(GetConfigFileName());

            Version = ini.GetInt("General", "Version", 0);

            // General
            CheckUpdates     = ini.GetBool(Version < 2 ? "UI" : "General", "CheckUpdates", true);      // At version 2 (FamiStudio 3.0.0, changed section)
            TrackPadControls = ini.GetBool(Version < 2 ? "UI" : "General", "TrackPadControls", false); // At version 2 (FamiStudio 3.0.0, changed section)
            ShowTutorial     = ini.GetBool(Version < 2 ? "UI" : "General", "ShowTutorial", true);      // At version 2 (FamiStudio 3.0.0, changed section)

            // UI
            DpiScaling             = ini.GetInt("UI", "DpiScaling", 0);
            TimeFormat             = ini.GetInt("UI", "TimeFormat", 0);
            FollowMode             = ini.GetInt("UI", "FollowMode", FollowModeContinuous);
            FollowSync             = ini.GetInt("UI", "FollowSync", FollowSyncBoth);
            ShowNoteLabels         = ini.GetBool("UI", "ShowNoteLabels", true);
            ShowScrollBars         = ini.GetBool("UI", "ShowScrollBars", false);
            ShowOscilloscope       = ini.GetBool("UI", "ShowOscilloscope", true);
            ForceCompactSequencer  = ini.GetBool("UI", "ForceCompactSequencer", false);
            ShowPianoRollViewRange = ini.GetBool("UI", "ShowPianoRollViewRange", true);
            ReverseTrackPad        = ini.GetBool("UI", "ReverseTrackPad", false);
            TrackPadMoveSensitity  = ini.GetInt("UI", "TrackPadMoveSensitity", 1);
            TrackPadZoomSensitity  = ini.GetInt("UI", "TrackPadZoomSensitity", 8);
            ShowImplicitStopNotes  = ini.GetBool("UI", "ShowImplicitStopNotes", true);

            // Audio
            NumBufferedAudioFrames = ini.GetInt("Audio", "NumBufferedFrames", DefaultNumBufferedAudioFrames);
            InstrumentStopTime     = ini.GetInt("Audio", "InstrumentStopTime", 2);
            SquareSmoothVibrato    = ini.GetBool("Audio", "SquareSmoothVibrato", true);
            NoDragSoungWhenPlaying = ini.GetBool("Audio", "NoDragSoungWhenPlaying", false);

            // MIDI
            MidiDevice = ini.GetString("MIDI", "Device", "");

            // Folders
            LastFileFolder       = ini.GetString("Folders", "LastFileFolder", "");
            LastInstrumentFolder = ini.GetString("Folders", "LastInstrumentFolder", "");
            LastSampleFolder     = ini.GetString("Folders", "LastSampleFolder", "");
            LastExportFolder     = ini.GetString("Folders", "LastExportFolder", "");

            // FFmpeg
            FFmpegExecutablePath = ini.GetString("FFmpeg", "ExecutablePath", "");

            // Mixer.
            Array.Copy(DefaultExpansionMixerSettings, ExpansionMixerSettings, ExpansionMixerSettings.Length);

            for (int i = 0; i < ExpansionType.Count; i++)
            {
                var section = "Mixer" + ExpansionType.ShortNames[i];
                ExpansionMixerSettings[i].volume = ini.GetFloat(section, "Volume", DefaultExpansionMixerSettings[i].volume);
                ExpansionMixerSettings[i].treble = ini.GetFloat(section, "Treble", DefaultExpansionMixerSettings[i].treble);
            }

            // QWERTY
            Array.Copy(DefaultQwertyKeys, QwertyKeys, DefaultQwertyKeys.Length);

            // Stop note.
            {
                if (ini.HasKey("QWERTY", "StopNote"))
                {
                    QwertyKeys[0, 0] = ini.GetInt("QWERTY", "StopNote", QwertyKeys[0, 0]);
                }
                if (ini.HasKey("QWERTY", "StopNoteAlt"))
                {
                    QwertyKeys[0, 1] = ini.GetInt("QWERTY", "StopNoteAlt", QwertyKeys[0, 1]);
                }
            }

            // Regular notes.
            for (int idx = 1; idx < QwertyKeys.GetLength(0); idx++)
            {
                var octave = (idx - 1) / 12;
                var note   = (idx - 1) % 12;

                var keyName0 = $"Octave{octave}Note{note}";
                var keyName1 = $"Octave{octave}Note{note}Alt";

                if (ini.HasKey("QWERTY", keyName0))
                {
                    QwertyKeys[idx, 0] = ini.GetInt("QWERTY", keyName0, QwertyKeys[idx, 0]);
                }
                if (ini.HasKey("QWERTY", keyName1))
                {
                    QwertyKeys[idx, 1] = ini.GetInt("QWERTY", keyName1, QwertyKeys[idx, 1]);
                }
            }

            UpdateKeyCodeMaps();

            if (DpiScaling != 100 && DpiScaling != 150 && DpiScaling != 200)
            {
                DpiScaling = 0;
            }

            InstrumentStopTime = Utils.Clamp(InstrumentStopTime, 0, 10);

            if (MidiDevice == null)
            {
                MidiDevice = "";
            }
            if (!Directory.Exists(LastInstrumentFolder))
            {
                LastInstrumentFolder = "";
            }
            if (!Directory.Exists(LastSampleFolder))
            {
                LastSampleFolder = "";
            }
            if (!Directory.Exists(LastExportFolder))
            {
                LastExportFolder = "";
            }

            // Try to point to the demo songs initially.
            if (string.IsNullOrEmpty(LastFileFolder) || !Directory.Exists(LastFileFolder))
            {
                var appPath       = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                var demoSongsPath = Path.Combine(appPath, "Demo Songs");
                LastFileFolder = Directory.Exists(demoSongsPath) ? demoSongsPath : "";
            }

            // Clamp to something reasonable.
            NumBufferedAudioFrames = Utils.Clamp(NumBufferedAudioFrames, 2, 16);

#if FAMISTUDIO_LINUX || FAMISTUDIO_MACOS
            // Linux or Mac is more likely to have standard path for ffmpeg.
            if (string.IsNullOrEmpty(FFmpegExecutablePath) || !File.Exists(FFmpegExecutablePath))
            {
                if (File.Exists("/usr/bin/ffmpeg"))
                {
                    FFmpegExecutablePath = "/usr/bin/ffmpeg";
                }
                else if (File.Exists("/usr/local/bin/ffmpeg"))
                {
                    FFmpegExecutablePath = "/usr/local/bin/ffmpeg";
                }
                else
                {
                    FFmpegExecutablePath = "ffmpeg"; // Hope for the best!
                }
            }
#endif

            // No deprecation at the moment.
            Version = SettingsVersion;
        }
示例#4
0
        public static void Load()
        {
            var ini = new IniFile();

            ini.Load(GetConfigFileName());

            Version                = ini.GetInt("General", "Version", 0);
            ShowTutorial           = ini.GetBool("UI", "ShowTutorial", true);
            DpiScaling             = ini.GetInt("UI", "DpiScaling", 0);
            TimeFormat             = ini.GetInt("UI", "TimeFormat", 0);
            FollowMode             = ini.GetInt("UI", "FollowMode", FollowModeContinuous);
            FollowSync             = ini.GetInt("UI", "FollowSync", FollowSyncBoth);
            CheckUpdates           = ini.GetBool("UI", "CheckUpdates", true);
            ShowNoteLabels         = ini.GetBool("UI", "ShowNoteLabels", true);
            ShowPianoRollViewRange = ini.GetBool("UI", "ShowPianoRollViewRange", true);
            TrackPadControls       = ini.GetBool("UI", "TrackPadControls", false);
            ReverseTrackPad        = ini.GetBool("UI", "ReverseTrackPad", false);
            NumBufferedAudioFrames = ini.GetInt("Audio", "NumBufferedFrames", DefaultNumBufferedAudioFrames);
            InstrumentStopTime     = ini.GetInt("Audio", "InstrumentStopTime", 2);
            SquareSmoothVibrato    = ini.GetBool("Audio", "SquareSmoothVibrato", true);
            NoDragSoungWhenPlaying = ini.GetBool("Audio", "NoDragSoungWhenPlaying", false);
            MidiDevice             = ini.GetString("MIDI", "Device", "");
            LastFileFolder         = ini.GetString("Folders", "LastFileFolder", "");
            LastInstrumentFolder   = ini.GetString("Folders", "LastInstrumentFolder", "");
            LastSampleFolder       = ini.GetString("Folders", "LastSampleFolder", "");
            LastExportFolder       = ini.GetString("Folders", "LastExportFolder", "");
            FFmpegExecutablePath   = ini.GetString("FFmpeg", "ExecutablePath", "");

            if (DpiScaling != 100 && DpiScaling != 150 && DpiScaling != 200)
            {
                DpiScaling = 0;
            }

            InstrumentStopTime = Utils.Clamp(InstrumentStopTime, 0, 10);

            if (MidiDevice == null)
            {
                MidiDevice = "";
            }
            if (!Directory.Exists(LastInstrumentFolder))
            {
                LastInstrumentFolder = "";
            }
            if (!Directory.Exists(LastSampleFolder))
            {
                LastSampleFolder = "";
            }
            if (!Directory.Exists(LastExportFolder))
            {
                LastExportFolder = "";
            }

            // Try to point to the demo songs initially.
            if (string.IsNullOrEmpty(LastFileFolder) || !Directory.Exists(LastFileFolder))
            {
                var appPath       = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                var demoSongsPath = Path.Combine(appPath, "Demo Songs");
                LastFileFolder = Directory.Exists(demoSongsPath) ? demoSongsPath : "";
            }

            // Clamp to something reasonable.
            NumBufferedAudioFrames = Utils.Clamp(NumBufferedAudioFrames, 2, 16);

#if FAMISTUDIO_LINUX || FAMISTUDIO_MACOS
            // Linux or Mac is more likely to have standard path for ffmpeg.
            if (string.IsNullOrEmpty(FFmpegExecutablePath) || !File.Exists(FFmpegExecutablePath))
            {
                if (File.Exists("/usr/bin/ffmpeg"))
                {
                    FFmpegExecutablePath = "/usr/bin/ffmpeg";
                }
                else if (File.Exists("/usr/local/bin/ffmpeg"))
                {
                    FFmpegExecutablePath = "/usr/local/bin/ffmpeg";
                }
                else
                {
                    FFmpegExecutablePath = "ffmpeg"; // Hope for the best!
                }
            }
#endif

            // No deprecation at the moment.
            Version = SettingsVersion;
        }
示例#5
0
        public static void Load()
        {
            var ini = new IniFile();

            ini.Load(GetConfigFileName());

            Version = ini.GetInt("General", "Version", 0);

            // General
            CheckUpdates           = ini.GetBool(Version < 2 ? "UI" : "General", "CheckUpdates", true);      // At version 2 (FamiStudio 3.0.0, changed section)
            TrackPadControls       = ini.GetBool(Version < 2 ? "UI" : "General", "TrackPadControls", false); // At version 2 (FamiStudio 3.0.0, changed section)
            ShowTutorial           = ini.GetBool(Version < 2 ? "UI" : "General", "ShowTutorial", true);      // At version 2 (FamiStudio 3.0.0, changed section)
            ClearUndoRedoOnSave    = ini.GetBool("General", "ClearUndoRedoOnSave", true);
            OpenLastProjectOnStart = ini.GetBool("General", "OpenLastProjectOnStart", true);
            AutoSaveCopy           = ini.GetBool("General", "AutoSaveCopy", true);
            LastProjectFile        = OpenLastProjectOnStart ? ini.GetString("General", "LastProjectFile", "") : "";

            // UI
            DpiScaling             = ini.GetInt("UI", "DpiScaling", 0);
            TimeFormat             = ini.GetInt("UI", "TimeFormat", 0);
            FollowMode             = ini.GetInt("UI", "FollowMode", FollowModeContinuous);
            FollowSync             = ini.GetInt("UI", "FollowSync", FollowSyncBoth);
            ShowNoteLabels         = ini.GetBool("UI", "ShowNoteLabels", true);
            ScrollBars             = Version < 3 ? (ini.GetBool("UI", "ShowScrollBars", false) ? ScrollBarsThin : ScrollBarsNone) : ini.GetInt("UI", "ScrollBars", ScrollBarsNone);
            ShowOscilloscope       = ini.GetBool("UI", "ShowOscilloscope", true);
            ForceCompactSequencer  = ini.GetBool("UI", "ForceCompactSequencer", false);
            ShowPianoRollViewRange = ini.GetBool("UI", "ShowPianoRollViewRange", true);
            ReverseTrackPad        = ini.GetBool("UI", "ReverseTrackPad", false);
            TrackPadMoveSensitity  = ini.GetInt("UI", "TrackPadMoveSensitity", 1);
            TrackPadZoomSensitity  = ini.GetInt("UI", "TrackPadZoomSensitity", 8);
            ShowImplicitStopNotes  = ini.GetBool("UI", "ShowImplicitStopNotes", true);

            // Audio
            NumBufferedAudioFrames        = ini.GetInt("Audio", "NumBufferedFrames", DefaultNumBufferedAudioFrames);
            InstrumentStopTime            = ini.GetInt("Audio", "InstrumentStopTime", 2);
            SquareSmoothVibrato           = ini.GetBool("Audio", "SquareSmoothVibrato", true);
            NoDragSoungWhenPlaying        = ini.GetBool("Audio", "NoDragSoungWhenPlaying", false);
            MetronomeVolume               = ini.GetInt("Audio", "MetronomeVolume", 50);
            SeparateChannelsExportTndMode = ini.GetInt("Audio", "SeparateChannelsExportTndMode", NesApu.TND_MODE_SINGLE);

            // MIDI
            MidiDevice = ini.GetString("MIDI", "Device", "");

            // Folders
            LastFileFolder       = ini.GetString("Folders", "LastFileFolder", "");
            LastInstrumentFolder = ini.GetString("Folders", "LastInstrumentFolder", "");
            LastSampleFolder     = ini.GetString("Folders", "LastSampleFolder", "");
            LastExportFolder     = ini.GetString("Folders", "LastExportFolder", "");

            // FFmpeg
            FFmpegExecutablePath = ini.GetString("FFmpeg", "ExecutablePath", "");

            // Mixer.
            GlobalVolume = ini.GetFloat("Mixer", "GlobalVolume", -3.0f);

            Array.Copy(DefaultExpansionMixerSettings, ExpansionMixerSettings, ExpansionMixerSettings.Length);

            for (int i = 0; i < ExpansionType.Count; i++)
            {
                var section = "Mixer" + ExpansionType.ShortNames[i];
                ExpansionMixerSettings[i].volume = ini.GetFloat(section, "Volume", DefaultExpansionMixerSettings[i].volume);
                ExpansionMixerSettings[i].treble = ini.GetFloat(section, "Treble", DefaultExpansionMixerSettings[i].treble);
            }

            // QWERTY
            Array.Copy(DefaultQwertyKeys, QwertyKeys, DefaultQwertyKeys.Length);

            // Stop note.
            {
                if (ini.HasKey("QWERTY", "StopNote"))
                {
                    QwertyKeys[0, 0] = ini.GetInt("QWERTY", "StopNote", QwertyKeys[0, 0]);
                }
                if (ini.HasKey("QWERTY", "StopNoteAlt"))
                {
                    QwertyKeys[0, 1] = ini.GetInt("QWERTY", "StopNoteAlt", QwertyKeys[0, 1]);
                }
            }

            // Regular notes.
            for (int idx = 1; idx < QwertyKeys.GetLength(0); idx++)
            {
                var octave = (idx - 1) / 12;
                var note   = (idx - 1) % 12;

                var keyName0 = $"Octave{octave}Note{note}";
                var keyName1 = $"Octave{octave}Note{note}Alt";

                if (ini.HasKey("QWERTY", keyName0))
                {
                    QwertyKeys[idx, 0] = ini.GetInt("QWERTY", keyName0, QwertyKeys[idx, 0]);
                }
                if (ini.HasKey("QWERTY", keyName1))
                {
                    QwertyKeys[idx, 1] = ini.GetInt("QWERTY", keyName1, QwertyKeys[idx, 1]);
                }
            }

            UpdateKeyCodeMaps();

            if (Array.IndexOf(global::FamiStudio.DpiScaling.GetAvailableScalings(), DpiScaling) < 0)
            {
                DpiScaling = 0;
            }

            InstrumentStopTime = Utils.Clamp(InstrumentStopTime, 0, 10);

            if (MidiDevice == null)
            {
                MidiDevice = "";
            }
            if (!Directory.Exists(LastInstrumentFolder))
            {
                LastInstrumentFolder = "";
            }
            if (!Directory.Exists(LastSampleFolder))
            {
                LastSampleFolder = "";
            }
            if (!Directory.Exists(LastExportFolder))
            {
                LastExportFolder = "";
            }

            // Try to point to the demo songs initially.
            if (string.IsNullOrEmpty(LastFileFolder) || !Directory.Exists(LastFileFolder))
            {
                var appPath       = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                var demoSongsPath = Path.Combine(appPath, "Demo Songs");
                LastFileFolder = Directory.Exists(demoSongsPath) ? demoSongsPath : "";
            }

            // Clamp to something reasonable.
            NumBufferedAudioFrames = Utils.Clamp(NumBufferedAudioFrames, 2, 16);

            // Linux or Mac is more likely to have standard path for ffmpeg.
            if (PlatformUtils.IsLinux || PlatformUtils.IsMacOS)
            {
                if (string.IsNullOrEmpty(FFmpegExecutablePath) || !File.Exists(FFmpegExecutablePath))
                {
                    if (File.Exists("/usr/bin/ffmpeg"))
                    {
                        FFmpegExecutablePath = "/usr/bin/ffmpeg";
                    }
                    else if (File.Exists("/usr/local/bin/ffmpeg"))
                    {
                        FFmpegExecutablePath = "/usr/local/bin/ffmpeg";
                    }
                    else
                    {
                        FFmpegExecutablePath = "ffmpeg"; // Hope for the best!
                    }
                }
            }

            // Mobile section
            AllowVibration    = ini.GetBool("Mobile", "AllowVibration", true);
            DoubleClickDelete = ini.GetBool("Mobile", "DoubleClickDelete", false);

            // At 3.2.0, we added a new Discord screen to the tutorial.
            if (Version < 4)
            {
                ShowTutorial = true;
            }

            // No deprecation at the moment.
            Version = SettingsVersion;
        }