コード例 #1
0
        private void ThreadPlaySound(object stateInfo)
        {
            int readBytes;

            using (Stream pcmStream = new FileStream(@"Audio.au", FileMode.Open))
            {
                using (Stream adpcmStream = new Pcm8ToAdpcm4Stream(pcmStream))
                {
                    using (Stream speakerStream = new WiimoteSpeakerStream(_Wiimote))
                    {
                        byte[] adpcm_data = new byte[20];

                        _Wiimote.IsSpeakerEnabled = true;

                        while ((readBytes = adpcmStream.Read(adpcm_data, 0, 20)) > 0)
                        {
                            speakerStream.Write(adpcm_data, 0, readBytes);
                        }

                        _Wiimote.IsSpeakerEnabled = false;

                        speakerStream.Close();
                    }
                    adpcmStream.Close();
                }
                pcmStream.Close();
            }
        }
コード例 #2
0
        private void playSoundToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int readBytes;

            using (Stream pcmStream = new FileStream(@"Audio.au", FileMode.Open))
            {
                using (Stream adpcmStream = new Pcm8ToAdpcm4Stream(pcmStream))
                {
                    using (Stream speakerStream = new WiimoteSpeakerStream(_Wiimote))
                    {
                        byte[] adpcm_data = new byte[20];

                        Wiimote.IsSpeakerEnabled = true;

                        while ((readBytes = adpcmStream.Read(adpcm_data, 0, 20)) > 0)
                        {
                            speakerStream.Write(adpcm_data, 0, readBytes);
                        }

                        Wiimote.IsSpeakerEnabled = false;

                        speakerStream.Close();
                    }
                    adpcmStream.Close();
                }
                pcmStream.Close();
            }
        }
コード例 #3
0
        private void playSoundToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int readBytes;
            using (Stream pcmStream = new FileStream(@"Audio.au", FileMode.Open))
            {
                using (Stream adpcmStream = new Pcm8ToAdpcm4Stream(pcmStream))
                {
                    using (Stream speakerStream = new WiimoteSpeakerStream(_Wiimote))
                    {

                        byte[] adpcm_data = new byte[20];

                        Wiimote.IsSpeakerEnabled = true;

                        while ((readBytes = adpcmStream.Read(adpcm_data, 0, 20)) > 0)
                            speakerStream.Write(adpcm_data, 0, readBytes);

                        Wiimote.IsSpeakerEnabled = false;

                        speakerStream.Close();
                    }
                    adpcmStream.Close();
                }
                pcmStream.Close();
            }
        }