Aaron
Wed May 04 06:08:54 CDT 2005
Lionel,
I am looking to create a simular application to what you are working on. In
your previous post, you stated that the recording / playback was unusable and
that you would need to make some real changes to get it to work.
Were you successfull at making the sould quality acceptable? Or have you
stopped utilizing this example as a starting point?
Thanks in advance.
Aaron
"Lionel Reyero" wrote:
> Hi,
>
> Now I call the "preload()" function before to start recording, it is working.
> The sound quality is awful... when recording sound by 100ms slices, there
> are terrible gaps, it is impossible to understand anything...
> ..I think I'll make real changes to the example to have it suitable for voIP.
> Thanks,
>
> Lionel
>
> "Alex Feinman [MVP]" wrote:
>
> > Looking at the MSDN code the only way you can get MMSYSERR_ERROR from
> > wi.Start is if you did not call wi.Initialize or have already started
> > recording on this object. You can easily detect which one is it by stepping
> > into the code
> >
> > --
> > Alex Feinman
> > ---
> > Visit
http://www.opennetcf.org
> > "Lionel Reyero" <LionelReyero@discussions.microsoft.com> wrote in message
> > news:085CB7FC-11CE-4688-901C-3699EB581DC1@microsoft.com...
> > > wi.Start() returns the error : Wave.MMSYSERR.ERROR.
> > > If that can help... Thanks Alex.
> > >
> > >
> > > "Alex Feinman [MVP]" wrote:
> > >
> > >> I meant, what is the return value of wi.Start()?
> > >>
> > >> --
> > >> Alex Feinman
> > >> ---
> > >> Visit
http://www.opennetcf.org
> > >> "Lionel Reyero" <LionelReyero@discussions.microsoft.com> wrote in message
> > >> news:06CFFE32-F66D-4C59-AC07-CD9E695EA4DA@microsoft.com...
> > >> >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
> > >> >
> > >> >
> > >> >
> > >> > "Lionel Reyero" wrote:
> > >> >
> > >> >> 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
> > >>
> > >>
> >
> >