Thread View: borland.public.cppbuilder.multimedia
6 messages
6 total messages
Started by markhatesspam
Thu, 12 May 2005 19:05
Re: wave playback headers
Author: markhatesspam
Date: Thu, 12 May 2005 19:05
Date: Thu, 12 May 2005 19:05
31 lines
1704 bytes
1704 bytes
I assume you open the wave out device with something like this :-
HWAVEOUT phwo; WAVEFORMATEX wvfx;
MMRESULT wh;
wh=waveOutOpen(&phwo,WAVE_MAPPER,&wvfx,(DWORD)WaveOutProc,(DWORD)this,CALLBACK_FUNCTION);
When you are processing and playing back your wave headers, you must set a bool as follows :-
In your TForm1 declaration in the public section, put bool sounding;
In your code for processing the buffers, put at the top sounding=true;
In your code for processing the buffers, put at the bottom sounding=false;
Change the routine I gave you to this :-
//---------------------------------------------------------------------------
void CALLBACK WaveOutProc(HWAVEOUT waveOut,UINT uMsg,DWORD dwInstance,DWORD
dwParam1,DWORD dwParam2)
{
if (dwParam1==0 || Form1->sounding) return;
WAVEHDR *mh=(WAVEHDR *)dwParam1;
if (uMsg==MM_WOM_DONE)
{
waveOutUnprepareHeader(waveOut,mh,sizeof(WAVEHDR));
mh->dwFlags=WHDR_DONE;
}
}
HTH
Mark Jacobs
Re: wave playback headers
Author: Jonathan Benedicto
Date: Thu, 12 May 2005 19:21
Date: Thu, 12 May 2005 19:21
35 lines
1981 bytes
1981 bytes
<markhatesspam@spamcatch.com> wrote in message
news:4283a8dc@newsgroups.borland.com...
>
> I assume you open the wave out device with something like this :-
>
I do, like this:
MMRESULT mmr;
WAVEFORMATEX wfx;
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = (WORD)channels;
wfx.nSamplesPerSec = (DWORD)frequency;
wfx.wBitsPerSample = (WORD)sample_size;
wfx.nBlockAlign = (WORD)((wfx.nChannels * wfx.wBitsPerSample) / 8);
wfx.nAvgBytesPerSec = (DWORD)(wfx.nSamplesPerSec * wfx.nBlockAlign);
wfx.cbSize = 0;
mmr = waveOutOpen(PHWaveOut, WAVE_MAPPER, &wfx,
VComMMThread->ThreadID, 0, CALLBACK_THREAD);
if(mmr != MMSYSERR_NOERROR)
throw Exception("waveOutOpen failed");
> When you are processing and playing back your wave headers, you must
> set a bool as follows :-
I do have that, called IsPlaybackStarted.
> Change the routine I gave you to this :-
I didn't have the line 'mh->dwFlags=WHDR_DONE' in my code, but even
when I added it, it didn't help.
Jonathan
Re: wave playback headers
Author: Mark Jacobs
Date: Fri, 13 May 2005 08:41
Date: Fri, 13 May 2005 08:41
9 lines
1486 bytes
1486 bytes
Jonathan Benedicto wrote: > I didn't have the line 'mh->dwFlags=WHDR_DONE' in my code, but even > when I added it, it didn't help. I am at a loss at to to why you're getting clicks. The only difference is that you use CALLBACK_THREAD and I use CALLBACK_PROCEDURE. Weird. -- Mark Jacobs http://www.dkcomputing.co.uk
Re: wave playback headers
Author: Jonathan Benedicto
Date: Fri, 13 May 2005 19:45
Date: Fri, 13 May 2005 19:45
44 lines
2023 bytes
2023 bytes
"Mark Jacobs" <http://www.jacobsm.com/mjmsg.htm?mj@critical> wrote in
message news:42846822$1@newsgroups.borland.com...
>
> I am at a loss at to to why you're getting clicks. The only
> difference is that you use CALLBACK_THREAD and I use
> CALLBACK_PROCEDURE. Weird.
Thank you for trying. I just tested it again, and when I use this
code:
for(i=0;i<PlaybackHeaderCount;++i)
{
WaveHeader = PlaybackHeaders[i];
if(WaveHeader->dwFlags == WHDR_DONE)
{
WaveHeader->dwFlags = 0;
break;
}
}
if(WaveHeader->dwFlags != WHDR_DONE)
{
WaveHeader = new WAVEHDR;
WaveHeader->lpData = new char[8192];
WaveHeader->dwFlags = 0;
PlaybackHeaders.push_back(WaveHeader);
}
Instead of just:
WaveHeader = new WAVEHDR;
WaveHeader->lpData = new char[8192];
WaveHeader->dwFlags = 0;
I get those clicks.
However, in the MM_WOM_DONE message, with the lower code, I have this
code after the waveOutUnprepareHeader.
delete[] WaveHeader->lpData;
delete WaveHeader;
Jonathan
Re: wave playback headers
Author: Jonathan Benedicto
Date: Fri, 13 May 2005 20:04
Date: Fri, 13 May 2005 20:04
22 lines
1511 bytes
1511 bytes
"Jonathan Benedicto" <incorrect@no.server> wrote in message
news:428503d8$1@newsgroups.borland.com...
>
> Thank you for trying. I just tested it again, and when I use this
> code:
Sorry, that should be:
for(i=0;i<PlaybackHeaderCount;++i)
{
WaveHeader = PlaybackHeaders[i];
if(WaveHeader->dwFlags == WHDR_DONE)
break;
}
if(WaveHeader->dwFlags != WHDR_DONE)
{
WaveHeader = new WAVEHDR;
WaveHeader->lpData = new char[8192];
PlaybackHeaders.push_back(WaveHeader);
}
Re: wave playback headers
Author: Jonathan Benedicto
Date: Fri, 13 May 2005 20:40
Date: Fri, 13 May 2005 20:40
11 lines
1376 bytes
1376 bytes
"Mark Jacobs" <http://www.jacobsm.com/mjmsg.htm?mj@critical> wrote in message news:42846822$1@newsgroups.borland.com... > > I am at a loss at to to why you're getting clicks. The only > difference is that you use CALLBACK_THREAD and I use > CALLBACK_PROCEDURE. Weird. More info. The click aren't coming every buffer it seems, rather every third or fourth. Jonathan
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads