static void Main(string[] args) { MIDI.Load(); Dispatch.TriggerStart(); ReadCSV(@"C:\Users\admin\Desktop\Dance.csv"); Console.ReadLine(); }
private static void Receive(IAsyncResult result) { if (connection == null || result == null) { return; } IPEndPoint source = null; byte[] message = connection.EndReceive(result, ref source); connection.BeginReceive(new AsyncCallback(Receive), connection); if (source.Address.Equals(localhost)) { if (!portMap.ContainsKey(source)) { connection?.SendAsync(new byte[] { 244, Convert.ToByte((portMap[source] = MIDI.ConnectAbleton()).Name.Substring(18)) }, 2, source); } if (message[0] < 128) { NoteOnMessage msg = new NoteOnMessage(Channel.Channel1, (Key)message[0], message[1]); portMap[source].NoteOn(null, in msg); } else if (message[0] == 245) { MIDI.Disconnect(portMap[source]); portMap.Remove(source); } } }
// Use this for initialization void Start() { midi = GetComponent<MIDI>(); midi.ReadMIDIFile(midiFilePath); int trackCount = midi.tracks.Count; if(generateOnlyFromFirstTrack){ trackCount = 1; } for(int i = 0; i < trackCount; i++){ MIDITrack track = midi.tracks[i]; foreach(MIDIEvent e in track.events){ Debug.Log("type of event" + e.GetType().ToString()); if(e.GetType() != typeof(MIDINote)){ continue; } MIDINote note = (MIDINote)e; GameObject platform; if(this.platforms.Length > 0){ int idx = Random.Range(0, this.platforms.Length); platform = GameObject.Instantiate(this.platforms[idx]) as GameObject; }else{ platform = GameObject.CreatePrimitive(PrimitiveType.Cube); } Vector3 pos = new Vector3(note.absoluteStartTime, (float)note.note, 0.0f); platform.transform.position = pos; } } }
void Update() { if (!MIDISettings.instance.inputSettings.midiThrough) { MIDI.Fetch(); } ProcessMidiInMessages(); }
public MainWindow() { InitializeComponent(); KeysDown = new List <Key>(); midi = new MIDI(); midi.Open(); this.KeyDown += new KeyEventHandler(wpfKeyDown); this.KeyUp += new KeyEventHandler(wpfKeyUp); }
public Pattern loadPattern(MIDI midi) { if (midi == null) { return(new Pattern(new BeatGenerator().quarters(numQuartersCalibration), GameManager.Instance.lookAhead)); } else { return(new Pattern(midi.regularMapping(), GameManager.Instance.lookAhead)); } }
public override void ApplyPropertyValues() { Setup.ApplyPropertyValues(); InputOutput.ApplyPropertyValues(); USB.ApplyPropertyValues(); MIDI.ApplyPropertyValues(); #region DefaultMemory Track1.ApplyPropertyValues(); Track2.ApplyPropertyValues(); Track3.ApplyPropertyValues(); Track4.ApplyPropertyValues(); Track5.ApplyPropertyValues(); Rhythm.ApplyPropertyValues(); //Name.ApplyPropertyValues(); Master.ApplyPropertyValues(); RecOption.ApplyPropertyValues(); PlayOption.ApplyPropertyValues(); Assign1.ApplyPropertyValues(); Assign2.ApplyPropertyValues(); Assign3.ApplyPropertyValues(); Assign4.ApplyPropertyValues(); Assign5.ApplyPropertyValues(); Assign6.ApplyPropertyValues(); Assign7.ApplyPropertyValues(); Assign8.ApplyPropertyValues(); Assign9.ApplyPropertyValues(); Assign10.ApplyPropertyValues(); Assign11.ApplyPropertyValues(); Assign12.ApplyPropertyValues(); Assign13.ApplyPropertyValues(); Assign14.ApplyPropertyValues(); Assign15.ApplyPropertyValues(); Assign16.ApplyPropertyValues(); InputFx.ApplyPropertyValues(); TrackFx.ApplyPropertyValues(); BeatFxA.ApplyPropertyValues(); BeatFxB.ApplyPropertyValues(); BeatFxC.ApplyPropertyValues(); InputFxA.ApplyPropertyValues(); InputFxB.ApplyPropertyValues(); InputFxC.ApplyPropertyValues(); TrackFxA.ApplyPropertyValues(); TrackFxB.ApplyPropertyValues(); TrackFxC.ApplyPropertyValues(); #endregion DefaultMemory }
void Awake() { if (MIDIObject == null) { // Avoid duplication MIDIObject = GameObject.FindObjectOfType<MIDI>(); if (MIDIObject == null) { MIDIObject = new GameObject(typeof(MIDI).ToString()).AddComponent<MIDI>(); } } }
//private IEnumerator OnTriggerEnter(Collider other) private void OnTriggerEnter(Collider other) { if (hacia_abajo) { int id; int velocidad = 100; if (this.CompareTag("left_mando")) { id = 0; //velocidad = Clamp(PSMoveService.mando_left.vel_j); } else { id = 1; //velocidad = Clamp(PSMoveService.mando_right.vel_j); } switch (other.gameObject.tag) { case "snare": MIDI.SendNota(26, velocidad); break; case "ride": MIDI.SendNota(71, velocidad); break; case "hihat": MIDI.SendNota(30, velocidad); break; case "middletom": MIDI.SendNota(35, velocidad); break; case "hitom": MIDI.SendNota(38, velocidad); break; case "floortom": MIDI.SendNota(31, velocidad); break; } //PSMoveService.SetRumble(PSMoveService.Cliente, id, 0.5f); //yield return new WaitForSeconds(0.5f); //PSMoveService.SetRumble(PSMoveService.Cliente, id, 0.0f); } }
public MIDI Read(string midiPath, int format) { MIDI data = Read(midiPath); if (data.Format != format && format == 1) { return(ConvertToFormat1(data)); } else { return(data); } }
private void Unloaded(object sender, EventArgs e) { _launchpad.Window = null; Preferences.AlwaysOnTopChanged -= UpdateTopmost; if (_launchpad.GetType() == typeof(VirtualLaunchpad)) { MIDI.Disconnect(_launchpad); } _launchpad = null; }
//private IEnumerator OnTriggerEnter(Collider other) private IEnumerator OnTriggerEnter(Collider other) { int id; int velocidad = 100; if (this.CompareTag("left_mando")) { id = 0; } else { id = 1; } //velocidad = Clamp(PSMoveService.mando_right.vel_j); switch (other.gameObject.tag) { case "esferasnare": MIDI.SendNota(26, velocidad); Debug.Log("Ingrese"); Debug.Log(other.GetComponent <Renderer>().material.color); break; case "ride": MIDI.SendNota(71, velocidad); break; case "hihat": MIDI.SendNota(30, velocidad); break; case "middletom": MIDI.SendNota(35, velocidad); break; case "hitom": MIDI.SendNota(38, velocidad); break; case "floortom": MIDI.SendNota(31, velocidad); break; } PSMoveService.SetRumble(PSMoveService.Cliente, id, 0.5f); yield return(new WaitForSeconds(0.5f)); PSMoveService.SetRumble(PSMoveService.Cliente, id, 0.0f); }
void Launchpad_LockToggle() { VirtualLaunchpad lp = (VirtualLaunchpad)_launchpad; Preferences.VirtualLaunchpadsToggle(lp.VirtualIndex); bool state = Preferences.VirtualLaunchpads.Contains(lp.VirtualIndex); LockToggle.SetState(state); if (!state && lp.Window == null) { MIDI.Disconnect(lp); } }
// Use this for initialization void Start() { midi = GetComponent <MIDI>(); midi.ReadMIDIFile(midiFilePath); int trackCount = midi.tracks.Count; if (generateOnlyFromFirstTrack) { trackCount = 1; } for (int i = 0; i < trackCount; i++) { MIDITrack track = midi.tracks[i]; foreach (MIDIEvent e in track.events) { Debug.Log("type of event" + e.GetType().ToString()); if (e.GetType() != typeof(MIDINote)) { continue; } MIDINote note = (MIDINote)e; GameObject platform; if (this.platforms.Length > 0) { int idx = Random.Range(0, this.platforms.Length); platform = GameObject.Instantiate(this.platforms[idx]) as GameObject; } else { platform = GameObject.CreatePrimitive(PrimitiveType.Cube); } Vector3 pos = new Vector3(note.absoluteStartTime, (float)note.note, 0.0f); platform.transform.position = pos; } } }
void Unloaded(object sender, CancelEventArgs e) { _launchpad.Window = null; Preferences.AlwaysOnTopChanged -= UpdateTopmost; _launchpad.Info?.SetPopout(true); if (_launchpad is VirtualLaunchpad lp && !Preferences.VirtualLaunchpads.Contains(lp.VirtualIndex)) { MIDI.Disconnect(_launchpad); } _launchpad = null; foreach (IDisposable observable in observables) { observable.Dispose(); } this.Content = null; }
void onClick() { // Debug.Log (path); // GameManager.Instance.musicFile = path; // GameManager.Instance.midiFile = getAssociatedMidi (); if (isReady) { if (!local) { GameManager.Instance.currentSong = songMeta; APICacheManager.Instance.downloadAudio(songMeta.musicPath, clip => { Debug.Log("Music ready"); GameManager.Instance.currentAudio = clip; StartCoroutine(API.downloadMIDI(songMeta.midiPath, midi => { Debug.Log("MIDI ready"); GameManager.Instance.currentMidi = midi; SceneManager.LoadScene("rhythmTester"); }, e => { Debug.LogWarning("MIDI not found using default"); MIDI m = new MIDI("bike2"); GameManager.Instance.currentMidi = m; SceneManager.LoadScene("rhythmTester"); })); }); } else { GameManager.Instance.currentAudio = localSong.getAudioClip(); GameManager.Instance.currentMidi = localSong.getMIDI(); GameManager.Instance.currentSong = localSong.getSongMeta(); Messenger.Invoke(MessengerKeys.LOAD_PROGRESS); SceneManager.LoadScene("rhythmTester"); } } }
void Launchpad_Add() { LaunchpadWindow.Create(MIDI.ConnectVirtual(), this); MIDI.Update(); }
static void Receive(IAsyncResult result) { lock (locker) { if (connection == null || result == null) { return; } IPEndPoint source = null; byte[] message = connection?.EndReceive(result, ref source); connection?.BeginReceive(new AsyncCallback(Receive), connection); if (!source.Address.Equals(localhost)) { return; } if (!portMap.ContainsKey(source)) { if (message[0] == 247) { App.Args = new string[] { Encoding.UTF8.GetString(message.Skip(1).ToArray()) }; if (handlingFileOpen) { return; } handlingFileOpen = true; Dispatcher.UIThread.InvokeAsync(async() => { if (Program.Project == null) { App.Windows.OfType <SplashWindow>().First().ReadFile(App.Args[0]); } else { await Program.Project.AskClose(); } App.Args = null; handlingFileOpen = false; }); } else if (message[0] >= 242 && message[0] <= 244) { connection?.SendAsync(new byte[] { 244, Convert.ToByte((portMap[source] = MIDI.ConnectAbleton(244 - message[0])).Name.Substring(18)) }, 2, source); } } else if (message[0] < 128) { portMap[source].HandleNote(message[0], message[1]); } else if (message[0] == 245) { MIDI.Disconnect(portMap[source]); portMap.Remove(source); } else if (message[0] == 246 && Program.Project != null) { Program.Project.BPM = BitConverter.ToUInt16(message, 1); } } }
// Use this for initialization void Start() { midi = GetComponent<MIDI>(); sampler = GetComponent<MIDISampler>(); }
[STAThread] // Needed for ASIOOutput.StartDriver method static void Main(string[] args) { // Create window, GraphicsDevice, and all resources necessary for the demo. VeldridStartup.CreateWindowAndGraphicsDevice( new WindowCreateInfo(50, 50, 3600, 2000, WindowState.Normal, "Vector Engine Editor"), new GraphicsDeviceOptions(true, null, true), out _window, out _gd); _gd.MainSwapchain.SyncToVerticalBlank = false; _window.Resized += () => { _gd.MainSwapchain.Resize((uint)_window.Width, (uint)_window.Height); _controller.WindowResized(_window.Width, _window.Height); }; _cl = _gd.ResourceFactory.CreateCommandList(); _controller = new ImGuiController(_gd, _gd.MainSwapchain.Framebuffer.OutputDescription, _window.Width, _window.Height); string assetsPath = HostHelper.AssetsPath; FileLoader.Init(assetsPath); FileLoader.LoadAllComponentGroups(); if (_showEditor) { HostHelper.StopGame(true); } else { HostHelper.PlayGame(true); } // Main application loop while (_window.Exists) { GameLoop.Tick(); InputSnapshot snapshot = _window.PumpEvents(); if (!_window.Exists) { break; } foreach (var keypress in snapshot.KeyEvents) { if (keypress.Key == Key.E && keypress.Down && keypress.Modifiers == ModifierKeys.Control) { _showEditor = !_showEditor; } if (keypress.Key == Key.S && keypress.Down && keypress.Modifiers == ModifierKeys.Control) { HostHelper.SaveScene(); } if (keypress.Key == Key.D && keypress.Down && keypress.Modifiers == ModifierKeys.Control) { HostHelper.Duplicate(); } } if (_showEditor) { if (EditorCamera == null) { foreach (var component in EntityAdmin.Instance.Components) { if (component.Entity.Name == EmptyScene.EDITOR_CAM_ENTITY_NAME) { EditorCamera = component.Entity; break; } } } if (midi == null) { midi = new MIDI(); midi.SetupWatchersAndPorts(); while (!midi.SetupComplete) { Thread.Sleep(1); } } IMidiMessage midiMessage; while (midi.MidiMessageQueue.TryDequeue(out midiMessage)) { MidiState.UpdateState(midiMessage); } // TODO: figure out why LastFrameTime makes ImGui run stupid fast... (for things like key repeats) _controller.Update(GameTime.LastFrameTime / 10f, snapshot); // Feed the input events to our ImGui controller, which passes them through to ImGui. EditorUI.SubmitUI(EntityAdmin.Instance); _cl.Begin(); _cl.SetFramebuffer(_gd.MainSwapchain.Framebuffer); _cl.ClearColorTarget(0, new RgbaFloat(ClearColor.X, ClearColor.Y, ClearColor.Z, 1f)); _controller.Render(_gd, _cl); _cl.End(); _gd.SubmitCommands(_cl); _gd.SwapBuffers(_gd.MainSwapchain); } } if (!HostHelper.PlayingGame) { HostHelper.SaveScene(); } // Clean up Veldrid resources _gd.WaitForIdle(); _controller.Dispose(); _cl.Dispose(); _gd.Dispose(); }
public void Refresh() { MIDI.RefreshMidiIO(); Init(); }
private MIDI ConvertToFormat1(MIDI src) { try { Track srcTrack = src.TrackList[0]; var newTracks = new List <Track>(); int cnt = 0; // event counter var eventlist = new LinkedList <Event>(); uint deltaTime = 0; // Create Conductor track foreach (Event ev in srcTrack.EventList) { deltaTime += ev.DeltaTime; if (ev is MetaEvent) { MetaEvent modEv; if (ev is SetTempo) { var st = (SetTempo)ev; modEv = new SetTempo(deltaTime, st.Value); } else if (ev is TimeSignature) { var ts = (TimeSignature)ev; modEv = new TimeSignature(deltaTime, ts.Numerator, ts.DenominatorBitShift, ts.MIDIClockPerMetronomeTick, ts.NumberOfNotesPerClocks); } else if (ev is KeySignature) { var ks = (KeySignature)ev; modEv = new KeySignature(deltaTime, ks.SignatureNumber, ks.MinorFlagNumber); } else if (ev is SequenceTrackName) { var stn = (SequenceTrackName)ev; modEv = new SequenceTrackName(deltaTime, stn.Name); } else if (ev is EndOfTrack) { modEv = new EndOfTrack(deltaTime); } else { modEv = new MetaEvent(deltaTime); } eventlist.AddLast(modEv); deltaTime = 0; if (!(ev is EndOfTrack)) { cnt++; } } } newTracks.Add(new Track(eventlist)); eventlist = new LinkedList <Event>(); deltaTime = 0; // Create System Setup track foreach (Event ev in srcTrack.EventList) { deltaTime += ev.DeltaTime; if (ev is SysExEvent) { eventlist.AddLast(new SysExEvent(deltaTime)); deltaTime = 0; cnt++; } else if (ev is EndOfTrack) { eventlist.AddLast(new EndOfTrack(deltaTime)); } } newTracks.Add(new Track(eventlist)); // Create Notes track for (int ch = 0; cnt + 1 < srcTrack.EventList.Count; ch++) { eventlist = new LinkedList <Event>(); deltaTime = 0; foreach (Event ev in srcTrack.EventList) { deltaTime += ev.DeltaTime; if (ev is MIDIEvent) { var midiEv = (MIDIEvent)ev; if (midiEv.Channel == ch) { MIDIEvent modEv; if (midiEv is NoteOn) { var nton = (NoteOn)midiEv; modEv = new NoteOn(deltaTime, nton.Channel, nton.Number, nton.Velocity); } else if (midiEv is NoteOff) { var ntoff = (NoteOff)midiEv; modEv = new NoteOff(deltaTime, ntoff.Channel, ntoff.Number, ntoff.Velocity); } else if (midiEv is ProgramChange) { var pc = (ProgramChange)midiEv; modEv = new ProgramChange(deltaTime, pc.Channel, pc.Number); } else if (midiEv is Volume) { var vol = (Volume)midiEv; modEv = new Volume(deltaTime, vol.Channel, vol.Value); } else if (midiEv is Pan) { var pan = (Pan)midiEv; modEv = new Pan(deltaTime, pan.Channel, pan.Value); } else if (midiEv is ControlChange) { var cc = (ControlChange)midiEv; modEv = new ControlChange(deltaTime, cc.Channel, cc.Value); } else { modEv = new MIDIEvent(deltaTime, midiEv.Channel); } eventlist.AddLast(modEv); deltaTime = 0; cnt++; } } else if (ev is EndOfTrack) { eventlist.AddLast(new EndOfTrack(deltaTime)); } } newTracks.Add(new Track(eventlist)); } return(new MIDI(newTracks, 1, newTracks.Count, src.TimeDivision)); } catch (Exception ex) { throw new Exception(Resources.ErrorMIDIFormat1, ex); } }
void monitoringMap_MessageReceived(object sender, MIDI.MidiMessage message, int channel, int key, int value) { if (monitoringMap != null) { ControlMap map = monitoringMap.FindMap(channel, key); if (map != null) { MethodInvoker doIt = delegate { foreach (ListViewItem item in MapsView.Items) { ControlBinding cb = item.Tag as ControlBinding; if (cb != null) { if (cb.Parent == map) { item.Selected = true; MapsView.EnsureVisible(item.Index); break; } } } }; if (this.InvokeRequired) { try { this.Invoke(doIt); } catch { } } else { doIt(); } } } }
// Use this for initialization void Start() { midi = GetComponent <MIDI>(); sampler = GetComponent <MIDISampler>(); }
// Use this for initialization void Start() { MIDI midi = new MIDI("bicycle-ride"); midi.dumbMapping(); }
private void OnTriggerStay(Collider other) { MIDI.OffNota(); }