Esempio n. 1
0
        public virtual IList <OutputFile> ProcessStream(Stream input, ConvertOptions options)
        {
            List <RPCCommand> rpc = new List <RPCCommand>();

            using (BinaryReader reader = new BinaryReader(input))
            {
                reader.ReadInt16();
                int  length = reader.ReadInt16();
                byte lastb  = 0;
                int  delay  = 0;
                for (int i = 0; i < length; i++)
                {
                    byte b = reader.ReadByte();
                    if (b != lastb)
                    {
                        rpc.Add(RPCCommand.Delay(delay * 1000 / 140));
                        delay = 0;
                    }
                    if (b == 0)
                    {
                        rpc.Add(RPCCommand.ClearCountdown());
                    }
                    else
                    {
                        double freq = b * 15;                      //frequencies[b];
                        rpc.Add(RPCCommand.SetCountdown(LoadMDT.FrequencyToCountdown(freq)));
                    }
                    delay += 1;
                    lastb  = b;
                }
                rpc.Add(RPCCommand.Delay(delay * 1000 / 140));
            }
            return(LoadPCS.ProcessRPC(rpc, options));
        }
Esempio n. 2
0
            public IEnumerable <RPCCommand> GetCommands(string ppMusicString)
            {
                int pos = 0;

                while (NextNote(ppMusicString, ref pos))
                {
                    double freq = Note2Freq(Note) * 2;
                    NoteTime += NoteDuration;
                    State     = PlayerState.Parsing;
                    double silence = 0;
                    if (Mode == PlayerMode.Normal)
                    {
                        silence = NoteDuration / 8;
                    }
                    else if (Mode == PlayerMode.Staccato)
                    {
                        silence = NoteDuration / 4;
                    }
                    if (freq > 0)
                    {
                        yield return(RPCCommand.SetCountdown(LoadMDT.FrequencyToCountdown(freq)));
                    }
                    else
                    {
                        yield return(RPCCommand.ClearCountdown());
                    }
                    yield return(RPCCommand.Delay((int)Math.Round((NoteDuration - silence) * 1000)));

                    if (silence > 0)
                    {
                        yield return(RPCCommand.ClearCountdown());

                        yield return(RPCCommand.Delay((int)Math.Round(silence * 1000)));
                    }
                }
            }