Click or drag to resize

Note Class

Defines fundamental musical note frequencies and methods to create them.
Inheritance Hierarchy
SystemObject
  GSF.Media.MusicNote

Namespace: GSF.Media.Music
Assembly: GSF.Media (in GSF.Media.dll) Version: 2.4.207-beta
Syntax
public class Note : IEquatable<Note>, IComparable<Note>, 
	IComparable
View Source

The Note type exposes the following members.

Constructors
 NameDescription
Public methodCode exampleNote Creates a new note of the specified frequency and length.
Top
Properties
 NameDescription
Public propertyDamping Gets or sets the individual damping function used to lower the sound volume for this note over time. If this damping function is not defined, the damping algorithm of the song will be used for the note.
Public propertyDotsGets or sets the total dotted note length extensions that apply to this note.
Public propertyDynamic Gets or sets the dynamic (i.e., volume) expressed as percentage in the range of 0 to 1 for this note. If the dynamic is set to -1, the dynamic of the song will be used.
Public propertyEndTimeIndexGets or sets end time index for this note.
Public propertyFrequencyGets or sets frequency of this note.
Public propertyIDGets or sets note ID of the note.
Public propertyNamedDynamic Gets or sets the named dynamic (i.e., volume) for this note. If the dynamic is undefined, the dynamic of the song will be used.
Public propertyNamedValueGet or sets the note value, expressed in American form, representing the length of the note.
Public propertyNamedValueBritishGet or sets the note value, expressed in British form, representing the length of the note.
Public propertySamplePeriodGets or sets the sample period for this note.
Public propertyStartTimeIndexGets or sets start time index for this note.
Public propertyTimbre Gets or sets the individual tibre function used to synthesize the sounds for this note (i.e., the instrument). If this timbre function is not defined, the timbre of the song will be used for the note.
Public propertyValueGet or sets the relative note value representing the length of the note.
Public propertyValueTime Gets the cached note value time, in seconds, calculated from a call to CalculateValueTime(Tempo).
Top
Methods
 NameDescription
Public methodCalculateValueTime Calculates the actual time duration, in seconds, for the specified tempo that the note value will last. For example, if tempo is M.M. 120 quarter-notes per minte, then each quarter-note would last a half-second.
Public methodCompareTo(Note)Notes are compared by frequency, then by value (i.e., duration).
Public methodCompareTo(Object)Notes are compared by frequency, then by value (i.e., duration).
Public methodEquals(Note)Returns True if the frequency and value of this note equals the frequency and value of the specified other note.
Public methodEquals(Object)Returns True if the frequency and value of this note equals the frequency and value of the specified other note.
(Overrides ObjectEquals(Object))
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Public methodStatic memberGetFrequency(String) Gets the specified note frequency.
Public methodStatic memberGetFrequency(Char, Int32, Boolean) Gets the specified note frequency.
Public methodGetHashCode Serves as a hash function for the current Note.
(Overrides ObjectGetHashCode)
Public methodStatic memberGetNextID Gets the next note ID in sequence after the specified note ID.
Public methodStatic memberGetPreviousID Gets the previous note ID in sequence before the specified note ID.
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Public methodStatic memberNamedValueIndex Returns closest note value index (for NoteValue or NoteValueBritish) given the relative duration of a note.
Public methodToString Returns a string representation for the note.
(Overrides ObjectToString)
Top
Operators
 NameDescription
Public operatorStatic memberEquality(Note, Note) Compares two Note frequencies and values for equality.
Public operatorStatic memberGreaterThan(Note, Note) Returns true if left Note timestamp is greater than right Note.
Public operatorStatic memberGreaterThanOrEqual(Note, Note) Returns true if left Note timestamp is greater than or equal to right Note.
Public operatorStatic memberInequality(Note, Note) Compares two Note frequencies and values for inequality.
Public operatorStatic memberLessThan(Note, Note) Returns true if left Note timestamp is less than right Note.
Public operatorStatic memberLessThanOrEqual(Note, Note) Returns true if left Note timestamp is less than or equal to right Note.
Top
Fields
 NameDescription
Public fieldStatic memberA0 Fundamental frequency for note A0.
Public fieldStatic memberA0S Fundamental frequency for note A0#.
Public fieldStatic memberA1 Fundamental frequency for note A1.
Public fieldStatic memberA1S Fundamental frequency for note A1#.
Public fieldStatic memberA2 Fundamental frequency for note A2.
Public fieldStatic memberA2S Fundamental frequency for note A2#.
Public fieldStatic memberA3 Fundamental frequency for note A3.
Public fieldStatic memberA3S Fundamental frequency for note A3#.
Public fieldStatic memberA4 Fundamental frequency for note A4.
Public fieldStatic memberA4S Fundamental frequency for note A4#.
Public fieldStatic memberA5 Fundamental frequency for note A5.
Public fieldStatic memberA5S Fundamental frequency for note A5#.
Public fieldStatic memberA6 Fundamental frequency for note A6.
Public fieldStatic memberA6S Fundamental frequency for note A6#.
Public fieldStatic memberA7 Fundamental frequency for note A7.
Public fieldStatic memberA7S Fundamental frequency for note A7#.
Public fieldStatic memberB0 Fundamental frequency for note B0.
Public fieldStatic memberB1 Fundamental frequency for note B1.
Public fieldStatic memberB2 Fundamental frequency for note B2.
Public fieldStatic memberB3 Fundamental frequency for note B3.
Public fieldStatic memberB4 Fundamental frequency for note B4.
Public fieldStatic memberB5 Fundamental frequency for note B5.
Public fieldStatic memberB6 Fundamental frequency for note B6.
Public fieldStatic memberB7 Fundamental frequency for note B7.
Public fieldStatic memberC0 Fundamental frequency for note C0.
Public fieldStatic memberC0S Fundamental frequency for note C0#.
Public fieldStatic memberC1 Fundamental frequency for note C1.
Public fieldStatic memberC1S Fundamental frequency for note C1#.
Public fieldStatic memberC2 Fundamental frequency for note C2.
Public fieldStatic memberC2S Fundamental frequency for note C2#.
Public fieldStatic memberC3 Fundamental frequency for note C3.
Public fieldStatic memberC3S Fundamental frequency for note C3#.
Public fieldStatic memberC4 Fundamental frequency for note C4 - Middle C.
Public fieldStatic memberC4S Fundamental frequency for note C4#.
Public fieldStatic memberC5 Fundamental frequency for note C5.
Public fieldStatic memberC5S Fundamental frequency for note C5#.
Public fieldStatic memberC6 Fundamental frequency for note C6.
Public fieldStatic memberC6S Fundamental frequency for note C6#.
Public fieldStatic memberC7 Fundamental frequency for note C7.
Public fieldStatic memberC7S Fundamental frequency for note C7#.
Public fieldStatic memberC8 Fundamental frequency for note C8.
Public fieldStatic memberC8S Fundamental frequency for note C8#.
Public fieldStatic memberD0 Fundamental frequency for note D0.
Public fieldStatic memberD0S Fundamental frequency for note D0#.
Public fieldStatic memberD1 Fundamental frequency for note D1.
Public fieldStatic memberD1S Fundamental frequency for note D1#.
Public fieldStatic memberD2 Fundamental frequency for note D2.
Public fieldStatic memberD2S Fundamental frequency for note D2#.
Public fieldStatic memberD3 Fundamental frequency for note D3.
Public fieldStatic memberD3S Fundamental frequency for note D3#.
Public fieldStatic memberD4 Fundamental frequency for note D4.
Public fieldStatic memberD4S Fundamental frequency for note D4#.
Public fieldStatic memberD5 Fundamental frequency for note D5.
Public fieldStatic memberD5S Fundamental frequency for note D5#.
Public fieldStatic memberD6 Fundamental frequency for note D6.
Public fieldStatic memberD6S Fundamental frequency for note D6#.
Public fieldStatic memberD7 Fundamental frequency for note D7.
Public fieldStatic memberD7S Fundamental frequency for note D7#.
Public fieldStatic memberD8 Fundamental frequency for note D8.
Public fieldStatic memberD8S Fundamental frequency for note D8#.
Public fieldStatic memberE0 Fundamental frequency for note E0.
Public fieldStatic memberE1 Fundamental frequency for note E1.
Public fieldStatic memberE2 Fundamental frequency for note E2.
Public fieldStatic memberE3 Fundamental frequency for note E3.
Public fieldStatic memberE4 Fundamental frequency for note E4.
Public fieldStatic memberE5 Fundamental frequency for note E5.
Public fieldStatic memberE6 Fundamental frequency for note E6.
Public fieldStatic memberE7 Fundamental frequency for note E7.
Public fieldStatic memberF0 Fundamental frequency for note F0.
Public fieldStatic memberF0S Fundamental frequency for note F0#.
Public fieldStatic memberF1 Fundamental frequency for note F1.
Public fieldStatic memberF1S Fundamental frequency for note F1#.
Public fieldStatic memberF2 Fundamental frequency for note F2.
Public fieldStatic memberF2S Fundamental frequency for note F2#.
Public fieldStatic memberF3 Fundamental frequency for note F3.
Public fieldStatic memberF3S Fundamental frequency for note F3#.
Public fieldStatic memberF4 Fundamental frequency for note F4.
Public fieldStatic memberF4S Fundamental frequency for note F4#.
Public fieldStatic memberF5 Fundamental frequency for note F5.
Public fieldStatic memberF5S Fundamental frequency for note F5#.
Public fieldStatic memberF6 Fundamental frequency for note F6.
Public fieldStatic memberF6S Fundamental frequency for note F6#.
Public fieldStatic memberF7 Fundamental frequency for note F7.
Public fieldStatic memberF7S Fundamental frequency for note F7#.
Public fieldStatic memberG0 Fundamental frequency for note G0.
Public fieldStatic memberG0S Fundamental frequency for note G0#.
Public fieldStatic memberG1 Fundamental frequency for note G1.
Public fieldStatic memberG1S Fundamental frequency for note G1#.
Public fieldStatic memberG2 Fundamental frequency for note G2.
Public fieldStatic memberG2S Fundamental frequency for note G2#.
Public fieldStatic memberG3 Fundamental frequency for note G3.
Public fieldStatic memberG3S Fundamental frequency for note G3#.
Public fieldStatic memberG4 Fundamental frequency for note G4.
Public fieldStatic memberG4S Fundamental frequency for note G4#.
Public fieldStatic memberG5 Fundamental frequency for note G5.
Public fieldStatic memberG5S Fundamental frequency for note G5#.
Public fieldStatic memberG6 Fundamental frequency for note G6.
Public fieldStatic memberG6S Fundamental frequency for note G6#.
Public fieldStatic memberG7 Fundamental frequency for note G7.
Public fieldStatic memberG7S Fundamental frequency for note G7#.
Public fieldStatic memberMiddleCNote ID for "Middle C"
Top
Extension Methods
 NameDescription
