/// <summary>
 /// Returns notename plus octave number: A1, C3, etc. Notes out of piano scope marked like: A13[WRN]
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     if (octave >= Octave.Subcontra && octave <= Octave.Fifthline)
     {
         return(nameOfTheNote.ToString() + octave.ToString("D"));
     }
     else
     {
         return(nameOfTheNote.ToString() + unboundOctave.ToString("D") + "[WRN]");
     }
 }
Ejemplo n.º 2
0
        public async Task DrawTransposition(NoteName key, double x)
        {
            x += this.Location.X;
            var y      = this.Owner.GetHeight(VoicePart.Treble, x);
            var bounds = await this.PrimitiveRenderer.DrawTranspositionText(x, y, key.ToString());

            this.EnsureHeightForOrnament(VoicePart.Treble, bounds);
        }
Ejemplo n.º 3
0
        static string GetNoteKey(NoteName noteName, int octave = BaseOctave, NoteTuning tuning = NoteTuning.LA_440)
        {
            var sb = new StringBuilder();

            sb.Append(noteName.ToString());
            sb.Append(octave.ToString());
            sb.Append(tuning.ToString());
            return(sb.ToString());
        }
Ejemplo n.º 4
0
 public static Chord X(NoteName root)
 {
     return(Chord.Construct(root.ToString(), root, Intervals.M3, Intervals.P5));
 }
Ejemplo n.º 5
0
        internal static void Test2()
        {
            var g = Enum.GetValues(typeof(NoteName));

            // CancellationTokenSource cts = new CancellationTokenSource();

            using (var outputDevice = OutputDevice.GetByName("Microsoft GS Wavetable Synth"))
            {
                Grid grid = new Grid();
                grid.Background          = new SolidColorBrush(Colors.DarkGreen);
                grid.HorizontalAlignment = HorizontalAlignment.Stretch;
                grid.VerticalAlignment   = VerticalAlignment.Stretch;
                MetroWindow w = new MetroWindow();
                w.TitleCharacterCasing = CharacterCasing.Normal;
                w.Width   = 600;
                w.Height  = 400;
                w.Content = grid;

                for (int o = 0; o < 6; o++)
                {
                    grid.RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(57, GridUnitType.Star)
                    });
                }
                for (int i = 0; i < g.Length; i++)
                {
                    grid.ColumnDefinitions.Add(new ColumnDefinition {
                        Width = new GridLength(48, GridUnitType.Star)
                    });
                }


                // List<Task> L = new List<Task>();
                for (int o = 1; o < 7; o++)
                {
                    for (int i = 0; i < g.Length; i++)
                    {
                        NoteName n  = (NoteName)g.GetValue(i);
                        var      nn = n.ToString().Replace("Sharp", "#") + o;
                        var      b  = new Button {
                            Content = nn
                        };
                        if (nn.Contains("#"))
                        {
                            b.Background = new SolidColorBrush(Colors.LimeGreen);
                        }
                        b.BorderThickness = new Thickness(0);
                        b.Margin          = new Thickness(1);

                        Grid.SetRow(b, o - 1);
                        Grid.SetColumn(b, i);
                        var tp = new ToPlay {
                            Note = n, Octave = o, Device = outputDevice
                        };
                        tp.InitPlay();
                        b.Tag = tp;

                        b.Click += B_Click;;
                        grid.Children.Add(b);

                        // MessageBox.Show(n.ToString());
                    }
                }

                w.ShowDialog();

                /*  List<Task> L = new List<Task>();
                 * for (int i = 0; i < g.Length; i++)
                 * {
                 *    NoteName n = (NoteName)g.GetValue(i);
                 *    L.Add(Task.Run(() => PlayNote(outputDevice, n, 2)));//);
                 *    MessageBox.Show(n.ToString());
                 * }
                 * // cts.Cancel();
                 */

                // Task.WaitAll(L.ToArray());
            }
        }
Ejemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        if (state == 0)
        {
            if (KeyboardInput.GetAnyKey(ref firstNote))
            {
                Debug.Log("Entered: " + firstNote.ToString());

                state = 1;
                Debug.Log("Enter second note...");
            }
        }
        else if (state == 1)
        {
            if (KeyboardInput.GetAnyKey(ref secondNote))
            {
                Debug.Log("Entered: " + secondNote.ToString());

                Debug.Log("Calculating Dissonance...");

                ////Ratio Based Calculation Model
                float f1 = (float)KeyboardInput.NoteFrequency(firstNote);
                float f2 = (float)KeyboardInput.NoteFrequency(secondNote);

                float d = Mathf.Min(f1, f2) / Mathf.Max(f1, f2);
                Debug.Log("Dissonance: " + d.ToString());

                ////Roughness Calculation Model
                ////(Not yet producing accurate results)

                //float fmin = Mathf.Min(f1, f2);
                //float fmax = Mathf.Max(f1, f2);
                //float fdif = fmax - fmin;

                //float R = 0.0f;
                //float X = 0.0f;
                //float Y = 0.0f;
                //float Z = 0.0f;

                ////assume that A is 1.0 for both waves, A min and max are both 1.0
                //X = 1;
                //Y = 1;

                //float e = Mathf.Exp(1);
                //float s = 0.24f / ((0.0207f * fmin) + 18.96f);

                //Z = (
                //    Mathf.Pow(e, (-3.5f * s) * fdif) -
                //    Mathf.Pow(e, (-5.75f * s) * fdif)
                //    );

                //R = (Mathf.Pow(X, 0.1f)) *
                //    (0.5f * Mathf.Pow(Y, 3.11f)) *
                //    (Z);

                //Debug.Log("F: " + f1.ToString() + "," + f2.ToString());
                //Debug.Log("XYZ: " + X.ToString() + "," + Y.ToString() + "," + Z.ToString());
                //Debug.Log("R: " + R.ToString());

                state = 0;
                Debug.Log("Enter first note...");
            }
        }
    }