<?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[wav-file erstellen]]></title><description><![CDATA[<p>Guten abend!</p>
<p>Habe folgenden Code um ein wav-file zu erstellen:</p>
<p>#include &lt;stdio.h&gt;<br />
#include &lt;windows.h&gt;<br />
#include &lt;math.h&gt;<br />
#include &lt;iostream.h&gt;<br />
#define M_PI 3.141592654</p>
<p>const int SAMPLESIZE = 36000;<br />
const int FAKTOR=200;<br />
void main(void)<br />
{</p>
<p>// Die Wavedatei</p>
<p>char ID[4];<br />
int ChunkSize;<br />
char Format[4];<br />
char Subchunk1ID[4];<br />
int Subchunk1Size;<br />
WORD AudioFormat;<br />
WORD NumChannels;<br />
int SampleRate;<br />
int ByteRate;<br />
WORD BlockAlign;<br />
WORD BitsPerSample;<br />
char Subchunk2ID[4];<br />
int Subchunk2Size;<br />
short Data[SAMPLESIZE];</p>
<p>printf(&quot;Hallo 1&quot;);</p>
<p>/// Variablen mit Daten fuellen</p>
<p>ID[0] = 'R';<br />
ID[1] = 'I';<br />
ID[2] = 'F';<br />
ID[3] = 'F';</p>
<p>ChunkSize = FAKTOR*(36 /*groeße des wave headers*/ + SAMPLESIZE*2/*sampledaten*/);</p>
<p>Format[0] = 'W';<br />
Format[1] = 'A';<br />
Format[2] = 'V';<br />
Format[3] = 'E';</p>
<p>Subchunk1ID[0] = 'f';<br />
Subchunk1ID[1] = 'm';<br />
Subchunk1ID[2] = 't';<br />
Subchunk1ID[3] = ' ';</p>
<p>Subchunk1Size = 16;<br />
AudioFormat = 1; // PCM<br />
NumChannels = 1; // MONO<br />
SampleRate = 44100;<br />
ByteRate = 44100*2;<br />
BlockAlign = 2;<br />
BitsPerSample = 16;</p>
<p>printf(&quot;Hallo 2&quot;);</p>
<p>Subchunk2ID[0] = 'd';<br />
Subchunk2ID[1] = 'a';<br />
Subchunk2ID[2] = 't';<br />
Subchunk2ID[3] = 'a';<br />
Subchunk2Size = FAKTOR*(SAMPLESIZE*2);</p>
<p>for(int x = 0; x&lt;SAMPLESIZE; x++)<br />
{<br />
<div class="plugin-markdown"><input type="checkbox" id="checkbox8053" checked="true" /><label for="checkbox8053">= sin((x/180.0f*M_PI)*4) *30000;</label></div><br />
printf(&quot;%d\n&quot;,Data[x]);<br />
}</p>
<p>printf(&quot;Hallo 4&quot;);</p>
<p>// WaveDatei speichern</p>
<p>FILE <em>file = NULL;<br />
file = fopen(&quot;sine.wav&quot;, &quot;wb&quot;);<br />
fwrite(&amp;ID, 4</em>sizeof(char), 1, file);<br />
fwrite(&amp;ChunkSize, sizeof(int), 1, file);<br />
fwrite(&amp;Format, 4<em>sizeof(char), 1, file);<br />
fwrite(&amp;Subchunk1ID, 4</em>sizeof(char), 1, file);<br />
fwrite(&amp;Subchunk1Size, sizeof(int), 1, file);<br />
fwrite(&amp;AudioFormat, sizeof(AudioFormat), 1, file);<br />
fwrite(&amp;NumChannels, sizeof(NumChannels), 1, file);<br />
fwrite(&amp;SampleRate, sizeof(int), 1, file);<br />
fwrite(&amp;ByteRate, sizeof(int), 1, file);<br />
fwrite(&amp;BlockAlign, sizeof(WORD), 1, file);<br />
fwrite(&amp;BitsPerSample, sizeof(WORD), 1, file);<br />
fwrite(&amp;Subchunk2ID, 4*sizeof(char), 1, file);<br />
fwrite(&amp;Subchunk2Size, sizeof(int), 1, file);</p>
<p>for (int i=0;i&lt;2<em>FAKTOR;i++)<br />
{<br />
fwrite(&amp;Data, 2</em>SAMPLESIZE, 1, file);<br />
}</p>
<p>fclose(file);</p>
<p>}</p>
<p>Meine Frage:</p>
<p>In der for-Schleife:<br />
for(int x = 0; x&lt;SAMPLESIZE; x++)<br />
{<br />
<div class="plugin-markdown"><input type="checkbox" id="checkbox8054" checked="true" /><label for="checkbox8054">= sin((x/180.0f*M_PI)*4) *30000;</label></div><br />
printf(&quot;%d\n&quot;,Data[x]);<br />
}</p>
<p>Moechte ich gerne die Amplitude bzw. die Frequenz dieser Sinus Schwingung festlegen!<br />
Kann mir da jemand mit dem einbinden der Formeln helfen???</p>
<p>Amplitudenmodulation:<br />
<a href="http://de.wikipedia.org/wiki/Amplitudenmodulation" rel="nofollow">http://de.wikipedia.org/wiki/Amplitudenmodulation</a></p>
<p>Frequenzmodulation:<br />
<a href="http://de.wikipedia.org/wiki/Frequenzmodulation" rel="nofollow">http://de.wikipedia.org/wiki/Frequenzmodulation</a></p>
<p>MfG</p>
<p>Spanockel</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/133041/wav-file-erstellen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 05:07:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/133041.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 14 Jan 2006 21:56:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to wav-file erstellen on Sat, 14 Jan 2006 21:56:03 GMT]]></title><description><![CDATA[<p>Guten abend!</p>
<p>Habe folgenden Code um ein wav-file zu erstellen:</p>
<p>#include &lt;stdio.h&gt;<br />
#include &lt;windows.h&gt;<br />
#include &lt;math.h&gt;<br />
#include &lt;iostream.h&gt;<br />
#define M_PI 3.141592654</p>
<p>const int SAMPLESIZE = 36000;<br />
const int FAKTOR=200;<br />
void main(void)<br />
{</p>
<p>// Die Wavedatei</p>
<p>char ID[4];<br />
int ChunkSize;<br />
char Format[4];<br />
char Subchunk1ID[4];<br />
int Subchunk1Size;<br />
WORD AudioFormat;<br />
WORD NumChannels;<br />
int SampleRate;<br />
int ByteRate;<br />
WORD BlockAlign;<br />
WORD BitsPerSample;<br />
char Subchunk2ID[4];<br />
int Subchunk2Size;<br />
short Data[SAMPLESIZE];</p>
<p>printf(&quot;Hallo 1&quot;);</p>
<p>/// Variablen mit Daten fuellen</p>
<p>ID[0] = 'R';<br />
ID[1] = 'I';<br />
ID[2] = 'F';<br />
ID[3] = 'F';</p>
<p>ChunkSize = FAKTOR*(36 /*groeße des wave headers*/ + SAMPLESIZE*2/*sampledaten*/);</p>
<p>Format[0] = 'W';<br />
Format[1] = 'A';<br />
Format[2] = 'V';<br />
Format[3] = 'E';</p>
<p>Subchunk1ID[0] = 'f';<br />
Subchunk1ID[1] = 'm';<br />
Subchunk1ID[2] = 't';<br />
Subchunk1ID[3] = ' ';</p>
<p>Subchunk1Size = 16;<br />
AudioFormat = 1; // PCM<br />
NumChannels = 1; // MONO<br />
SampleRate = 44100;<br />
ByteRate = 44100*2;<br />
BlockAlign = 2;<br />
BitsPerSample = 16;</p>
<p>printf(&quot;Hallo 2&quot;);</p>
<p>Subchunk2ID[0] = 'd';<br />
Subchunk2ID[1] = 'a';<br />
Subchunk2ID[2] = 't';<br />
Subchunk2ID[3] = 'a';<br />
Subchunk2Size = FAKTOR*(SAMPLESIZE*2);</p>
<p>for(int x = 0; x&lt;SAMPLESIZE; x++)<br />
{<br />
<div class="plugin-markdown"><input type="checkbox" id="checkbox8053" checked="true" /><label for="checkbox8053">= sin((x/180.0f*M_PI)*4) *30000;</label></div><br />
printf(&quot;%d\n&quot;,Data[x]);<br />
}</p>
<p>printf(&quot;Hallo 4&quot;);</p>
<p>// WaveDatei speichern</p>
<p>FILE <em>file = NULL;<br />
file = fopen(&quot;sine.wav&quot;, &quot;wb&quot;);<br />
fwrite(&amp;ID, 4</em>sizeof(char), 1, file);<br />
fwrite(&amp;ChunkSize, sizeof(int), 1, file);<br />
fwrite(&amp;Format, 4<em>sizeof(char), 1, file);<br />
fwrite(&amp;Subchunk1ID, 4</em>sizeof(char), 1, file);<br />
fwrite(&amp;Subchunk1Size, sizeof(int), 1, file);<br />
fwrite(&amp;AudioFormat, sizeof(AudioFormat), 1, file);<br />
fwrite(&amp;NumChannels, sizeof(NumChannels), 1, file);<br />
fwrite(&amp;SampleRate, sizeof(int), 1, file);<br />
fwrite(&amp;ByteRate, sizeof(int), 1, file);<br />
fwrite(&amp;BlockAlign, sizeof(WORD), 1, file);<br />
fwrite(&amp;BitsPerSample, sizeof(WORD), 1, file);<br />
fwrite(&amp;Subchunk2ID, 4*sizeof(char), 1, file);<br />
fwrite(&amp;Subchunk2Size, sizeof(int), 1, file);</p>
<p>for (int i=0;i&lt;2<em>FAKTOR;i++)<br />
{<br />
fwrite(&amp;Data, 2</em>SAMPLESIZE, 1, file);<br />
}</p>
<p>fclose(file);</p>
<p>}</p>
<p>Meine Frage:</p>
<p>In der for-Schleife:<br />
for(int x = 0; x&lt;SAMPLESIZE; x++)<br />
{<br />
<div class="plugin-markdown"><input type="checkbox" id="checkbox8054" checked="true" /><label for="checkbox8054">= sin((x/180.0f*M_PI)*4) *30000;</label></div><br />
printf(&quot;%d\n&quot;,Data[x]);<br />
}</p>
<p>Moechte ich gerne die Amplitude bzw. die Frequenz dieser Sinus Schwingung festlegen!<br />
Kann mir da jemand mit dem einbinden der Formeln helfen???</p>
<p>Amplitudenmodulation:<br />
<a href="http://de.wikipedia.org/wiki/Amplitudenmodulation" rel="nofollow">http://de.wikipedia.org/wiki/Amplitudenmodulation</a></p>
<p>Frequenzmodulation:<br />
<a href="http://de.wikipedia.org/wiki/Frequenzmodulation" rel="nofollow">http://de.wikipedia.org/wiki/Frequenzmodulation</a></p>
<p>MfG</p>
<p>Spanockel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/966781</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/966781</guid><dc:creator><![CDATA[spanockel]]></dc:creator><pubDate>Sat, 14 Jan 2006 21:56:03 GMT</pubDate></item><item><title><![CDATA[Reply to wav-file erstellen on Sun, 15 Jan 2006 03:40:31 GMT]]></title><description><![CDATA[<p>mmh, komm da jetzt noch net so mit was du willst, und warum postest du links zu fm und am??</p>
<p>du willst die amplitude und frequenz der schwingung festlegen?? amlitude legst du fest mit 30000 bei dir.Und frequenz ist perioden pro secunde, so kommt dann noch die samplefrequenz fs, mit ins spiel, fs gibt die punkte pro sekunde an.</p>
<p>F die freguenz die du haben willst, f/fs gibt dir wieviel punkte du fuer eine schwingungsperiode hast. 2PI/(fs/f) gibts dir das inkrement im sin fuer die Frequenz. Also fuer x=0,1,3..... Amplitude * sin( X * 2PI * Frequenz/ Samplefrequenz) ist deine Schwinung.<br />
Ich tendier meist inherhalb des Programms die frequenz immer in f/fs anzugeben, da man so soweit wie moeglich unabhaenig von der samplefrequenz arbeiten kann.</p>
<p>So, ich hoffe das hilft etwas, oder wolltest du was ganz anderes?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/966844</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/966844</guid><dc:creator><![CDATA[Flow_cplus]]></dc:creator><pubDate>Sun, 15 Jan 2006 03:40:31 GMT</pubDate></item><item><title><![CDATA[Reply to wav-file erstellen on Sun, 15 Jan 2006 12:36:45 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Danke fuer die Muehe!</p>
<p>In der Schleife:<br />
for(int x = 0; x&lt;SAMPLESIZE; x++)<br />
{<br />
<div class="plugin-markdown"><input type="checkbox" id="checkbox8055" checked="true" /><label for="checkbox8055">= sin((x/180.0f*M_PI)*4) *30000;</label></div><br />
printf(&quot;%d\n&quot;,Data[x]);<br />
}</p>
<p>-&gt;Was bedeutet das 180.0f ??</p>
<p>Ich haette da noch eine Bitte!<br />
Kannst du mir ein Beispiel bzw eine Formel fuer eine AM bzw FM nennen?</p>
<p>Vielen Dank im vorraus!</p>
<p>MfG</p>
<p>Spanockel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/966987</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/966987</guid><dc:creator><![CDATA[spanockel]]></dc:creator><pubDate>Sun, 15 Jan 2006 12:36:45 GMT</pubDate></item><item><title><![CDATA[Reply to wav-file erstellen on Sun, 15 Jan 2006 13:53:36 GMT]]></title><description><![CDATA[<p>Was das beudeutet, 180.0 is ne nummer und f steht fuer float constant?? Was ist unklar. Heisst in dem fall 180 punkte pro halbwelle, da aber hinten noch mal 4 - also 45 punkte, das heisst bei 44100 fs sind das 44100/45 hz was du hoerst.</p>
<p>AM und FM</p>
<p>AM:</p>
<p>normale formel:<br />
Amplitude * ( 1 + Modulationsindex * sin(ModulationsFrequenz * t))* Sin(traegerfrequenz * t).</p>
<p>Der Modulations index ist der grad der Modulation (spielt mit rum und lass nen graph zeichnen.) Wenn groesser als 1, dann gibts phasenspruenge im traeger. (normal 0.5-0.75 fuer technische anwendungen, grob gesagt)</p>
<p>Das f*t jeweils in x*2_pi*f/fs umbasteln damit es quasi diskret geht.<br />
Genauso auch bei fm:</p>
<p>Formel FM:<br />
Amplitude * Sin( TraegerFrequenz * t * Frequenzhub * sin(ModulationsFrequenz *t))</p>
<p>Der Hub sagt aus in welchem Frequenzbereich der Traeger morduliert wird.</p>
<p>Der hub beiflusst massiv das Spektrum der FM (-&gt; besselfunktionen),</p>
<p>Generell, wenn du das zur sound creation nimmts kann man die Waveform - hier sin - auch mit Rechteck, Saegzahn, dreick etc ... ersetzten, das gilt fuer traeger als auch fuer Modulator.</p>
<p>Gruss<br />
Flow</p>
<p>Ps: der gepostete Code ist kein C++, sollte eigentlich ins c forum, was du hier machst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/967046</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/967046</guid><dc:creator><![CDATA[Flow_cplus]]></dc:creator><pubDate>Sun, 15 Jan 2006 13:53:36 GMT</pubDate></item><item><title><![CDATA[Reply to wav-file erstellen on Wed, 28 Jan 2009 13:34:17 GMT]]></title><description><![CDATA[<p>Hallo, sorry dass ich das alte Thema wieder rauskrame aber ich verstehe nicht was das t in der FM-Formel darstellt?</p>
<blockquote>
<p>Formel FM:<br />
Amplitude * Sin( TraegerFrequenz * t * Frequenzhub * sin(ModulationsFrequenz *t))</p>
</blockquote>
<p>Was muss ich für t einsetzen damits funktioniert?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1653836</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1653836</guid><dc:creator><![CDATA[sine22]]></dc:creator><pubDate>Wed, 28 Jan 2009 13:34:17 GMT</pubDate></item><item><title><![CDATA[Reply to wav-file erstellen on Wed, 28 Jan 2009 13:47:23 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Flow_cplus schrieb:</p>
<blockquote>
<p>Formel FM:<br />
Amplitude * Sin( TraegerFrequenz * t * Frequenzhub * sin(ModulationsFrequenz *t))</p>
</blockquote>
<p>Ich meine in die Formel hat sich ein Fehler eingeschlichen. Richtig heisst es:<br />
Amplitude * sin( (TraegerFrequenz * t) + (Frequenzhub * sin(ModulationsFrequenz *t)))</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1653848</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1653848</guid><dc:creator><![CDATA[Drehleiter]]></dc:creator><pubDate>Wed, 28 Jan 2009 13:47:23 GMT</pubDate></item><item><title><![CDATA[Reply to wav-file erstellen on Wed, 28 Jan 2009 14:42:49 GMT]]></title><description><![CDATA[<p>Aha, und wofür steht nun das t ??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1653881</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1653881</guid><dc:creator><![CDATA[sine22]]></dc:creator><pubDate>Wed, 28 Jan 2009 14:42:49 GMT</pubDate></item><item><title><![CDATA[Reply to wav-file erstellen on Wed, 28 Jan 2009 18:19:37 GMT]]></title><description><![CDATA[<p>sine22 schrieb:</p>
<blockquote>
<p>Aha, und wofür steht nun das t ??</p>
</blockquote>
<p>t = time = Zeit?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1654017</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1654017</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Wed, 28 Jan 2009 18:19:37 GMT</pubDate></item></channel></rss>