Skip to content

Commit

Permalink
GUI: Finish controls data binding (except "TuningSelection")
Browse files Browse the repository at this point in the history
  • Loading branch information
shoomilas committed May 26, 2019
1 parent d9fdb0e commit 32df5ef
Show file tree
Hide file tree
Showing 5 changed files with 383 additions and 241 deletions.
255 changes: 172 additions & 83 deletions HarmonicStructures/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,90 +15,155 @@

namespace HarmonicStructures
{
public enum Intervals
{
Root = 0, //0 semitones
MinorSecond, //1 semitones
MajorSecond, //2 semitones
MinorThird, //3
MajorThird, //4
Fourth, //5
DiminishedFifth,//6
Fifth, //7
AugmentedFifth, //8
Sixth, //9
MinorSeventh,
MajorSeventh,
Octave, //12
MinorNinth, //13
MajorNinth, //14
MinorTenth,
MajorTenth, //16
}

enum Notes // C, Csharp, D, ... : Contains the note names which are implemented in Pitch type.
{
C = 0,
Csharp,
D,
Dsharp,
E,
F,
Fsharp,
G,
Gsharp,
A,
Asharp,
B
}
public enum Intervals
{
Root = 0, //0 semitones
MinorSecond, //1 semitones
MajorSecond, //2 semitones
MinorThird, //3
MajorThird, //4
Fourth, //5
DiminishedFifth,//6
Fifth, //7
AugmentedFifth, //8
Sixth, //9
MinorSeventh,
MajorSeventh,
Octave, //12
MinorNinth, //13
MajorNinth, //14
MinorTenth,
MajorTenth, //16
}

public enum Notes // C, Csharp, D, ... : Contains the note names which are implemented in Pitch type.
{
C = 0,
Csharp,
D,
Dsharp,
E,
F,
Fsharp,
G,
Gsharp,
A,
Asharp,
B
}

class Pitches
{
public static Dictionary<string, Pitch> RootsDictionary = new Dictionary<string, Pitch>
{
//{"C", C},
//{"C#/Db", Csharp},
//{"D" },
//{"D#/Eb", new Pitch(Notes.Dsharp)},
//{"E", new Pitch(Notes.E)},
//{"F", F},
//{"F#/Gb", Fsharp},
//{"G", G},
//{"G#/Ab", Gsharp},
//{"A", A},
//{"A#/Bb", Asharp},
//{"B", B},

//{"[Rootless]", null}, //then do <string, Pitch?>
{"C", new Pitch(Notes.C)},
{"C#/Db", new Pitch(Notes.Csharp)},
{"D", new Pitch(Notes.D)},
{"D#/Eb", new Pitch(Notes.Dsharp)},
{"E", new Pitch(Notes.E)},
{"F", new Pitch(Notes.F)},
{"F#/Gb", new Pitch(Notes.Fsharp)},
{"G", new Pitch(Notes.G)},
{"G#/Ab", new Pitch(Notes.Gsharp)},
{"A", new Pitch(Notes.A)},
{"A#/Bb", new Pitch(Notes.Asharp)},
{"B", new Pitch(Notes.B)},
};

public static Pitch GetPitch(string name)
{
return RootsDictionary[name];
}

public static readonly Pitch C = new Pitch(Notes.C);
public static readonly Pitch Csharp = new Pitch(Notes.Csharp);
public static readonly Pitch D = new Pitch(Notes.D);
public static readonly Pitch Dsharp = new Pitch(Notes.Dsharp);
public static readonly Pitch E = new Pitch(Notes.E);
public static readonly Pitch F = new Pitch(Notes.F);
public static readonly Pitch Fsharp = new Pitch(Notes.Fsharp);
public static readonly Pitch G = new Pitch(Notes.G);
public static readonly Pitch Gsharp = new Pitch(Notes.Gsharp);
public static readonly Pitch A = new Pitch(Notes.A);
public static readonly Pitch Asharp = new Pitch(Notes.Asharp);
public static readonly Pitch B = new Pitch(Notes.B);

//public static implicit operator object? (Pitches v)
//{
// throw new NotImplementedException();
//}
}

public class Interval
{
public const int Root = 0; //0 semitones
public const int MinorSecond = 1;
public const int MajorSecond = 2;
public const int MinorThird = 3;
public const int MajorThird = 4;
public const int Fourth = 5;
public const int AugmentedFourth = 5;
public const int DiminishedFifth = 6;
public const int Fifth = 7;
public const int AugmentedFifth = 8;
public const int MinorSixth = 8;
public const int Sixth = 9;
public const int MinorSeventh = 10;
public const int MajorSeventh = 11;
public const int Octave = 12;
public const int MinorNinth = 13;
public const int MajorNinth = 14;
public const int AugmentedNinth = 15; //or Minor Tenth
public const int MajorTenth = 16;
public const int Eleventh = 17; //... check wiki for more
}

public class Scales
{
public static readonly Pitch C = new Pitch(Notes.C);
public static readonly Pitch Csharp = new Pitch(Notes.Csharp);
public static readonly Pitch D = new Pitch(Notes.D);
public static readonly Pitch Dsharp = new Pitch(Notes.Dsharp);
public static readonly Pitch E = new Pitch(Notes.E);
public static readonly Pitch F = new Pitch(Notes.F);
public static readonly Pitch Fsharp = new Pitch(Notes.Fsharp);
public static readonly Pitch G = new Pitch(Notes.G);
public static readonly Pitch Gsharp = new Pitch(Notes.Gsharp);
public static readonly Pitch A = new Pitch(Notes.A);
public static readonly Pitch Asharp = new Pitch(Notes.Asharp);
public static readonly Pitch B = new Pitch(Notes.B);

//public static implicit operator object? (Pitches v)
//{
// throw new NotImplementedException();
//}
}
public static Dictionary<string, int[]> ScalesDictionary = new Dictionary<string, int[]>
{
//CHROMATIC:
{ "Chromatic", new []{ MinorSecond, MajorSecond, MinorThird, MajorThird, Fourth, DiminishedFifth, Fifth, AugmentedFifth, Sixth, MinorSeventh, MajorSeventh } },

//Pentatonic
{ "Major Pentatonic", new []{ MajorSecond, MajorThird, Fifth, Sixth} },
{ "Minor Pentatonic", new []{ MinorThird, Fourth, Fifth, MinorSeventh } },

//Major Scale modes
{ "Major (1) Ionian", new []{ MajorSecond, MajorThird, Fourth, Fifth, Sixth, MajorSeventh } },
{ "Major (2) Dorian", new []{ MajorSecond, MinorThird, Fourth, Fifth, Sixth, MinorSeventh } },
{ "Major (3) Phrygian", new []{ MinorSecond, MinorThird, Fourth, Fifth, DiminishedFifth, MinorSeventh} },
{ "Major (4) Lydian", new []{ MajorSecond, MajorThird, DiminishedFifth, Fifth, Sixth, MajorSeventh } },
{ "Major (5) Mixolydian", new []{ MajorSecond, MajorThird, Fourth, Fifth, Sixth, MinorSeventh } },
{ "Major (6) Aeolian", new []{ MajorSecond, MinorThird, Fourth, Fifth, Sixth, MinorSeventh } },
{ "Major (7) Locrian", new []{ MinorSecond, MinorThird, Fourth, DiminishedFifth, AugmentedFifth, MinorSeventh } },

//TODO: Natural Melodic Minor's modes
{ "Melodic Minor", new []{MajorSecond, MinorThird, Fourth, Fifth, Sixth, MinorSeventh } },

//TODO: Harmonic Minor Modes
{ "Harmonic Minor", new []{ MajorSecond, MinorThird, Fourth, Fifth, MinorSixth, MajorSeventh } }
};

public static int[] GetScale(string name)
{
return ScalesDictionary[name];
}

public static class Interval
{
public const int Root = 0; //0 semitones
public const int MinorSecond = 1;
public const int MajorSecond = 2;
public const int MinorThird = 3;
public const int MajorThird = 4;
public const int Fourth = 5;
public const int AugmentedFourth = 5;
public const int DiminishedFifth = 6;
public const int Fifth = 7;
public const int AugmentedFifth = 8;
public const int MinorSixth = 8;
public const int Sixth = 9;
public const int MinorSeventh = 10;
public const int MajorSeventh = 11;
public const int Octave = 12;
public const int MinorNinth = 13;
public const int MajorNinth = 14;
public const int AugmentedNinth = 15; //or Minor Tenth
public const int MajorTenth = 16;
public const int Eleventh = 17; //... check wiki for more
}

public static class Scales
{
//TODO: Change degree's names so that they're harmonically correct, e.g. lydian's #4 instead of b5. etc.

//CHROMATIC:
Expand Down Expand Up @@ -126,8 +191,32 @@ public static class Scales

public static class Chords //TODO: When you'll be writing piano keyboard mapping - consider adding extended chords support.
{
//Template: public static readonly int[] NAME = { ... };
public static readonly int[] Maj = { MajorThird, Fifth };
public static Dictionary<string, int[]> ChordsDictionary = new Dictionary<string, int[]>
{
//CHROMATIC:
{ "Maj", new []{ MajorThird, Fifth } },
{ "min", new []{ MinorThird, Fifth } },
{ "dim", new []{ MinorThird, DiminishedFifth } },
{ "Aug", new []{ MajorThird, AugmentedFifth } },

{ "Maj7", new []{ MajorThird, Fifth, MajorSeventh } },
{ "7", new []{ MajorThird, Fifth, MinorSeventh } },
{ "min7", new []{ MinorThird, Fifth, MinorSeventh } },
{ "dim7", new []{ MinorThird, DiminishedFifth, Sixth } },
{ "m7b5", new []{ MinorThird, DiminishedFifth, MinorSeventh } },

{ "sus2", new []{ MajorSecond, Fifth } },
{ "7sus4", new []{ Fourth, Fifth, MinorSeventh } },
};

public static int[] GetChord(string name)
{
return ChordsDictionary[name];
}


//Template: public static readonly int[] NAME = { ... };
public static readonly int[] Maj = { MajorThird, Fifth };
public static readonly int[] Min = { MinorThird, Fifth };
public static readonly int[] Dim = { MinorThird, DiminishedFifth };
public static readonly int[] Aug = { MajorThird, AugmentedFifth };
Expand All @@ -139,7 +228,7 @@ public static class Chords //TODO: When you'll be writing piano keyboard mapping
public static readonly int[] m7b5 = { MinorThird, DiminishedFifth, MinorSeventh };

public static readonly int[] sus2 = { MajorSecond, Fifth };
public static readonly int[] _7sus4 = { Fourth, Fifth, MinorSeventh};
public static readonly int[] _7sus4 = { Fourth, Fifth, MinorSeventh };
}
}

Expand Down
2 changes: 1 addition & 1 deletion HarmonicStructures/FretboardMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public string PlotAsNotes(Pitch Root, int[] Factor)
}

