static void YOYO(string[] args) { Console.WriteLine("teVirtualMIDI C# loopback sample"); Console.WriteLine("using dll-version: " + TeVirtualMIDI.versionString); Console.WriteLine("using driver-version: " + TeVirtualMIDI.driverVersionString); TeVirtualMIDI.logging(TeVirtualMIDI.TE_VM_LOGGING_MISC | TeVirtualMIDI.TE_VM_LOGGING_RX | TeVirtualMIDI.TE_VM_LOGGING_TX); Guid manufacturer = new Guid("aa4e075f-3504-4aab-9b06-9a4104a91cf0"); Guid product = new Guid("bb4e075f-3504-4aab-9b06-9a4104a91cf0"); port = new TeVirtualMIDI("C# loopback", 65535, TeVirtualMIDI.TE_VM_FLAGS_PARSE_RX, ref manufacturer, ref product); // alernatively: simple instantiation without any "special" stuff: // port = new TeVirtualMIDI( "C# loopback" ); Thread thread = new Thread(new ThreadStart(WorkThreadFunction)); thread.Start(); Console.WriteLine("Virtual port created - press enter to close port again"); Console.ReadKey(); port.shutdown(); Console.WriteLine("Virtual port closed - press enter to terminate application"); Console.ReadKey(); }
static void OrbitMap() { Orbit = MIDIManager.GetInputDevice("Numark ORBIT", new TranslationMap(new List<ITranslation>() { new Translation(new ChannelMessage(ChannelCommand.NoteOn, 1, 49, 1), new ChannelMessage(ChannelCommand.NoteOn, 1, 2, 1), InputMatchFunctions.NoteMatch, TranslationFunctions.DirectTranslation) })); TeVirtualMIDI.logging(TeVirtualMIDI.TE_VM_LOGGING_MISC | TeVirtualMIDI.TE_VM_LOGGING_RX | TeVirtualMIDI.TE_VM_LOGGING_TX); var manufacturer = new Guid("aa4e075f-3504-4aab-9b06-9a4104a91cf0"); var product = new Guid("bb4e075f-3504-4aab-9b06-9a4104a91cf0"); OrbitReader = new TeVirtualMIDI("MIDIator - OrbitReader", 65535, TeVirtualMIDI.TE_VM_FLAGS_PARSE_RX, ref manufacturer, ref product); Orbit.AddChannelMessageAction(new ChannelMessageAction(message => true, message => { Debug.WriteLine($"Data1:{message.Data1} | Command:{message.Command.ToString()}"); OrbitReader.sendCommand(BitConverter.GetBytes(message.Message)); })); Orbit.StartRecording(); Thread.Sleep(300000); }
static void GuitarWingMap() { var channel = 1; var guitarWing = MIDIManager.GetInputDevice("Livid Guitar Wing", new TranslationMap(new List<ITranslation>() { new Translation(new ChannelMessage(ChannelCommand.ProgramChange, channel, 0), new ChannelMessage(ChannelCommand.NoteOn, channel, 1), InputMatchFunctions.Data1Match, TranslationFunctions.PCToNote) })); TeVirtualMIDI.logging(TeVirtualMIDI.TE_VM_LOGGING_MISC | TeVirtualMIDI.TE_VM_LOGGING_RX | TeVirtualMIDI.TE_VM_LOGGING_TX); var manufacturer = new Guid("aa4e075f-3504-4aab-9b06-9a4104a91cf0"); var product = new Guid("bb4e075f-3504-4aab-9b06-9a4104a91cf0"); var guitarWingReader = new TeVirtualMIDI("MIDIator - GuitarWingReader", 65535, TeVirtualMIDI.TE_VM_FLAGS_PARSE_RX, ref manufacturer, ref product); guitarWing.AddChannelMessageAction(new ChannelMessageAction(message => true, message => { Debug.WriteLine($"Command:{message.Command.ToString()} | Data1:{message.Data1.ToString()} | Data2:{message.Data2.ToString()} | Ch:{message.MidiChannel} | MsgType:{message.MessageType}"); //OrbitReader.sendCommand(BitConverter.GetBytes(message.msg)); })); guitarWing.StartRecording(); Thread.Sleep(300000); }
public Form1() { InitializeComponent(); small = GetIcon(ShellIconSize.SmallIcon); large = GetIcon(ShellIconSize.LargeIcon); //set normal icons SendMessage(this.Handle, WM_SETICON, SHGFI_LARGEICON, small.Handle); SendMessage(this.Handle, WM_SETICON, SHGFI_SMALLICON, large.Handle); //fully hide window but at least load it this.WindowState = FormWindowState.Minimized; this.ShowInTaskbar = false; trayMenu = new ContextMenu(); trayMenu.MenuItems.Add("Exit", trayIcon_Close); trayIcon = new NotifyIcon(); trayIcon.Text = this.Text; if (SystemInformation.SmallIconSize.Width == 16 && SystemInformation.SmallIconSize.Height == 16) //get 16x16 trayIcon.Icon = new Icon(small, SystemInformation.SmallIconSize); else //just calculate from base 32x32 icon to (hopefully) look better trayIcon.Icon = new Icon(large, SystemInformation.SmallIconSize); // Add menu to tray icon and show it. trayIcon.ContextMenu = trayMenu; trayIcon.Visible = true; trayIcon.MouseClick += trayIcon_MouseClick; devInBox.DropDownStyle = ComboBoxStyle.DropDownList; devOutBox.DropDownStyle = ComboBoxStyle.DropDownList; inDevs = new List<int>(); outDevs = new List<int>(); mahPort = new TeVirtualMIDI(pString); inPort = new MidiInPort(); outPort = new MidiOutPort(); pthrough = new Thread(new ThreadStart(readInput)); config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); inPort.Successor = new MyReceiver(); this.Load += onLoad; this.FormClosed += onClosed; this.Resize += onResize; }
public static void Main() { Thread newWindowThread = new Thread(new ThreadStart(() => { // create and show the window App obj = new App(); // start the Dispatcher processing System.Windows.Threading.Dispatcher.Run(); })); newWindowThread.SetApartmentState(ApartmentState.STA); newWindowThread.IsBackground = true; newWindowThread.Start(); while (!GBL.DONE_EDITING) { System.Threading.Thread.Sleep(1000); } // Connect to LeapMotion Controller Console.WriteLine("Initializing Leap..."); var leapMotion = new Controller(); do { System.Threading.Thread.Sleep(1000); Console.WriteLine("."); } while (!leapMotion.IsConnected); Console.WriteLine("Leap ready."); // Connect to UHDK5 ultrasonic emitters Console.WriteLine("Initializing UHDK5..."); var uhdk5 = new AmplitudeModulationEmitter(); Console.WriteLine("UHDK5 ready."); Console.WriteLine("Dog Friendly Mode: " + GBL.DOG_FRIENDLY); // Connect virtual MIDI ports Console.WriteLine("Initializing virtual MIDI ports..."); MIDI.logging(MIDI.TE_VM_LOGGING_MISC | MIDI.TE_VM_LOGGING_RX | MIDI.TE_VM_LOGGING_TX); var leftManu = new Guid("aa4e075f-3504-4aab-9b06-9a4104a91cf0"); var leftProd = new Guid("bb4e075f-3504-4aab-9b06-9a4104a91cf0"); var leftMIDI = new MIDI("Air Drums Left Hand", 65535, MIDI.TE_VM_FLAGS_PARSE_RX, ref leftManu, ref leftProd); var rightManu = new Guid("cc4e075f-3504-4aab-9b06-9a4104a91cf0"); var rightProd = new Guid("dd4e075f-3504-4aab-9b06-9a4104a91cf0"); var rightMIDI = new MIDI("Air Drums Right Hand", 65535, MIDI.TE_VM_FLAGS_PARSE_RX, ref rightManu, ref rightProd); Console.WriteLine("MIDI resources ready."); // Haptics resources var hapticTargets = new List <AmplitudeModulationControlPoint>(); var hapticTimes = new List <int>(); var hapticVH = new VectorHelper(); var hapticJH = new JointsHelper(hapticVH); var haptic = new Haptic(hapticJH, uhdk5); // MIDI resources var leftComTable = new Commands(true); var leftNotes = new List <int>(); var leftTimes = new List <int>(); var leftPort = new Port(leftMIDI); var rightComTable = new Commands(false); var rightNotes = new List <int>(); var rightTimes = new List <int>(); var rightPort = new Port(rightMIDI); // Classification resources var leftVH = new VectorHelper(); var leftJH = new JointsHelper(leftVH); var leftStats = new Stats(leftJH); var leftClassify = new Classify(leftVH, leftStats); var leftQueues = new Queues(leftJH); var leftDataManager = new DataManager(leftQueues, true); var rightVH = new VectorHelper(); var rightJH = new JointsHelper(rightVH); var rightStats = new Stats(rightJH); var rightClassify = new Classify(rightVH, rightStats); var rightQueues = new Queues(rightJH); var rightDataManager = new DataManager(rightQueues, false); // Concurrency structures var leftFrameStream = new ConcurrentQueue <Frame>(); var leftCommandStream = new ConcurrentQueue <int>(); var rightFrameStream = new ConcurrentQueue <Frame>(); var rightCommandStream = new ConcurrentQueue <int>(); var hapticStream = new ConcurrentQueue <Joints>(); // Processes var data = new Proc_Data(leapMotion, leftFrameStream, rightFrameStream) as IProc; var leftGesture = new Proc_Gesture(leftClassify, leftDataManager, leftVH, leftFrameStream, leftCommandStream, hapticStream) as IProc; var leftCommand = new Proc_MIDI(leftPort, leftCommandStream, leftNotes, leftTimes, leftComTable) as IProc; var rightGesture = new Proc_Gesture(rightClassify, rightDataManager, rightVH, rightFrameStream, rightCommandStream, hapticStream) as IProc; var rightCommand = new Proc_MIDI(rightPort, rightCommandStream, rightNotes, rightTimes, rightComTable) as IProc; var haptics = new Proc_Haptics(haptic, hapticStream, hapticTargets, hapticTimes) as IProc; // Instantiate threads with looped pipelines var dataThread = new Thread(data.Loop); var leftGestureThread = new Thread(leftGesture.Loop); var rightGestureThread = new Thread(rightGesture.Loop); var leftCommandThread = new Thread(leftCommand.Loop); var rightCommandThread = new Thread(rightCommand.Loop); var hapticsThread = new Thread(haptics.Loop); // Start threads dataThread.Start(); leftGestureThread.Start(); rightGestureThread.Start(); leftCommandThread.Start(); rightCommandThread.Start(); hapticsThread.Start(); }