Example #1
0
        public virtual IEnumerator <ITask> PlayToneHandler(tone.PlayTone request)
        {
            if (request.Body.Frequency < 0 || request.Body.Duration < 0)
            {
                LogError("Improper PlayTone Frequency or Duration");
                request.ResponsePort.Post(new Fault());
                yield break;
            }

            brick.PlayToneBody play = new brick.PlayToneBody();
            play.Frequency1 = request.Body.Frequency;
            play.Frequency2 = 0;
            play.Duration   = request.Body.Duration;

            Activate(Arbiter.Choice(_scribblerPort.PlayTone(play),
                                    delegate(DefaultUpdateResponseType response)
            {
                request.ResponsePort.Post(DefaultUpdateResponseType.Instance);
            },
                                    delegate(Fault fault)
            {
                request.ResponsePort.Post(new Fault());
            }
                                    ));

            yield break;
        }
Example #2
0
        public void PlaySong(MyroInterfaces.IMyroSong song)
        {
            MyroSong msong = (MyroSong)song;

            foreach (MyroSong.ListItem li in msong.songSequence)
            {
                if (li.chord)
                {
                    tonegen.PlayTone2Request request = new tonegen.PlayTone2Request();
                    request.Duration   = (int)(li.duration * 1000f);
                    request.Frequency1 = (int)li.frequency1;
                    request.Frequency2 = (int)li.frequency2;
                    tonegen.PlayTone2 ptone = new tonegen.PlayTone2(request);
                    tonePort.Post(ptone);
                }
                else
                {
                    tonegen.PlayToneRequest request = new tonegen.PlayToneRequest();
                    request.Duration  = (int)(li.duration * 1000f);
                    request.Frequency = (int)li.frequency1;
                    tonegen.PlayTone ptone = new tonegen.PlayTone(request);
                    tonePort.Post(ptone);
                }
            }
        }
Example #3
0
        public void PlaySong(MyroInterfaces.IMyroSong song)
        {
            MyroSong msong = (MyroSong)song;

            foreach (MyroSong.ListItem li in msong.songSequence)
            {
                if (li.chord)
                {
                    tonegen.PlayTone2Request request = new tonegen.PlayTone2Request();
                    request.Duration   = (int)(li.duration * 1000f);
                    request.Frequency1 = (int)li.frequency1;
                    request.Frequency2 = (int)li.frequency2;
                    tonegen.PlayTone2 ptone = new tonegen.PlayTone2(request);
                    tonePort.Post(ptone);
                    bool done = false;
                    Arbiter.Activate(DssEnvironment.TaskQueue,
                                     Arbiter.Receive <DefaultUpdateResponseType>(false,
                                                                                 ptone.ResponsePort,
                                                                                 delegate(DefaultUpdateResponseType state)
                    {
                        done = true;
                    }
                                                                                 ));

                    while (!done)
                    {
                        ;
                    }
                }
                else
                {
                    tonegen.PlayToneRequest request = new tonegen.PlayToneRequest();
                    request.Duration  = (int)(li.duration * 1000f);
                    request.Frequency = (int)li.frequency1;
                    tonegen.PlayTone ptone = new tonegen.PlayTone(request);
                    tonePort.Post(ptone);
                    bool done = false;
                    Arbiter.Activate(DssEnvironment.TaskQueue,
                                     Arbiter.Receive <DefaultUpdateResponseType>(false,
                                                                                 ptone.ResponsePort,
                                                                                 delegate(DefaultUpdateResponseType state)
                    {
                        done = true;
                    }
                                                                                 ));
                    while (!done)
                    {
                        ;
                    }
                }
            }
        }
Example #4
0
        public void beep(float duration, float frequency)
        {
            bool flag = false;

            tonegen.PlayToneRequest request = new tonegen.PlayToneRequest();
            request.Duration  = (int)duration;
            request.Frequency = (int)frequency;

            tonegen.PlayTone ptone = new tonegen.PlayTone(request);
            tonePort.Post(ptone);

            Arbiter.Activate(DssEnvironment.TaskQueue,
                             Arbiter.Receive <DefaultUpdateResponseType>(false, ptone.ResponsePort,
                                                                         delegate(DefaultUpdateResponseType state)
            {
                flag = true;
            }
                                                                         ));

            while (!flag)
            {
                ;
            }
        }