User Forum    :: Powered by YaBB
  « MIDI-OX User Forum - Midi-OX com and c# »
Welcome, Guest. Please Login or Register.
May 9th, 2025, 8:56am


Home Home Help Help Search Search Members Members Login Login Register Register


   MIDI-OX User Forum
   MIDI-OX
   Scripting Questions
(Moderator: Jamie OConnell)
   Midi-OX com and c#
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Midi-OX com and c#  (Read 3026 times)
yigiman
New Member
*



MIDI-OX Rules!

   
Email

Posts: 1
Midi-OX com and c#
« on: Nov 15th, 2003, 10:54am »
Quote Quote Modify Modify

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.
 Huh
IP Logged
cmerziotis
New Member
*



MIDI-OX Rules!

   


Posts: 1
Re: Midi-OX com and c#
« Reply #1 on: Nov 29th, 2003, 4:19pm »
Quote Quote Modify Modify

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);
 
  }
 }
}
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »


MIDI-OX User Forum » Powered by YaBB 1 Gold - SP 1.3.1!
YaBB © 2000-2003. All Rights Reserved.