void ReplaceFontExecuted() { _ofd.Filter = "Soundfonts (sf2/sf2pack)|*.sf2;*.sf2pack|All files|*.*"; if (!_ofd.ShowDialog().Value) { return; } var newfont = BassMidi.FontInit(_ofd.FileName, FontInitFlags.Unicode); if (newfont == 0) { return; } var sf = new[] { new MidiFont { Handle = newfont, Preset = -1, // use all presets Bank = 0 // use default bank(s) } }; BassMidi.StreamSetFonts(0, sf, 1); // set default soundfont BassMidi.StreamSetFonts(_chan, sf, 1); // set for current stream too BassMidi.FontFree(_font); // free old soundfont _font = newfont; }
public static void BASSPlayBackEngine(Int64 length, Int64 pos) { if (MainWindow.Seeking) { BassMidi.BASS_MIDI_StreamEvent(MainWindow.KMCGlobals._recHandle, 0, BASSMIDIEvent.MIDI_EVENT_NOTESOFF, 0); BassVst.BASS_VST_ProcessEvent(MainWindow.VSTs._VSTiHandle, 0, BASSMIDIEvent.MIDI_EVENT_NOTESOFF, 0); Bass.BASS_ChannelSetPosition(MainWindow.KMCGlobals._recHandle, MainWindow.CurrentSeek, BASSMode.BASS_POS_MIDI_TICK); MainWindow.Seeking = false; return; } Int32 tempo = BassMidi.BASS_MIDI_StreamGetEvent(MainWindow.KMCGlobals._recHandle, 0, BASSMIDIEvent.MIDI_EVENT_TEMPO); MainWindow.KMCGlobals.OriginalTempo = 60000000 / tempo; Bass.BASS_ChannelFlags(MainWindow.KMCGlobals._recHandle, Properties.Settings.Default.DisableEffects ? BASSFlag.BASS_MIDI_NOFX : 0, BASSFlag.BASS_MIDI_NOFX); Bass.BASS_ChannelFlags(MainWindow.KMCGlobals._recHandle, Properties.Settings.Default.NoteOff1 ? BASSFlag.BASS_MIDI_NOTEOFF1 : 0, BASSFlag.BASS_MIDI_NOTEOFF1); for (Int32 i = 0; i <= 15; i++) { BassMidi.BASS_MIDI_StreamEvent(MainWindow.KMCGlobals._recHandle, i, BASSMIDIEvent.MIDI_EVENT_MIXLEVEL, MainWindow.KMCStatus.ChannelsVolume[i]); } MainWindow.KMCGlobals._VolFXParam.fCurrent = 1.0f; MainWindow.KMCGlobals._VolFXParam.fTarget = Properties.Settings.Default.Volume; MainWindow.KMCGlobals._VolFXParam.fTime = 0.0f; MainWindow.KMCGlobals._VolFXParam.lCurve = 0; Bass.BASS_FXSetParameters(MainWindow.KMCGlobals._VolFX, MainWindow.KMCGlobals._VolFXParam); Bass.BASS_ChannelSetAttribute(MainWindow.KMCGlobals._recHandle, BASSAttribute.BASS_ATTRIB_MIDI_VOICES, Properties.Settings.Default.Voices); }
public static bool BASSEncodingEngine(Int64 pos, Int64 length) { int tempo = BassMidi.BASS_MIDI_StreamGetEvent(MainWindow.KMCGlobals._recHandle, 0, BASSMIDIEvent.MIDI_EVENT_TEMPO); MainWindow.KMCGlobals.OriginalTempo = 60000000 / tempo; byte[] buffer = new byte[length]; for (int i = 0; i <= 15; i++) { BassMidi.BASS_MIDI_StreamEvent(MainWindow.KMCGlobals._recHandle, i, BASSMIDIEvent.MIDI_EVENT_MIXLEVEL, MainWindow.KMCStatus.ChannelsVolume[i]); } if (MainWindow.VSTs.VSTInfo[0].isInstrument) { Bass.BASS_ChannelGetData(MainWindow.VSTs._VSTiHandle, buffer, (Int32)length); } int got = Bass.BASS_ChannelGetData(MainWindow.KMCGlobals._recHandle, buffer, (Int32)length); if (got < 0) { MainWindow.KMCGlobals.CancellationPendingValue = MainWindow.KMCConstants.CONVERSION_ENDED; return(false); } return(true); }
public static void BASSTempoAndFilter() { SetTempo(true, true); MainWindow.KMCGlobals._myTempoSync = new SYNCPROC(TempoSync); Bass.BASS_ChannelSetSync(MainWindow.KMCGlobals._recHandle, BASSSync.BASS_SYNC_MIDI_EVENT | BASSSync.BASS_SYNC_MIXTIME, (long)BASSMIDIEvent.MIDI_EVENT_TEMPO, MainWindow.KMCGlobals._myTempoSync, IntPtr.Zero); BASSCheckError(); Bass.BASS_ChannelSetSync(MainWindow.KMCGlobals._recHandle, BASSSync.BASS_SYNC_SETPOS | BASSSync.BASS_SYNC_MIXTIME, 0, MainWindow.KMCGlobals._myTempoSync, IntPtr.Zero); BASSCheckError(); if (Properties.Settings.Default.IgnoreNotes1 || Properties.Settings.Default.AskForIgnoreTracks || MainWindow.VSTs.VSTInfo[0].isInstrument) { Int32 TracksCount = BassMidi.BASS_MIDI_StreamGetTrackCount(MainWindow.KMCGlobals._recHandle); if (Properties.Settings.Default.AskForIgnoreTracks) { new TracksToIgnore(TracksCount).ShowDialog(); } else { TracksList = new bool[TracksCount]; } GC.KeepAlive(MainWindow.KMCGlobals._FilterProc); MainWindow.KMCGlobals._FilterProc = new MIDIFILTERPROC(MidiFilterProc); BassMidi.BASS_MIDI_StreamSetFilter(MainWindow.KMCGlobals._recHandle, false, MainWindow.KMCGlobals._FilterProc, IntPtr.Zero); BASSCheckError(); } }
private void GetInfoFromStream_DoWork(object sender, DoWorkEventArgs e) { try { while (true) { if (chan != 0) { normalpos = Bass.BASS_ChannelGetPosition(chan); normallen = Bass.BASS_ChannelGetLength(chan); tick = Bass.BASS_ChannelGetPosition(chan, BASSMode.BASS_POS_MIDI_TICK); // get position in ticks lentick = Bass.BASS_ChannelGetLength(chan, BASSMode.BASS_POS_MIDI_TICK); // get length in ticks Bass.BASS_ChannelSetAttribute(chan, BASSAttribute.BASS_ATTRIB_MIDI_VOICES, maxvoices); // apply to current MIDI file too Bass.BASS_ChannelSetAttribute(chan, BASSAttribute.BASS_ATTRIB_MIDI_CPU, Convert.ToSingle(maxcpu)); // apply to current MIDI file too Bass.BASS_ChannelGetAttribute(chan, BASSAttribute.BASS_ATTRIB_MIDI_VOICES_ACTIVE, ref active); // get active voices Bass.BASS_ChannelGetAttribute(chan, BASSAttribute.BASS_ATTRIB_CPU, ref cpu); // get cpu usage PassedTime = TimeSpan.FromSeconds(Bass.BASS_ChannelBytes2Seconds(chan, normalpos)); LengthTime = TimeSpan.FromSeconds(Bass.BASS_ChannelBytes2Seconds(chan, normallen)); } BASS_MIDI_FONTINFO i = new BASS_MIDI_FONTINFO(); BassMidi.BASS_MIDI_FontGetInfo(font, i); sfinfolabel = String.Format("Name: {0}\nLoaded: {1} / {2}", i.name, i.samload, i.samsize); System.Threading.Thread.Sleep(1); } } catch { } }
void LyricSync(int Handle, int Channel, int Data, IntPtr User) { MidiMarker mark; BassMidi.StreamGetMark(Channel, (MidiMarkerType)User.ToInt32(), Data, out mark); // get the lyric/text var text = mark.Text; switch (text[0]) { case '@': break; // skip info case '\\': // clear display Lyrics = text.Substring(1); break; default: // new line if (text[0] == '/') { Lyrics += '\n' + text.Substring(1); } else { Lyrics += text; } break; } }
// 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 MainViewModel() { _ofd = new OpenFileDialog { Filter = "Soundfonts (sf2/sf2pack/sfz)|*.sf2;*.sf2pack;*.sfz|All files|*.*" }; InitBass(); ResetCommand = new DelegateCommand(() => { BassMidi.StreamEvent(_stream, 0, MidiEventType.System, (int)MidiSystem.GS); // send system reset event if (_drums) { BassMidi.StreamEvent(_stream, 16, MidiEventType.Drums, 1); // send drum switch event } BassMidi.StreamEvent(_stream, 16, MidiEventType.Program, _preset); // send program/preset event }); IncreaseBufferLengthCommand = new DelegateCommand(() => BufferLength++); DecreaseBufferLengthCommand = new DelegateCommand(() => BufferLength--); OpenCommand = new DelegateCommand(OpenSoundFont); }
private void CheckPosition() { Int64 MIDILengthRAW = Bass.BASS_ChannelGetLength(Data.StreamHandle); Int64 MIDICurrentPosRAW = Bass.BASS_ChannelGetPosition(Data.StreamHandle); RAWTotal = ((float)MIDILengthRAW) / 1048576f; RAWConverted = ((float)MIDICurrentPosRAW) / 1048576f; Double LenRAWToDouble = Bass.BASS_ChannelBytes2Seconds(Data.StreamHandle, MIDILengthRAW); Double CurRAWToDouble = Bass.BASS_ChannelBytes2Seconds(Data.StreamHandle, MIDICurrentPosRAW); Data.TotalTime = TimeSpan.FromSeconds(LenRAWToDouble); Data.CurrentTime = TimeSpan.FromSeconds(CurRAWToDouble); Bass.BASS_ChannelGetAttribute(Data.StreamHandle, BASSAttribute.BASS_ATTRIB_MIDI_PPQN, ref Data.PPQN); Data.TotalTicks = Convert.ToUInt32(Bass.BASS_ChannelGetLength(Data.StreamHandle, BASSMode.BASS_POS_MIDI_TICK)); Data.Tick = Convert.ToUInt32(Bass.BASS_ChannelGetPosition(Data.StreamHandle, BASSMode.BASS_POS_MIDI_TICK)); Int32 Tempo = 60000000 / BassMidi.BASS_MIDI_StreamGetEvent(Data.StreamHandle, 0, BASSMIDIEvent.MIDI_EVENT_TEMPO); Data.Tempo = Convert.ToUInt32(Tempo.LimitIntegerToRange(0, 999)); try { Data.Bar = Convert.ToUInt32(((Int64)(Data.Tick / (Data.PPQN / (8 / 4) * 4))).LimitLongToRange(0, 9223372036854775807)); Data.TotalBars = Convert.ToUInt32(((Int64)(Data.TotalTicks / (Data.PPQN / (8 / 4) * 4))).LimitLongToRange(0, 9223372036854775807)); Data.HowManyZeroesBars = String.Concat(Enumerable.Repeat("0", Data.TotalBars.ToString().Length)); } catch { Data.Bar = 0; Data.TotalBars = 0; } }
public BASSMIDI(WaveFormat WF) { lock (Lock) { WaveFormat = WF; InitializeSettings(); Handle = BassMidi.BASS_MIDI_StreamCreate(16, Flags, WaveFormat.SampleRate); if (!CheckError(Handle, "Unable to create stream.")) { ErroredOut = true; return; } if (Handle == 0) { BASSError ERR = Bass.BASS_ErrorGetCode(); Debug.ShowMsgBox( "BASSMIDI error", String.Format("Unable to create stream.\n\nError encountered: {0}", ERR), null, MessageBoxButtons.OK, MessageBoxIcon.Error); ErroredOut = true; return; } Debug.PrintToConsole("ok", String.Format("{0} - Stream is open.", UniqueID)); Int32 Tracks = BassMidi.BASS_MIDI_StreamGetTrackCount(Handle); Debug.PrintToConsole("ok", String.Format("{0} - Total tracks = {1}", UniqueID, Tracks)); SetSoundFonts(); } }
// This is a really unstable mode, touching anything in its code might break it public BASSMIDI(Boolean RTS, WaveFormat WF) { if (!RTS) { Debug.ShowMsgBox("Wait what!?", "The \"RTS\" argument should be set to TRUE!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); ErroredOut = true; return; } lock (Lock) { Int32 MT = Properties.Settings.Default.MultiThreadedMode ? Properties.Settings.Default.MultiThreadedLimitV : 1; RTSMode = RTS; WaveFormat = WF; InitializeSettings(); // Remove DECAYEND since it's not applicable to this type of stream Flags &= ~BASSFlag.BASS_MIDI_DECAYEND; // Create stream which will feed the events to Handle = BassMidi.BASS_MIDI_StreamCreate(16, Flags, WaveFormat.SampleRate); if (!CheckError(Handle, String.Format("Unable to create RTS stream ({0}).", UniqueID))) { ErroredOut = true; return; } Debug.PrintToConsole("ok", String.Format("{0} - RTS stream.", UniqueID)); SetSoundFonts(); } }
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(); } }
public void PlayTestSong() { int stream = BassMidi.BASS_MIDI_StreamCreateFile("zumn.mid", 0, 0, 0, 0); BassMidi.BASS_MIDI_StreamSetFonts(stream, Fonts, 1); PlayInVolume(stream, true, volumeNote); }
public void Dispose(bool disposeManagedObjects) { if (!this.bDisposed済み) { if (disposeManagedObjects) { for (int i = 0; i < BassMidi.BASS_MIDI_InGetDeviceInfos(); i++) { BassMidi.BASS_MIDI_InStop(i); BassMidi.BASS_MIDI_InFree(i); } foreach (IInputDevice device2 in this.list入力デバイス) { device2.Dispose(); } lock (this.objMidiIn排他用) { this.list入力デバイス.Clear(); } //if( this.timer != null ) //{ // this.timer.Dispose(); // this.timer = null; //} } this.bDisposed済み = true; } }
public void GetTags() { if (Program.mainWindow == null) { return; } try { if (Program.mainWindow.supportedModuleTypes.Contains(Path.GetExtension(filename).ToLower())) { Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); int track = Bass.BASS_MusicLoad(filename, 0, 0, BASSFlag.BASS_MUSIC_NOSAMPLE | BASSFlag.BASS_MUSIC_PRESCAN, 0); title = Bass.BASS_ChannelGetMusicName(track); artist = Bass.BASS_ChannelGetMusicMessage(track); length = (int)Bass.BASS_ChannelBytes2Seconds(track, (int)Bass.BASS_ChannelGetLength(track)); Bass.BASS_Free(); } else if (Program.mainWindow.supportedMidiTypes.Contains(Path.GetExtension(filename).ToLower())) { Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); int track = BassMidi.BASS_MIDI_StreamCreateFile(filename, 0, 0, BASSFlag.BASS_DEFAULT, 0); title = Path.GetFileName(filename); length = (int)Bass.BASS_ChannelBytes2Seconds(track, (int)Bass.BASS_ChannelGetLength(track)); Bass.BASS_Free(); } else { TagLib.File tagFile = TagLib.File.Create(filename); title = tagFile.Tag.Title; if (tagFile.Tag.Performers.Length > 0) { artist = tagFile.Tag.Performers[0]; } album = tagFile.Tag.Album; //year = tagFile.Tag.Year+""; //comment = tagFile.Tag.Comment; length = (int)tagFile.Properties.Duration.TotalSeconds; bitrate = tagFile.Properties.AudioBitrate; tagFile.Dispose(); } } catch (Exception) { title = filename; length = 0; } if (String.IsNullOrWhiteSpace(title)) { title = Path.GetFileName(filename); } try { listened = Int32.Parse(Program.mainWindow.xmlCacher.GetListened(filename)); } catch (Exception) { listened = 0; } }
public static void BASSLoadSoundFonts(String str) { if (!MainWindow.VSTs.VSTInfo[0].isInstrument) { int sfnum = 0; if (MainWindow.SoundFontChain.SoundFonts.Length == 0) { DirectoryInfo PathToGenericSF = Directory.GetParent(Assembly.GetExecutingAssembly().Location); String FullPath = String.Format("{0}\\GMGeneric.sf2", PathToGenericSF.Parent.FullName); MainWindow.KMCGlobals.SoundFonts = new BASS_MIDI_FONTEX[1]; if (LoadSpecificSoundFont(FullPath, ref sfnum) != true) { BASSCloseStreamCrash(new InvalidSoundFont("No SoundFonts available!")); } 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(); } else { if (Properties.Settings.Default.PreloadSFOfMIDI) { String SFToLoad = String.Format("{0}\\{1}.sf2", Path.GetDirectoryName(str), Path.GetFileNameWithoutExtension(str)); MainWindow.KMCGlobals.SoundFonts = new BASS_MIDI_FONTEX[1]; if (LoadSpecificSoundFont(SFToLoad, 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(); } else { BASSLoadSoundFonts2(ref sfnum); } } else { BASSLoadSoundFonts2(ref sfnum); } } } else { MainWindow.KMCGlobals.SoundFonts = null; } }
void SetTempo(bool Reset) { if (Reset) { _originalTempo = BassMidi.StreamGetEvent(_chan, 0, MidiEventType.Tempo); // get the file's tempo } Tempo = (int)(_originalTempo * _tempoScale); // set tempo }
internal override void ConnectMidiDev(clsBassOutMidi bassoutmidi) { //mixed by windows/hardware bassoutmidi.MidiStream = CheckHandle(BassMidi.CreateStream( bassoutmidi.NumMidiChans, BassFlags.AutoFree, 1)); bassoutmidi.InitStream(); //soundfonts etc. CheckOK(Bass.ChannelPlay(bassoutmidi.MidiStream, false)); }
internal override void ConnectMidiDev(clsBassOutMidi bassoutmidi) { bassoutmidi.MidiStream = CheckHandleHard(BassMidi.CreateStream( bassoutmidi.NumMidiChans, BassFlags.Decode | BassFlags.Float, 1)); bassoutmidi.InitStream(); CheckOKHard(BassMix.MixerAddChannel( MixerStream, bassoutmidi.MidiStream, BassFlags.Default)); }
void TimerOnTick(object Sender, EventArgs Args) { MidiFontInfo i; if (BassMidi.FontGetInfo(_font, out i)) { SoundFontStatus = $"Name: {i.Name}\nLoaded: {i.SampleDataLoaded} / {i.SampleDataSize}"; } }
public static long GetMIDILength(string str) { Bass.BASS_Init(0, 22050, BASSInit.BASS_DEVICE_NOSPEAKER, IntPtr.Zero); Int32 time = BassMidi.BASS_MIDI_StreamCreateFile(str, 0L, 0L, BASSFlag.BASS_STREAM_DECODE, 0); Bass.BASS_StreamFree(time); Bass.BASS_Free(); return(Bass.BASS_ChannelGetLength(time)); }
// コンストラクタ public CInputManager(IntPtr hWnd) { this.list入力デバイス = new List <IInputDevice>(10); #region [ Enumerate keyboard/mouse: exception is masked if keyboard/mouse is not connected ] CInputKeyboard cinputkeyboard = null; CInputMouse cinputmouse = null; try { cinputkeyboard = new CInputKeyboard(); cinputmouse = new CInputMouse(); } catch { } if (cinputkeyboard != null) { this.list入力デバイス.Add(cinputkeyboard); } if (cinputmouse != null) { this.list入力デバイス.Add(cinputmouse); } #endregion #region [ Enumerate joypad ] try { for (int joynum = 0; joynum < 8; joynum++) //2020.06.28 Mr-Ojii joystickの検出数を返す関数が見つからないので適当に8個で { if (OpenTK.Input.Joystick.GetState(joynum).IsConnected) { this.list入力デバイス.Add(new CInputJoystick(joynum)); } } } catch (Exception e) { Trace.WriteLine(e.ToString()); } #endregion try { this.proc = new MIDIINPROC(this.MidiInCallback); for (int i = 0; i < BassMidi.BASS_MIDI_InGetDeviceInfos(); i++) { BassMidi.BASS_MIDI_InInit(i, this.proc, IntPtr.Zero); BassMidi.BASS_MIDI_InStart(i); CInputMIDI item = new CInputMIDI((uint)i); this.list入力デバイス.Add(item); } } catch (Exception e) { Trace.TraceError(e.ToString()); } }
public unsafe int SendEndEvent() { var ev = new[] { new BASS_MIDI_EVENT(BASSMIDIEvent.MIDI_EVENT_END_TRACK, 0, 0, 0, 0), new BASS_MIDI_EVENT(BASSMIDIEvent.MIDI_EVENT_END, 0, 0, 0, 0), }; var mode = BASSMIDIEventMode.BASS_MIDI_EVENTS_TIME | BASSMIDIEventMode.BASS_MIDI_EVENTS_STRUCT; return(BassMidi.BASS_MIDI_StreamEvents(Handle, mode, ev)); }
void OpenSoundFont() { if (!_ofd.ShowDialog().Value) { return; } var newfont = BassMidi.FontInit(_ofd.FileName, FontInitFlags.Unicode); if (newfont == 0) { return; } var sf = new[] { new MidiFont { Handle = newfont, Preset = -1, // use all presets Bank = 0 // use default bank(s) } }; BassMidi.StreamSetFonts(0, sf, 1); // set default soundfont BassMidi.StreamSetFonts(_stream, sf, 1); // apply to current stream too BassMidi.FontFree(_font); // free old soundfont _font = newfont; MidiFontInfo i; BassMidi.FontGetInfo(_font, out i); SoundFont = string.IsNullOrWhiteSpace(i.Name) ? Path.GetFileNameWithoutExtension(_ofd.FileName) : i.Name; if (i.Presets == 1) { // only 1 preset, auto-select it... var p = new int[1]; BassMidi.FontGetPresets(_font, p); Drums = p[0].HiWord() == 128; // bank 128 = drums Preset = p[0].LoWord(); MultiPresets = false; } else { MultiPresets = true; } UpdatePresetList(); }
private void SetTempo(bool reset) { new Thread(() => { if (reset) { miditempo = BassMidi.BASS_MIDI_StreamGetEvent(chan, 0, BASSMIDIEvent.MIDI_EVENT_TEMPO); // get the file's tempo } BassMidi.BASS_MIDI_StreamEvent(chan, 0, BASSMIDIEvent.MIDI_EVENT_TEMPO, Convert.ToInt32(miditempo * temposcale)); // set tempo }).Start(); }
// look for a marker (eg. loop points) static bool FindMarker(int handle, string text, out MidiMarker mark) { for (var a = 0; BassMidi.StreamGetMark(handle, MidiMarkerType.Marker, a, out mark); a++) { if (mark.Text == text) { return(true); // found it } } return(false); }
private void ApplySoundfontToStream(string SoundfontFilename) { int FontHandle = BassMidi.BASS_MIDI_FontInit(SoundfontFilename); if (FontHandle != 0) { BASS_MIDI_FONT Font = new BASS_MIDI_FONT(FontHandle, -1, 0); BassMidi.BASS_MIDI_StreamSetFonts(this.ChannelID, new BASS_MIDI_FONT[] { Font }, 1); // apply it to the stream } }
private void FreeSoundFonts() { Debug.PrintToConsole("ok", "Freeing SoundFont handles..."); foreach (BASS_MIDI_FONTEX SF in Program.SFArray.BMFEArray) { BassMidi.BASS_MIDI_FontFree(SF.font); } Debug.PrintToConsole("ok", "Handles freed."); Program.SFArray.BMFEArray.Clear(); }
public void AllNotesOff() { MidiMon.Reset(); for (int ch = 0; ch < 16; ch++) { //for (int n = 0; n < 128; n++) { // BassMidi.BASS_MIDI_StreamEvent(MidiStream, ch, BASSMIDIEvent.MIDI_EVENT_NOTE, n); //} BassMidi.StreamEvent(MidiStream, ch, MidiEventType.NotesOff, 0); BassMidi.StreamEvent(MidiStream, ch, MidiEventType.Sustain, 0); } }
private bool FindMarker(int handle, string text, BASS_MIDI_MARK mark) { int a; for (a = 0; BassMidi.BASS_MIDI_StreamGetMark(handle, BASSMIDIMarker.BASS_MIDI_MARK_MARKER, a, mark); a++) { if (mark.text.ToLowerInvariant() == text.ToLowerInvariant()) { return(true); } } return(false); }