<div>Well, I do have, and they work fine, the buzz you are hearing could be me the White noise I'm hearing, since I'm repeating the same sources over and over (like a loop), this can be "masked" as some sort of smaller white noise. What I'm trying to achieve is something like this <a href="http://lab.andre-michelle.com/tonematrix">http://lab.andre-michelle.com/tonematrix</a> , it's a polyphone matrix, much like the tenory from Yamaha, now, if I'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"><<a href="mailto:chris.kcat@gmail.com">chris.kcat@gmail.com</a>></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>
> Ok, so it's a little big, but you can see the error (on the audio output),<br>
> then again, this maybe the normal behaviour when you put together 3 or more<br>
> 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'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>
> #include <stdio.h><br>
> #include <stdlib.h><br>
> #include <string.h><br>
> #include <errno.h><br>
> #include <AL/al.h><br>
> #include <AL/alc.h><br>
> #include <AL/alut.h><br>
><br>
> #define KMAX_BUFFERS 16<br>
> #define KMAX_SOURCES 255<br>
> #define KFREQ 440<br>
> #define KPHASE 90<br>
> #define KDURATION 10<br>
><br>
><br>
> ALuint m_buffers[KMAX_BUFFERS];<br>
> ALuint m_sources[KMAX_SOURCES];<br>
><br>
> void printALError(ALenum error)<br>
> {<br>
> switch(error)<br>
> {<br>
> /* ALut errors */<br>
> case ALUT_ERROR_INVALID_VALUE: fprintf(stderr,"[ERROR] (ALUT)<br>
> Invalid error");break;<br>
> case ALUT_ERROR_INVALID_OPERATION: fprintf(stderr,"[ERROR] (ALUT)<br>
> Invalid operation");break;<br>
> case ALUT_ERROR_OPEN_DEVICE: fprintf(stderr,"[ERROR] (ALUT)<br>
> Open device");break;<br>
> case ALUT_ERROR_CREATE_CONTEXT: fprintf(stderr,"[ERROR] (ALUT)<br>
> Create context");break;<br>
> case ALUT_ERROR_MAKE_CONTEXT_CURRENT: fprintf(stderr,"[ERROR] (ALUT)<br>
> Couldn't create context");break;<br>
> case ALUT_ERROR_NO_CURRENT_CONTEXT: fprintf(stderr,"[ERROR] (ALUT) No<br>
> current context");break;<br>
> case ALUT_ERROR_AL_ERROR_ON_ENTRY: fprintf(stderr,"[ERROR] (ALUT) AL<br>
> error on entry");break;<br>
> case ALUT_ERROR_ALC_ERROR_ON_ENTRY: fprintf(stderr,"[ERROR] (ALUT)<br>
> ALC error on entry");break;<br>
> case ALUT_ERROR_CLOSE_DEVICE: fprintf(stderr,"[ERROR] (ALUT)<br>
> Close device");break;<br>
> case ALUT_ERROR_DESTROY_CONTEXT: fprintf(stderr,"[ERROR] (ALUT)<br>
> Destroy context");break;<br>
> case ALUT_ERROR_OUT_OF_MEMORY: fprintf(stderr,"[ERROR] (ALUT)<br>
> Out of memory");break;<br>
> case ALUT_ERROR_INVALID_ENUM: fprintf(stderr,"[ERROR] (ALUT)<br>
> Invalid enumaration");break;<br>
> case ALUT_ERROR_GEN_BUFFERS: fprintf(stderr,"[ERROR] (ALUT)<br>
> Generating buffers");break;<br>
> case ALUT_ERROR_BUFFER_DATA: fprintf(stderr,"[ERROR] (ALUT)<br>
> Error passing buffer data");break;<br>
> /* OpenAL Errors */<br>
> case AL_INVALID_VALUE: fprintf(stderr,"[ERROR] (OpenAL) Invalid<br>
> value");break;<br>
> case AL_INVALID_ENUM: fprintf(stderr,"[ERROR] (OpenAL) Invalid<br>
> enumeration");break;<br>
> case AL_INVALID_OPERATION: fprintf(stderr,"[ERROR] (OpenAL) Invalid<br>
> operation");break;<br>
><br>
> default: fprintf(stderr,"[ERROR] Unknown error");break;<br>
> }<br>
> fprintf(stderr,"\n");<br>
> }<br>
><br>
> ALboolean loadALData(void)<br>
> {<br>
> ALenum error;<br>
> ALfloat freq = 0.0;<br>
> unsigned int i,j;<br>
> i=j=0;<br>
><br>
> #ifdef DEBUG<br>
> fprintf(stderr,"[DEBUG] Creating buffers\n");<br>
> #endif<br>
><br>
> for(i = 0; i < KMAX_BUFFERS; i++)<br>
> {<br>
> freq = KFREQ*(i+1);<br>
> freq /= 2;<br>
> m_buffers[i] =<br>
> alutCreateBufferWaveform(ALUT_WAVEFORM_SINE,freq,KPHASE, KDURATION);<br>
> if(m_buffers[i] == AL_NONE)<br>
> {<br>
> printALError(alGetError());<br>
> return AL_FALSE;<br>
> }<br>
> }<br>
><br>
> #ifdef DEBUG<br>
> fprintf(stderr,"[DEBUG] Creating sources\n");<br>
> #endif<br>
> //Creating sources<br>
> alGenSources((ALsizei)KMAX_SOURCES,m_sources);<br>
> if((error = alGetError()) != AL_NO_ERROR)<br>
> {<br>
> printALError(error);<br>
> return AL_FALSE;<br>
> }<br>
> for(i = 0; i < KMAX_SOURCES; i++)<br>
> {<br>
> alSourcei (m_sources[i], AL_BUFFER, m_buffers[j++]);<br>
> alSourcef (m_sources[i], AL_PITCH, 1.0);<br>
> alSourcef (m_sources[i], AL_GAIN, 1.0);<br>
> alSourcei (m_sources[i], AL_LOOPING, AL_TRUE);<br>
> alSource3f(m_sources[i], AL_POSITION, 0, 0, 0);<br>
> alSource3f(m_sources[i], AL_VELOCITY, 0, 0, 0);<br>
> alSource3f(m_sources[i], AL_DIRECTION, 0, 0, 0);<br>
> if(j >= KMAX_BUFFERS) j = 0;<br>
> }<br>
> return AL_TRUE;<br>
> }<br>
><br>
> ALboolean setListener(void)<br>
> {<br>
> ALenum error;<br>
> ALfloat m_fListenerPos[] = {0.0, 0.0, 0.0}; //Position of the listener<br>
> ALfloat m_fListenerVel[] = {0.0, 0.0, 0.0}; //Velocity of the listener<br>
> ALfloat m_fListenerOri[] = {0.0, 0.0, -1.0, 0.0, 1.0, 0.0}; //Orientation<br>
> of the listener, first 3 elements are "at", second 3 are "up"<br>
> alListenerfv(AL_POSITION, m_fListenerPos);<br>
> alListenerfv(AL_VELOCITY, m_fListenerVel);<br>
> alListenerfv(AL_ORIENTATION, m_fListenerOri);<br>
> if((error = alGetError()) != AL_NO_ERROR)<br>
> {<br>
> printALError(error);<br>
> return AL_FALSE;<br>
> }<br>
> return AL_TRUE;<br>
> }<br>
><br>
> void killAllData(void)<br>
> {<br>
> alDeleteBuffers(KMAX_BUFFERS,m_buffers);<br>
> alDeleteSources(KMAX_SOURCES,m_sources);<br>
> alutExit();<br>
> }<br>
><br>
> int main()<br>
> {<br>
> ALenum error;<br>
> char ch = '\0';<br>
> #ifdef DEBUG<br>
> fprintf(stderr,"[DEBUG] Starting OpenAL via ALUT\n");<br>
> #endif<br>
> if(alutInit(NULL,0)!=AL_TRUE)<br>
> {<br>
> printALError(alGetError());<br>
> return 1;<br>
> }<br>
> alGetError(); /* Clearing error bit */<br>
><br>
> #ifdef DEBUG<br>
> fprintf(stderr,"[DEBUG] Setting listener values\n");<br>
> #endif<br>
><br>
> if(setListener() == AL_FALSE)<br>
> {<br>
> #ifdef DEBUG<br>
> fprintf(stderr,"[DEBUG] Killing all data\n");<br>
> #endif<br>
> killAllData();<br>
> return 1;<br>
> }<br>
><br>
> #ifdef DEBUG<br>
> fprintf(stderr,"[DEBUG] Setting buffers and sources\n");<br>
> #endif<br>
> if(loadALData()==AL_FALSE)<br>
> {<br>
> #ifdef DEBUG<br>
> fprintf(stderr,"[DEBUG] Killing all data\n");<br>
> #endif<br>
> killAllData();<br>
> return 1;<br>
> }<br>
><br>
> #ifdef DEBUG<br>
> fprintf(stderr,"[DEBUG] Playing sounds\n");<br>
> #endif<br>
><br>
> while(ch!='q')<br>
> {<br>
> fprintf(stdout,"Command> ");<br>
> fscanf(stdin,"%c",&ch);<br>
> switch(ch)<br>
> {<br>
> case '1':<br>
> {<br>
> alSourcePlay(m_sources[1]);<br>
> if((error = alGetError()) != AL_NO_ERROR)<br>
> printALError(error);<br>
> break;<br>
> }<br>
> case '2':<br>
> {<br>
> alSourcePlay(m_sources[2]);<br>
> if((error = alGetError()) != AL_NO_ERROR)<br>
> printALError(error);<br>
> break;<br>
> }<br>
> case '3':<br>
> {<br>
> alSourcePlay(m_sources[3]);<br>
> if((error = alGetError()) != AL_NO_ERROR)<br>
> printALError(error);<br>
> break;<br>
> }<br>
> case '4':<br>
> {<br>
> alSourcePlay(m_sources[4]);<br>
> if((error = alGetError()) != AL_NO_ERROR)<br>
> printALError(error);<br>
> break;<br>
> }<br>
> case 's':<br>
> {<br>
> alSourceStopv(KMAX_SOURCES,m_sources);<br>
> if((error = alGetError()) != AL_NO_ERROR)<br>
> printALError(error);<br>
> break;<br>
> }<br>
> case 'q':<br>
> {<br>
> fprintf(stdout,"Shutting down\n");break;<br>
> }<br>
> default: fprintf(stdout,"Unknown command\n");break;<br>
> }<br>
> }<br>
><br>
> #ifdef DEBUG<br>
> fprintf(stderr,"[DEBUG] Killing all data\n");<br>
> #endif<br>
> killAllData();<br>
><br>
> return 0;<br>
> }<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>