Help guys, I have a List of Points List points = new List(); , what I'm trying to do is removing some data from the list. I used a listbox to see whether it works. This is my code:
points.Add(new PointF(50, 100));
points.Add(new PointF(50, 100));
points.Add(new PointF(200, 300));
points.Add(new PointF(100, 200 ));
points.Add(new PointF(50, 100));
points.Add(new PointF(100, 200));
points.Add(new PointF(200, 300));
points.Add(new PointF(100, 200));
points.Add(new PointF(200, 300));
listBox1.DataSource = points;
float[] sumofxandy = new float[points.Count()];
for (int x = 0; x < points.Count(); x++)
{
sumofxandy[x] = points.ElementAt(x).X + points.ElementAt(x).Y;
}
//code that removes data from list starts from here
float[] difference = new float[points.Count()]; //there is something wrong with this and I don't know what. It has no error but it doesn't make my list to be shown in the listbox.
for (int i = 0; i <= points.Count(); i++)
{
for (int j = 1; j <= points.Count(); j++)
{
difference[j] = sumofxandy[i] - sumofxandy[j];
if (difference[i] == 0)
{
points.RemoveAt(j);
MessageBox.Show("removed");
}
}
} // ends here
listBox2.DataSource = points;
When I erased the code that removes data from the list, the elements inside the list will be shown in the listbox. Help guys
Try changing your for loops as follows (from <= to <). I think you are getting a hidden IndexOutOfBoundsException.
for (int i = 0; i < points.Count(); i++)
{
for (int j = 1; j < points.Count(); j++)
Notice that you are modifying the very same list you are iterating over. This may just as easy remove all the points. You should better create a new list for points that should be removed:
//code that removes data from list starts from here
List<PointF> pointsToRemove = new List<PointF>();
float[] difference = new float[points.Count()];
for (int i = 0; i <= points.Count(); i++)
{
for (int j = 1; j <= points.Count(); j++)
{
difference[j] = sumofxandy[i] - sumofxandy[j];
if (difference[i] != 0)
{
pointsToRemove.Add(points[j]);
MessageBox.Show("removed");
}
}
}
listBox2.DataSource = points.Except(pointsToRemove).ToList();
Could it be that you are using the wrong variable in the if(difference[i] == 0)?
When using your solution I get an ArgumentOutOfRangeException on the line points.RemoveAt(j);
difference[j] = sumofxandy[i] - sumofxandy[j];
if (difference[i] == 0)
{
points.RemoveAt(j);
MessageBox.Show("removed");
}
When the line if(difference[i] == 0) are changed to:
if(difference[j] == 0)
then the code executes successful, with 3 items in listbox2.
EDIT:
As #wdosanjos mentions, you should do your loops with a < rather than <= since you start counting at zero, and not 1. The last element is really at position Count - 1, since the list are zero indexed.
EDIT:
When I changed the loops to: (notice the change in <= to <, it does not throw an exception.)
for (int i = 0; i < points.Count(); i++)
{
for (int j = 1; j < points.Count(); j++)
{
difference[j] = sumofxandy[i] - sumofxandy[j];
if (difference[i] == 0)
{
points.RemoveAt(j);
MessageBox.Show("removed");
}
}
} // ends here
This returns two elements.
Related
Long time lurker on this website, because I always find my answer without having to post... I cannot tell what I'm doing in this case... does someone mind to take a look and help with what I am missing?
I downloaded a linear algebra class library (CSML) that I am trying to use. I'm trying to store individual values to a Matrix class. I get the error: Cannot implicitly convert type 'double' to 'CSML.Complex'.
I've tried many different ways to initiate the Matrix and add the array:
Matrix A = new Matrix(B);
Matrix A = new Matrix(double[,] B);
I have even tried to use a for loop to add the values individually:
Matrix A = new Matrix(new double[TotalARows,TotalACols]);
for (int i = 0; i < TotalARows; i++) {
for (int j = 0; j < TotalACols; j++) {
A[i,j] = B[i,j];
}
}
Here is the code in the DLL for the creation of the Matrix Class with double[,] input
public Matrix(double[,] values)
{
if (values == null)
{
Values = new ArrayList();
columnCount = 0;
rowCount = 0;
}
rowCount = (int)values.GetLongLength(0);
columnCount = (int)values.GetLongLength(1);
Values = new ArrayList(rowCount);
for (int i = 0; i < rowCount; i++)
{
Values.Add(new ArrayList(columnCount));
for (int j = 0; j < columnCount; j++)
{
((ArrayList)Values[i]).Add(new Complex(values[i, j]));
}
}
}
Here is the 'get' 'set' of Class Complex.
public virtual Complex this[int i, int j]
{
set
{
if (i <= 0 || j <= 0)
throw new ArgumentOutOfRangeException("Indices must be real positive.");
if (i > rowCount)
{
// dynamically add i-Rows new rows...
for (int k = 0; k < i - rowCount; k++)
{
this.Values.Add(new ArrayList(columnCount));
// ...with Cols columns
for (int t = 0; t < columnCount; t++)
{
((ArrayList)Values[rowCount + k]).Add(Complex.Zero);
}
}
rowCount = i; // ha!
}
if (j > columnCount)
{
// dynamically add j-Cols columns to each row
for (int k = 0; k < rowCount; k++)
{
for (int t = 0; t < j - columnCount; t++)
{
((ArrayList)Values[k]).Add(Complex.Zero);
}
}
columnCount = j;
}
((ArrayList)Values[i - 1])[j - 1] = value;
//this.Values[i - 1, j - 1] = value;
}
get
{
if (i > 0 && i <= rowCount && j > 0 && j <= columnCount)
{
return (Complex)(((ArrayList)Values[i - 1])[j - 1]);
}
else
throw new ArgumentOutOfRangeException("Indices must not exceed size of matrix.");
}
}```
The Complex class doesn't contain an implicit conversion from double. If you want to get an instance of Complex, you need to call new Complex(_your_double_here_). You can initialize a matrix with a double array, and it will perform the conversion for you in the constructor:
var array = new double[,] {
{1,1,1,1},
{1,2,3,4},
{4,3,2,1}
};
var matrix = new Matrix(array);
// Complex has a constructor which a single 'real' value as a double
matrix[1, 2] = new Complex(3);
// It also has a constructor which a 'real' value and an 'imaginary' value
matrix[1, 2] = new Complex(3, 4);
But again, this library hasn't been updated since 2007 and will teach you some bad and obsolete practices. Have a look at Math.Net, it is up to date and has great documentation
I'm developing an app will be used for calculating matrixes and I'm currently working on minor function and I need a minor matrix for that. So, I wrote the code shown below. It actually works without any error but there is an issue about 4x4 matrices. It changes the 4x1 and 4x2 values.
In this image, places of 9 and 10 are wrong. They are at each others place.
enter image description here
Note: There isn't any problem about textboxes, it's about the array (matrix).
Here is my code. I could easily solve it by rechanging them with a few lines of code but I'm trying to learn C# and Visual Studio, so I want to find the problem in my algorithm.
minorMatrix = new int[rowA.Value - 1, colA.Value - 1];
int k = 0, l = 0;
for (int i = 0; i < rowA.Value - 1; i++)
{
for (int j = 0; j < colA.Value - 1; j++)
{
if (i < row - 1)
{
k = i;
}
else
{
k = i + 1;
}
if (j < col - 1)
{
l = j;
}
else
{
l = j + 1;
}
minorMatrix[i, j] = matrixA[k, l];
}
}
Are you trying to remove the ith row and jth column? This should do it:
int[,] A = new int[3, 3]; // Original matrix
int[,] M = new int[2, 2]; // Matrix with ith row and jth column removed
int i = 2, j = 1; // 3rd row, 2nd column to remove
for (int Mi = 0; Mi < A.GetLength(0); Mi++)
for (int Mj = 0; Mj < A.GetLength(1); Mj++)
{
int Ai = Mi, Aj = Mj;
if (Mi >= i)
Ai = Mi + 1;
if (Mj >= j)
Aj = Mj + 1;
M[Mi, Mj] = A[Ai, Aj];
}
private Button[,] arrButton = new Button[10, 10];
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
arrButton[i, j] = new Button();//getting System.IndexOutOfRangeException
arrButton[i, j].Size = new Size(30, 30);
arrButton[i, j].Location = new Point(i * 30, j * 30);
arrButton[i, j].Click += new EventHandler(arrButton_Click);
this.Controls.Add(arrButton[i, j]);
}
}
this.ClientSize = new Size(300, 300);
After create, array button come up top left corner on form.
how to get array button to a place on form
#choz comment is correct, but a couple things to also consider.
Put the row value and column value in constant variables and use the variables, instead of directly using a number repeatedly.
Example:
private const ROW = 10;
private const COL = 10;
private Button[,] arrButton = new Button[ROW, COL];
...
for (int i = 0; i < ROW; i++)
{
// Change from your code -|
// |----------
// V
for (int j = 0; j < COL; j++)
{
// Create your buttons
}
}
If you are going to use constant numerals, then reference the GetUpperBound() from your array to know the last index value of each dimension.
Example:
private Button[,] arrButton = new Button[10, 10];
...
// GetUpperBound(0) = last index of rows (9 in this case)
for (int i = 0; i <= arrButton.GetUpperBound(0); i++)
{
// Change from your code -|
// |----------
// V GetUpperBound(1) = last index of columns (9 in this case)
for (int j = 0; j <= arrButton.GetUpperBound(1); j++)
{
// Create your buttons
}
}
Syntax error! Your second loop should be:
for (int j = 0; j < 10; j++)
You put "i" instead of "j",
Normally, when you get an System.IndexOutOfRangeException. The debugger error is telling you that the loop or loops you are using are counting the elements more than you specific. Check The count of elements you tinkering with.
I think you are making a mistake in inner loop. Can you please paste this and try to run:
private Button[,] arrButton = new Button[10, 10];
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)//Changed i to j
{
arrButton[i, j] = new Button();
arrButton[i, j].Size = new Size(30, 30);
arrButton[i, j].Location = new Point(i * 30, j * 30);
arrButton[i, j].Click += new EventHandler(arrButton_Click);
this.Controls.Add(arrButton[i, j]);
}
}
this.ClientSize = new Size(300, 300);
Objectives
Imagine that, we have matrix like
a11 a12 a13
a21 a22 a23
a31 a32 a33
What I want to do is, from textbox value rotate this matrix so that, for example if I write 2 and press rotate, program must keep both diagonal values of matrix (in this case a11, a22, a33, a13, a31) and rotate 2 times clockwise other values. So result must be like
a11 a32 a13
a23 a22 a21
a31 a12 a33
It must work for all N x N size matrices, and as you see every 4 rotation takes matrix into default state.
What I've done
So idea is like that, I have 2 forms. First takes size of matrix (1 value, for example if it's 5, it generates 5x5 matrix). When I press OK it generates second forms textbox matrix like that
Form 1 code
private void button1_Click(object sender, EventArgs e)
{
int matrixSize;
matrixSize = int.Parse(textBox1.Text);
Form2 form2 = new Form2(matrixSize);
form2.Width = matrixSize * 50 + 100;
form2.Height = matrixSize *60 + 200;
form2.Show();
//this.Hide();
}
Form 2 code generates textbox matrix from given value and puts random values into this fields
public Form2(int matrSize)
{
int counter = 0;
InitializeComponent();
TextBox[] MatrixNodes = new TextBox[matrSize*matrSize];
Random r = new Random();
for (int i = 1; i <= matrSize; i++)
{
for (int j = 1; j <= matrSize; j++)
{
var tb = new TextBox();
int num = r.Next(1, 1000);
MatrixNodes[counter] = tb;
tb.Name = string.Format("Node_{0}{1}", i, j);
Debug.Write(string.Format("Node_{0}{1}", i, j));
tb.Text = num.ToString();
tb.Location = new Point(j * 50, i * 50);
tb.Width = 30;
tb.Visible = true;
this.splitContainer1.Panel2.Controls.Add(tb);
counter++;
}
}
}
Form 2 has 1 textbox for controlling rotation (others are generated on the fly, programmatically). What I want to do is, when I enter rotation count and press Enter on this textbox, I want to rotate textbox matrix as I explained above. Can't figure out how to do it.
Copy both diagonals to separate arrays, then rotate your matrix and replace diagonals. Below code shows each step:
class Program
{
static void Main(string[] args)
{
int matrixSize = 3;
string[,] matrix = new string[matrixSize,matrixSize];
//create square matrix
for (int x = 0; x < matrixSize; x++)
{
for (int y = 0; y < matrixSize; y++)
{
matrix[x, y] = "a" + (x + 1).ToString() + (y + 1).ToString();
}
}
Console.WriteLine(Environment.NewLine + "Base square matrix");
for (int x = 0; x < matrixSize; x++)
{
for (int y = 0; y < matrixSize; y++)
{
Console.Write(matrix[x, y] + " ");
}
Console.Write(Environment.NewLine);
}
Console.ReadKey();
//copy diagonals
string[] leftDiagonal = new string[matrixSize];
string[] rightDiagonal = new string[matrixSize];
for (int x = 0; x < matrixSize; x++)
{
leftDiagonal[x] = matrix[x, x];
rightDiagonal[x] = matrix[matrixSize - 1 - x, x];
}
Console.WriteLine(Environment.NewLine + "Diagonals");
for (int x = 0; x < matrixSize; ++x)
{
Console.Write(leftDiagonal[x] + " " + rightDiagonal[x] + Environment.NewLine);
}
Console.ReadKey();
//rotate matrix
string[,] rotatedMatrix = new string[matrixSize, matrixSize];
for (int x = 0; x < matrixSize; x++)
{
for (int y = 0; y < matrixSize; y++)
{
rotatedMatrix[x, y] = matrix[matrixSize - y - 1, x];
}
}
Console.WriteLine(Environment.NewLine + "Rotated");
for (int x = 0; x < matrixSize; x++)
{
for (int y = 0; y < matrixSize; y++)
{
Console.Write(rotatedMatrix[x, y] + " ");
}
Console.Write(Environment.NewLine);
}
Console.ReadKey();
//rotate matrix again
string[,] rotatedMatrixAgain = new string[matrixSize, matrixSize];
for (int x = 0; x < matrixSize; x++)
{
for (int y = 0; y < matrixSize; y++)
{
rotatedMatrixAgain[x, y] = rotatedMatrix[matrixSize - y - 1, x];
}
}
Console.WriteLine(Environment.NewLine + "Rotated again");
for (int x = 0; x < matrixSize; x++)
{
for (int y = 0; y < matrixSize; y++)
{
Console.Write(rotatedMatrixAgain[x, y] + " ");
}
Console.Write(Environment.NewLine);
}
Console.ReadKey();
//replace diagonals
for (int x = 0; x < matrixSize; x++)
{
rotatedMatrixAgain[x, x] = leftDiagonal[x];
rotatedMatrixAgain[matrixSize - 1 - x, x] = rightDiagonal[x];
}
Console.WriteLine(Environment.NewLine + "Completed" + Environment.NewLine);
for (int x = 0; x < matrixSize; x++)
{
for (int y = 0; y < matrixSize; y++)
{
Console.Write(rotatedMatrixAgain[x, y] + " ");
}
Console.Write(Environment.NewLine);
}
Console.ReadKey();
}
}
I don't know C#, so I can only give a suggestion in pseudocode:
Input: An N by N matrix in
Output: The input matrix rotated as described in the OP out
for i = 1 to N
for j = 1 to N
if N - j != i and i != j // Do not change values on either diagonal
out[j][N-i] = in[i][j]
else
out[i][j] = in[i][j]
Disclaimer: This algorithm is untested. I suggest you use a debugger to check that it works as you want.
This seems like quite an unorthodox UI presentation, but you're not too far off in terms of being able to achieve your functionality. Instead of a linear array, a rectangular array will make your job much easier. The actual rotation could be implemented with a for loop repeating a single rotation (which would be implemented as in the case 1 code), but I've decided to combine them into the four possible cases. This actually allows you to enter a negative number for number of rotations. Which reminds me, you really should do more error checking. At least protect against int.Parse throwing an exception both places it's used (with a try catch block or by switching to int.TryParse) and make sure it returns a meaningful number (greater than 0, possibly set a reasonable maximum other than int.MaxValue) for matrixSize in button1_Click.
namespace RotatingMatrices
{
public class Form2 : Form
{
// note these class fields
private TextBox[,] matrixNodes;
private int matrixSize;
public Form2(int matrSize)
{
InitializeComponent();
// note these inits
matrixSize = matrSize;
matrixNodes = new TextBox[matrixSize, matrixSize];
Random r = new Random();
// note the new loop limits
for (int i = 0; i < matrixSize; i++)
{
for (int j = 0; j < matrixSize; j++)
{
var tb = new TextBox();
int num = r.Next(1, 1000);
// note the change in indexing
matrixNodes[i,j] = tb;
tb.Name = string.Format("Node_{0}_{1}", i, j);
Debug.Write(string.Format("Node_{0}_{1}", i, j));
tb.Text = num.ToString();
tb.Location = new Point(j * 50, i * 50);
tb.Width = 30;
tb.Visible = true;
this.splitContainer1.Panel2.Controls.Add(tb);
}
}
}
private void buttonRotate_Click(object sender, EventArgs e)
{
string[,] matrix = new string[matrixSize, matrixSize];
int rotations = (4 + int.Parse(textBoxRotations.Text)) % 4; // note the addition of and mod by 4
switch(rotations)
{
case 1: // rotate clockwise
for (int i = 0; i < matrixSize; i++)
{
for (int j = 0; j < matrixSize; j++)
{
matrix[j, matrixSize - i - 1] = matrixNodes[i, j].Text;
}
}
break;
case 2: // rotate 180 degrees
for (int i = 0; i < matrixSize; i++)
{
for (int j = 0; j < matrixSize; j++)
{
matrix[i, j] = matrixNodes[matrixSize - i - 1, matrixSize - j - 1].Text;
}
}
break;
case 3: // rotate counter-clockwise
for (int i = 0; i < matrixSize; i++)
{
for (int j = 0; j < matrixSize; j++)
{
matrix[i, j] = matrixNodes[j, matrixSize - i - 1].Text;
}
}
break;
default: // do nothing
return;
}
// restore diagonals
for(int i = 0; i < matrixSize; i++)
{
matrix[i, i] = matrixNodes[i, i].Text;
matrix[i, matrixSize - i - 1] = matrixNodes[i, matrixSize - i - 1].Text;
}
// write strings back to text boxes
for (int i = 0; i < matrixSize; i++)
{
for (int j = 0; j < matrixSize; j++)
{
matrixNodes[i, j].Text = matrix[i, j];
}
}
}
}
}
I decided to tackle the issue using a listView instead of a text box, which makes the logic easier for me. Using this method, I was able to think of the matrix as successive boxes. I start on the outside and move in toward the middle, changing the size of my box each time.
Also, rather than using two forms, I use one. At the top I have a textbox where the user enters the size they want the array to be, and a button labeled "Fill" (button2). And at the bottom I have a textbox where the user enters the degree of rotation. When they click "Rotate," it kicks off a process of adding values to linked lists, combining and shifting the list, and then writing back out to the matrix. I'm sure I made it more convoluted than it has to be, but it was a great learning exercise.
After looking over jerry's code above, I think I'm going to look into rectangular arrays. :)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Recycle
{
public partial class Form1 : Form
{
public int size;
public LinkedList<string> topRight = new LinkedList<string>();
public LinkedList<string> bottomLeft = new LinkedList<string>();
public LinkedList<string> myMatrix = new LinkedList<string>();
public LinkedList<string> shiftMatrix = new LinkedList<string>();
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
listView1.Clear();
size = int.Parse(textBox2.Text);
int c = 0;
int q = 0;
int w = 0;
string[] content = new string[size];
Random rnd = new Random();
for (c = 0; c < size; c++)
{
listView1.Columns.Add("", 25);
}
for (q = 0; q < size; q++)
{
for (w = 0; w < size; w++)
{
content[w] = rnd.Next(9,100).ToString();
}
ListViewItem lvi = new ListViewItem(content);
listView1.Items.Add(lvi);
}
}
public bool iseven(int size)
{
if (size % 2 == 0)
{
return true;
}
else
{
return false;
}
}
public void button1_Click(object sender, EventArgs e)
{
if (listView1.Items.Count < 3)
{
MessageBox.Show("Matrix cannot be rotated.");
return;
}
bool even = false;
int shift = int.Parse(textBox1.Text); //amount to shift by
int box = listView1.Items.Count - 1; //size of box
int half = Convert.ToInt32(listView1.Items.Count / 2);
int corner = 0; //inside corner of box
if (shift > listView1.Items.Count)
{
shift = shift % ((listView1.Items.Count - 2) * 4);
}
do
{
eachPass(shift, box, corner);
++corner;
--box;
} while (box >= half + 1);
}
public void eachPass(int shift, int box, int corner)
{
int x;
int i;
//Read each non-diagonal value into one of two lists
for (x = corner + 1; x < box; x++)
{
topRight.AddLast(listView1.Items[corner].SubItems[x].Text);
}
x = box;
for (i = corner + 1; i < box; i++)
{
topRight.AddLast(listView1.Items[i].SubItems[x].Text);
}
for (x = box - 1; x > corner; x--)
{
bottomLeft.AddLast(listView1.Items[box].SubItems[x].Text);
}
x = corner;
for (i = box - 1; i > corner; i--)
{
bottomLeft.AddLast(listView1.Items[i].SubItems[x].Text);
}
string myTest = "";
//join the two lists, so they can be shifted
foreach (string tR in topRight)
{
myMatrix.AddLast(tR);
}
foreach (string bL in bottomLeft)
{
myMatrix.AddLast(bL);
}
int sh;
//shift the list using another list
for (sh = shift; sh < myMatrix.Count; sh++)
{
shiftMatrix.AddLast(myMatrix.ElementAt(sh));
}
for (sh = 0; sh < shift; sh++)
{
shiftMatrix.AddLast(myMatrix.ElementAt(sh));
}
//we need the sizes of the current lists
int trCnt = topRight.Count;
int blCnt = bottomLeft.Count;
//clear them for reuse
topRight.Clear();
bottomLeft.Clear();
int s;
//put the shifted values back
for (s = 0; s < trCnt; s++)
{
topRight.AddLast(shiftMatrix.ElementAt(s));
}
for (s = blCnt; s < shiftMatrix.Count; s++)
{
bottomLeft.AddLast(shiftMatrix.ElementAt(s));
}
int tRn = 0;
int bLn = 0;
//write each non-diagonal value from one of two lists
for (x = corner + 1; x < box; x++)
{
listView1.Items[corner].SubItems[x].Text = topRight.ElementAt(tRn);
++tRn;
}
x = box;
for (i = corner + 1; i < box; i++)
{
listView1.Items[i].SubItems[x].Text = topRight.ElementAt(tRn);
++tRn;
}
for (x = box - 1; x > corner; x--)
{
listView1.Items[box].SubItems[x].Text = bottomLeft.ElementAt(bLn);
++bLn;
}
x = corner;
for (i = box - 1; i > corner; i--)
{
listView1.Items[i].SubItems[x].Text = bottomLeft.ElementAt(bLn);
++bLn;
}
myMatrix.Clear();
shiftMatrix.Clear();
topRight.Clear();
bottomLeft.Clear();
}
}
}
I'm trying to write a test for one of my audio programs, and I'm having trouble wrapping my brain around this test setup. First, I've got a table of 60 rows by 10000 columns that needs to be filled. Each cell has a value of ON, OFF, or LEFT (meaning I have the same value as my nearest ON/OFF to my left). I want a random twenty to forty rows to be on at any given time. Each has to be on for a random 6 to 200 cells. The commands to set ON or OFF have to be ordered by row then column. I'm picturing a sparse dictionary coming out with a coordinate key and on/off value. What I don't understand is how store my ON/OFF cells such that I can easily determine if my current row is ON or OFF. Help? Thanks for your time.
After further thought on this, I realized I could do it in two passes. Here's what I ended up with. Feel free to comment on this approach:
var table = new byte[60, 10000];
for(int i = 0; i < 60; i++)
{
// we want at least half the row to be blank
int j = 0;
while(j < 10000)
{
var width = rand.Next(7, 200);
j += width * 2;
var vol = (byte)rand.Next(50, 125);
for(int k = j - width; k < Math.Min(10000, j); k++)
table[i, k] = vol;
}
}
var midiEvents = new List<BASS_MIDI_EVENT>();
midiEvents.Add(new BASS_MIDI_EVENT(BASSMIDIEvent.MIDI_EVENT_PROGRAM, 0, 0, 0, 0));
for(int j = 0; j < 10000; j++)
{
for(int i = 0; i < 60; i++)
{
var cur = (int)table[i, j];
var left = j > 0 ? table[i, j - 1] : 0;
if(cur > 0 && left == 0)
{
cur <<= 8;
cur |= i + 33;
midiEvents.Add(new BASS_MIDI_EVENT(BASSMIDIEvent.MIDI_EVENT_NOTE, cur, 0, j, 0));
}
else if(cur == 0 && left > 0)
{
midiEvents.Add(new BASS_MIDI_EVENT(BASSMIDIEvent.MIDI_EVENT_NOTE, i + 33, 0, j, 0));
}
}
}