<?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[Hilfe! Thread und Aufnehmen von Sound]]></title><description><![CDATA[<p>Ich möchte Sound aufnehmen, dafür aber nicht meine ganze Anwendung<br />
blockieren. Also dachte ich an einen Thread. Den habe ich auch angelegt<br />
und darin dann versucht die Aufnahme zu starten.</p>
<p>Aber irgendwie wird dann nicht richtig aufgenommen. Da wohl immer<br />
wieder die vorherige Aufnahme überschrieben wird.</p>
<p>Ich bin absolut ahnungslos wie ich das noch anstellen könnte.<br />
Ich habe mich an diesem Code orientiert:</p>
<pre><code class="language-cpp">DWORD CMyRecordDlg::RecordWAVEFile(DWORD dwMilliSeconds)
{
    UINT wDeviceID;
    DWORD dwReturn;
    MCI_OPEN_PARMS mciOpenParms;
    MCI_RECORD_PARMS mciRecordParms;
    MCI_SAVE_PARMS mciSaveParms;
    MCI_PLAY_PARMS mciPlayParms;

    // Open a waveform-audio device with a new file for recording.
    mciOpenParms.lpstrDeviceType = &quot;waveaudio&quot;;
    mciOpenParms.lpstrElementName = &quot;&quot;;
    if (dwReturn = mciSendCommand(0, MCI_OPEN,
        MCI_OPEN_ELEMENT | MCI_OPEN_TYPE, 
        (DWORD)(LPVOID) &amp;mciOpenParms))
    {
        // Failed to open device; don't close it, just return error.
        return (dwReturn);
    }

    // The device opened successfully; get the device ID.
    wDeviceID = mciOpenParms.wDeviceID;

    // Begin recording and record for the specified number of 
    // milliseconds. Wait for recording to complete before continuing. 
    // Assume the default time format for the waveform-audio device 
    // (milliseconds).
    mciRecordParms.dwTo = dwMilliSeconds;
    if (dwReturn = mciSendCommand(wDeviceID, MCI_RECORD, 
        MCI_TO | MCI_WAIT, (DWORD)(LPVOID) &amp;mciRecordParms))
    {
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
        return (dwReturn);
    }

    // Play the recording and query user to save the file.
    mciPlayParms.dwFrom = 0L;
    if (dwReturn = mciSendCommand(wDeviceID, MCI_PLAY,
        MCI_FROM | MCI_WAIT, (DWORD)(LPVOID) &amp;mciPlayParms))
    {
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
        return (dwReturn);
    }
    if (MessageBox(&quot;Do you want to save this recording?&quot;,
        &quot;&quot;, MB_YESNO) == IDNO)
    {
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
        return (0L);
    }

    // Save the recording to a file named TEMPFILE.WAV. Wait for
    // the operation to complete before continuing.
    mciSaveParms.lpfilename = &quot;tempfile.wav&quot;;
    if (dwReturn = mciSendCommand(wDeviceID, MCI_SAVE,
        MCI_SAVE_FILE | MCI_WAIT, (DWORD)(LPVOID) &amp;mciSaveParms))
    {
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
        return (dwReturn);
    }

    return (0L);

}
</code></pre>
<p>Das ganze habe ich zerpflückt und in meiner vom Thread aufgerufenen Funktion<br />
dann dies übernommen um die Aufnahme zu starten:</p>
<pre><code class="language-cpp">if(isnotjetstarted)
{
 if (dwReturn = mciSendCommand(wDeviceID, MCI_RECORD, 
        MCI_TO | MCI_WAIT, (DWORD)(LPVOID) &amp;mciRecordParms))
    {
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
    }
}
</code></pre>
<p>Die Datei ist immer 44Byte groß <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
Ich bin zwar blutiger Neuling, würde mich aber freuen wenn mir jemand<br />
erklären könnte was ich falsch mache <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/134391/hilfe-thread-und-aufnehmen-von-sound</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Jul 2026 21:59:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/134391.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 25 Jan 2006 17:29:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hilfe! Thread und Aufnehmen von Sound on Wed, 25 Jan 2006 17:29:51 GMT]]></title><description><![CDATA[<p>Ich möchte Sound aufnehmen, dafür aber nicht meine ganze Anwendung<br />
blockieren. Also dachte ich an einen Thread. Den habe ich auch angelegt<br />
und darin dann versucht die Aufnahme zu starten.</p>
<p>Aber irgendwie wird dann nicht richtig aufgenommen. Da wohl immer<br />
wieder die vorherige Aufnahme überschrieben wird.</p>
<p>Ich bin absolut ahnungslos wie ich das noch anstellen könnte.<br />
Ich habe mich an diesem Code orientiert:</p>
<pre><code class="language-cpp">DWORD CMyRecordDlg::RecordWAVEFile(DWORD dwMilliSeconds)
{
    UINT wDeviceID;
    DWORD dwReturn;
    MCI_OPEN_PARMS mciOpenParms;
    MCI_RECORD_PARMS mciRecordParms;
    MCI_SAVE_PARMS mciSaveParms;
    MCI_PLAY_PARMS mciPlayParms;

    // Open a waveform-audio device with a new file for recording.
    mciOpenParms.lpstrDeviceType = &quot;waveaudio&quot;;
    mciOpenParms.lpstrElementName = &quot;&quot;;
    if (dwReturn = mciSendCommand(0, MCI_OPEN,
        MCI_OPEN_ELEMENT | MCI_OPEN_TYPE, 
        (DWORD)(LPVOID) &amp;mciOpenParms))
    {
        // Failed to open device; don't close it, just return error.
        return (dwReturn);
    }

    // The device opened successfully; get the device ID.
    wDeviceID = mciOpenParms.wDeviceID;

    // Begin recording and record for the specified number of 
    // milliseconds. Wait for recording to complete before continuing. 
    // Assume the default time format for the waveform-audio device 
    // (milliseconds).
    mciRecordParms.dwTo = dwMilliSeconds;
    if (dwReturn = mciSendCommand(wDeviceID, MCI_RECORD, 
        MCI_TO | MCI_WAIT, (DWORD)(LPVOID) &amp;mciRecordParms))
    {
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
        return (dwReturn);
    }

    // Play the recording and query user to save the file.
    mciPlayParms.dwFrom = 0L;
    if (dwReturn = mciSendCommand(wDeviceID, MCI_PLAY,
        MCI_FROM | MCI_WAIT, (DWORD)(LPVOID) &amp;mciPlayParms))
    {
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
        return (dwReturn);
    }
    if (MessageBox(&quot;Do you want to save this recording?&quot;,
        &quot;&quot;, MB_YESNO) == IDNO)
    {
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
        return (0L);
    }

    // Save the recording to a file named TEMPFILE.WAV. Wait for
    // the operation to complete before continuing.
    mciSaveParms.lpfilename = &quot;tempfile.wav&quot;;
    if (dwReturn = mciSendCommand(wDeviceID, MCI_SAVE,
        MCI_SAVE_FILE | MCI_WAIT, (DWORD)(LPVOID) &amp;mciSaveParms))
    {
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
        return (dwReturn);
    }

    return (0L);

}
</code></pre>
<p>Das ganze habe ich zerpflückt und in meiner vom Thread aufgerufenen Funktion<br />
dann dies übernommen um die Aufnahme zu starten:</p>
<pre><code class="language-cpp">if(isnotjetstarted)
{
 if (dwReturn = mciSendCommand(wDeviceID, MCI_RECORD, 
        MCI_TO | MCI_WAIT, (DWORD)(LPVOID) &amp;mciRecordParms))
    {
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
    }
}
</code></pre>
<p>Die Datei ist immer 44Byte groß <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
Ich bin zwar blutiger Neuling, würde mich aber freuen wenn mir jemand<br />
erklären könnte was ich falsch mache <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/976209</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976209</guid><dc:creator><![CDATA[Isella]]></dc:creator><pubDate>Wed, 25 Jan 2006 17:29:51 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe! Thread und Aufnehmen von Sound on Wed, 25 Jan 2006 20:16:58 GMT]]></title><description><![CDATA[<p>Hat denn niemand von euch eine kleine Hilfe dazu für mich?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/976361</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976361</guid><dc:creator><![CDATA[Isella]]></dc:creator><pubDate>Wed, 25 Jan 2006 20:16:58 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe! Thread und Aufnehmen von Sound on Wed, 25 Jan 2006 20:40:34 GMT]]></title><description><![CDATA[<p>Isella schrieb:</p>
<blockquote>
<p>Aber irgendwie wird dann nicht richtig aufgenommen.</p>
</blockquote>
<p>Ich deute jetzt mal daraus dass es vorher, ohne Threads funktioniert hat, oder?</p>
<p>mfg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/976388</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976388</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Wed, 25 Jan 2006 20:40:34 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe! Thread und Aufnehmen von Sound on Wed, 25 Jan 2006 21:07:05 GMT]]></title><description><![CDATA[<p>Ja ohne Thread geht es. Allerdings ist dann ja die ganze Anwendung für<br />
die Dauer der Aufnahme blockiert. Und ich will ja auch unbegrenzt aufnehmen<br />
können und nicht vorab die Millisekunden angeben müssen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/976400</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976400</guid><dc:creator><![CDATA[Isella]]></dc:creator><pubDate>Wed, 25 Jan 2006 21:07:05 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe! Thread und Aufnehmen von Sound on Thu, 26 Jan 2006 08:38:19 GMT]]></title><description><![CDATA[<p>Also ich wäre natürlich auch an einer alternativen Lösung interessiert<br />
um Sound aufnehmen zu können, ohne die ganze Anwendung lahmlegen zu müssen.<br />
Ich finde nur keine <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/976582</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976582</guid><dc:creator><![CDATA[Isella]]></dc:creator><pubDate>Thu, 26 Jan 2006 08:38:19 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe! Thread und Aufnehmen von Sound on Thu, 26 Jan 2006 18:54:44 GMT]]></title><description><![CDATA[<p>Dann gehts wohl nicht weiter. *snief* =|:`-(</p>
]]></description><link>https://www.c-plusplus.net/forum/post/977229</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/977229</guid><dc:creator><![CDATA[Isella]]></dc:creator><pubDate>Thu, 26 Jan 2006 18:54:44 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe! Thread und Aufnehmen von Sound on Thu, 26 Jan 2006 19:40:20 GMT]]></title><description><![CDATA[<p>Wie genau sieht deine Thread Funktion aus?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/977289</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/977289</guid><dc:creator><![CDATA[qasdfgh]]></dc:creator><pubDate>Thu, 26 Jan 2006 19:40:20 GMT</pubDate></item></channel></rss>