Skip to content

Commit

Permalink
Class Pitches renamed to HelperContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidWeed committed Jan 4, 2018
1 parent 1aa2a5b commit 56de97a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
1 change: 0 additions & 1 deletion MusicXMLParser/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 8 additions & 12 deletions MusicXMLParser/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Xml;
using System.IO.Compression;


namespace MusicXMLParser
{
/// <summary>
Expand All @@ -28,18 +29,13 @@ namespace MusicXMLParser

public partial class FormMain : Form
{
Pitch pitch = new Pitch(); //used to store dict of frequncies
HelperContainer helper = new HelperContainer(); //used to store dict of frequncies
List<Note> notes = new List<Note>(); //used to store the notes

public FormMain()
{
InitializeComponent();
}

private void MainForm_Load(object sender, EventArgs e)
{

}
}

public void LoadMXL(string xml)
{
Expand Down Expand Up @@ -86,7 +82,7 @@ public void LoadMXL(string xml)
step = snode.SelectSingleNode("pitch").SelectSingleNode("step").InnerText;
octave = snode.SelectSingleNode("pitch").SelectSingleNode("octave").InnerText;
n.noteString = "NOTE_" + step + octave;
n.frequency = pitch.pitches[n.noteString];
n.frequency = helper.pitches[n.noteString];
if (snode.SelectSingleNode("pitch").SelectSingleNode("alter").InnerText == "1")
{
n.frequency = (int)Math.Round(n.frequency * 1.05946);
Expand All @@ -103,7 +99,7 @@ public void LoadMXL(string xml)
step = snode.SelectSingleNode("pitch").SelectSingleNode("step").InnerText;
octave = snode.SelectSingleNode("pitch").SelectSingleNode("octave").InnerText; n.noteString = "NOTE_" + step + octave;

n.frequency = pitch.pitches[n.noteString];
n.frequency = helper.pitches[n.noteString];
n.duration = oneDuration * Convert.ToInt32(snode.SelectSingleNode("duration").InnerText);
}

Expand Down Expand Up @@ -150,7 +146,7 @@ private void buttonOpenFile_Click(object sender, EventArgs e)

openFileDialogMXL.InitialDirectory = Environment.CurrentDirectory;
openFileDialogMXL.Title = "Open MXL File";
openFileDialogMXL.Filter = "MXL/XML Files (*.xml; *.mxl)|*.xml; *.mxl|All files (*.*)|*.*";
openFileDialogMXL.Filter = "MXL/XML Files (*.xml; *.mxl)|*.xml; *.mxl";
openFileDialogMXL.CheckFileExists = true;
openFileDialogMXL.CheckPathExists = true;
openFileDialogMXL.Multiselect = false;
Expand Down Expand Up @@ -212,10 +208,10 @@ private void btnPlayPreview_Click(object sender, EventArgs e)
{
Console.Beep(note.frequency, note.duration);
}

}
}


private void btnConvert_Click(object sender, EventArgs e)
{
rtbArduinoCode.Text = "";
Expand All @@ -238,7 +234,7 @@ private void btnConvert_Click(object sender, EventArgs e)

rtbArduinoCode.Text += melodyString;
rtbArduinoCode.Text += durationString;
rtbArduinoCode.Text += pitch.ArduinoBottom;
rtbArduinoCode.Text += helper.ArduinoBottom;
}
}
}
4 changes: 2 additions & 2 deletions MusicXMLParser/Note.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Note
}


public class Pitch
public class HelperContainer
{
public Dictionary<string, int> pitches = new Dictionary<string, int>();

Expand All @@ -37,7 +37,7 @@ void loop() {
}
";

public Pitch()
public HelperContainer()
{
pitches.Add("NOTE_B0", 31);
pitches.Add("NOTE_C1", 33);
Expand Down

0 comments on commit 56de97a

Please sign in to comment.