Dependencies/Build/mac/include/faust/audio/alsa-dsp.h
void read()
	{
        if (fSampleAccess == SND_PCM_ACCESS_RW_INTERLEAVED) {

			int count = snd_pcm_readi(fInputDevice, fInputCardBuffer, fBuffering);
			if (count < 0) {
				 //display_error_msg(count, "reading samples");
				 snd_pcm_prepare(fInputDevice);
				 //check_error_msg(err, "preparing input stream");
			}

			if (fSampleFormat == SND_PCM_FORMAT_S16) {
				short* buffer16b = (short*)fInputCardBuffer;
				for (unsigned int s = 0; s < fBuffering; s++) {
					for (unsigned int c = 0; c < fCardInputs; c++) {
						fInputSoftChannels[c][s] = float(buffer16b[c + s*fCardInputs])*(1.0/float(SHRT_MAX));
					}
				}
			} else if (fSampleFormat == SND_PCM_FORMAT_S32) {
				int32* buffer32b = (int32*)fInputCardBuffer;
				for (unsigned int s = 0; s < fBuffering; s++) {
					for (unsigned int c = 0; c < fCardInputs; c++) {
						fInputSoftChannels[c][s] = float(buffer32b[c + s*fCardInputs])*(1.0/float(INT_MAX));
					}
				}
			} else {
				printf("unrecognized input sample format : %u\n", fSampleFormat);
				exit(1);
			}

		} else if (fSampleAccess == SND_PCM_ACCESS_RW_NONINTERLEAVED) {

			int count = snd_pcm_readn(fInputDevice, fInputCardChannels, fBuffering);
			if (count < 0) {
				 //display_error_msg(count, "reading samples");
				 snd_pcm_prepare(fInputDevice);
				 //check_error_msg(err, "preparing input stream");
			}

			if (fSampleFormat == SND_PCM_FORMAT_S16) {
				for (unsigned int c = 0; c < fCardInputs; c++) {
					short* chan16b = (short*)fInputCardChannels[c];
					for (unsigned int s = 0; s < fBuffering; s++) {
						fInputSoftChannels[c][s] = float(chan16b[s])*(1.0/float(SHRT_MAX));
					}
				}
			} else if (fSampleFormat == SND_PCM_FORMAT_S32) {
				for (unsigned int c = 0; c < fCardInputs; c++) {
					int32* chan32b = (int32*)fInputCardChannels[c];
					for (unsigned int s = 0; s < fBuffering; s++) {
						fInputSoftChannels[c][s] = float(chan32b[s])*(1.0/float(INT_MAX));
					}
				}
			} else {
				printf("unrecognized input sample format : %u\n", fSampleFormat);
				exit(1);
			}

		} else {
			check_error_msg(-10000, "unknown access mode");
		}
    }
/**
	 * Read audio samples from the audio card. Convert samples to floats and take
	 * care of interleaved buffers
	 */
Read audio samples from the audio card. Convert samples to floats and take
care of interleaved buffers
Read audio samples from the audio card . Convert samples to floats and take care of interleaved buffers
void read()
	{
        if (fSampleAccess == SND_PCM_ACCESS_RW_INTERLEAVED) {
			int count = snd_pcm_readi(fInputDevice, fInputCardBuffer, fBuffering);
			if (count < 0) {
				 snd_pcm_prepare(fInputDevice);
			}
			if (fSampleFormat == SND_PCM_FORMAT_S16) {
				short* buffer16b = (short*)fInputCardBuffer;
				for (unsigned int s = 0; s < fBuffering; s++) {
					for (unsigned int c = 0; c < fCardInputs; c++) {
						fInputSoftChannels[c][s] = float(buffer16b[c + s*fCardInputs])*(1.0/float(SHRT_MAX));
					}
				}
			} else if (fSampleFormat == SND_PCM_FORMAT_S32) {
				int32* buffer32b = (int32*)fInputCardBuffer;
				for (unsigned int s = 0; s < fBuffering; s++) {
					for (unsigned int c = 0; c < fCardInputs; c++) {
						fInputSoftChannels[c][s] = float(buffer32b[c + s*fCardInputs])*(1.0/float(INT_MAX));
					}
				}
			} else {
				printf("unrecognized input sample format : %u\n", fSampleFormat);
				exit(1);
			}
		} else if (fSampleAccess == SND_PCM_ACCESS_RW_NONINTERLEAVED) {
			int count = snd_pcm_readn(fInputDevice, fInputCardChannels, fBuffering);
			if (count < 0) {
				 snd_pcm_prepare(fInputDevice);
			}
			if (fSampleFormat == SND_PCM_FORMAT_S16) {
				for (unsigned int c = 0; c < fCardInputs; c++) {
					short* chan16b = (short*)fInputCardChannels[c];
					for (unsigned int s = 0; s < fBuffering; s++) {
						fInputSoftChannels[c][s] = float(chan16b[s])*(1.0/float(SHRT_MAX));
					}
				}
			} else if (fSampleFormat == SND_PCM_FORMAT_S32) {
				for (unsigned int c = 0; c < fCardInputs; c++) {
					int32* chan32b = (int32*)fInputCardChannels[c];
					for (unsigned int s = 0; s < fBuffering; s++) {
						fInputSoftChannels[c][s] = float(chan32b[s])*(1.0/float(INT_MAX));
					}
				}
			} else {
				printf("unrecognized input sample format : %u\n", fSampleFormat);
				exit(1);
			}
		} else {
			check_error_msg(-10000, "unknown access mode");
		}
    }
