|
||
Title: Midi-OX com and c# Post by yigiman on Nov 15th, 2003, 10:54am Hi, does anybody know how I can use Scripting from c#. I add the library as a reference, and I can create an instence of the MoxScriptClass. But the constructor does not accept any parmeters so I have no idea how to initialize my object, or if it's even the correct object. Please help. ??? |
||
Title: Re: Midi-OX com and c# Post by cmerziotis on Nov 29th, 2003, 4:19pm I came here to ask the same question but later on I found the answer myself. Here is the code for a simple program that opens an empty window: If you click your mouse on it it plays a note. If you play something it transposes it by semitones. Of course you have to add the com assembly to your references first. I guess you can figure it out from here. **************************************** using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace WindowsApplication2 { /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; MIDIOXLib.MoxScriptClass t = new MIDIOXLib.MoxScriptClass(); public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); t.MidiInput += new MIDIOXLib._IMoxScriptEvents_MidiInputEventHandler(this.MidiIn); t.FireMidiInput=1; t.DivertMidiInput=1; // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 266); this.Name = "Form1"; this.Text = "Costis"; this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown); } #endregion /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { t.OutputMidiMsg(-1, 144, 78, 127); } private void MidiIn(int ts,int port, int stat,int dat1,int dat2) { t.OutputMidiMsg(-1, stat, dat1+10, dat2); } } } |
||
MIDI-OX User Forum » Powered by YaBB 1 Gold - SP 1.3.1! YaBB © 2000-2003. All Rights Reserved. |