예제 #1
0
        private void WaveOutOpen()
        {
            // WAVEデバイス設定
            WAVEFORMATEX waveformatex = new WAVEFORMATEX();

            waveformatex.wFormatTag      = 0x0001; // PCM
            waveformatex.nChannels       = (ushort)channel_number_;
            waveformatex.nSamplesPerSec  = (uint)sample_rate_;
            waveformatex.wBitsPerSample  = (ushort)(bits_per_sample_);
            waveformatex.nBlockAlign     = (ushort)(waveformatex.nChannels * waveformatex.wBitsPerSample / 8);
            waveformatex.nAvgBytesPerSec = waveformatex.nSamplesPerSec * waveformatex.nBlockAlign;
            waveformatex.cbSize          = 0;

            h_wave_out_ = new IntPtr();
            dlg_        = new WaveCallbackDelegate(WaveCallbackProc);

            System.Diagnostics.Debug.Write("call waveOutOpen");
            uint error_code = waveOutOpen(ref h_wave_out_, (IntPtr)0x0000, ref waveformatex, dlg_, (IntPtr)0, 0x00030000);

            if (error_code != 0)
            {
                throw new WaveOutApiException("waveOutOpen", error_code);
            }
        }
예제 #2
0
 private static extern uint waveOutOpen(ref IntPtr phwo, IntPtr uDeviceID, ref WAVEFORMATEX pwfx, WaveCallbackDelegate dwCallback, IntPtr dwInstance, uint fdwOpen);