예제 #1
0
        private static void PlayThings(Context ctx, Node srcNode)
        {
            FrameworkDispatcher.Update();
            using (var aud = new DynamicSoundEffectInstance(48000, AudioChannels.Mono))
            {
                SampleSize = aud.GetSampleSizeInBytes(new TimeSpan(0, 0, 0, 0, SampleTimeMs));

                var sub = ctx.Socket(SocketType.SUB);
                sub.Subscribe(new byte[0]);
                sub.Connect(srcNode.Url);

                mBar.SignalAndWait();

                bool bufferNeeded = true;
                aud.BufferNeeded += (_, __) => bufferNeeded = true;

                while (isRunning)
                {
                    if (bufferNeeded)
                    {
                        foreach (var n in mNodes.Where(n => n is GeneratorNode).Cast<GeneratorNode>())
                        {
                            n.SignalForData();
                        }
                        bufferNeeded = false;
                    }

                    var bytes = sub.Recv(SampleTimeMs / 2);

                    if (bytes != null)
                    {
                        aud.SubmitBuffer(bytes);
                        if (aud.State == SoundState.Stopped)
                            aud.Play();
                    }

                    FrameworkDispatcher.Update();

                    //running = false;
                }

                aud.Stop();
                sub.Dispose();
            }
        }
예제 #2
0
 private static void AddNode(Node n)
 {
     mNodes.Add(n);
     mBar.AddParticipant();
 }
예제 #3
0
파일: Node.cs 프로젝트: AustinWise/ZmqMusic
 public void AddParent(Node node)
 {
     if (node == null)
         throw new ArgumentNullException();
     mParents.Add(node);
 }