Public Extension MethodGetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Public Extension MethodGetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Top
Example
This example creates an in-memory wave file and adds notes to create a basic musical scale:
C#
using System;
using GSF.Media;
using GSF.Media.Music;

static class Program
{
    static void Main()
     {
         WaveFile waveFile = new WaveFile();
         long samplePeriod = 6 * waveFile.SampleRate;   // Compute total sample period
         int totalNotes = 15;                           // Total notes to traverse
         string noteID = Note.MiddleC;                  // Start note at middle C
         double frequency = Note.GetFrequency(noteID);  // Get frequency for middle C
         bool reverse = false;                          // Traverse notes in reverse order

         for (int sample = 0; sample < samplePeriod; sample++)
         {
             // Change notes at even intervals within the sample period
             if (sample > 0 && (sample % (samplePeriod / totalNotes)) == 0)
             {
                 if (reverse)
                 {
                     noteID = Note.GetPreviousID(noteID, false);
                     frequency = Note.GetFrequency(noteID);
                 }
                 else
                 {
                     noteID = Note.GetNextID(noteID, false);
                     frequency = Note.GetFrequency(noteID);
                 }

                 // Go back down the scale after C5
                 if (noteID == "C5")
                     reverse = true;
             }

             waveFile.AddSample(Timbre.BasicNote(frequency, sample, samplePeriod, waveFile.SampleRate) * 4500);
         }

         waveFile.Play();
         Console.ReadKey();
     }
}
See Also