• Advertisement

Archived

This topic is now archived and is closed to further replies.

windows API question

This topic is 6202 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need help !!! I have created a simple win32 program to view the input volume from the soundcard using the windows API waveInOpen() and similar functions. There is no problem with the program - compiles - shows the windows and all that - all waveIn....() functions return MMSYSERR_NOERROR - as they should but the app doesn''t work. this is how the program is laid out: first waveInOpen(); then allocate space for buffers in WAVEHDR structs waveInPrepareHeader(); waveInAddHeader(); waveInStart(); Listen for messages: WIM_DATA check for highest volume in buffer - the recorded size is OK//this is not the problem waveInUnprepareHeader(); waveInPrepareHeader(); waveInAddHeader(); when closing application: waveInStop(); // this is where the program hangs waveInReset(); // or here if i remove the prevoius line waveInClose(); // or here if i remove both prevoius lines I don''t get any input even though at least the first buffer seems OK. I just don''t get any input !!!!!!!!! GRRRR.... I can not figure it out - have I missed something !

Share this post


Link to post
Share on other sites
Advertisement

Hi
That API is waveInAddBuffer.

For your problem click on the speaker on the tray (mixer settings) and check that you have selected the MIC as recording
device.
Be careful that when you call waveInReset it will generate another WIM_DATA message which may mess up things. I usually
call only the waveInReset not waveInStop coz this way you
get only one WIM_DATA message.
(this is a very serious problem, coz when you call waveInStop
you suppose that you won''t get any more WIM_DATA messages, but
after calling waveInReset there maybe some code which hangs your
system while processing the messages. Most common case is that :
in your message processing code when you get WIM_DATA you call
the waveInReset which will generate another WIM_DATA and so on,
there will be an infinite loop which hangs up your progy

--MFC (The Matrix Foundation Crew)



Share this post


Link to post
Share on other sites
I need the same kind of help too, just to play
something simple under Windows and I haven''t
even gotten as far to understand what you did.

Could you explain what you did in detail? I''d
really appreciate that!

Share this post


Link to post
Share on other sites
THANK YOU Seyedof for your answer - I really appreciate it. I will need to redesign some stuff in my AudioProc. So how do you deal with the waveInReset() - do you have a isDying flag or something that you check for or do you have C++ CTOR / DTOR.
- I have the class stuff, I think maybe that that is part of my problem too, (except for no girlfriend and beeing teased for my hunchback and bad english), deleting something before the buffers are done with it or something.
- thank you again.

- and to LearFox -
there is a nice ''tutorial'' sort of at www.relisoft.com - maybe you don''t have to be as rigourous as they are (I''m not) but there you can get the basic ideas and code together with a win32 API reference.... it''s where I got it (didn''t get it I suppose). They have some other pretty neat tricks too.


By the way - I''ve been thinking of how to get the ''volume'' from a audiobuffer. - how SHOULD it be done the right way. - as for now I just take the ''highest'' value as the volume - the peak - is this the way to go or should i calculate some kind of difference between highs and lows (delta) and have that as the peak - maximum energy - but that would show a low volume for low HZ - so.... ?

well - thanks again
Josef

Share this post


Link to post
Share on other sites
Hi
Ok guys, i will send my wave playback source code and reply
back with the URL to download. My code is written in C++ using
C++ Builder, but there should be no problem understanding
my code since it is pure C and i don''t use the borland''s
components that much. My progy simply plays a wave file
using windows wave device API.



--MFC (The Matrix Foundation Crew)

Share this post


Link to post
Share on other sites
I looked through the web sites that ya''ll listed, but
I''m afraid I couldn''t find any information about
sound programming on Windows on there.

Could I ask a favor please? That if any of you who''s
helped me write a short module to play a sound file?

I''m pretty fluent in the wav file format and have been
working with it for four years on UNIX however on UNIX
we have a whole set of library calls to play wav files
but on Windows the closest was sndPlaySound() but it was
too limited and didn''t offer enough features.

I''d prefer to play async and not have to read the .wav
files on my own application if that is possible.
Also can Windows do sample rate deviancing? like simulating
a car engine at different speeds?

Share this post


Link to post
Share on other sites








Hi

Download this zip file, it is my full C source code for
recording from MIC then applying a software echo effect on
the sound buffer and then playing back the result.The code is
clear and easy to read/understand.



</body>
</html>





Edited by - Seyedof on February 23, 2001 3:42:28 AM

Share this post


Link to post
Share on other sites
Thank you seyedof - I''m thrilled to have a look at the source. and to LearFox -
this is where it''s at.
http://www.relisoft.com/recorder.html

but you will need to read the previous tuts before this one - probably - if you want to understand it though, they do some win32 api wrapping, both windows and threads are wrapped inside classes, even the WinProc is sort of special. - intresting reading for anyone dealing with c++ and win32.

and thanks again seyedof, the echo almost scared me
CYA

Share this post


Link to post
Share on other sites
I''m sort of working on what you wanted LearFox, but I''m not able to work with deadlines or anything.... -
I''m not plannig on supporting all types of waveformats or anything, but when I have a working async play mixer thingie I can post here and let you know...
I WILL TAKE A WHILE THOUGH !!!!!

Share this post


Link to post
Share on other sites
Oh thank you, BOTH!

I really appreciate your help, I''ve downloaded the sample
source and I''ll review it tonight!

I''ve waited two years to write code on Windows and I have
plenty of patience. *wink*

I would really like to see a demo though, you can
e-mail me privatly at learfox ET furry.ao.net
Nothing fancy, just a few sample modules to play sound.

Preferably C (not too much C++) so I can port some UNIX games over to Windows
easier.

Thanks a bunch!

Share this post


Link to post
Share on other sites

  • Advertisement