Capsim Block Documentation
Writes samples from an arbitrary number of input buffers to an AIFF file, which is named as a parameter.
char sample;
float sampf;
long int i;
long int j;
char buffer[100];
unsigned char *samples_P;
|
|---|
if((numberInputBuffers = NO_INPUT_BUFFERS()) <= 0) {
fprintf(stdout,"wraiff: no input buffers\n");
return(1);
}
if((numberOutputBuffers = NO_OUTPUT_BUFFERS()) > numberInputBuffers) {
fprintf(stdout,"wraiff: more output than input buffers\n");
return(2);
}
switch(bufferType) {
case FLOAT_BUFFER:
for(i=0; i< numberInputBuffers; i++)
SET_CELL_SIZE_IN(i,sizeof(float));
for(i=0; i< numberOutputBuffers; i++)
SET_CELL_SIZE_OUT(0,sizeof(float));
break;
case INTEGER_BUFFER:
for(i=0; i< numberInputBuffers; i++)
SET_CELL_SIZE_IN(i,sizeof(int));
for(i=0; i< numberOutputBuffers; i++)
SET_CELL_SIZE_OUT(0,sizeof(int));
break;
default:
fprintf(stderr,"wraiff: Bad buffer type specified \n");
return(4);
break;
}
wordSize = 1;
wordSize <<= bits-1;
/*
*
+++++++++++++++++++++++++++++++++++++++++++++++++++++
* AIFC File Creation
*/
if(IIP_WriteAIFF((char*)fileName,NULL,NULL,NULL,(int)bits,
samplingRate,(int)1,
scale,dcOffset,range,0,
NULL,1,
&formSizeOffset,&formBaseSize,
&numberFramesOffset,
&sndSizeOffset,&samplesOffset,NULL)) {
fprintf(stderr,"wraiff: problems writting aiff file\n");
return(5);
}
fprintf(stderr,"formSizeOffset=%d,formBaseSize=%d,numberFramesOffset=%d,sndSizeOffset=%d,samplesOffset=%d\n",
formSizeOffset,formBaseSize,
numberFramesOffset,
sndSizeOffset,samplesOffset);
/*
* Open AIFF file now that the chunks have been written
*/
fp=fopen(fileName,"rb+");
if(fp==NULL) {
fprintf(stderr,"wraiff: could not open aiff file to write samples\n");
return(6);
}
/*
* Position the file pointer where the samples should be written
*/
fseek(fp,samplesOffset,SEEK_SET);
|
|---|
/*
* This mode synchronizes all input buffers
*/
for(i = MIN_AVAIL(); i>0; i--) {
/*
* Calculate total number of samples inputted
* If more than samples return
*/
totalSamples++;
for(j=0; j
|
|---|
if(totalSamples%2) totalSamples++;
IIP_UpdateNumberFramesAIFF(fp,
bits,1,
totalSamples,
formSizeOffset,formBaseSize,
numberFramesOffset,
sndSizeOffset,samplesOffset);
fclose(fp);
#if 0
if(playFlag)
Cs_PlayAIFF(fileName);
#endif
|
|---|
/* Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
Copyright (C) 1989-2002 XCAD 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://capsimtmk.sourceforge.net
XCAD Corporation
Raleigh, North Carolina */
|
|---|
/**********************************************************************
wraiff()
***********************************************************************
writes samples from an arbitrary number of input buffers to an AIFF file,
which is named as a parameter.
- Data "flow-through" is implemented: if any outputs are connected,
their values come from the correspondingly numbered input.
(This feature is not affected by the control parameter.)
(There cannot be more outputs than inputs.)
|
|---|