Dependencies/Build/mac/include/faust/audio/alsa-dsp.h
void write()
	{
		recovery :

		if (fSampleAccess == SND_PCM_ACCESS_RW_INTERLEAVED) {

			if (fSampleFormat == SND_PCM_FORMAT_S16) {
				short* buffer16b = (short*)fOutputCardBuffer;
				for (unsigned int f = 0; f < fBuffering; f++) {
					for (unsigned int c = 0; c < fCardOutputs; c++) {
						float x = fOutputSoftChannels[c][f];
						buffer16b[c + f*fCardOutputs] = short(max(min(x,1.0f),-1.0f) * float(SHRT_MAX)) ;
					}
				}

			} else if (fSampleFormat == SND_PCM_FORMAT_S32)  {
				int32* buffer32b = (int32*)fOutputCardBuffer;
				for (unsigned int f = 0; f < fBuffering; f++) {
					for (unsigned int c = 0; c < fCardOutputs; c++) {
						float x = fOutputSoftChannels[c][f];
						buffer32b[c + f*fCardOutputs] = int(max(min(x,1.0f),-1.0f) * float(INT_MAX));
					}
				}
			} else {
				printf("unrecognized output sample format : %u\n", fSampleFormat);
				exit(1);
			}

			int count = snd_pcm_writei(fOutputDevice, fOutputCardBuffer, fBuffering);
			if (count<0) {
				//display_error_msg(count, "w3");
				snd_pcm_prepare(fOutputDevice);
				//check_error_msg(err, "preparing output stream");
				goto recovery;
			}


		} else if (fSampleAccess == SND_PCM_ACCESS_RW_NONINTERLEAVED) {

			if (fSampleFormat == SND_PCM_FORMAT_S16) {

				for (unsigned int c = 0; c < fCardOutputs; c++) {
					short* chan16b = (short*)fOutputCardChannels[c];
					for (unsigned int f = 0; f < fBuffering; f++) {
						float x = fOutputSoftChannels[c][f];
						chan16b[f] = short(max(min(x,1.0f),-1.0f) * float(SHRT_MAX));
					}
				}

			} else if (fSampleFormat == SND_PCM_FORMAT_S32) {

				for (unsigned int c = 0; c < fCardOutputs; c++) {
					int32* chan32b = (int32*)fOutputCardChannels[c];
					for (unsigned int f = 0; f < fBuffering; f++) {
						float x = fOutputSoftChannels[c][f];
						chan32b[f] = int(max(min(x,1.0f),-1.0f) * float(INT_MAX));
					}
				}

			} else {
				printf("unrecognized output sample format : %u\n", fSampleFormat);
				exit(1);
			}

			int count = snd_pcm_writen(fOutputDevice, fOutputCardChannels, fBuffering);
			if (count < 0) {
				//display_error_msg(count, "w3");
				snd_pcm_prepare(fOutputDevice);
				//check_error_msg(err, "preparing output stream");
				goto recovery;
			}

		} else {
			check_error_msg(-10000, "unknown access mode");
		}
	}
/**
	 * write the output soft channels to the audio card. Convert sample
	 * format and interleaves buffers when needed
	 */
write the output soft channels to the audio card. Convert sample
format and interleaves buffers when needed
write the output soft channels to the audio card . Convert sample format and interleaves buffers when needed
void write()
	{
		recovery :
		if (fSampleAccess == SND_PCM_ACCESS_RW_INTERLEAVED) {
			if (fSampleFormat == SND_PCM_FORMAT_S16) {
				short* buffer16b = (short*)fOutputCardBuffer;
				for (unsigned int f = 0; f < fBuffering; f++) {
					for (unsigned int c = 0; c < fCardOutputs; c++) {
						float x = fOutputSoftChannels[c][f];
						buffer16b[c + f*fCardOutputs] = short(max(min(x,1.0f),-1.0f) * float(SHRT_MAX)) ;
					}
				}
			} else if (fSampleFormat == SND_PCM_FORMAT_S32)  {
				int32* buffer32b = (int32*)fOutputCardBuffer;
				for (unsigned int f = 0; f < fBuffering; f++) {
					for (unsigned int c = 0; c < fCardOutputs; c++) {
						float x = fOutputSoftChannels[c][f];
						buffer32b[c + f*fCardOutputs] = int(max(min(x,1.0f),-1.0f) * float(INT_MAX));
					}
				}
			} else {
				printf("unrecognized output sample format : %u\n", fSampleFormat);
				exit(1);
			}
			int count = snd_pcm_writei(fOutputDevice, fOutputCardBuffer, fBuffering);
			if (count<0) {
				snd_pcm_prepare(fOutputDevice);
				goto recovery;
			}
		} else if (fSampleAccess == SND_PCM_ACCESS_RW_NONINTERLEAVED) {
			if (fSampleFormat == SND_PCM_FORMAT_S16) {
				for (unsigned int c = 0; c < fCardOutputs; c++) {
					short* chan16b = (short*)fOutputCardChannels[c];
					for (unsigned int f = 0; f < fBuffering; f++) {
						float x = fOutputSoftChannels[c][f];
						chan16b[f] = short(max(min(x,1.0f),-1.0f) * float(SHRT_MAX));
					}
				}
			} else if (fSampleFormat == SND_PCM_FORMAT_S32) {
				for (unsigned int c = 0; c < fCardOutputs; c++) {
					int32* chan32b = (int32*)fOutputCardChannels[c];
					for (unsigned int f = 0; f < fBuffering; f++) {
						float x = fOutputSoftChannels[c][f];
						chan32b[f] = int(max(min(x,1.0f),-1.0f) * float(INT_MAX));
					}
				}
			} else {
				printf("unrecognized output sample format : %u\n", fSampleFormat);
				exit(1);
			}
			int count = snd_pcm_writen(fOutputDevice, fOutputCardChannels, fBuffering);
			if (count < 0) {
				snd_pcm_prepare(fOutputDevice);
				goto recovery;
			}
		} else {
			check_error_msg(-10000, "unknown access mode");
		}
	}