void read ( ) { if ( fSampleAccess == SND_PCM_ACCESS_RW_INTERLEAVED ) { int count = snd_pcm_readi ( fInputDevice , fInputCardBuffer , fBuffering ) ; if ( count < 0 ) { snd_pcm_prepare ( fInputDevice ) ; } if ( fSampleFormat == SND_PCM_FORMAT_S16 ) { short * buffer16b = ( short * ) fInputCardBuffer ; for ( unsigned int s = 0 ; s < fBuffering ; s ++ ) { for ( unsigned int c = 0 ; c < fCardInputs ; c ++ ) { fInputSoftChannels [ c ] [ s ] = float ( buffer16b [ c + s * fCardInputs ] ) * ( 1.0 / float ( SHRT_MAX ) ) ; } } } else if ( fSampleFormat == SND_PCM_FORMAT_S32 ) { int32 * buffer32b = ( int32 * ) fInputCardBuffer ; for ( unsigned int s = 0 ; s < fBuffering ; s ++ ) { for ( unsigned int c = 0 ; c < fCardInputs ; c ++ ) { fInputSoftChannels [ c ] [ s ] = float ( buffer32b [ c + s * fCardInputs ] ) * ( 1.0 / float ( INT_MAX ) ) ; } } } else { printf ( " \n " , fSampleFormat ) ; exit ( 1 ) ; } } else if ( fSampleAccess == SND_PCM_ACCESS_RW_NONINTERLEAVED ) { int count = snd_pcm_readn ( fInputDevice , fInputCardChannels , fBuffering ) ; if ( count < 0 ) { snd_pcm_prepare ( fInputDevice ) ; } if ( fSampleFormat == SND_PCM_FORMAT_S16 ) { for ( unsigned int c = 0 ; c < fCardInputs ; c ++ ) { short * chan16b = ( short * ) fInputCardChannels [ c ] ; for ( unsigned int s = 0 ; s < fBuffering ; s ++ ) { fInputSoftChannels [ c ] [ s ] = float ( chan16b [ s ] ) * ( 1.0 / float ( SHRT_MAX ) ) ; } } } else if ( fSampleFormat == SND_PCM_FORMAT_S32 ) { for ( unsigned int c = 0 ; c < fCardInputs ; c ++ ) { int32 * chan32b = ( int32 * ) fInputCardChannels [ c ] ; for ( unsigned int s = 0 ; s < fBuffering ; s ++ ) { fInputSoftChannels [ c ] [ s ] = float ( chan32b [ s ] ) * ( 1.0 / float ( INT_MAX ) ) ; } } } else { printf ( " \n " , fSampleFormat ) ; exit ( 1 ) ; } } else { check_error_msg ( -10000 , " " ) ; } }
Read audio samples from the audio card.
Read audio samples from the audio card .
//display_error_msg(count, "reading samples"); //check_error_msg(err, "preparing input stream"); //display_error_msg(count, "reading samples"); //check_error_msg(err, "preparing input stream");