<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Sampledaten Buffern]]></title><description><![CDATA[<p>Hallo!<br />
Also ich hab folgendes problem, ich muss die sampledaten die übers mikro reinkommen buffern. Ich lese die sampledaten mit DirectSound ein:</p>
<pre><code class="language-cpp">HRESULT CreateCaptureBuffer(LPDIRECTSOUNDCAPTURE8 pDSC,  
                            LPDIRECTSOUNDCAPTUREBUFFER8* ppDSCB8) 
{ 
 HRESULT hr; 
DSCBUFFERDESC dscbd;
LPDIRECTSOUNDCAPTUREBUFFER  pDSCB;
WAVEFORMATEX wfx = {WAVE_FORMAT_PCM, 1, 44100, 176400/2, 2, 16, 0}; 

// wFormatTag, nChannels, nSamplesPerSec, mAvgBytesPerSec, 
// nBlockAlign, wBitsPerSample, cbSize 

if ((NULL == pDSC) || (NULL == ppDSCB8))
{
return E_INVALIDARG;
}
dscbd.dwSize = sizeof(DSCBUFFERDESC); 
dscbd.dwFlags = 0; 
dscbd.dwBufferBytes =Buffersize; //wfx.nAvgBytesPerSec * 10; 
dscbd.dwReserved = 0; 
dscbd.lpwfxFormat = &amp;wfx; 
dscbd.dwFXCount = 0; 
dscbd.lpDSCFXDesc = NULL; 

if (SUCCEEDED(hr = pDSC-&gt;CreateCaptureBuffer(&amp;dscbd, &amp;pDSCB, NULL))) 
{ 
hr = pDSCB-&gt;QueryInterface(IID_IDirectSoundCaptureBuffer8, 
(LPVOID*)ppDSCB8);
if(IsCapturing(lpCaptureBuffer)==FALSE)
{
} 
pDSCB-&gt;Release(); 
} 
MessageBox(NULL,&quot;Ende&quot;,NULL,MB_OK);
return hr; 
 }

bool IsCapturing(LPDIRECTSOUNDCAPTUREBUFFER8 lpCB) 
{ 
        DWORD dwStatus = 0; 
        lpCB-&gt;GetStatus(&amp;dwStatus); 
        if( ((dwStatus &amp; DSCBSTATUS_CAPTURING) == DSCBSTATUS_CAPTURING)  || 
            ((dwStatus &amp; DSCBSTATUS_LOOPING) == DSCBSTATUS_LOOPING)     ) 
              return true; 
        return false; 
} 

void InitDirectSound(void) 
{ 
        DirectSoundCaptureCreate8(NULL, &amp;lpCaptureDevice, NULL); 
        CreateCaptureBuffer(lpCaptureDevice, &amp;lpCaptureBuffer); 
} 

DWORD GetCaptureBufferSize(LPDIRECTSOUNDCAPTUREBUFFER8 lpCB) 
{ 
        DSCBCAPS Caps; 
        Caps.dwSize = sizeof(Caps); 
       lpCB-&gt;GetCaps(&amp;Caps); 

       return Caps.dwBufferBytes; 
} 

void ShutdownDirectSound(void) 
{ 
      if(lpCaptureBuffer!=NULL) 
            lpCaptureBuffer-&gt;Release(); 
      if(lpCaptureDevice!=NULL) 
            lpCaptureDevice-&gt;Release(); 
}
</code></pre>
<p>Also ich hab mir schonmal überlegt die ganze zeit in nem thread abzufragen ob IsCapturing==FALSE is. mein Thread sieht so aus:</p>
<pre><code class="language-cpp">void Thread(PVOID pvoid)
{
if(IsCapturing(lpCaptureBuffer)==FALSE)
{
      lpCaptureBuffer-&gt;Lock(0, Buffersize/2, &amp;SoundData1, &amp;dwSoundDataSize1, 
                              &amp;SoundData2, &amp;dwSoundDataSize2, 0); 
      memcpy(Array, SoundData1, Buffersize/2); 
    lpCaptureBuffer-&gt;Unlock(SoundData1, dwSoundDataSize1, SoundData2, 
                     dwSoundDataSize2); 
	MessageBox(NULL, &quot;fertig mit aufnehmen&quot;,&quot;&quot;, MB_OK); 

}
if(IsCapturing(lpCaptureBuffer)==TRUE)
{MessageBox(NULL, &quot;nimmt noch auf&quot;,&quot;&quot;, MB_OK);
}
}
</code></pre>
<p>ich starte den Thread mit</p>
<pre><code class="language-cpp">_beginthread(Thread,0,NULL);
</code></pre>
<p>Aber irgendwie wird der thread nur einmal aufgerufen und danach nicht mehr was mach ich denn falsch??? Is die Sache mit dem thread überhaupt schnellgenug für FFT?</p>
<p>Danke</p>
<p>MFG</p>
<p>Hansi</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/144845/sampledaten-buffern</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Jul 2026 05:25:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/144845.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 22 Apr 2006 13:09:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Sampledaten Buffern on Sat, 22 Apr 2006 13:11:08 GMT]]></title><description><![CDATA[<p>Hallo!<br />
Also ich hab folgendes problem, ich muss die sampledaten die übers mikro reinkommen buffern. Ich lese die sampledaten mit DirectSound ein:</p>
<pre><code class="language-cpp">HRESULT CreateCaptureBuffer(LPDIRECTSOUNDCAPTURE8 pDSC,  
                            LPDIRECTSOUNDCAPTUREBUFFER8* ppDSCB8) 
{ 
 HRESULT hr; 
DSCBUFFERDESC dscbd;
LPDIRECTSOUNDCAPTUREBUFFER  pDSCB;
WAVEFORMATEX wfx = {WAVE_FORMAT_PCM, 1, 44100, 176400/2, 2, 16, 0}; 

// wFormatTag, nChannels, nSamplesPerSec, mAvgBytesPerSec, 
// nBlockAlign, wBitsPerSample, cbSize 

if ((NULL == pDSC) || (NULL == ppDSCB8))
{
return E_INVALIDARG;
}
dscbd.dwSize = sizeof(DSCBUFFERDESC); 
dscbd.dwFlags = 0; 
dscbd.dwBufferBytes =Buffersize; //wfx.nAvgBytesPerSec * 10; 
dscbd.dwReserved = 0; 
dscbd.lpwfxFormat = &amp;wfx; 
dscbd.dwFXCount = 0; 
dscbd.lpDSCFXDesc = NULL; 

if (SUCCEEDED(hr = pDSC-&gt;CreateCaptureBuffer(&amp;dscbd, &amp;pDSCB, NULL))) 
{ 
hr = pDSCB-&gt;QueryInterface(IID_IDirectSoundCaptureBuffer8, 
(LPVOID*)ppDSCB8);
if(IsCapturing(lpCaptureBuffer)==FALSE)
{
} 
pDSCB-&gt;Release(); 
} 
MessageBox(NULL,&quot;Ende&quot;,NULL,MB_OK);
return hr; 
 }

bool IsCapturing(LPDIRECTSOUNDCAPTUREBUFFER8 lpCB) 
{ 
        DWORD dwStatus = 0; 
        lpCB-&gt;GetStatus(&amp;dwStatus); 
        if( ((dwStatus &amp; DSCBSTATUS_CAPTURING) == DSCBSTATUS_CAPTURING)  || 
            ((dwStatus &amp; DSCBSTATUS_LOOPING) == DSCBSTATUS_LOOPING)     ) 
              return true; 
        return false; 
} 

void InitDirectSound(void) 
{ 
        DirectSoundCaptureCreate8(NULL, &amp;lpCaptureDevice, NULL); 
        CreateCaptureBuffer(lpCaptureDevice, &amp;lpCaptureBuffer); 
} 

DWORD GetCaptureBufferSize(LPDIRECTSOUNDCAPTUREBUFFER8 lpCB) 
{ 
        DSCBCAPS Caps; 
        Caps.dwSize = sizeof(Caps); 
       lpCB-&gt;GetCaps(&amp;Caps); 

       return Caps.dwBufferBytes; 
} 

void ShutdownDirectSound(void) 
{ 
      if(lpCaptureBuffer!=NULL) 
            lpCaptureBuffer-&gt;Release(); 
      if(lpCaptureDevice!=NULL) 
            lpCaptureDevice-&gt;Release(); 
}
</code></pre>
<p>Also ich hab mir schonmal überlegt die ganze zeit in nem thread abzufragen ob IsCapturing==FALSE is. mein Thread sieht so aus:</p>
<pre><code class="language-cpp">void Thread(PVOID pvoid)
{
if(IsCapturing(lpCaptureBuffer)==FALSE)
{
      lpCaptureBuffer-&gt;Lock(0, Buffersize/2, &amp;SoundData1, &amp;dwSoundDataSize1, 
                              &amp;SoundData2, &amp;dwSoundDataSize2, 0); 
      memcpy(Array, SoundData1, Buffersize/2); 
    lpCaptureBuffer-&gt;Unlock(SoundData1, dwSoundDataSize1, SoundData2, 
                     dwSoundDataSize2); 
	MessageBox(NULL, &quot;fertig mit aufnehmen&quot;,&quot;&quot;, MB_OK); 

}
if(IsCapturing(lpCaptureBuffer)==TRUE)
{MessageBox(NULL, &quot;nimmt noch auf&quot;,&quot;&quot;, MB_OK);
}
}
</code></pre>
<p>ich starte den Thread mit</p>
<pre><code class="language-cpp">_beginthread(Thread,0,NULL);
</code></pre>
<p>Aber irgendwie wird der thread nur einmal aufgerufen und danach nicht mehr was mach ich denn falsch??? Is die Sache mit dem thread überhaupt schnellgenug für FFT?</p>
<p>Danke</p>
<p>MFG</p>
<p>Hansi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1042558</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1042558</guid><dc:creator><![CDATA[Hansi]]></dc:creator><pubDate>Sat, 22 Apr 2006 13:11:08 GMT</pubDate></item><item><title><![CDATA[Reply to Sampledaten Buffern on Sat, 22 Apr 2006 13:17:01 GMT]]></title><description><![CDATA[<p>Wenn Du aus dem Thread rausgehst, denn beendet sich logischerweise der Thread (was soll er auch sonst tun!?).<br />
Wenn Du immer was im Thread tun willst, dann musst Du sowas wie ne Schleife da rein machen...</p>
<p>Und nicht vergessen: Zugriff auf die selben Daten von zwei Threads müssen immer synchronisiert werden, sonst geht es schief... (Critical Section) ... ach so, tust Du ja mit dem &quot;Lock/Unlock&quot;...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1042565</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1042565</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 22 Apr 2006 13:17:01 GMT</pubDate></item><item><title><![CDATA[Reply to Sampledaten Buffern on Sat, 22 Apr 2006 13:29:44 GMT]]></title><description><![CDATA[<p>alles klar, danke! hab mich schon gewundert... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> . Hab nämlich noch nie was mit threads gemacht...</p>
<p>Danke!</p>
<p>MFG</p>
<p>Hansi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1042579</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1042579</guid><dc:creator><![CDATA[Hansi]]></dc:creator><pubDate>Sat, 22 Apr 2006 13:29:44 GMT</pubDate></item><item><title><![CDATA[Reply to Sampledaten Buffern on Sun, 23 Apr 2006 23:06:44 GMT]]></title><description><![CDATA[<p>So habs hinbekommen. Es sind zwar minimale Knackser drin, aber das is kein Problem... Hätte nur nochmal ne Frage is das jetzt die schnellste Möglichkeit oder gibts noch schnellere Möglichkeiten die Sampledaten zu buffern?<br />
Würde mich mal interesieren...</p>
<p>MFG</p>
<p>Hansi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1043696</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043696</guid><dc:creator><![CDATA[Hansi]]></dc:creator><pubDate>Sun, 23 Apr 2006 23:06:44 GMT</pubDate></item><item><title><![CDATA[Reply to Sampledaten Buffern on Wed, 26 Apr 2006 20:44:21 GMT]]></title><description><![CDATA[<p>*WS_POPUP* <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1046025</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1046025</guid><dc:creator><![CDATA[Hansi]]></dc:creator><pubDate>Wed, 26 Apr 2006 20:44:21 GMT</pubDate></item></channel></rss>