Exemplo n.º 1
0
        //Event handler for clicking the update button
        private void updateButton_Click(object sender, RoutedEventArgs e)
        {
            float customFreq = SineWavePlayer.ConstrainFrequency(float.Parse(freqBox.Text.Trim()));
            float customAmp  = SineWavePlayer.ConstrainAmplitude(float.Parse(volBox.Text.Trim()) / 100);

            player.UpdateFrequency(customFreq);
            player.UpdateAmplitude(customAmp);
            freqBox.Text = customFreq.ToString();
            volBox.Text  = (customAmp * 100).ToString();
        }
Exemplo n.º 2
0
        //Event handler for changing the frequency slider
        private void freqSlider_Change(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            float customFreq = SineWavePlayer.ConstrainFrequency((float)freqSlider.Value);

            if (player.IsPlaying())
            {
                player.UpdateFrequency((customFreq));
            }
            freqBox.Text = customFreq.ToString();
        }
Exemplo n.º 3
0
 //Event handler for clicking the play button
 private void playButton_Click(object sender, RoutedEventArgs e)
 {
     if (!player.IsPlaying())
     {
         player.Frequency = SineWavePlayer.ConstrainFrequency(float.Parse(freqBox.Text.Trim()));
         player.Amplitude = SineWavePlayer.ConstrainAmplitude(float.Parse(volBox.Text.Trim()) / 100);
         player.Start();
         playButton.Content = "Stop";
     }
     else
     {
         player.Stop();
         playButton.Content = "Play";
     }
 }
Exemplo n.º 4
0
        //Event handler for changes in the Kinect's skeleton data
        private void SkeletonDataChange(object sender, SkeletonDataChangeEventArgs e)
        {
            //Get the coordinates of the right and left hands
            Skeleton skel = null;

            for (int i = 0; i < e.skeletons.Length; i++)
            {
                if (e.skeletons[i].TrackingState == SkeletonTrackingState.Tracked)
                {
                    skel = e.skeletons[i];
                    break;
                }
            }
            if (skel == null)
            {
                return;
            }
            Point rightHand = helper.SkeletonPointToScreen(skel.Joints[JointType.HandRight].Position);

            rightLabel.Content = "(" + rightHand.X + "," + rightHand.Y + ")";
            Point leftHand = helper.SkeletonPointToScreen(skel.Joints[JointType.HandLeft].Position);

            leftLabel.Content = "(" + leftHand.X + "," + leftHand.Y + ")";

            //Adjust the frequency based on the position of the left hand
            float ratio      = player.MaxFreq / player.MinFreq;
            float customFreq = (float)(player.MaxFreq - (ratio * leftHand.Y / skelImage.Height) * player.MinFreq);

            customFreq = SineWavePlayer.ConstrainFrequency(customFreq);
            if (player.IsPlaying())
            {
                player.UpdateFrequency(customFreq);
                freqSlider.Value = customFreq;
                freqBox.Text     = customFreq.ToString();
            }

            //Adjust the amplitude based on the position of the right hand
            float customAmp = (float)(1 - (rightHand.Y / skelImage.Height));

            customAmp = SineWavePlayer.ConstrainAmplitude(customAmp);
            if (player.IsPlaying())
            {
                player.UpdateAmplitude(customAmp);
                volBox.Text = (customAmp * 100).ToString();
            }
        }