private void InitializeBASSMIDIStream() { // Init stream ChangePreviewButtonText("Initializing stream...", false); ChangeWindowTitle("Initializing stream..."); hStream = BassMidi.BASS_MIDI_StreamCreateFile(MIDIPreview, 0L, 0L, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_SAMPLE_SOFTWARE | (Convert.ToBoolean(Program.SynthSettings.GetValue("EnableSFX", 0)) ? BASSFlag.BASS_DEFAULT : BASSFlag.BASS_MIDI_NOFX) | (LoopYesNo.Checked ? BASSFlag.BASS_SAMPLE_LOOP : BASSFlag.BASS_DEFAULT), 0); Bass.BASS_ChannelSetAttribute(hStream, BASSAttribute.BASS_ATTRIB_MIDI_CPU, (int)(Convert.ToInt32(Program.SynthSettings.GetValue("MaxRenderingTime", 75)) / 100)); System.Threading.Thread.Sleep(50); // Init SoundFont ChangePreviewButtonText("Loading SoundFont...", false); ChangeWindowTitle("Loading SoundFont..."); BASS_MIDI_FONTEX[] fonts = new BASS_MIDI_FONTEX[1]; if (OriginalSF.ToLower().IndexOf('=') != -1) { var matches = System.Text.RegularExpressions.Regex.Matches(OriginalSF, "[0-9]+"); string sf = OriginalSF.Substring(OriginalSF.LastIndexOf('|') + 1); fonts[0].font = BassMidi.BASS_MIDI_FontInit(sf); fonts[0].spreset = Convert.ToInt32(matches[0].ToString()); fonts[0].sbank = Convert.ToInt32(matches[1].ToString()); fonts[0].dpreset = Convert.ToInt32(matches[2].ToString()); fonts[0].dbank = Convert.ToInt32(matches[3].ToString()); } else { fonts[0].font = BassMidi.BASS_MIDI_FontInit(OriginalSF); fonts[0].spreset = -1; fonts[0].sbank = -1; fonts[0].dpreset = -1; fonts[0].dbank = 0; } BassMidi.BASS_MIDI_FontSetVolume(fonts[0].font, 1.0f); BassMidi.BASS_MIDI_StreamSetFonts(hStream, fonts, 1); BassMidi.BASS_MIDI_StreamLoadSamples(hStream); }
private void InitializeBASSMIDIStream() { // Init stream ChangePreviewButtonText("Initializing stream...", false); ChangeWindowTitle("Initializing stream..."); hStream = BassMidi.BASS_MIDI_StreamCreateFile(MIDIPreview, 0L, 0L, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_SAMPLE_SOFTWARE, 0); Bass.BASS_ChannelSetAttribute(hStream, BASSAttribute.BASS_ATTRIB_MIDI_CPU, (int)(KeppySynthConfiguratorMain.Delegate.MaxCPU.Value / 100)); System.Threading.Thread.Sleep(50); // Init SoundFont ChangePreviewButtonText("Loading SoundFont...", false); ChangeWindowTitle("Loading SoundFont..."); BASS_MIDI_FONTEX[] fonts = new BASS_MIDI_FONTEX[1]; List <int> termsList = new List <int>(); termsList.Reverse(); if (OriginalSF.ToLower().IndexOf('=') != -1) { var matches = System.Text.RegularExpressions.Regex.Matches(OriginalSF, "[0-9]+"); string sf = OriginalSF.Substring(OriginalSF.LastIndexOf('|') + 1); fonts[0].font = BassMidi.BASS_MIDI_FontInit(sf); fonts[0].spreset = Convert.ToInt32(matches[0].ToString()); fonts[0].sbank = Convert.ToInt32(matches[1].ToString()); fonts[0].dpreset = Convert.ToInt32(matches[2].ToString()); fonts[0].dbank = Convert.ToInt32(matches[3].ToString()); BassMidi.BASS_MIDI_FontSetVolume(fonts[0].font, 1.0f); BassMidi.BASS_MIDI_StreamSetFonts(hStream, fonts, 1); } else { fonts[0].font = BassMidi.BASS_MIDI_FontInit(OriginalSF); fonts[0].spreset = -1; fonts[0].sbank = -1; fonts[0].dpreset = -1; fonts[0].dbank = 0; BassMidi.BASS_MIDI_StreamSetFonts(hStream, fonts, 1); } BassMidi.BASS_MIDI_StreamLoadSamples(hStream); }
private void BASSStreamSystemRT(String str, int type) { try { Microsoft.Win32.RegistryKey Settings = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Keppy's MIDI Converter\\Settings", false); if (type == 0) KMCGlobals._recHandle = BassMidi.BASS_MIDI_StreamCreateFile(str, 0L, 0L, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT, KMCGlobals.Frequency); else KMCGlobals._recHandle = BassMidi.BASS_MIDI_StreamCreateFile(str, 0L, 0L, BASSFlag.BASS_MIDI_DECAYEND | BASSFlag.BASS_SAMPLE_FLOAT, KMCGlobals.Frequency); KMCGlobals.StreamSizeFLAC = Bass.BASS_ChannelGetLength(KMCGlobals._recHandle); try { KMCGlobals.eventc = BassMidi.BASS_MIDI_StreamGetEvents(KMCGlobals._recHandle, -1, 0, null); KMCGlobals.events = new BASS_MIDI_EVENT[KMCGlobals.eventc]; } catch { throw new MIDIIsTooBig("The MIDI is too big for real-time simulation."); } BassMidi.BASS_MIDI_StreamGetEvents(KMCGlobals._recHandle, -1, 0, KMCGlobals.events); Bass.BASS_StreamFree(KMCGlobals._recHandle); if (type == 0) KMCGlobals._recHandle = BassMidi.BASS_MIDI_StreamCreate(16, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_SAMPLE_SOFTWARE, KMCGlobals.Frequency); // create MIDI player else KMCGlobals._recHandle = BassMidi.BASS_MIDI_StreamCreate(16, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_SAMPLE_SOFTWARE, KMCGlobals.Frequency); // create MIDI player Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_GVOL_STREAM, KMCGlobals.Volume); Bass.BASS_ChannelSetAttribute(KMCGlobals._recHandle, BASSAttribute.BASS_ATTRIB_MIDI_VOICES, KMCGlobals.LimitVoicesInt); Bass.BASS_ChannelSetAttribute(KMCGlobals._recHandle, BASSAttribute.BASS_ATTRIB_MIDI_CPU, 0); if (Path.GetFileNameWithoutExtension(str).Length >= 49) KMCGlobals.NewWindowName = Path.GetFileNameWithoutExtension(str).Truncate(45); else KMCGlobals.NewWindowName = Path.GetFileNameWithoutExtension(str); BASS_MIDI_FONTEX[] fonts = new BASS_MIDI_FONTEX[KMCGlobals.Soundfonts.Length]; int sfnum = 0; int sfzload = 0; List<int> termsList = new List<int>(); termsList.Reverse(); foreach (string s in KMCGlobals.Soundfonts) { if (s.ToLower().IndexOf('=') != -1) { var matches = System.Text.RegularExpressions.Regex.Matches(s, "[0-9]+"); string sf = s.Substring(s.LastIndexOf('|') + 1); fonts[sfnum].font = BassMidi.BASS_MIDI_FontInit(sf); fonts[sfnum].spreset = Convert.ToInt32(matches[0].ToString()); fonts[sfnum].sbank = Convert.ToInt32(matches[1].ToString()); fonts[sfnum].dpreset = Convert.ToInt32(matches[2].ToString()); fonts[sfnum].dbank = Convert.ToInt32(matches[3].ToString()); if (type == 0) { BassMidi.BASS_MIDI_FontSetVolume(fonts[sfnum].font, ((float)KMCGlobals.Volume / 10000)); } BassMidi.BASS_MIDI_StreamSetFonts(KMCGlobals._recHandle, fonts, sfnum + 1); sfnum += 1; } else { fonts[sfnum].font = BassMidi.BASS_MIDI_FontInit(s); fonts[sfnum].spreset = -1; fonts[sfnum].sbank = -1; fonts[sfnum].dpreset = -1; fonts[sfnum].dbank = 0; if (type == 0) { BassMidi.BASS_MIDI_FontSetVolume(fonts[sfnum].font, ((float)KMCGlobals.Volume / 10000)); } BassMidi.BASS_MIDI_StreamSetFonts(KMCGlobals._recHandle, fonts, sfnum + 1); sfnum += 1; } } KMCGlobals._plm = new Un4seen.Bass.Misc.DSP_PeakLevelMeter(KMCGlobals._recHandle, 1); KMCGlobals._plm.CalcRMS = true; BassMidi.BASS_MIDI_StreamLoadSamples(KMCGlobals._recHandle); } catch (Exception ex) { BASSCloseStreamCrash(ex); } }