Ejemplo n.º 1
0
        public SoundFontInfo(String SoundFont)
        {
            InitializeComponent();

            ERROR = false;

            // Here we go
            String   next;
            String   sf = "";
            Int32    fonthandle;
            FileInfo f;

            OriginalSF = SoundFont;

            if (SoundFont.ToLower().IndexOf('=') != -1)
            {
                sf = SoundFont.Substring(SoundFont.LastIndexOf('|') + 1);
                if (!File.Exists(sf))
                {
                    Program.ShowError(4, "Error", String.Format("The SoundFont \"{0}\" doesn't exist.", SoundFont), null);
                    ERROR = true;
                    Close();
                    return;
                }
                fonthandle = BassMidi.BASS_MIDI_FontInit(sf);
                f          = new FileInfo(sf);
                next       = sf;
            }
            else
            {
                sf = SoundFont;
                if (!File.Exists(SoundFont))
                {
                    Program.ShowError(4, "Error", String.Format("The SoundFont \"{0}\" doesn't exist.", SoundFont), null);
                    ERROR = true;
                    Close();
                    return;
                }
                fonthandle = BassMidi.BASS_MIDI_FontInit(SoundFont);
                f          = new FileInfo(SoundFont);
                next       = SoundFont;
            }

            BASS_MIDI_FONTINFO fontinfo = BassMidi.BASS_MIDI_FontGetInfo(fonthandle);

            FNBox.Text  = next;
            ISFBox.Text = ReturnName(fontinfo.name, next);
            CIBox.Text  = ReturnCopyright(fontinfo.copyright);
            SamF.Text   = String.Format("{0} ({1})", ReturnSampleType(fontinfo.samtype), fontinfo.samtype);

            if (f.Length > (long)2147483648)
            {
                SofSFLab.Font      = new Font(SofSFLab.Font, FontStyle.Bold);
                SofSFLab.ForeColor = Color.DarkRed;
                SofSFLab.Cursor    = Cursors.Help;
                SizeWarning.SetToolTip(SofSFLab, "SoundFonts bigger than 2GB may not load correctly\non 32-bit applications, cause audio corruptions or even cause loss of data!\n\nBe careful!");
            }

            if (Path.GetExtension(sf).ToLowerInvariant() == ".sfz")
            {
                SofSFLab.Text = String.Format("{0} (Samples: {1}, Presets: {2})",
                                              Functions.ReturnLength(f.Length + SFZ.GetSoundFontZSize(sf), true),
                                              Functions.ReturnLength(SFZ.GetSoundFontZSize(sf), true),
                                              Functions.ReturnLength(f.Length - (long)fontinfo.samsize, false));
            }
            else
            {
                SofSFLab.Text = String.Format("{0} (Samples: {1}, Presets: {2})",
                                              Functions.ReturnLength(f.Length, false),
                                              Functions.ReturnLength(fontinfo.samsize, false),
                                              Functions.ReturnLength(f.Length - (long)fontinfo.samsize, false));
            }

            SFfLab.Text      = SoundFontListExtension.ReturnSoundFontFormatMore(Path.GetExtension(next));
            CommentRich.Text = ReturnComment(fontinfo.comment);
            LELabel.Text     = f.LastWriteTimeUtc.ToString();

            BassMidi.BASS_MIDI_FontFree(fonthandle);
        }
Ejemplo n.º 2
0
        public SoundFontInfo(String SoundFont)
        {
            InitializeComponent();

            ERROR = false;

            LastMIDIPath = KeppySynthConfiguratorMain.SynthPaths.GetValue("lastpathmidimport", Environment.GetFolderPath(Environment.SpecialFolder.Desktop)).ToString();

            // Here we go
            String   next;
            String   sf = "";
            Int32    fonthandle;
            FileInfo f;

            OriginalSF = SoundFont;

            if (SoundFont.ToLower().IndexOf('=') != -1)
            {
                sf = SoundFont.Substring(SoundFont.LastIndexOf('|') + 1);
                if (!File.Exists(sf))
                {
                    Functions.ShowErrorDialog(2, System.Media.SystemSounds.Exclamation, "Error", String.Format("The SoundFont \"{0}\" doesn't exist.", SoundFont), false, null);
                    ERROR = true;
                    Close();
                }
                SoundFontT = sf;
                fonthandle = BassMidi.BASS_MIDI_FontInit(sf);
                f          = new FileInfo(sf);
                next       = sf;
            }
            else
            {
                sf = SoundFont;
                if (!File.Exists(SoundFont))
                {
                    Functions.ShowErrorDialog(2, System.Media.SystemSounds.Exclamation, "Error", String.Format("The SoundFont \"{0}\" doesn't exist.", SoundFont), false, null);
                    ERROR = true;
                    Close();
                }
                SoundFontT = SoundFont;
                fonthandle = BassMidi.BASS_MIDI_FontInit(SoundFont);
                f          = new FileInfo(SoundFont);
                next       = SoundFont;
            }

            BASS_MIDI_FONTINFO fontinfo = BassMidi.BASS_MIDI_FontGetInfo(fonthandle);

            FNBox.Text  = next;
            ISFBox.Text = ReturnName(fontinfo.name, next);
            CIBox.Text  = ReturnCopyright(fontinfo.copyright);

            if (f.Length > (long)2147483648)
            {
                SofSFLab.Font      = new Font(SofSFLab.Font, FontStyle.Bold);
                SofSFLab.ForeColor = Color.DarkRed;
                SofSFLab.Cursor    = Cursors.Help;
                SizeWarning.SetToolTip(SofSFLab, "SoundFonts bigger than 2GB may not load correctly\non 32-bit applications, cause audio corruptions or even cause loss of data!\n\nBe careful!");
            }

            if (Path.GetExtension(sf).ToLowerInvariant() == ".sfz")
            {
                SofSFLab.Text = String.Format("{0} (Samples: {1}, Presets: {2})",
                                              Functions.ReturnLength(f.Length + SFZInfo.GetSoundFontZSize(sf)),
                                              Functions.ReturnLength(SFZInfo.GetSoundFontZSize(sf)),
                                              Functions.ReturnLength(f.Length - (long)fontinfo.samsize));
            }
            else
            {
                SofSFLab.Text = String.Format("{0} (Samples: {1}, Presets: {2})",
                                              Functions.ReturnLength(f.Length),
                                              Functions.ReturnLength(fontinfo.samsize),
                                              Functions.ReturnLength(f.Length - (long)fontinfo.samsize));
            }

            SFfLab.Text      = Functions.ReturnSoundFontFormatMore(Path.GetExtension(next));
            CommentRich.Text = ReturnComment(fontinfo.comment);
            LELabel.Text     = f.LastWriteTimeUtc.ToString();

            BassMidi.BASS_MIDI_FontFree(fonthandle);
        }