internal void InitStream() { //TestBass.SetAtrrAndFont(MidiStream); CheckOK(Bass.ChannelSetAttribute(MidiStream, ChannelAttribute.MidiCPU, 75)); CheckOK(Bass.ChannelSetAttribute(MidiStream, ChannelAttribute.Volume, (float)0.5)); CheckOK(Bass.ChannelSetAttribute(MidiStream, ChannelAttribute.Pan, 0)); if (Font != "") { string path = Cfg.SoundFontsPath + "\\" + Font; int fonthandle = CheckHandleHard(BassMidi.FontInit(path, 0)); //int fonthandle = CheckHandle(BassMidi.BASS_MIDI_FontInit(@"D:\0\Sonar\SoundFonts\FluidR3 GM2-2.SF2", 0)); //MidiFont font = new MidiFont(fonthandle, -1, 0); MidiFont font = new MidiFont(); font.Handle = fonthandle; font.Preset = -1; font.Bank = 0; MidiFont[] fontarr = new MidiFont[] { font }; CheckOKHard(BassMidi.StreamSetFonts(0, fontarr, 1)); CheckOKHard(BassMidi.StreamSetFonts(MidiStream, fontarr, 1)); if (indFreeverb[FXTypeSeq]) { SetFreeverb(); //****SetReverb(); } //InitStreamSub(); } }
void InitBass() { // Setup output - Default device if (!Bass.Init()) { MessageBox.Show("Can't Initialize Device"); Application.Current.Shutdown(); } // Get default font (28mbgm.sf2/ct8mgm.sf2/ct4mgm.sf2/ct2mgm.sf2 if available) var sf = new MidiFont[1]; if (BassMidi.StreamGetFonts(0, sf, 1) != 0) { _font = sf[0].Handle; } // FX enabled by default Effects = true; // load optional plugins for packed soundfonts (others may be used too) Bass.PluginLoad("bassflac.dll"); Bass.PluginLoad("basswv.dll"); }
void InitBass() { Bass.VistaTruePlayPosition = false; // allows lower latency on Vista and newer Bass.UpdatePeriod = 10; // 10ms update period // initialize default output device (and measure latency) if (!Bass.Init(-1, 44100, DeviceInitFlags.Latency)) { MessageBox.Show("Can't initialize output device"); Application.Current.Shutdown(); } Bass.GetInfo(out _info); // default buffer size = update period + 'minbuf' + 1ms margin BufferLength = _info.MinBufferLength <= 0 ? 41 : 10 + _info.MinBufferLength + 1; // enumerate available input devices MidiDeviceInfo di; int dev; for (dev = 0; BassMidi.InGetDeviceInfo(dev, out di); dev++) { Devices.Add(new KeyValuePair <int, string>(dev, di.Name)); } if (dev != 0) { // got sone, try to initialize one int a; for (a = 0; a < dev; a++) { if (BassMidi.InInit(a, MidiInProc)) { // succeeded, start it _device = a; BassMidi.InStart(Device); break; } } if (a == dev) { MessageBox.Show("Can't initialize MIDI device"); } } // get default font (28mbgm.sf2/ct8mgm.sf2/ct4mgm.sf2/ct2mgm.sf2 if available) var sf = new MidiFont[1]; if (BassMidi.StreamGetFonts(0, sf, 1) != 0) { _font = sf[0].Handle; MidiFontInfo i; BassMidi.FontGetInfo(_font, out i); SoundFont = i.Name; } UpdatePresetList(); // load optional plugins for packed soundfonts (others may be used too) Bass.PluginLoad("bassflac.dll"); Bass.PluginLoad("basswv.dll"); }
void OpenExecuted() { _ofd.Filter = "MIDI files (mid/midi/rmi/kar)|*.mid;*.midi;*.rmi;*.kar|All files|*.*"; if (!_ofd.ShowDialog().Value) { return; } Bass.StreamFree(_chan); // free old stream before opening new Lyrics = null; // clear lyrics display if ((_chan = BassMidi.CreateStream(_ofd.FileName, 0, 0, BassFlags.Loop | (Effects ? 0 : BassFlags.MidiNoFx), 1)) == 0) { // it ain't a MIDI FileName = "Click here to Open File..."; MessageBox.Show("Can't play the file"); return; } FileName = Path.GetFileName(_ofd.FileName); // set the title (track name of first track) MidiMarker titlemark; if (BassMidi.StreamGetMark(_chan, MidiMarkerType.TrackName, 0, out titlemark) && titlemark.Track == 0) { FileName += $" - {titlemark.Text}"; } // set looping syncs MidiMarker loopmark; if (FindMarker(_chan, "loopend", out loopmark)) // found a loop end point { Bass.ChannelSetSync(_chan, SyncFlags.Position | SyncFlags.Mixtime, loopmark.Position, LoopSync); } // set a sync there Bass.ChannelSetSync(_chan, SyncFlags.End | SyncFlags.Mixtime, 0, LoopSync); // set one at the end too (eg. in case of seeking past the loop point) // clear lyrics buffer and set lyrics syncs MidiMarker lyricmark; if (BassMidi.StreamGetMark(_chan, MidiMarkerType.Lyric, 0, out lyricmark)) // got lyrics { Bass.ChannelSetSync(_chan, SyncFlags.MidiMarker, (int)MidiMarkerType.Lyric, LyricSync, new IntPtr((int)MidiMarkerType.Lyric)); } else if (BassMidi.StreamGetMark(_chan, MidiMarkerType.Text, 20, out lyricmark)) { // got text instead (over 20 of them) Bass.ChannelSetSync(_chan, SyncFlags.MidiMarker, (int)MidiMarkerType.Text, LyricSync, new IntPtr((int)MidiMarkerType.Text)); } Bass.ChannelSetSync(_chan, SyncFlags.End, 0, EndSync); // override the initial tempo, and set a sync to override tempo events and another to override after seeking SetTempo(true); Bass.ChannelSetSync(_chan, SyncFlags.MidiEvent | SyncFlags.Mixtime, (int)MidiEventType.Tempo, TempoSync); Bass.ChannelSetSync(_chan, SyncFlags.Seeking | SyncFlags.Mixtime, 0, TempoSync); // get default soundfont in case of matching soundfont being used var sf = new MidiFont[1]; if (BassMidi.StreamGetFonts(_chan, sf, 1) != 0) { _font = sf[0].Handle; } Bass.ChannelPlay(_chan); }