示例#1
0
        private void startStopButton_Click(object sender, RoutedEventArgs e)
        {
            if (startStopButton.Content.Equals("Start"))
            {
                // Start the audio source running
                sio.start();

                // Output debugging info
                textOutput.Text  = "Sound Parameters:\n";
                textOutput.Text += "Input: " + sio.getInputNumChannels() +
                                   " channels at " + sio.getInputSampleRate() / 1000.0 +
                                   " KHz, " + sio.getInputBitdepth() + " bits per sample\n";
                textOutput.Text += "Output: " + sio.getOutputNumChannels() +
                                   " channels at " + sio.getOutputSampleRate() / 1000.0 +
                                   " KHz, " + sio.getOutputBitdepth() + " bits per sample\n";

                startStopButton.Content = "Stop";
            }
            else
            {
                sio.stop();
                textOutput.Text         = "Sound Stopped";
                startStopButton.Content = "Start";
            }
        }
示例#2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Initialize sio
            sio = new SoundIO();

            // Initialize AudioTool with sio's output parameters:
            at = new AudioTool(sio.getOutputNumChannels(), sio.getOutputSampleRate());

            // Setup event logic with a lambda to run every time we get an input buffer of audio
            sio.audioInEvent += (float[] data) =>
            {
                // When we get a buffer of data, make Audio Tool convert it from mono to stereo:
                float[] output = at.convertChannels(data, 1);

                // Output that data to the speakers
                sio.writeAudio(output);
            };
        }
        private void setupSensors()
        {
            // Initialize the combined orientation sensor
            try
            {
                motion = new Motion();
                motion.TimeBetweenUpdates = TimeSpan.FromMilliseconds(100);
                motion.CurrentValueChanged += motion_CurrentValueChanged;
                motion.Start();
            }
            catch
            {
                // Print out an error
                MessageBox.Show("Could not initialize Motion API.  This phone does not have the necessary sensors to run this code properly!");

                // The kill the current application
                Application.Current.Terminate();
            }

            // Setup sound output
            sio = new SoundIO();
            sio.audioOutEvent += sio_audioOutEvent;
            sio.start();
            at = new AudioTool(sio.getOutputNumChannels(), sio.getOutputSampleRate());
        }