Hello friends I am using port audio to perform multichannel recording but when I am running the code its giving some 10 warnings which I am not able to rectify as the format used is correct. Earlier it was giving some 72 errors and 19 warnings, i have brought these down to 10 warnings only but I am not able to rectify the remaining ones. Pls do help me......The code is as below:
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "portaudio.h"
//#define INPUT_DEVICE_NAME ("EWS88 MT Interleaved Rec")
#define OUTPUT_DEVICE (Pa_GetDefaultOutputDeviceID())
//#define OUTPUT_DEVICE (18)
#define SAMPLE_RATE (22050)
#define FRAMES_PER_BUFFER (256)
#define MIN_LATENCY_MSEC (400)
#define NUM_BUFFERS ((MIN_LATENCY_MSEC * SAMPLE_RATE) / (FRAMES_PER_BUFFER * 1000))
#ifndef M_PI
#define M_PI (3.14159265)
#endif
typedef struct
{
int liveChannel;
int numChannels;
}
paTestData;
/* This routine will be called by the PortAudio engine when audio is needed.
** It may called at interrupt level on some machines so don't do anything
** that could mess up the system like calling malloc() or free().
*/
static int patestCallback( void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,PaTime outTime,
void *userData )
{
paTestData *data = (paTestData*)userData;
float *out = (float*)outputBuffer;
float *in = (float*)inputBuffer;
unsigned long i;
int finished = 0;
/* Prevent unused variable warnings. */
(void) inputBuffer;
if( in == NULL ) return 0;
for( i=0; i<framesPerBuffer; i++ )
{
/* Copy one channel of input to output. */
*out++ = in[data->liveChannel];
*out++ = in[data->liveChannel];
in += data->numChannels;
}
return 0;
}
/*******************************************************************/
int PaFindDeviceByName( const char *name )
{
int i;
int numDevices;
const PaDeviceInfo *pdi;
int len = strlen( name );
PaDeviceIndex result = paNoDevice;
numDevices = Pa_GetDeviceCount();
for( i=0; i<numDevices; i++ )
{
pdi = Pa_GetDeviceInfo( i );
if( strncmp( name, pdi->name, len ) == 0 )
{
result = i;
break;
}
}
return result;
}
/*******************************************************************/
int main(void);
int main(void)
{
PaStream *stream;
PaError err;
paTestData data;
int i;
PaDeviceIndex inputDevice;
const PaDeviceInfo *pdi;
printf("PortAudio Test: input signal from each channel. %d buffersn", NUM_BUFFERS );
data.liveChannel = 0;
err = Pa_Initialize();
if( err != paNoError ) goto error;
#ifdef INPUT_DEVICE_NAME
printf("Try to use device: %sn", INPUT_DEVICE_NAME );
inputDevice = PaFindDeviceByName(INPUT_DEVICE_NAME);
if( inputDevice == paNoDevice )
{
printf("Could not find %s. Using default instead.n", INPUT_DEVICE_NAME );
inputDevice = Pa_GetDefaultInputDeviceID();
}
#else
printf("Using default input device.n");
inputDevice = Pa_GetDefaultInputDevice();
#endif
pdi = Pa_GetDeviceInfo( inputDevice );
if( pdi == NULL )
{
printf("Could not get device info!n");
goto error;
}
data.numChannels = pdi->maxInputChannels;
printf("Input Device name is %sn", pdi->name );
printf("Input Device has %d channels.n", pdi->maxInputChannels);
err = Pa_OpenStream(
&stream,
pdi->name,
pdi->maxInputChannels,
paFloat32,
NULL,
OUTPUT_DEVICE,
2,
paFloat32,
NULL,
SAMPLE_RATE,
FRAMES_PER_BUFFER, /* frames per buffer */
NUM_BUFFERS, /* number of buffers, if zero then use default minimum */
paClipOff, /* we won't output out of range samples so don't bother clipping them */
patestCallback,
&data );
if( err != paNoError ) goto error;
data.liveChannel = 0;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
for( i=0; i<data.numChannels; i++ )
{
data.liveChannel = i;
printf("Channel %d being sent to output. Hit ENTER for next channel.", i );
fflush(stdout);
getchar();
}
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
err = Pa_CloseStream( stream );
Pa_Terminate();
printf("Test finished.n");
return err;
error:
Pa_Terminate();
fprintf( stderr, "An error occured while using the portaudio streamn" );
fprintf( stderr, "Error number: %dn", err );
fprintf( stderr, "Error message: %sn", Pa_GetErrorText( err ) );
return err;
}
Pls run the code if u have time and help me out.
Port Audio issue
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
-
saviour2009
- Posts: 6
- Joined: Mon Feb 08, 2010 12:17 pm
- Operating System: Please select