Can you provide me an example of using WaveOutOpen multimedia api using CALLBACK_THREAD option in the main thread like you have given for Signal Spectrum display using CALLBACK_WINDOW.
dear jsvenu:
Why do you have so many questions?
ha ha!
Do not know what you are mainly engaged in work, the main development of what tools?
Dear xiaoyao,
I have idea of how to do this in unmanaged vc++ 6.0 win32 and MFC apps because they support message loop ,threading(including worker and user interface threads) directly.I wanted to do the same using vb6 by taking help from members of vbforums like Trick .I already tried and having some problems as you can see in http://www.vbforums.com/showthread.p...ignal-spectrum.
regards,
JSVenu
Last edited by jsvenu; Feb 22nd, 2020 at 03:27 AM.
I tried to extend the app to form based app and put two buttons Play and display msgbox.
I made form as startup and call Main in Play button1 handler and display msgbox in display msgbox (button2) handler as follows:
Code:
Private Sub Command1_Click()
Main
End Sub
Private Sub Command2_Click()
MsgBox "in btn2" 'the playing sound stops when msgbox displayed
End Sub
I increased the play duration upto 1000 secs so that I can try to display msgbox when I play it by clicking on display msgbox (button2) as follows:
Code:
Loop While m_fPlayedSec < 1000
When I click Play button the sound starts playing and then when I click on display msgbox (button2) we get msgbox displayed but the audio stops immediately.
How to make the audio continue even when we click on display msgbox (button2) and terminate the application properly.
maybe you need play music in thread 2。
click button to play,stop。
when playing,if you click button about "msgbox now",music will play in background,It won't be interrupted Stop.
You can't show a modal box because it has it's own modal loop which doesn't know about your MM_WOM_DONE messages and just skips it.
Dear Trick,
But your signal spectrum which you are displaying using subclassing and CALLBACK_WINDOW continues playing audio even when I click on the new button1 handler to display a msgbox after clicking the play button which you can check in the attachment.
I was asking for same using CALLBACK_THREAD option in waveoutopen api. Please clarify.
When you use the CALLBACK_WINDOW method DispatchMessage sends the message to the WindowProc.
Dear Trick,
With CALLBACK_THREAD option in WaveOutOpen api can we call DispatchMessage using SetWindowsHookEx and WH_GETMESSAGE and in the callbackgetmsgproc friend function (main Form member function) so that DispatchMessage sends the message to the WindowProc in the sample link below which I already posted so that audio continues without stopping. http://www.vbforums.com/attachment.p...9&d=1582277698
regards,
JSVenu
Last edited by jsvenu; Feb 23rd, 2020 at 06:54 AM.
With CALLBACK_THREAD option in WaveOutOpen api can we call DispatchMessage using SetWindowsHookEx and WH_GETMESSAGE and in the callbackgetmsgproc friend function (main Form member function) so that DispatchMessage sends the message to the WindowProc in the sample link below which I already posted so that audio continues without stopping. http://www.vbforums.com/attachment.p...9&d=1582277698
regards,
JSVenu
Dear Trick,
I found the problem is with acquiring data and displaying it on the form when we hook main thread msg pump.
In the callbackgetmsgproc function which is the hook function for main thread msg pump for receiving MM_WOM_DONE event when we use waveoutopen with CALLBACK_THREAD and SetWindowshookex with WH_GETMESSAGE we will be receiving the MM_WOM_DONE when this playing is going on pressing Play button and even when we click on button1 handler which displays msgbox.
I had to modify the program by commenting acquiring data and displaying it on the form in the callbackgetmsgproc.
Now we get the same audio acquired in first sample only and it is written and played continuously.
Can you tell me how to make the program work as usual using this method of CALLBACK_THREAD in waveoutopen api.
I am attaching the working code with this limitation which plays audio in main thread even with msgbox displayed.Please clarify.
Why hooks? I don't understand you. I gave you the 2 codes with CALLBACK_THREAD and CALLBACK_WINDOW. What's your end goal?
Dear Trick,
The code you gave using CALLBACK_THREAD does not route MM_WOM_DONE to the default msg pump when we try to display msgbox while playing.So like you used subclassing I had to use WH_GETMESSAGE hook which is used to get default message loop and route MM_WOM_DONE to it even when a msgbox is displayed while playing just like using subclassing with CALLBACK_WINDOW.In addition to this updating audio buffer and displaying has to be updated in this sample code with linkhttp://www.vbforums.com/attachment.p...3&d=1582473415 like in the code you provided using CALLBACK_WINDOW.
Using CALLBACK_THREAD I only know WH_GETMESSAGE hook to get default msg pump and catch MM_WOM_DONE while displaying msgbox and I have difficulty in acquiring audio data and updating display.If you know any other way to tackle msg pump you can help me as you already helped using subclassing and CALLBACK_WINDOW for which I am thankful to you.
regards,
JSVenu
Last edited by jsvenu; Feb 24th, 2020 at 05:55 AM.
If you need a message box just use CALLBACK_WINDOW.
Dear Trick,
Ok I agree that here subclassing using CALLBACK_WINDOW is better than hooking with CALLBACK_THREAD in this example of playing audio and spectrum display.
Suppose we start say 10 threads each of which have lot of processing loops when we click on command1 button
instead of displaying a msgbox.
1. Can you tell me how to maintain the same quality of audio and spectrum display continuously for the main thread when the 10 threads are started by clicking on command1 button after clicking on play button.
How to make the main thread behave like it was behaving before without the 10 threads started.
2.When we stop or pause play how to make the other threads work as they work without clicking on play button.
Code attached.
regards,
JSVenu
Last edited by jsvenu; Feb 24th, 2020 at 08:06 AM.
Can you tell me how to maintain the same quality of audio and spectrum display continuously for the main thread when the 10 threads are started by clicking on command1 button after clicking on play button.
How to make the main thread behave like it was behaving before without the 10 threads started.
This is obliviously you shouldn't overload the thread which plays the audio. Alternatively you could use CALLBAC_FUNCTION mechanism but it isn't trivial.
This is obliviously you shouldn't overload the thread which plays the audio. Alternatively you could use CALLBAC_FUNCTION mechanism but it isn't trivial.
Dear Trick,
Thankyou for the reply.
In the main thread I will be playing audio.My intention is not to miss any MM_WOM_DONE event in main thread inspite of having other threads in an application which is generally the case in any practical situation so that loss of audio continuity won't be there.Please clarify.
Thankyou for the reply.
In the main thread I will be playing audio.My intention is not to miss any MM_WOM_DONE event in main thread inspite of having other threads in an application which is generally the case in any practical situation so that loss of audio continuity won't be there.Please clarify.
Just increase the buffer size and you'll have more time to process the message.