// SF system private static bool LoadSpecificSoundFont(string path, ref int sfnum) { if (File.Exists(path)) { MainWindow.KMCGlobals.SoundFonts[sfnum].font = BassMidi.BASS_MIDI_FontInit(path, BASSFlag.BASS_MIDI_FONT_XGDRUMS); MainWindow.KMCGlobals.SoundFonts[sfnum].dpreset = -1; MainWindow.KMCGlobals.SoundFonts[sfnum].dbank = 0; MainWindow.KMCGlobals.SoundFonts[sfnum].spreset = -1; MainWindow.KMCGlobals.SoundFonts[sfnum].sbank = -1; MainWindow.KMCGlobals.SoundFonts[sfnum].dbanklsb = 0; BASSCheckError(); if (!Properties.Settings.Default.PreloadSamplesNotSF) { BassMidi.BASS_MIDI_FontLoad(MainWindow.KMCGlobals.SoundFonts[sfnum].font, -1, -1); } BASSCheckError(); sfnum++; return(true); } else { return(false); } }
public static void BASSLoadSoundFonts2(ref int sfnum) { // Prepare SoundFonts list MainWindow.KMCGlobals.SoundFonts = new BASS_MIDI_FONTEX[MainWindow.SoundFontChain.SoundFonts.Length + 1]; String[] SoundFontsReverse = MainWindow.SoundFontChain.SoundFonts.Reverse().ToArray(); try { // Then load all the other SFs foreach (string s in SoundFontsReverse) { if (s.ToLower().IndexOf('=') != -1) { var matches = System.Text.RegularExpressions.Regex.Matches(s, "[0-9]+"); MainWindow.KMCGlobals.SoundFonts[sfnum].font = BassMidi.BASS_MIDI_FontInit(s.Substring(s.LastIndexOf('|') + 1), BASSFlag.BASS_MIDI_FONT_XGDRUMS); MainWindow.KMCGlobals.SoundFonts[sfnum].dbank = Convert.ToInt32(matches[0].ToString()); MainWindow.KMCGlobals.SoundFonts[sfnum].dpreset = Convert.ToInt32(matches[1].ToString()); MainWindow.KMCGlobals.SoundFonts[sfnum].sbank = Convert.ToInt32(matches[2].ToString()); MainWindow.KMCGlobals.SoundFonts[sfnum].spreset = Convert.ToInt32(matches[3].ToString()); MainWindow.KMCGlobals.SoundFonts[sfnum].dbanklsb = 0; BASSCheckError(); } else { MainWindow.KMCGlobals.SoundFonts[sfnum].font = BassMidi.BASS_MIDI_FontInit(s); MainWindow.KMCGlobals.SoundFonts[sfnum].dpreset = -1; MainWindow.KMCGlobals.SoundFonts[sfnum].dbank = 0; MainWindow.KMCGlobals.SoundFonts[sfnum].spreset = -1; MainWindow.KMCGlobals.SoundFonts[sfnum].sbank = -1; MainWindow.KMCGlobals.SoundFonts[sfnum].dbanklsb = 0; BASSCheckError(); } if (!Properties.Settings.Default.PreloadSamplesNotSF) { BassMidi.BASS_MIDI_FontLoad(MainWindow.KMCGlobals.SoundFonts[sfnum].font, MainWindow.KMCGlobals.SoundFonts[sfnum].spreset, MainWindow.KMCGlobals.SoundFonts[sfnum].sbank); } BASSCheckError(); sfnum++; } } catch { BASSCloseStreamException(new InvalidSoundFont("Invalid SoundFont chain.")); } finally { // Always preload default SoundFont if (Properties.Settings.Default.PreloadDefaultSF) { DirectoryInfo PathToGenericSF = Directory.GetParent(Assembly.GetExecutingAssembly().Location); String FullPath = String.Format("{0}\\GMGeneric.sf2", PathToGenericSF.Parent.FullName); LoadSpecificSoundFont(FullPath, ref sfnum); } BassMidi.BASS_MIDI_StreamSetFonts(MainWindow.KMCGlobals._recHandle, MainWindow.KMCGlobals.SoundFonts, sfnum); BASSCheckError(); if (Properties.Settings.Default.PreloadSamplesNotSF) { BassMidi.BASS_MIDI_StreamLoadSamples(MainWindow.KMCGlobals._recHandle); } BASSCheckError(); } }