string outcome = "";

//Responsible for printing out as notes:
for (int CurrentString = 0; CurrentString < NumberOfStrings; CurrentString++) //StringIteration
{
Expand Down
25 changes: 13 additions & 12 deletions HarmonicStructures/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:HarmonicStructures"
mc:Ignorable="d"
Title="HarmonicStructures" MinHeight="330" MinWidth="1000" SizeToContent="WidthAndHeight"
Title="HarmonicStructures" MinHeight="330" MinWidth="1100" SizeToContent="WidthAndHeight"
FontSize="15">
<Grid>
<!-- <Label Content="Hello .NET Core!" HorizontalAlignment="Center" VerticalAlignment="Center"
Expand All @@ -14,7 +14,7 @@
<Button Content="Exit" Grid.Row="1" FontSize="20" Click="ButtonExit_Click"/> -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20px"/>
<ColumnDefinition Width="1*" MinWidth="180px" />
<ColumnDefinition Width="1*" MinWidth="250px" />
<ColumnDefinition Width="30px" />
<ColumnDefinition Width="6*" />
<ColumnDefinition Width="30px" />
Expand All @@ -32,8 +32,8 @@
<StackPanel Grid.Column="1" Grid.Row="1">

<!-- Title -->
<Label HorizontalAlignment="Center" FontWeight="Bold" >HarmonicStructures</Label>

<Label x:Name="TitleLabel" HorizontalAlignment="Center" FontWeight="Bold">HarmonicStructures</Label>
<!-- Tuning choice -->
<Label/>
<Grid>
Expand All @@ -53,9 +53,9 @@
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0">Scale:</Label>
<ComboBox Grid.Column="1" SelectedIndex="1">
<ComboBoxItem>---</ComboBoxItem>
<ComboBoxItem>Major</ComboBoxItem>
<!--<ComboBox x:Name="ScaleSelection" Grid.Column="1" SelectedIndex="1" ItemsSource="{Binding Path=ScalesList}" SelectionChanged="ScaleSelection_SelectionChanged">-->
<ComboBox x:Name="ScaleSelection" Grid.Column="1" ItemsSource="{Binding Path=ScalesList}" SelectionChanged="ScaleSelection_SelectionChanged">
<!--<ComboBoxItem>...</ComboBoxItem>-->
</ComboBox>
</Grid>

Expand All @@ -68,8 +68,9 @@
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0">Chord:</Label>
<ComboBox Grid.Column="1" SelectedIndex="0">
<ComboBoxItem>---</ComboBoxItem>
<!--<ComboBox x:Name="ChordSelection" Grid.Column="1" SelectedIndex="0" ItemsSource="{Binding Path=ChordsList}" SelectionChanged="ChordSelection_SelectionChanged">-->
<ComboBox x:Name="ChordSelection" Grid.Column="1" ItemsSource="{Binding Path=ChordsList}" SelectionChanged="ChordSelection_SelectionChanged">
<!--<ComboBoxItem>...</ComboBoxItem>-->
</ComboBox>
</Grid>

Expand All @@ -81,8 +82,8 @@
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0">Root:</Label>
<ComboBox Grid.Column="1">
<ComboBoxItem>[Rootless]</ComboBoxItem>
<ComboBox x:Name="RootSelection" Grid.Column="1" ItemsSource="{Binding Path=RootsList}" SelectionChanged="RootSelection_SelectionChanged" >
<!--<ComboBoxItem>[Rootless]</ComboBoxItem>
<ComboBoxItem>C</ComboBoxItem>
<ComboBoxItem>C#/Db</ComboBoxItem>
<ComboBoxItem>D</ComboBoxItem>
Expand All @@ -94,7 +95,7 @@
<ComboBoxItem>G#/Ab</ComboBoxItem>
<ComboBoxItem>A</ComboBoxItem>
<ComboBoxItem>A#/Bb</ComboBoxItem>
<ComboBoxItem>B</ComboBoxItem>
<ComboBoxItem>B</ComboBoxItem>-->
</ComboBox>
</Grid>

Expand Down
Loading

0 comments on commit 32df5ef

Please sign in to comment.