void write ( ) { recovery : if ( fSampleAccess == SND_PCM_ACCESS_RW_INTERLEAVED ) { if ( fSampleFormat == SND_PCM_FORMAT_S16 ) { short * buffer16b = ( short * ) fOutputCardBuffer ; for ( unsigned int f = 0 ; f < fBuffering ; f ++ ) { for ( unsigned int c = 0 ; c < fCardOutputs ; c ++ ) { float x = fOutputSoftChannels [ c ] [ f ] ; buffer16b [ c + f * fCardOutputs ] = short ( max ( min ( x , 1.0f ) , -1.0f ) * float ( SHRT_MAX ) ) ; } } } else if ( fSampleFormat == SND_PCM_FORMAT_S32 ) { int32 * buffer32b = ( int32 * ) fOutputCardBuffer ; for ( unsigned int f = 0 ; f < fBuffering ; f ++ ) { for ( unsigned int c = 0 ; c < fCardOutputs ; c ++ ) { float x = fOutputSoftChannels [ c ] [ f ] ; buffer32b [ c + f * fCardOutputs ] = int ( max ( min ( x , 1.0f ) , -1.0f ) * float ( INT_MAX ) ) ; } } } else { printf ( " \n " , fSampleFormat ) ; exit ( 1 ) ; } int count = snd_pcm_writei ( fOutputDevice , fOutputCardBuffer , fBuffering ) ; if ( count < 0 ) { snd_pcm_prepare ( fOutputDevice ) ; goto recovery ; } } else if ( fSampleAccess == SND_PCM_ACCESS_RW_NONINTERLEAVED ) { if ( fSampleFormat == SND_PCM_FORMAT_S16 ) { for ( unsigned int c = 0 ; c < fCardOutputs ; c ++ ) { short * chan16b = ( short * ) fOutputCardChannels [ c ] ; for ( unsigned int f = 0 ; f < fBuffering ; f ++ ) { float x = fOutputSoftChannels [ c ] [ f ] ; chan16b [ f ] = short ( max ( min ( x , 1.0f ) , -1.0f ) * float ( SHRT_MAX ) ) ; } } } else if ( fSampleFormat == SND_PCM_FORMAT_S32 ) { for ( unsigned int c = 0 ; c < fCardOutputs ; c ++ ) { int32 * chan32b = ( int32 * ) fOutputCardChannels [ c ] ; for ( unsigned int f = 0 ; f < fBuffering ; f ++ ) { float x = fOutputSoftChannels [ c ] [ f ] ; chan32b [ f ] = int ( max ( min ( x , 1.0f ) , -1.0f ) * float ( INT_MAX ) ) ; } } } else { printf ( " \n " , fSampleFormat ) ; exit ( 1 ) ; } int count = snd_pcm_writen ( fOutputDevice , fOutputCardChannels , fBuffering ) ; if ( count < 0 ) { snd_pcm_prepare ( fOutputDevice ) ; goto recovery ; } } else { check_error_msg ( -10000 , " " ) ; } }
write the output soft channels to the audio card.
write the output soft channels to the audio card .
//display_error_msg(count, "w3"); //check_error_msg(err, "preparing output stream"); //display_error_msg(count, "w3"); //check_error_msg(err, "preparing output stream");