public static Boolean MidiFilterProc(int handle, int track, IntPtr midievent, bool seeking, IntPtr user) { try { Int32 Track = track; BASS_MIDI_EVENT temp = BASS_MIDI_EVENT.FromIntPtr(midievent); if (temp.eventtype == BASSMIDIEvent.MIDI_EVENT_NOTE && (Properties.Settings.Default.IgnoreNotes1 || Properties.Settings.Default.AskForIgnoreTracks)) { if (TracksList[Track]) { return(false); } int vel = (temp.param >> 0x08) & 0xFF; int note = temp.param & 0xFF; // First check if ((Properties.Settings.Default.IgnoreNotes1 && vel > 0) && (vel >= Properties.Settings.Default.IgnoreNotesLow && vel <= Properties.Settings.Default.IgnoreNotesHigh)) { return(false); } // Second if (Properties.Settings.Default.Limit88 && (temp.chan != 9 && !(note >= 21 && note <= 108))) { return(false); } } if (MainWindow.VSTs.VSTInfo[0].isInstrument) { BassVst.BASS_VST_ProcessEvent(MainWindow.VSTs._VSTiHandle, temp.chan, temp.eventtype, temp.param); } return(true); // process the event } catch (Exception ex) { BASSCloseStreamCrash(ex); return(false); } }
private void RealTimePlayBack_DoWork(object sender, DoWorkEventArgs e) { try { try { PlayConversionStart(); bool KeepLooping = true; BASSInitSystem(1); while (KeepLooping) { foreach (ListViewItem itemerino in getListViewItems(MIDIList)) { string str = itemerino.Text; string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(str); string encpath = null; BASSStreamSystem(str, 1); BASSVSTInit(KMCGlobals._recHandle); BASSEffectSettings(); Bass.BASS_ChannelPlay(KMCGlobals._recHandle, false); long pos = Bass.BASS_ChannelGetLength(KMCGlobals._recHandle); int count = BassMidi.BASS_MIDI_StreamGetEvents(KMCGlobals._recHandle, -1, BASSMIDIEvent.MIDI_EVENT_NOTE, null); // cac BASS_MIDI_EVENT[] events = new BASS_MIDI_EVENT[count]; BassMidi.BASS_MIDI_StreamGetEvents(KMCGlobals._recHandle, -1, BASSMIDIEvent.MIDI_EVENT_NOTE, events); int notes = 0; for (int a = 0; a < count; a++) { if ((events[a].param & 0xff00) != 0) { notes++; } } KMCGlobals._mySync = new SYNCPROC(NoteSyncProc); int sync = Bass.BASS_ChannelSetSync(KMCGlobals._recHandle, BASSSync.BASS_SYNC_MIDI_EVENT, (long)BASSMIDIEvent.MIDI_EVENT_NOTE, KMCGlobals._mySync, IntPtr.Zero); KMCGlobals.notecount = 0; int length = Convert.ToInt32(Bass.BASS_ChannelSeconds2Bytes(KMCGlobals._recHandle, 0.0275)); while (Bass.BASS_ChannelIsActive(KMCGlobals._recHandle) == BASSActive.BASS_ACTIVE_PLAYING) { if (KMCGlobals.CancellationPendingValue != 1) { notes = BASSPlayBackEngine(notes, length, pos); } else if (KMCGlobals.CancellationPendingValue == 1) { BASSCloseStream(res_man.GetString("PlaybackAborted", cul), res_man.GetString("PlaybackAborted", cul), 0); KMCGlobals.PlaybackMode = false; break; } } if (KMCGlobals.CancellationPendingValue == 1) { events = null; KeepLooping = false; break; } else { Bass.BASS_StreamFree(KMCGlobals._recHandle); continue; } } if (KMCGlobals.CancellationPendingValue == 1) { BASSCloseStream(res_man.GetString("PlaybackAborted", cul), res_man.GetString("PlaybackAborted", cul), 1); } else { BASSCloseStream("null", "null", 1); } } } catch (Exception exception) { WriteToConsole(exception); KMCGlobals.PlaybackMode = false; } } catch (Exception exception2) { BASSCloseStreamCrash(exception2); } }
private string[] GetMoreInfoMIDI(string str) { try { string[] strings; long length = new System.IO.FileInfo(str).Length; if (length / 1024f >= 9860) { if (ModifierKeys == Keys.Control) { } else { strings = new string[] { "N/A", "N/A" }; return strings; } } Bass.BASS_Init(0, 22050, BASSInit.BASS_DEVICE_NOSPEAKER, IntPtr.Zero); int time = BassMidi.BASS_MIDI_StreamCreateFile(str, 0L, 0L, BASSFlag.BASS_STREAM_DECODE, 0); long pos = Bass.BASS_ChannelGetLength(time); double num9 = Bass.BASS_ChannelBytes2Seconds(time, pos); TimeSpan span = TimeSpan.FromSeconds(num9); string str4 = span.Minutes.ToString() + ":" + span.Seconds.ToString().PadLeft(2, '0'); int count = BassMidi.BASS_MIDI_StreamGetEvents(time, -1, BASSMIDIEvent.MIDI_EVENT_NOTE, null); BASS_MIDI_EVENT[] events = new BASS_MIDI_EVENT[count]; BassMidi.BASS_MIDI_StreamGetEvents(time, -1, BASSMIDIEvent.MIDI_EVENT_NOTE, events); int notes = 0; for (int a = 0; a < count; a++) { if ((events[a].param & 0xff00) != 0) { notes++; } } Bass.BASS_Free(); strings = new string[] { str4, notes.ToString("N0") }; return strings; } catch (Exception ex) { string[] strings = new string[] { "N/A", "N/A" }; return strings; } }
public static void BASSStreamSystemRT(String str, Boolean PreviewMode) { try { MainWindow.KMCGlobals._recHandle = BassMidi.BASS_MIDI_StreamCreateFile(str, 0L, 0L, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT, 0); BASSCheckError(); BASS_MIDI_EVENT[] eventChunk; try { // Thank you so much Falcosoft for helping me there!!! // Visit his website: http://falcosoft.hu/index.html#start MainWindow.KMCGlobals.eventc = (UInt32)BassMidi.BASS_MIDI_StreamGetEvents(MainWindow.KMCGlobals._recHandle, -1, 0, null); // Counts all the events in the MIDI MainWindow.KMCGlobals.events = new BASS_MIDI_EVENT[MainWindow.KMCGlobals.eventc]; // Creates an array with the events count as size for (int i = 0; i <= (MainWindow.KMCGlobals.eventc / 50000000); i++) { int subCount = Math.Min(50000000, (int)MainWindow.KMCGlobals.eventc - (i * 50000000)); eventChunk = new BASS_MIDI_EVENT[subCount]; BassMidi.BASS_MIDI_StreamGetEvents(MainWindow.KMCGlobals._recHandle, -1, 0, eventChunk, i * 50000000, subCount); //Falcosoft: to avoid marshalling errors pass the smaller local buffer to the function eventChunk.CopyTo(MainWindow.KMCGlobals.events, i * 50000000); //Falcosoft: copy local buffer to global one at each iteration } eventChunk = null; } catch { BASSCloseStreamException(new MIDILoadError("This MIDI is too big for the real-time conversion process.\n\nMake sure you're using the 64-bit version of the converter.")); } Bass.BASS_StreamFree(MainWindow.KMCGlobals._recHandle); MainWindow.KMCGlobals._recHandle = BassMidi.BASS_MIDI_StreamCreate(16, BASSFlag.BASS_STREAM_DECODE | (PreviewMode ? 0 : (Properties.Settings.Default.SincInter ? BASSFlag.BASS_MIDI_SINCINTER : 0)) | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_SAMPLE_SOFTWARE, 0); BASSCheckError(); if (PreviewMode) { BASS_WASAPI_DEVICEINFO infoDW = new BASS_WASAPI_DEVICEINFO(); BassWasapi.BASS_WASAPI_Init(-1, 0, 2, BASSWASAPIInit.BASS_WASAPI_BUFFER, 0, 0, null, IntPtr.Zero); BassWasapi.BASS_WASAPI_GetDevice(); BassWasapi.BASS_WASAPI_GetDeviceInfo(BassWasapi.BASS_WASAPI_GetDevice(), infoDW); BassWasapi.BASS_WASAPI_Free(); BassWasapi.BASS_WASAPI_Init(-1, infoDW.mixfreq, 2, BASSWASAPIInit.BASS_WASAPI_SHARED, infoDW.minperiod, 0, null, IntPtr.Zero); BASSCheckError(); } BASSInitializeChanAttributes(); BASSTempoAndFilter(); if (Path.GetFileNameWithoutExtension(str).Length >= 49) { MainWindow.KMCGlobals.NewWindowName = Path.GetFileNameWithoutExtension(str).Truncate(45); } else { MainWindow.KMCGlobals.NewWindowName = Path.GetFileNameWithoutExtension(str); } MainWindow.KMCGlobals._plm = new Un4seen.Bass.Misc.DSP_PeakLevelMeter(MainWindow.KMCGlobals._recHandle, 1); MainWindow.KMCGlobals._plm.CalcRMS = true; } catch (Exception ex) { BASSCloseStreamException(ex); } }