rdaiff

Capsim Block Documentation

Short Description

This function performs the task of reading sample values in from an aiff file, and then placing them on its output buffer.

Top
Parameters
Num Description Type Name Default Value
0 Name of AIFF File file fileName aiff.aif
Top
States
Num Type Name Initial Value Description
0 int obufs
1 int j 0
2 FILE* fp
3 char* sample_P
4 float* x_P
5 float* y_P
6 int points
7 float samplingRate
8 int numberChannels
9 int bits
Top

Declarations


 

        int i,k,k1;
	float	x,y;
	short xsamp;
	unsigned char x0,x1;
	unsigned long  xc0,xc1;



Top

Initialization Code



 

if( (obufs = NO_OUTPUT_BUFFERS()) < 1 ) {
                fprintf(stderr,"rdaiff: no output buffers\n");
                return(1);
}
fp=fopen(fileName,"rb");
if(fp == NULL) {
                fprintf(stderr,"Error opening AIFF file\n");
                return(2);
}
if(IIP_ReadAIFF(NULL,&x_P,&y_P,&points,&samplingRate,
                                &bits,NULL,&numberChannels,fp,NULL)) {
                fprintf(stderr,"rdaiff: Trouble reading AIFF File\n");
                return(3);
}
fprintf(stderr,"AIFF: Points=%d\n",points);
fprintf(stderr,"AIFF: Sampling Rate=%f\n",samplingRate);
fprintf(stderr,"AIFF: Bits=%d\n",bits);
fprintf(stderr,"AIFF: Channels=%d\n",numberChannels);
if(numberChannels > 2) {
        fprintf(stderr,"rdaiff: Only two channels supported\n");
        fclose(fp);
        return(6);
}
if(bits <= 8) {
        /*
         * allocate array to store samples
         */
        sample_P=(char*)calloc(numberChannels*NUMBER_SAMPLES_PER_VISIT,sizeof(char));
        if(sample_P == NULL) {
                fprintf(stderr,"Could not allocate space in rdaiff\n");
                return(4);
        }
} else {
	x_P=(float*)calloc(NUMBER_SAMPLES_PER_VISIT*numberChannels,sizeof(float));
	if(x_P==NULL) {
                fprintf(stderr,"rdaiff: Could not allocate space\n");
                return(5);
	}
}




Top

Main Code



 


if(bits <= 8) {

  if(fread(sample_P,sizeof(char),numberChannels*NUMBER_SAMPLES_PER_VISIT,fp)==(int)NULL) 
                                        return(0);


} else if(bits <= 16) {
   for(i=0; i
    
Top

Wrapup Code



 

        fclose(fp);




Top

License



/*  Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
    Copyright (C) 1989-2017  Silicon DSP Corporation

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    http://www.silicondsp.com
    Silicon DSP  Corporation
    Las Vegas, Nevada
*/


Top

Description



 

/*
                        rdaiff()
***************************************************************
This function performs the  task of reading
sample values in from an aiff file, and then placing them on
it's output buffer.
If more than one output buffer is connected, then the samples are
routed to each buffer in sequence mod the number of buffers.

rdaiff


This function performs the  task of reading
sample values in from an aiff file, and then placing them on
it's output buffer.
If more than one output buffer is connected, then the samples are
routed to each buffer in sequence mod the number of buffers.


Programmer: Sasan H. Ardalan
Date: August 4, 1993

*/