-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStave.cs
151 lines (141 loc) · 5.61 KB
/
Stave.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//Foo Bars are yummy!
//No moor bullshit
//http://www.youtube.com/watch?v=MdpwVEUMzW8&feature=player_embedded
namespace BandaGaraxxjata
{
public partial class Stave : Form
{
static int min = 50;//Roovle sets limits!
static int interval = 15;//Roovle sets the stave interval
int h = interval*4; //Roovle sets the total height
int width = 800; //Roovle sets the width of the stave
//Roovle creates an instance of the Noti class
Noti roovle = new Noti();
private MusicKeyboard pjanu;
public Stave(MusicKeyboard mk)
{
InitializeComponent();
//Roovle inits the stave class
this.Width = width + 80;
this.Height = 190;
pjanu = mk;
}
private void Stave_Paint(object sender, PaintEventArgs picasso)
{
System.Drawing.Graphics objGraffiku;
objGraffiku = this.CreateGraphics();
Pen pinna = new Pen(System.Drawing.Color.Black, 2);
//Roovle preapres the pen to paint the stave
for (int i = min; i <= h+min; i+=interval)
objGraffiku.DrawLine(pinna, min, i, width + min, i);
objGraffiku.DrawLine(pinna, min, min, min, h + min);
//Roovle draws coke lines like a now rich meth head
roovle.drawNote(picasso);
//Roovle asks picasso to draw a nice treble cleff
for (int i = 0; i <= 35; i++)
{
roovle.drawNote(
picasso, roovle.xebaNoti[i].duration,
((i + 1) * 20) + 80, roovle.xebaNoti[i].y,
roovle.xebaNoti[i].accidental, roovle.xebaNoti[i].mod
);
//Roovle draws empty notes like a baws
}
}
private void Stave_MouseDown(object sender, MouseEventArgs gurdien)
{
//Roovle steals coordinates from deadmau5
int x = gurdien.X;
int y = gurdien.Y;
//Roovle checks for which button was pressed and acts accordingly
if (gurdien.Button == MouseButtons.Right)
roovle.changeNote(x);
else if (gurdien.Button == MouseButtons.Left)
roovle.changeNote(x, y);
else if (gurdien.Button == MouseButtons.Middle)
roovle.changeNote(x, true);
this.Refresh();
//Roovle asks your mum to go and take a shower after banging her....
}
private void btUpload_Click(object sender, EventArgs e)
{
pjanu.disablePlayback();//Clears previous stuff
for (int i = 0; i < 36; i++)
{
int temp = roovle.xebaNoti[i].duration;
if (temp == 0)
{// Insert gap in recording
pjanu.recording.Add(-1);
pjanu.keytimings.Add(0);
}
else
{// Add key to recording
pjanu.recording.Add(roovle.xebaNoti[i].pitch);
pjanu.keytimings.Add(-1);
}
pjanu.enablePlayback();
}
}
private void btClear_Click(object sender, EventArgs e)
{
for (int i = 0; i < 36; i++)
{//bad roovle, clean roovle
roovle.xebaNoti[i].duration = 0;
roovle.xebaNoti[i].accidental = "blank";
roovle.xebaNoti[i].pitch = 0;
roovle.xebaNoti[i].y = 0;
roovle.xebaNoti[i].mod = null;
}
this.Refresh();
}
public void addNoteFromKeyboard(int pitch, long ms)
{// Passing noteID (pitch) and duration from MusicKeyboard in realtime, like a boss
int duration = (int)ms;
if (roovle.xebaNoti[35].duration == 0)
{
string acc = "blank";
int[] sharp = { 2, 4, 7, 9, 11, 14, 16, 19, 21, 23 };
for (int i = 35; i >= 0; i--)
{//Roovle searches for an empty place on the stave
if (i == 0)
{
for (int j = 0; j < sharp.Length; j++)
{
if (pitch == sharp[j])
acc = "#";
}
roovle.changeNote(0, pitch, duration, acc);
break;
}
else if (roovle.xebaNoti[i - 1].duration != 0)
{//Found and the latested data is deposited
for (int j = 0; j < sharp.Length; j++)
{
if (pitch == sharp[j])
acc = "#";
}
roovle.changeNote(i, pitch, duration, acc);
break;
}
}
this.Refresh();
}
}
private void Stave_FormClosing(object sender, FormClosingEventArgs e)
{
// Hides stave window instead of closing it
if (e.CloseReason != CloseReason.FormOwnerClosing)
{
this.Hide();
pjanu.cbStave.Checked = false;
e.Cancel = true; // cancels the close event
}
}
}
}