Hi Kjetil, On Mon, Aug 19, 2002 at 02:42:54PM +0200, Kjetil S. Matheussen wrote: > Here are some code from ceres to play: Which is wrong in some places.
> > struct JackPlayChannel{ > jack_port_t *output_port; > sample_t buffer[BUFFERSIZE]; > }; > > struct Jackplay{ > struct JackPlayChannel jpc[4]; > jack_client_t *client; > struct FFTSound *fftsound; These four ints must be some kind of atomic variables, to make it work. > int writeplace; > int readplace; > int buffersize; > int unread; > }; > /* Consumer */ > > int jackprocess (nframes_t nframes, void *arg){ > int ch,i; > struct Jackplay *jackplay=(struct Jackplay *)arg; > int numch=jackplay->fftsound->samps_per_frame; > sample_t *out[numch]; > > for(ch=0;ch<numch;ch++){ > out[ch]= (sample_t *) jack_port_get_buffer (jackplay->jpc[ch].output_port, >nframes); > memset(out[ch],0.0f,nframes*sizeof(sample_t)); This doesn't work and isn't needed. The second argument will be intepreted as a byte. You also filling the buffer all the time, so zero initialisation is not necessary. > } > > for(i=0;i<nframes;i++){ > if(jackplay->unread==0) break; > > for(ch=0;ch<numch;ch++){ > out[ch][i]=jackplay->jpc[ch].buffer[jackplay->readplace]; > } > jackplay->unread--; > > jackplay->readplace++; > if(jackplay->readplace==jackplay->buffersize){ > jackplay->readplace=0; > } > } > > return 0; > } > > > /* Providor */ > > void JackWritePlay( > struct FFTSound *fftsound, > void *port,double **samples,int num_samples > ) > { > struct Jackplay *jackplay=(struct Jackplay *)port; > > int i,ch; > > for (i=0; i<num_samples; i++) { > while(jackplay->unread==jackplay->buffersize){ > usleep(128); > } > for (ch=0; ch<fftsound->samps_per_frame; ch++){ > jackplay->jpc[ch].buffer[jackplay->writeplace]=(sample_t)samples[ch][i]; > } > jackplay->unread++; > jackplay->writeplace++; > if(jackplay->writeplace==jackplay->buffersize){ > jackplay->writeplace=0; > } > } > } But for pseudocode all of this is ok ;-) Regards Ingo Oeser -- Science is what we can tell a computer. Art is everything else. --- D.E.Knuth