Click here to Skip to main content
15,894,362 members
Articles / Programming Languages / C#

ProjectMIDI: an extensible set of small MIDI .NET programs

Rate me:
Please Sign up or sign in to vote.
4.70/5 (14 votes)
24 Jan 200626 min read 85.4K   3.4K   57  
This article describes how multiple .NET assemblies work together to control MIDI devices in a live performance environment.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace TD8NS
{
	/// <summary>
	/// Summary description for TD8CopyTemplate.
	/// </summary>
	public class TD8CopyTemplate : System.Windows.Forms.Form
	{
		private System.Windows.Forms.ListBox templatesListBox;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button cancelButton;
		private System.Windows.Forms.Button okButton;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		private TD8 td8;
		private int kitNum = 0;
		private int padNum = 0;
		private string[] templates = {
			"VCustom",		// 20
			"TR808",
			"JazzFunk",
			"HardRock",
			"Birch",
			"RoseWood",
			"Oyster",
			"Sizzle",
			"Pocket",
			"Gospel",
			"PowrFusn",	// 30
			"HomeBoy",
			"JazzXstk",
			"Fat-So",
			"Science!",
			"Buzz",
			"Kids",
			"JunkYard",
			"Fusion",
			"Crack!",
			"MIDIbrsh",	// 40
			"RockBand",
			"Tekno",
			"Ringer",
			"Brushes",
			"Congakit",
			"Electro",
			"Mondo",
			"Timbongo",
			"Mexi-Mix",
			"LiteFunk",	// 50
			"Metal",
			"BrikHous",
			"LowFi",
			"CoprTubs",
			"Hi&Loose",
			"Lo&Loose",
			"LatnSqnc",
			"Syn&Bass",
			"Standrd1",
			"Standrd2",	// 60
			"Room",
			"Power",
			"Jazz",
			"Pop X-stk (default)"
		};

		#region Properties
		public int PadNum 
		{
			get { return padNum; }
			set { padNum = value; }
		}
		public int KitNum
		{
			get { return kitNum; }
			set { kitNum = value; }
		}
		public TD8 Td8
		{
			get { return td8; }
			set { td8 = value; }
		}
		#endregion

		public TD8CopyTemplate()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// 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()
		{
			this.templatesListBox = new System.Windows.Forms.ListBox();
			this.label1 = new System.Windows.Forms.Label();
			this.cancelButton = new System.Windows.Forms.Button();
			this.okButton = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// templatesListBox
			// 
			this.templatesListBox.Location = new System.Drawing.Point(8, 32);
			this.templatesListBox.Name = "templatesListBox";
			this.templatesListBox.Size = new System.Drawing.Size(272, 199);
			this.templatesListBox.TabIndex = 0;
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(272, 16);
			this.label1.TabIndex = 1;
			this.label1.Text = "Select the template to copy from:";
			// 
			// cancelButton
			// 
			this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.cancelButton.Location = new System.Drawing.Point(208, 240);
			this.cancelButton.Name = "cancelButton";
			this.cancelButton.TabIndex = 2;
			this.cancelButton.Text = "Cancel";
			// 
			// okButton
			// 
			this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.okButton.Location = new System.Drawing.Point(128, 240);
			this.okButton.Name = "okButton";
			this.okButton.TabIndex = 3;
			this.okButton.Text = "OK";
			this.okButton.Click += new System.EventHandler(this.okButton_Click);
			// 
			// TD8CopyTemplate
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 266);
			this.Controls.Add(this.okButton);
			this.Controls.Add(this.cancelButton);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.templatesListBox);
			this.Name = "TD8CopyTemplate";
			this.Text = "Copy From Template";
			this.Load += new System.EventHandler(this.TD8CopyTemplate_Load);
			this.ResumeLayout(false);

		}
		#endregion

		// FORM LOAD
		private void TD8CopyTemplate_Load(object sender, System.EventArgs e)
		{
			// Fill the template list box
			foreach(string str in templates)
			{
				templatesListBox.Items.Add( str );
			}
		}

		// OK Pressed, copy the kit and download it to the TD8
		private void okButton_Click(object sender, System.EventArgs e)
		{
			int sel = templatesListBox.SelectedIndex;
			if(sel >= 0)
			{
				td8.CopyKit(td8.kits[kitNum],td8.kits[sel+20]);
				td8.SendKitToTD8(kitNum);
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United States United States
Ron is a senior software engineer.
His hobbies include riding motorcycles, travel, and scuba diving.

He enjoys learning about science, particularly quantum physics and cosmology.

He is active with his church where he plays drums and keyboards with the contemporary church band each week.
He also designed and maintains his church and band websites (http://TheRockUMC.org and http://TheRockBand.org).

Comments and Discussions