Exemplo n.º 1
0
        /// <summary>
        /// Offsets the keystroke by both an interval and an octave.
        /// </summary>
        /// <param name="scale">The scale you want to offset by</param>
        /// <param name="offset"> Moves by intevals/tonesteps. </param>
        /// <param name="octaveOffset"> Moves by octave. </param>
        /// <returns> Returns a new keystroke that has been offset within the scale. </returns>
        public Note OffsetBy(Scale scale, int offset, int octaveOffset)
        {
            Keystroke k      = Keystroke.OffsetBy(scale, offset, octaveOffset);
            Note      result = new Note(k.Tone, Pause.Duration, k.Velocity);

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Projects all music objects of specified type into a <see cref="MusicObject"/> of the same structure.
        /// </summary>
        /// <typeparam name="T">The MusicObject subtype to modify.</typeparam>
        /// <param name="selector">A transform function to apply to each element.</param>
        /// <returns>A <see cref="MusicObject"/> of identical structure that is the result of invoking the transform function of all elements of type T.</returns>
        public override MusicObject Select <T>(Func <T, MusicObject> selector)
        {
            Keystroke result = new Keystroke(Tone, Duration, Velocity)
            {
                Tone         = Tone,
                OctaveOffset = OctaveOffset
            };  //Tone and OctaveOffset must be copied directly because of the weird conversion in the constructor.

            if (this is T)
            {
                return(selector(result as T));
            }
            else
            {
                return(result);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Plays a tone with duration, velocity and start-time specified.
        /// Time is measured in beats from the start of the music. Get the curent time by calling CurrentTime from the orchestra.
        /// </summary>
        /// <param name="startTime">When the music should play.</param>
        /// <param name="tone">The tone to play. </param>
        /// <param name="duration">How long the tone should las in beats</param>
        /// <param name="velocity">Goes from 0 to 127. Default is 64.</param>
        public void Play(double startTime, Tone tone, double duration, byte velocity = 64)
        {
            Keystroke keystroke = new Keystroke(tone, duration, velocity);

            Play(startTime, keystroke);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new instance of the Note class by initializing a <see cref="T:MidiGremlin.Keystroke"/> and a <see cref="T:MidiGremlin.Pause"/> with the same duration.
 /// </summary>
 /// <param name="tone"> The tone that the keystroke represents. </param>
 /// <param name="duration">How long the tone is played in beats, and how long to wait before playing the next MusicObject. </param>
 /// <param name="velocity"> The severety with which the keystroke is struck. </param>
 public Note(Tone tone, double duration, byte velocity = 64)
 {
     Keystroke = new Keystroke(tone, duration, velocity);
     Pause     = new Pause(duration);
 }