Exemplo n.º 1
0
        public static bool TryParse(ReadOnlySpan <char> text, [MaybeNullWhen(returnValue: false)] out Rtttl rtttl)
        {
            rtttl = null;

            var endOfName = text.IndexOf(Separator);

            var readOnlySpan = text.Slice(0, endOfName);

#if NETSTANDARD2_1
            var name = new string(readOnlySpan);
#else
            var name = new string(readOnlySpan.ToArray());
#endif

            text = text.Slice(endOfName + 1);

            var endOfSettings = text.IndexOf(Separator);

            if (!RtttlSettings.TryParse(text.Slice(0, endOfSettings), out var rtttlSettings))
            {
                return(false);
            }

            if (!TryParseNotes(text.Slice(endOfSettings + 1), out var notes))
            {
                return(false);
            }

            rtttl = new Rtttl(name, rtttlSettings, notes);

            return(true);
        }
Exemplo n.º 2
0
 public static void PlayWithConsoleBeep(this Rtttl rtttl)
 {
     rtttl.Play(new ConsoleBeepPlayer());
 }
Exemplo n.º 3
0
 /// <summary>
 /// Play With PWM Channel.
 /// </summary>
 /// <param name="rtttl">Ring Tone Transfer Language.</param>
 /// <param name="pwmChannel">PWM channel.</param>
 public static void PlayWithPwmChannel(this Rtttl rtttl, PwmChannel pwmChannel)
 {
     rtttl.Play(new PwmChannelPlayer(pwmChannel));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Play With PWM Channel.
 /// </summary>
 /// <param name="rtttl">Ring Tone Transfer Language.</param>
 /// <param name="chip">The PWM chip number.</param>
 /// <param name="channel">The PWM channel number.</param>
 public static void PlayWithPwmChannel(this Rtttl rtttl, int chip, int channel)
 {
     rtttl.Play(new PwmChannelPlayer(PwmChannel.Create(chip, channel)));
 }