<div>Well, I do have, and they work fine, the buzz you are hearing could be me the White noise I&#39;m hearing, since I&#39;m repeating the same sources over and over (like a loop), this can be &quot;masked&quot; as some sort of smaller white noise. What I&#39;m trying to achieve is something like this <a href="http://lab.andre-michelle.com/tonematrix">http://lab.andre-michelle.com/tonematrix</a> , it&#39;s a polyphone matrix, much like the tenory from Yamaha, now, if I&#39;m not mistaken, this is MIDI right? But I should be able to mimic something like this using Wave Sines right?<br clear="all">
</div><div><br></div><div>Any help on this (books or whatever) would be really apreciated.</div><div><br></div><div>Thanks</div><div> </div>Mateus<br><a href="http://www.geekvault.org">http://www.geekvault.org</a><br>
<br><br><div class="gmail_quote">On Mon, Jun 29, 2009 at 10:24 PM, Chris Robinson <span dir="ltr">&lt;<a href="mailto:chris.kcat@gmail.com">chris.kcat@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Monday 29 June 2009 7:37:54 am you wrote:<br>
&gt; Ok, so it&#39;s a little big, but you can see the error (on the audio output),<br>
&gt; then again, this maybe the normal behaviour when you put together 3 or more<br>
&gt; wave sines to play at the same time.<br>
<br>
</div>Hmm, it seems to work for me. I start getting a buzz after starting 2 or 3<br>
sources, but it doesn&#39;t seem to turn into white noise. Tried with both 44.1khz<br>
and 48khz output. Do you have an OpenAL Soft config set somewhere?<br>
<div><div class="h5"><br>
&gt; #include &lt;stdio.h&gt;<br>
&gt; #include &lt;stdlib.h&gt;<br>
&gt; #include &lt;string.h&gt;<br>
&gt; #include &lt;errno.h&gt;<br>
&gt; #include &lt;AL/al.h&gt;<br>
&gt; #include &lt;AL/alc.h&gt;<br>
&gt; #include &lt;AL/alut.h&gt;<br>
&gt;<br>
&gt; #define KMAX_BUFFERS 16<br>
&gt; #define KMAX_SOURCES 255<br>
&gt; #define KFREQ 440<br>
&gt; #define KPHASE 90<br>
&gt; #define KDURATION 10<br>
&gt;<br>
&gt;<br>
&gt; ALuint m_buffers[KMAX_BUFFERS];<br>
&gt; ALuint m_sources[KMAX_SOURCES];<br>
&gt;<br>
&gt; void printALError(ALenum error)<br>
&gt; {<br>
&gt;   switch(error)<br>
&gt;   {<br>
&gt;     /* ALut errors */<br>
&gt;     case ALUT_ERROR_INVALID_VALUE:        fprintf(stderr,&quot;[ERROR] (ALUT)<br>
&gt; Invalid error&quot;);break;<br>
&gt;     case ALUT_ERROR_INVALID_OPERATION:    fprintf(stderr,&quot;[ERROR] (ALUT)<br>
&gt; Invalid operation&quot;);break;<br>
&gt;     case ALUT_ERROR_OPEN_DEVICE:          fprintf(stderr,&quot;[ERROR] (ALUT)<br>
&gt; Open device&quot;);break;<br>
&gt;     case ALUT_ERROR_CREATE_CONTEXT:       fprintf(stderr,&quot;[ERROR] (ALUT)<br>
&gt; Create context&quot;);break;<br>
&gt;     case ALUT_ERROR_MAKE_CONTEXT_CURRENT: fprintf(stderr,&quot;[ERROR] (ALUT)<br>
&gt; Couldn&#39;t create context&quot;);break;<br>
&gt;     case ALUT_ERROR_NO_CURRENT_CONTEXT:   fprintf(stderr,&quot;[ERROR] (ALUT) No<br>
&gt; current context&quot;);break;<br>
&gt;     case ALUT_ERROR_AL_ERROR_ON_ENTRY:    fprintf(stderr,&quot;[ERROR] (ALUT) AL<br>
&gt; error on entry&quot;);break;<br>
&gt;     case ALUT_ERROR_ALC_ERROR_ON_ENTRY:   fprintf(stderr,&quot;[ERROR] (ALUT)<br>
&gt; ALC error on entry&quot;);break;<br>
&gt;     case ALUT_ERROR_CLOSE_DEVICE:         fprintf(stderr,&quot;[ERROR] (ALUT)<br>
&gt; Close device&quot;);break;<br>
&gt;     case ALUT_ERROR_DESTROY_CONTEXT:      fprintf(stderr,&quot;[ERROR] (ALUT)<br>
&gt; Destroy context&quot;);break;<br>
&gt;     case ALUT_ERROR_OUT_OF_MEMORY:        fprintf(stderr,&quot;[ERROR] (ALUT)<br>
&gt; Out of memory&quot;);break;<br>
&gt;     case ALUT_ERROR_INVALID_ENUM:         fprintf(stderr,&quot;[ERROR] (ALUT)<br>
&gt; Invalid enumaration&quot;);break;<br>
&gt;     case ALUT_ERROR_GEN_BUFFERS:          fprintf(stderr,&quot;[ERROR] (ALUT)<br>
&gt; Generating buffers&quot;);break;<br>
&gt;     case ALUT_ERROR_BUFFER_DATA:          fprintf(stderr,&quot;[ERROR] (ALUT)<br>
&gt; Error passing buffer data&quot;);break;<br>
&gt;     /* OpenAL Errors */<br>
&gt;     case AL_INVALID_VALUE:     fprintf(stderr,&quot;[ERROR] (OpenAL) Invalid<br>
&gt; value&quot;);break;<br>
&gt;     case AL_INVALID_ENUM:      fprintf(stderr,&quot;[ERROR] (OpenAL) Invalid<br>
&gt; enumeration&quot;);break;<br>
&gt;     case AL_INVALID_OPERATION: fprintf(stderr,&quot;[ERROR] (OpenAL) Invalid<br>
&gt; operation&quot;);break;<br>
&gt;<br>
&gt;     default: fprintf(stderr,&quot;[ERROR] Unknown error&quot;);break;<br>
&gt;   }<br>
&gt;   fprintf(stderr,&quot;\n&quot;);<br>
&gt; }<br>
&gt;<br>
&gt; ALboolean loadALData(void)<br>
&gt; {<br>
&gt;   ALenum error;<br>
&gt;   ALfloat freq = 0.0;<br>
&gt;   unsigned int i,j;<br>
&gt;   i=j=0;<br>
&gt;<br>
&gt;   #ifdef DEBUG<br>
&gt;   fprintf(stderr,&quot;[DEBUG] Creating buffers\n&quot;);<br>
&gt;   #endif<br>
&gt;<br>
&gt;   for(i = 0; i &lt; KMAX_BUFFERS; i++)<br>
&gt;   {<br>
&gt;     freq  = KFREQ*(i+1);<br>
&gt;     freq /= 2;<br>
&gt;     m_buffers[i]     =<br>
&gt; alutCreateBufferWaveform(ALUT_WAVEFORM_SINE,freq,KPHASE, KDURATION);<br>
&gt;     if(m_buffers[i] == AL_NONE)<br>
&gt;     {<br>
&gt;       printALError(alGetError());<br>
&gt;       return AL_FALSE;<br>
&gt;     }<br>
&gt;   }<br>
&gt;<br>
&gt;   #ifdef DEBUG<br>
&gt;   fprintf(stderr,&quot;[DEBUG] Creating sources\n&quot;);<br>
&gt;   #endif<br>
&gt;   //Creating sources<br>
&gt;   alGenSources((ALsizei)KMAX_SOURCES,m_sources);<br>
&gt;   if((error = alGetError()) != AL_NO_ERROR)<br>
&gt;   {<br>
&gt;     printALError(error);<br>
&gt;     return AL_FALSE;<br>
&gt;   }<br>
&gt;   for(i = 0; i &lt; KMAX_SOURCES; i++)<br>
&gt;   {<br>
&gt;     alSourcei (m_sources[i], AL_BUFFER,    m_buffers[j++]);<br>
&gt;     alSourcef (m_sources[i], AL_PITCH,     1.0);<br>
&gt;     alSourcef (m_sources[i], AL_GAIN,      1.0);<br>
&gt;     alSourcei (m_sources[i], AL_LOOPING,   AL_TRUE);<br>
&gt;     alSource3f(m_sources[i], AL_POSITION,  0, 0, 0);<br>
&gt;     alSource3f(m_sources[i], AL_VELOCITY,  0, 0, 0);<br>
&gt;     alSource3f(m_sources[i], AL_DIRECTION, 0, 0, 0);<br>
&gt;     if(j &gt;= KMAX_BUFFERS) j = 0;<br>
&gt;   }<br>
&gt;   return AL_TRUE;<br>
&gt; }<br>
&gt;<br>
&gt; ALboolean setListener(void)<br>
&gt; {<br>
&gt;   ALenum error;<br>
&gt;   ALfloat m_fListenerPos[] = {0.0, 0.0, 0.0}; //Position of the listener<br>
&gt;   ALfloat m_fListenerVel[] = {0.0, 0.0, 0.0}; //Velocity of the listener<br>
&gt;   ALfloat m_fListenerOri[] = {0.0, 0.0, -1.0, 0.0, 1.0, 0.0}; //Orientation<br>
&gt; of the listener, first 3 elements are &quot;at&quot;, second 3 are &quot;up&quot;<br>
&gt;   alListenerfv(AL_POSITION, m_fListenerPos);<br>
&gt;   alListenerfv(AL_VELOCITY, m_fListenerVel);<br>
&gt;   alListenerfv(AL_ORIENTATION, m_fListenerOri);<br>
&gt;   if((error = alGetError()) != AL_NO_ERROR)<br>
&gt;   {<br>
&gt;     printALError(error);<br>
&gt;     return AL_FALSE;<br>
&gt;   }<br>
&gt;   return AL_TRUE;<br>
&gt; }<br>
&gt;<br>
&gt; void killAllData(void)<br>
&gt; {<br>
&gt;   alDeleteBuffers(KMAX_BUFFERS,m_buffers);<br>
&gt;   alDeleteSources(KMAX_SOURCES,m_sources);<br>
&gt;   alutExit();<br>
&gt; }<br>
&gt;<br>
&gt; int main()<br>
&gt; {<br>
&gt;   ALenum error;<br>
&gt;   char ch = &#39;\0&#39;;<br>
&gt;   #ifdef DEBUG<br>
&gt;   fprintf(stderr,&quot;[DEBUG] Starting OpenAL via ALUT\n&quot;);<br>
&gt;   #endif<br>
&gt;   if(alutInit(NULL,0)!=AL_TRUE)<br>
&gt;   {<br>
&gt;     printALError(alGetError());<br>
&gt;     return 1;<br>
&gt;   }<br>
&gt;   alGetError(); /* Clearing error bit */<br>
&gt;<br>
&gt;   #ifdef DEBUG<br>
&gt;   fprintf(stderr,&quot;[DEBUG] Setting listener values\n&quot;);<br>
&gt;   #endif<br>
&gt;<br>
&gt;   if(setListener() == AL_FALSE)<br>
&gt;   {<br>
&gt;     #ifdef DEBUG<br>
&gt;     fprintf(stderr,&quot;[DEBUG] Killing all data\n&quot;);<br>
&gt;     #endif<br>
&gt;     killAllData();<br>
&gt;     return 1;<br>
&gt;   }<br>
&gt;<br>
&gt;   #ifdef DEBUG<br>
&gt;   fprintf(stderr,&quot;[DEBUG] Setting buffers and sources\n&quot;);<br>
&gt;   #endif<br>
&gt;   if(loadALData()==AL_FALSE)<br>
&gt;   {<br>
&gt;     #ifdef DEBUG<br>
&gt;     fprintf(stderr,&quot;[DEBUG] Killing all data\n&quot;);<br>
&gt;     #endif<br>
&gt;     killAllData();<br>
&gt;     return 1;<br>
&gt;   }<br>
&gt;<br>
&gt;   #ifdef DEBUG<br>
&gt;   fprintf(stderr,&quot;[DEBUG] Playing sounds\n&quot;);<br>
&gt;   #endif<br>
&gt;<br>
&gt;   while(ch!=&#39;q&#39;)<br>
&gt;   {<br>
&gt;     fprintf(stdout,&quot;Command&gt; &quot;);<br>
&gt;     fscanf(stdin,&quot;%c&quot;,&amp;ch);<br>
&gt;     switch(ch)<br>
&gt;     {<br>
&gt;       case &#39;1&#39;:<br>
&gt;       {<br>
&gt;         alSourcePlay(m_sources[1]);<br>
&gt;         if((error = alGetError()) != AL_NO_ERROR)<br>
&gt;           printALError(error);<br>
&gt;         break;<br>
&gt;       }<br>
&gt;       case &#39;2&#39;:<br>
&gt;       {<br>
&gt;         alSourcePlay(m_sources[2]);<br>
&gt;         if((error = alGetError()) != AL_NO_ERROR)<br>
&gt;           printALError(error);<br>
&gt;         break;<br>
&gt;       }<br>
&gt;       case &#39;3&#39;:<br>
&gt;       {<br>
&gt;         alSourcePlay(m_sources[3]);<br>
&gt;         if((error = alGetError()) != AL_NO_ERROR)<br>
&gt;           printALError(error);<br>
&gt;         break;<br>
&gt;       }<br>
&gt;       case &#39;4&#39;:<br>
&gt;       {<br>
&gt;         alSourcePlay(m_sources[4]);<br>
&gt;         if((error = alGetError()) != AL_NO_ERROR)<br>
&gt;           printALError(error);<br>
&gt;         break;<br>
&gt;       }<br>
&gt;       case &#39;s&#39;:<br>
&gt;       {<br>
&gt;         alSourceStopv(KMAX_SOURCES,m_sources);<br>
&gt;         if((error = alGetError()) != AL_NO_ERROR)<br>
&gt;           printALError(error);<br>
&gt;         break;<br>
&gt;       }<br>
&gt;       case &#39;q&#39;:<br>
&gt;       {<br>
&gt;         fprintf(stdout,&quot;Shutting down\n&quot;);break;<br>
&gt;       }<br>
&gt;       default: fprintf(stdout,&quot;Unknown command\n&quot;);break;<br>
&gt;     }<br>
&gt;   }<br>
&gt;<br>
&gt;   #ifdef DEBUG<br>
&gt;   fprintf(stderr,&quot;[DEBUG] Killing all data\n&quot;);<br>
&gt;   #endif<br>
&gt;   killAllData();<br>
&gt;<br>
&gt;   return 0;<br>
&gt; }<br>
<br>
</div></div><div><div class="h5">_______________________________________________<br>
Openal mailing list<br>
<a href="mailto:Openal@opensource.creative.com">Openal@opensource.creative.com</a><br>
<a href="http://opensource.creative.com/mailman/listinfo/openal" target="_blank">http://opensource.creative.com/mailman/listinfo/openal</a><br>
</div></div></blockquote></div><br>