wi.Start() returns the error : Wave.MMSYSERR.ERROR.
If that can help... Thanks Alex.
:
I meant, what is the return value of wi.Start()?
--
Alex Feinman
---
Visit
http://www.opennetcf.org
I use a slightly modified version of the sample of the Waveform Audio
Interface of MSDN. I added method SaveBuffer(), and PlayBuffer() to the
WaveIn and WaveOut. I have done very few changes in the sample code
(MemoryStream instead of FileStream, and I return the bytes[] of the
stream
as a result). Dealing with byte[] is very convenient to stream them in
UDP
packets.
Here is the code :
It record 100ms of sound, and play it. And loop 100 times.
I force the thread to sleep if the recording (or the playback) is not
finished.
So, there should never be 2 recording requests at the same time, and
never
2
playing requests at the same time. But recording takes place at the
same
time
the previous sample is played.
The code is working, but every second time approximately, recording
fails
(I
have the message "FAILURE: Failed to start recording" in the console).
If you can help, that would be great!
WaveIn wi = new WaveIn();
WaveOut wo = new WaveOut();
audioBuf = new byte[256*1024];
int bidul = 0;
if (Wave.MMSYSERR.NOERROR != wi.Preload(1000, 256*1024))
{
writeLineToConsole("FAILURE: Failed to preload buffers");
}
try
{
for (int i = 0; i < 100 ; i++)
{
if (!firstTime)
{
int sleepTime = 5;
int watchDog = 0;
int maxLoops = 100 / 5;
while(!wi.Done())
{
Thread.Sleep(sleepTime);
Application.DoEvents();
watchDog++;
if (watchDog > maxLoops)
{
writeLineToConsole("FAILURE: Failed to detecte end of sound");
return;
}
}
}
if (Wave.MMSYSERR.NOERROR != wi.Start())
{
writeLineToConsole("FAILURE: Failed to start recording");
}
Thread.Sleep(100);
wi.Stop();
if (Wave.MMSYSERR.NOERROR != wi.SaveBuffer(ref audioBuf, ref
audioSize))
{
writeLineToConsole("FAILURE: Failed to save file");
}
writeLineToConsole("recorded " + audioSize + " bytes of audio");
if (firstTime)
{
firstTime = false;
}
else
{
int sleepTime = 5;
int watchDog = 0;
int maxLoops = (int)(wo.Milliseconds() / sleepTime);
while(!wo.Done())
{
Thread.Sleep(sleepTime);
Application.DoEvents();
watchDog++;
if (watchDog > maxLoops)
{
writeLineToConsole("FAILURE: Failed to detecte end of sound");
return;
}
}
}
if (Wave.MMSYSERR.NOERROR != wo.PlayBuffer(ref audioBuf, ref audioSize,
ref bidul, 0xffff, 0xffff))
{
writeLineToConsole("FAILURE: Failed to play sound test.wav");
}
}
Lionel Reyero
:
Hello,
I am developping a VoIP application between Ipaq. I use the Waveform
Audio
Interface to capture and play audio.
(See the MSDN example, it is the best on audio capture and playback on
.NET:
http://msdn.microsoft.com/mobility/default.aspx?pull=/library/en-us/dnnetcomp/html/waveinout.asp
You can download the sample code, it is much easier to modify than
OpenNETCF).
I would like to make my application full duplex,(capture,stream and
play
the
sound simultaneously on the 2 ipaqs)).
Problem:
I get an error when I try to record sound while playing sound.
Does the problem come from my ipaq ? (I use Ipaq rx3715). Or is it a
limitation of the Waveform Audio Interface ?
Thank you,
Lionel Reyero