• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Pa_GetDefaultOutputDeviceID函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Pa_GetDefaultOutputDeviceID函数的典型用法代码示例。如果您正苦于以下问题:C++ Pa_GetDefaultOutputDeviceID函数的具体用法?C++ Pa_GetDefaultOutputDeviceID怎么用?C++ Pa_GetDefaultOutputDeviceID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Pa_GetDefaultOutputDeviceID函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: portaudio_load_default

static int portaudio_load_default (portaudio_driver_t *driver, 
                                    int numDevices, 
                                    int capturing, 
                                    int playing, 
                                    int* inputDeviceID,
                                    int* outputDeviceID)
{
    const PaDeviceInfo *pdi;
    int i,j;
    int found = 0;
    
    PALog("Look for default driver\n");
    
    *inputDeviceID = Pa_GetDefaultInputDeviceID();
    *outputDeviceID = Pa_GetDefaultOutputDeviceID();

    for(i=0; i<numDevices; i++)
    {
        pdi = Pa_GetDeviceInfo(i);
        PALog("---------------------------------------------- #%d\n", i);
        
        if (i == Pa_GetDefaultInputDeviceID()) {
            driver->capture_nchannels = (capturing) ? pdi->maxInputChannels : 0;
            strcpy (driver->driver_name,pdi->name);
            found = 1;
        }
        
        if (i == Pa_GetDefaultOutputDeviceID()){
            driver->playback_nchannels = (playing) ? pdi->maxOutputChannels : 0;
            strcpy (driver->driver_name,pdi->name);
            found = 1;
        }
        
        PALog("\nName         = %s\n", pdi->name);
        PALog("Max Inputs = %d ", pdi->maxInputChannels);
        PALog("Max Outputs = %d\n", pdi->maxOutputChannels);
        if( pdi->numSampleRates == -1 ){
            PALog("Sample Rate Range = %f to %f\n", pdi->sampleRates[0], pdi->sampleRates[1]);
        }else{
            PALog("Sample Rates =");
            for(j=0; j<pdi->numSampleRates; j++){
                PALog(" %8.2f,", pdi->sampleRates[j]);
            }
            PALog("\n");
        }
        
        PALog("Native Sample Formats = ");
        if (pdi->nativeSampleFormats & paInt8)        PALog("paInt8, ");
        if (pdi->nativeSampleFormats & paUInt8)       PALog("paUInt8, ");
        if (pdi->nativeSampleFormats & paInt16)       PALog("paInt16, ");
        if (pdi->nativeSampleFormats & paInt32)       PALog("paInt32, ");
        if (pdi->nativeSampleFormats & paFloat32)     PALog("paFloat32, ");
        if (pdi->nativeSampleFormats & paInt24)       PALog("paInt24, ");
        if (pdi->nativeSampleFormats & paPackedInt24) PALog("paPackedInt24, ");
        PALog("\n");
    }
    
    return found;
}
开发者ID:Llefjord,项目名称:jack1,代码行数:59,代码来源:portaudio_driver.c


示例2: main

int main(void)
{
    PortAudioStream *stream;
    PaError err;
    
    err = Pa_Initialize();
    if( err != paNoError ) goto error;
    
    printf("PortAudio Test: input device ID  = %d\n", Pa_GetDefaultInputDeviceID() );
    printf("PortAudio Test: output device ID = %d\n", Pa_GetDefaultOutputDeviceID() );
    err = Pa_OpenStream(
              &stream,
              Pa_GetDefaultInputDeviceID(), /* default output device */
              2,               /* stereo input */
              PA_SAMPLE_TYPE,
              NULL,
              Pa_GetDefaultOutputDeviceID(), /* default output device */
              2,               /* stereo output */
              PA_SAMPLE_TYPE,
              NULL,
              SAMPLE_RATE,
              FRAMES_PER_BUFFER,            /* frames per buffer */
              0,               /* number of buffers, if zero then use default minimum */
              paClipOff,       /* we won't output out of range samples so don't bother clipping them */
              wireCallback,
              NULL );          /* no data */
    if( err != paNoError ) goto error;
    
    err = Pa_StartStream( stream );
    if( err != paNoError ) goto error;
    
    printf("Full duplex sound test in progress.\n");
    printf("Hit ENTER to exit test.\n");  fflush(stdout);
    getchar();
    
    printf("Closing stream.\n");
    err = Pa_CloseStream( stream );
    if( err != paNoError ) goto error;
    Pa_Terminate();
    
    printf("Full duplex sound test complete.\n"); fflush(stdout);
    return 0;
error:
    Pa_Terminate();
    fprintf( stderr, "An error occured while using the portaudio stream\n" );
    fprintf( stderr, "Error number: %d\n", err );
    fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
    return -1;
}
开发者ID:mentat,项目名称:tehDJ,代码行数:49,代码来源:patest_wire.c


示例3: main

int main( int argc, char** argv) {
	std::ifstream m_f1;
	std::string in, out, fat;

	if( argc == 2 ) {
		fat = "none";
		in = argv[1];
	} else if( argc == 3 ) {
		fat = argv[1];
		in = argv[2];
	} else {
		std::cout << "Usage: " << argv[0] << " [fat_file] input_file" << std::endl;
		return EXIT_FAILURE;
	}

	Adpcm file(in,fat);
	PaError pa_err=Pa_Initialize();
	PaStream *stream;
	pa_err = Pa_OpenStream(&stream, paNoDevice, 0, paInt16, NULL, \
			Pa_GetDefaultOutputDeviceID(), \
			2, paInt16, NULL, 48000, 1234, 0, 0, \
			c_callback, &file.audioQueue);
	pa_err=Pa_StartStream(stream);
	while( !file.finished() || file.audioQueue.size() > 0) {
		sleep(1);

	}
	pa_err=Pa_CloseStream(stream);
	pa_err=Pa_Terminate();

	return EXIT_SUCCESS;
}
开发者ID:Keuronde,项目名称:performous,代码行数:32,代码来源:adpcm_play.cpp


示例4: main

int main(int argc, char* argv[])
{
    PaStream *stream;
    PaError err;
    patest1data data;
    int i;
    int inputDevice = Pa_GetDefaultInputDeviceID();
    int outputDevice = Pa_GetDefaultOutputDeviceID();
    /* initialise sinusoidal wavetable */
    for( i=0; i<100; i++ )
        data.sine[i] = sin( ((double)i/100.) * M_PI * 2. );
    data.phase = 0;
    data.sampsToGo = 44100 * 4;   // 20 seconds
    /* initialise portaudio subsytem */
    Pa_Initialize();
    err = Pa_OpenStream(
              &stream,
              inputDevice,
              2,              /* stereo input */
              paFloat32,  /* 32 bit floating point input */
              NULL,
              outputDevice,
              2,              /* stereo output */
              paFloat32,      /* 32 bit floating point output */
              NULL,
              44100.,
              //    22050,          /* half second buffers */
              //    4,              /* four buffers */
              512,          /* half second buffers */
              0,              /* four buffers */
              paClipOff,      /* we won't output out of range samples so don't bother clipping them */
              patest1Callback,
              &data );
    if( err == paNoError )
    {
        err = Pa_StartStream( stream );
        //       printf( "Press any key to end.\n" );
        //       getc( stdin ); //wait for input before exiting
        //       Pa_AbortStream( stream );

        printf( "Waiting for stream to complete...\n" );

        while( Pa_StreamActive( stream ) )
            Pa_Sleep(1000); /* sleep until playback has finished */

        err = Pa_CloseStream( stream );
    }
    else
    {
        fprintf( stderr, "An error occured while opening the portaudio stream\n" );
        if( err == paHostError )
            fprintf( stderr, "Host error number: %d\n", Pa_GetHostError() );
        else
            fprintf( stderr, "Error number: %d\n", err );
    }
    Pa_Terminate();
    printf( "bye\n" );

    return 0;
}
开发者ID:Excalibur201010,项目名称:sharpsdr,代码行数:60,代码来源:debug_test1.c


示例5: TestBadActions

static int TestBadActions( void )
{
    PortAudioStream *stream = NULL;
    PaError result;
    PaQaData myData;
    /* Setup data for synthesis thread. */
    myData.framesLeft = (unsigned long) (SAMPLE_RATE * 100); /* 100 seconds */
    myData.numChannels = 1;
    myData.mode = MODE_OUTPUT;
    /* Default output. */
    EXPECT( "TestBadActions", ((result = Pa_OpenStream(
                           &stream,
                           paNoDevice, 0, paFloat32, NULL,
                           Pa_GetDefaultOutputDeviceID(), 2, paFloat32, NULL,
                           SAMPLE_RATE, FRAMES_PER_BUFFER, NUM_BUFFERS,
                           paClipOff,
                           QaCallback,
                           &myData )
             ) == 0) );
    HOPEFOR( "start", ((result = Pa_StartStream( NULL )) == paBadStreamPtr) );
    HOPEFOR( "stop", ((result = Pa_StopStream( NULL )) == paBadStreamPtr) );
    HOPEFOR( "active?", ((result = Pa_StreamActive( NULL )) == paBadStreamPtr) );
    HOPEFOR( "close", ((result = Pa_CloseStream( NULL )) == paBadStreamPtr) );
    HOPEFOR( "time?", ((result = (PaError)Pa_StreamTime( NULL )) != 0) );
    HOPEFOR( "CPULoad?", ((result = (PaError)Pa_GetCPULoad( NULL )) != 0) );
error:
    if( stream != NULL ) Pa_CloseStream( stream );
    return result;
}
开发者ID:duralakun,项目名称:minorGems,代码行数:29,代码来源:paqa_errs.c


示例6: main

int main(void)
{
    int      i,j;
    int      numDevices;
    const    PaDeviceInfo *pdi;
    PaError  err;
    Pa_Initialize();
    numDevices = Pa_CountDevices();
    if( numDevices < 0 )
    {
        printf("ERROR: Pa_CountDevices returned 0x%x\n", numDevices );
        err = numDevices;
        goto error;
    }
    printf("Number of devices = %d\n", numDevices );
    for( i=0; i<numDevices; i++ )
    {
        pdi = Pa_GetDeviceInfo( i );
        printf("---------------------------------------------- #%d", i );
        if( i == Pa_GetDefaultInputDeviceID() ) printf(" DefaultInput");
        if( i == Pa_GetDefaultOutputDeviceID() ) printf(" DefaultOutput");
        printf("\nName         = %s\n", pdi->name );
        printf("Max Inputs   = %d", pdi->maxInputChannels  );
        printf(", Max Outputs = %d\n", pdi->maxOutputChannels  );
        if( pdi->numSampleRates == -1 )
        {
            printf("Sample Rate Range = %f to %f\n", pdi->sampleRates[0], pdi->sampleRates[1] );
        }
        else
        {
            printf("Sample Rates =");
            for( j=0; j<pdi->numSampleRates; j++ )
            {
                printf(" %8.2f,", pdi->sampleRates[j] );
            }
            printf("\n");
        }
        printf("Native Sample Formats = ");
        if( pdi->nativeSampleFormats & paInt8 )        printf("paInt8, ");
        if( pdi->nativeSampleFormats & paUInt8 )       printf("paUInt8, ");
        if( pdi->nativeSampleFormats & paInt16 )       printf("paInt16, ");
        if( pdi->nativeSampleFormats & paInt32 )       printf("paInt32, ");
        if( pdi->nativeSampleFormats & paFloat32 )     printf("paFloat32, ");
        if( pdi->nativeSampleFormats & paInt24 )       printf("paInt24, ");
        if( pdi->nativeSampleFormats & paPackedInt24 ) printf("paPackedInt24, ");
        printf("\n");
    }
    Pa_Terminate();

    printf("----------------------------------------------\n");
    return 0;
error:
    Pa_Terminate();
    fprintf( stderr, "An error occured while using the portaudio stream\n" );
    fprintf( stderr, "Error number: %d\n", err );
    fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
    return err;
}
开发者ID:Excalibur201010,项目名称:sharpsdr,代码行数:58,代码来源:pa_devs.c


示例7: main

int main(void)
{
    PortAudioStream *stream;
    PaError err;
    paTestData data;
    int i;
    printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
    /* initialise sinusoidal wavetable */
    for( i=0; i<TABLE_SIZE; i++ )
    {
        data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
    }
    data.left_phase = data.right_phase = data.sleepTime = 0;
    err = Pa_Initialize();
    if( err != paNoError ) goto error;
    err = Pa_OpenStream(
              &stream,
              paNoDevice,/* default input device */
              0,              /* no input */
              paFloat32,  /* 32 bit floating point input */
              NULL,
              Pa_GetDefaultOutputDeviceID(), /* default output device */
              2,          /* stereo output */
              paFloat32,      /* 32 bit floating point output */
              NULL,
              SAMPLE_RATE,
              FRAMES_PER_BUFFER,
              0,              /* 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;
    err = Pa_StartStream( stream );
    if( err != paNoError ) goto error;

    while( data.sleepTime < (2 * MSEC_PER_BUFFER) )
    {
        printf("SleepTime = %d\n", data.sleepTime );
        Pa_Sleep( data.sleepTime );
    }

    printf("Try to stop stream.\n");
    err = Pa_StopStream( stream ); /* */
    err = Pa_AbortStream( stream ); /* */
    if( err != paNoError ) goto error;
    err = Pa_CloseStream( stream );
    if( err != paNoError ) goto error;
    Pa_Terminate();
    printf("Test finished.\n");
    return err;
error:
    Pa_Terminate();
    fprintf( stderr, "An error occured while using the portaudio stream\n" );
    fprintf( stderr, "Error number: %d\n", err );
    fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
    return err;
}
开发者ID:Excalibur201010,项目名称:sharpsdr,代码行数:57,代码来源:patest_underflow.c


示例8: portaudio_driver_set_parameters

static int
portaudio_driver_set_parameters (portaudio_driver_t* driver,
				   jack_nframes_t nframes,
				   jack_nframes_t rate)
{
	int capturing = driver->capturing;
	int playing = driver->playing;

	int err = Pa_OpenStream(
		&driver->stream,
		((capturing) ? Pa_GetDefaultInputDeviceID() : paNoDevice),	
		((capturing) ? driver->capture_nchannels : 0),             
		paFloat32,		/* 32-bit float input */
		NULL,
		((playing) ? Pa_GetDefaultOutputDeviceID() : paNoDevice),
		((playing) ?  driver->playback_nchannels : 0),        
		paFloat32,		/* 32-bit float output */
		NULL,
		rate,			/* sample rate */
		nframes,		/* frames per buffer */
		0,				/* number of buffers = default min */
		paClipOff,		/* we won't output out of
						* range samples so don't
						* bother clipping them */
		paCallback,
		driver);
    
	if (err == paNoError) {
        
		driver->period_usecs = (((float) driver->frames_per_cycle)
					/ driver->frame_rate) * 1000000.0f;
		driver->frame_rate = rate;
		driver->frames_per_cycle = nframes;

		/* tell engine about buffer size */
		if (driver->engine) {
			if (driver->engine->set_buffer_size (
				    driver->engine, driver->frames_per_cycle)) {
				jack_error ("portaudio: cannot set engine buffer size to %d (check MIDI)", driver->frames_per_cycle);
				return -1;
			}
				
		}
		return 0;

	} else { 

		// JOQ: this driver is dead.  How do we terminate it?
		Pa_Terminate();
		jack_error("Unable to set portaudio parameters");
		jack_error("Error number: %d", err);
		jack_error("Error message: %s", Pa_GetErrorText(err));
		return EIO;
	}
}
开发者ID:Llefjord,项目名称:jack1,代码行数:55,代码来源:portaudio_driver.c


示例9: main

int main(void)
{
	PortAudioStream *stream;
	PaError err;
	paTestData data = {0};
	double load;
	printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
	/* initialise sinusoidal wavetable */

	err = Pa_Initialize();
	if( err != paNoError ) goto error;
	err = Pa_OpenStream(
				&stream,
				paNoDevice,/* default input device */
				0,              /* no input */
				paFloat32,		/* 32 bit floating point input */
				NULL,
				Pa_GetDefaultOutputDeviceID(), /* default output device */
				1,          /* mono output */
				paFloat32,      /* 32 bit floating point output */
				NULL,
				SAMPLE_RATE,
				FRAMES_PER_BUFFER,            /* frames per buffer */
				0,              /* 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;
	err = Pa_StartStream( stream );
	if( err != paNoError ) goto error;
	
	do
	{
		data.numSines++;
		Pa_Sleep( 200 );
		
		load = Pa_GetCPULoad( stream );
		printf("numSines = %d, CPU load = %f\n", data.numSines, load );
	} while( load < 0.8 );
	
	err = Pa_StopStream( stream );
	if( err != paNoError ) goto error;
	err = Pa_CloseStream( stream );
	if( err != paNoError ) goto error;
	Pa_Terminate();
	printf("Test finished.\n");
	return err;
error:
	Pa_Terminate();
	fprintf( stderr, "An error occured while using the portaudio stream\n" ); 
	fprintf( stderr, "Error number: %d\n", err );
	fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
	return err;
}
开发者ID:andreipaga,项目名称:audacity,代码行数:54,代码来源:patest_maxsines.c


示例10: main

int main(void)
{
    PortAudioStream *stream;
    PaError err;
    paTestData data;
    int totalSamps;

    printf("PortAudio Test: output " FORMAT_NAME "\n");


    data.left_phase = data.right_phase = 0.0;
    data.framesToGo = totalSamps =  NUM_SECONDS * SAMPLE_RATE; /* Play for a few seconds. */
    err = Pa_Initialize();
    if( err != paNoError ) goto error;

    err = Pa_OpenStream(
              &stream,
              paNoDevice,/* default input device */
              0,              /* no input */
              TEST_FORMAT,
              NULL,
              Pa_GetDefaultOutputDeviceID(), /* default output device */
              2,          /* stereo output */
              TEST_FORMAT,
              NULL,
              SAMPLE_RATE,
              FRAMES_PER_BUFFER,
              0,              /* 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;

    err = Pa_StartStream( stream );
    if( err != paNoError ) goto error;

    printf("Waiting %d seconds for sound to finish.\n", NUM_SECONDS );
    while( Pa_StreamActive( stream ) ) Pa_Sleep(10);

    err = Pa_CloseStream( stream );
    if( err != paNoError ) goto error;
    Pa_Terminate();

    printf("PortAudio Test Finished: " FORMAT_NAME "\n");

    return err;
error:
    Pa_Terminate();
    fprintf( stderr, "An error occured while using the portaudio stream\n" );
    fprintf( stderr, "Error number: %d\n", err );
    fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
    return err;
}
开发者ID:0521guo,项目名称:RakNet,代码行数:53,代码来源:debug_sine_formats.c


示例11: TestPlayback

PaError TestPlayback( paTestData *dataPtr )
{
    PaError    err;
    int        i;
    int        lastIndex = 0;

    /* Playback recorded data. */
    dataPtr->frameIndex = 0;
    printf("Begin playback.\n"); fflush(stdout);

/* Open output stream if not already open. */
    if( dataPtr->outputStream == NULL )
    {
        err = Pa_OpenStream(
                  &dataPtr->outputStream,
                  paNoDevice,
                  0,               /* NO input */
                  PA_SAMPLE_TYPE,
                  NULL,
                  Pa_GetDefaultOutputDeviceID(),
                  dataPtr->samplesPerFrame,               /* stereo output */
                  PA_SAMPLE_TYPE,
                  NULL,
                  SAMPLE_RATE,
                  FRAMES_PER_BUFFER,            /* frames per buffer */
                  0,               /* number of buffers, if zero then use default minimum */
                  paClipOff,       /* we won't output out of range samples so don't bother clipping them */
                  playCallback,
                  dataPtr );
        if( err != paNoError ) goto error;
    }

    err = Pa_StartStream( dataPtr->outputStream );
    if( err != paNoError ) goto error;

    printf("Waiting for playback to finish.\n"); fflush(stdout);
    for( i=0; i<(NUM_SECONDS*1000/SLEEP_DUR_MSEC); i++ )
    {
        int frameIndex, delta;
        Pa_Sleep(SLEEP_DUR_MSEC);
        frameIndex = dataPtr->frameIndex;
        delta = frameIndex - lastIndex;
        lastIndex = frameIndex;
        printf("index = %d, delta = %d\n", frameIndex, delta ); fflush(stdout);
    }

    err = Pa_StopStream( dataPtr->outputStream );
    if( err != paNoError ) goto error;
    
error:
    return err;
}
开发者ID:CoolOppo,项目名称:audacity,代码行数:52,代码来源:debug_record_reuse.c


示例12: TestOnce

PaError TestOnce( int buffersize )
{
    PortAudioStream *stream;
    PaError err;
    paTestData data;
    int i;
    int totalSamps;
    /* initialise sinusoidal wavetable */
    for( i=0; i<TABLE_SIZE; i++ )
    {
        data.sine[i] = (short) (30000.0 * sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. ));
    }
    data.left_phase = data.right_phase = 0;
    data.sampsToGo = totalSamps =  NUM_SECONDS * SAMPLE_RATE; /* Play for a few seconds. */
    err = Pa_Initialize();
    if( err != paNoError ) goto error;
    err = Pa_OpenStream(
              &stream,
              paNoDevice,/* default input device */
              0,              /* no input */
              paInt16,  /* sample format */
              NULL,
              Pa_GetDefaultOutputDeviceID(), /* default output device */
              2,              /* stereo output */
              paInt16,        /* sample format */
              NULL,
              SAMPLE_RATE,
              buffersize,           /* frames per buffer */
              0,              /* number of buffers, if zero then use default minimum */
              paClipOff,      /* we won't output out of range samples so don't bother clipping them */
              paSineCallback,
              &data );
    if( err != paNoError ) goto error;

    err = Pa_StartStream( stream );
    if( err != paNoError ) goto error;
    printf("Waiting for sound to finish.\n");
    fflush(stdout);
    Pa_Sleep(1000);
    err = Pa_CloseStream( stream );
    if( err != paNoError ) goto error;
    Pa_Terminate();
    return paNoError;
error:
    Pa_Terminate();
    fprintf( stderr, "An error occured while using the portaudio stream\n" );
    fprintf( stderr, "Error number: %d\n", err );
    fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
    return err;
}
开发者ID:BlitzMaxModules,项目名称:axe.mod,代码行数:50,代码来源:patest_buffer.c


示例13: printf

long TPortAudioRenderer::OpenDefault(long inChan, long outChan, long bufferSize, long sampleRate)
{
    PaError err;
    const PaDeviceInfo* pdi;
    int numDevices;
    int inDevice;
    int outDevice;

    printf("Opening device : inChan: %ld outChan: %ld bufferSize: %ld sampleRate: %ld\n",
           inChan, outChan, bufferSize, sampleRate);

    numDevices = Pa_CountDevices();
    if (numDevices < 0) {
        printf("ERROR: Pa_CountDevices returned 0x%x\n", numDevices);
        err = numDevices;
        printf("Error while opening device: device open error %s\n", Pa_GetErrorText(err));
		fStream = 0;
		return OPEN_ERR;
    } else {
        DisplayDevices();
    }

    // Compute input and output number : to be checked
    inDevice = Pa_GetDefaultInputDeviceID();
    pdi = Pa_GetDeviceInfo(inDevice);

    if (pdi != 0) {
        if (pdi->maxInputChannels == 0) {
            inDevice = GetFirstValidInputDevice();
            pdi = Pa_GetDeviceInfo(inDevice);
        }
        inChan = (inChan < pdi->maxInputChannels) ? inChan : pdi->maxInputChannels;
        printf("Input channel number %ld\n", inChan);
    }

    outDevice = Pa_GetDefaultOutputDeviceID();
    pdi = Pa_GetDeviceInfo(outDevice);

    if (pdi != 0) {
        if (pdi->maxOutputChannels == 0) {
            outDevice = GetFirstValidOutputDevice();
            pdi = Pa_GetDeviceInfo(outDevice);
        }
        outChan = (outChan < pdi->maxOutputChannels) ? outChan : pdi->maxOutputChannels;
        printf("Output channel number %ld\n", outChan);
    }
	
	return Open(inDevice, outDevice, inChan, outChan, bufferSize, sampleRate);
}
开发者ID:UIKit0,项目名称:libaudiostream,代码行数:49,代码来源:TPortAudioRenderer.cpp


示例14: Pa_GetDeviceCount

static const PaDeviceInfo *select_device(const char *device)
{
#if (USE_PORTAUDIO == 19)
	int numDevices = Pa_GetDeviceCount();
#else
	int numDevices = Pa_CountDevices();
#endif
	if (numDevices < 0)
		return NULL;

#if (USE_PORTAUDIO == 19)
	PaDeviceIndex i = 0, selectedIndex = 0;
#else
	PaDeviceID i = 0, selectedIndex = 0;
#endif
	const PaDeviceInfo *deviceInfo = NULL;
	const PaDeviceInfo *selectedDeviceInfo = NULL;

	if (option_device_number >= 0) {
		selectedIndex = option_device_number;
		selectedDeviceInfo = Pa_GetDeviceInfo(selectedIndex);
	}

	if (device == NULL) {
#if (USE_PORTAUDIO == 19)
		selectedIndex = Pa_GetDefaultOutputDevice();
#else
		selectedIndex = Pa_GetDefaultOutputDeviceID();
#endif
		selectedDeviceInfo = Pa_GetDeviceInfo(selectedIndex);
	}

	if (selectedDeviceInfo == NULL) {
		for (i = 0; i < numDevices; i++) {
			deviceInfo = Pa_GetDeviceInfo(i);

			if (deviceInfo != NULL && !strcmp(device, deviceInfo->name)) {
				selectedIndex = i;
				selectedDeviceInfo = deviceInfo;
			}
		}
	}

	if (selectedDeviceInfo)
		update_output_parameters(selectedIndex, selectedDeviceInfo);
	return selectedDeviceInfo;
}
开发者ID:leonardder,项目名称:espeak-ng,代码行数:47,代码来源:wave.c


示例15: main

int main(void)
{
    PortAudioStream *stream;
    PaError err;

    err = Pa_Initialize();
    if( err != paNoError ) goto error;

    err = Pa_OpenStream(
              &stream,
              Pa_GetDefaultInputDeviceID(), /* default output device */
              2,               /* stereo input */
              PA_SAMPLE_TYPE,
              NULL,
              Pa_GetDefaultOutputDeviceID(), /* default output device */
              2,               /* stereo output */
              PA_SAMPLE_TYPE,
              NULL,
              SAMPLE_RATE,
              FRAMES_PER_BUFFER,
              0,             /* number of buffers, if zero then use default minimum */
              0, // paClipOff,     /* we won't output out of range samples so don't bother clipping them */
              fuzzCallback,
              NULL );
    if( err != paNoError ) goto error;

    err = Pa_StartStream( stream );
    if( err != paNoError ) goto error;

    printf("Hit ENTER to stop program.\n");
    getchar();
    err = Pa_CloseStream( stream );
    if( err != paNoError ) goto error;

    printf("Finished. gNumNoInputs = %d\n", gNumNoInputs );
    Pa_Terminate();
    return 0;

error:
    Pa_Terminate();
    fprintf( stderr, "An error occured while using the portaudio stream\n" );
    fprintf( stderr, "Error number: %d\n", err );
    fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
    return -1;
}
开发者ID:Excalibur201010,项目名称:sharpsdr,代码行数:45,代码来源:pa_fuzz.c


示例16: Pa_CountDevices

void TPortAudioRenderer::DisplayDevices()
{
    const PaDeviceInfo *pdi;
    int i, j, numDevices;

    numDevices = Pa_CountDevices();

    printf("Number of devices = %d\n", numDevices);
    for (i = 0; i < numDevices; i++) {
        pdi = Pa_GetDeviceInfo(i);
        printf("---------------------------------------------- #%d", i );
        if (i == Pa_GetDefaultInputDeviceID())
            printf(" DefaultInput");
        if (i == Pa_GetDefaultOutputDeviceID())
            printf(" DefaultOutput");
        printf("\nName         = %s\n", pdi->name);
        printf("Max Inputs   = %d", pdi->maxInputChannels);
        printf(", Max Outputs = %d\n", pdi->maxOutputChannels);
        if (pdi->numSampleRates == -1) {
            printf("Sample Rate Range = %f to %f\n", pdi->sampleRates[0], pdi->sampleRates[1]);
        } else {
            printf("Sample Rates =");
            for (j = 0; j < pdi->numSampleRates; j++) {
                printf(" %8.2f,", pdi->sampleRates[j]);
            }
            printf("\n");
        }
        printf("Native Sample Formats = ");
        if (pdi->nativeSampleFormats & paInt8)
            printf("paInt8, ");
        if (pdi->nativeSampleFormats & paUInt8)
            printf("paUInt8, ");
        if (pdi->nativeSampleFormats & paInt16)
            printf("paInt16, ");
        if (pdi->nativeSampleFormats & paInt32)
            printf("paInt32, ");
        if (pdi->nativeSampleFormats & paFloat32)
            printf("paFloat32, ");
        if (pdi->nativeSampleFormats & paInt24)
            printf("paInt24, ");
        if (pdi->nativeSampleFormats & paPackedInt24)
            printf("paPackedInt24, ");
        printf("\n");
    }
}
开发者ID:UIKit0,项目名称:libaudiostream,代码行数:45,代码来源:TPortAudioRenderer.cpp


示例17: OpenAudioStream

bool SoundDevice::pablio_output(bool state) {
  if(state && !aOutStream) {
    err = OpenAudioStream( &aOutStream, SAMPLE_RATE, PA_SAMPLE_TYPE,
			   (PABLIO_WRITE | PABLIO_STEREO) );
    if( err != paNoError) {
      Pa_Terminate();
      error("error opening output sound device: %s",Pa_GetErrorText( err ) );
      return false;
    } else
      info_output = Pa_GetDeviceInfo( Pa_GetDefaultOutputDeviceID() );

  } else if(!state && aOutStream) {
    
    CloseAudioStream(aOutStream);
    aOutStream = NULL;
    info_output = NULL;

  }
  return true;
}
开发者ID:rektide,项目名称:dyne-muse,代码行数:20,代码来源:dev_sound.cpp


示例18: TestPlayback

PaError TestPlayback( paTestData *dataPtr )
{
    PortAudioStream *stream;
    PaError    err;
    int        i;

    /* Playback recorded data. */
    dataPtr->frameIndex = 0;
    printf("Begin playback.\n"); fflush(stdout);
    err = Pa_OpenStream(
              &stream,
              paNoDevice,
              0,               /* NO input */
              PA_SAMPLE_TYPE,
              NULL,
              Pa_GetDefaultOutputDeviceID(),
              dataPtr->samplesPerFrame,               /* stereo output */
              PA_SAMPLE_TYPE,
              NULL,
              SAMPLE_RATE,
              FRAMES_PER_BUFFER,            /* frames per buffer */
              0,               /* number of buffers, if zero then use default minimum */
              paClipOff,       /* we won't output out of range samples so don't bother clipping them */
              playCallback,
              dataPtr );
    if( err != paNoError ) goto error;
    err = Pa_StartStream( stream );
    if( err != paNoError ) goto error;
    printf("Waiting for playback to finish.\n"); fflush(stdout);
    for( i=0; i<(NUM_SECONDS*1000/SLEEP_DUR_MSEC); i++ )
    {
        Pa_Sleep(100);
        printf("index = %d\n", dataPtr->frameIndex );
    }
    err = Pa_CloseStream( stream );
    if( err != paNoError ) goto error;
    
error:
    return err;
}
开发者ID:MatthiasWM,项目名称:Einstein,代码行数:40,代码来源:debug_record.c


示例19: PaHost_Init

/* Build linked a list with all the available audio devices on this SGI machine (only 1 for now).  */
PaError PaHost_Init(void)                              /* Called by Pa_Initialize() from pa_lib.c. */
{
    internalPortAudioDevice*    pad;
	PaError                     r = paNoError;
    int                         audioLibFileID;             /* To test for the presence of audio.  */

    if (sDeviceList)                                        /* Allow re-init, only warn, no error. */
        {
        ERR_RPT(("Warning: PaHost_Init() did not really re-init PA.\n"));
        return r;
        }
    /*------------- ADD THE SGI DEFAULT DEVICE TO THE LIST: ---------------------------------------*/
    audioLibFileID = open("/dev/hdsp/hdsp0master", O_RDONLY);   /* Try to open Indigo style audio  */
    if (audioLibFileID < 0)                                     /* IO port. On failure, machine    */
        {                                                       /* has no audio ability.           */
        ERR_RPT(("PaHost_Init(): This machine has no (Indigo-style) audio abilities.\n"));
        return paHostError;
        }
    close(audioLibFileID);                              /* Allocate fast mem to hold device info.  */
	pad = PaHost_AllocateFastMemory(sizeof(internalPortAudioDevice));
	if (pad == NULL)
        return paInsufficientMemory;
    memset(pad, 0, sizeof(internalPortAudioDevice));    /* "pad->pad_Next = NULL" is more elegant. */
	r = Pa_sgiQueryDevice(AL_DEFAULT_DEVICE,            /* Set AL device num (AL_DEFAULT_DEVICE).  */
                          Pa_GetDefaultOutputDeviceID(),/* Set PA device num (or InputDeviceID()). */
                          "AL default",                 /* A suitable name.                        */
                          pad);                         /* Write args and queried info into pad.   */
	if (r != paNoError)
		{
        ERR_RPT(("Pa_QueryDevice for '%s' returned: %d\n", pad->pad_DeviceName, r));
		PaHost_FreeFastMemory(pad, sizeof(internalPortAudioDevice));   /* sDeviceList still NULL ! */
		}
    else
        sDeviceList = pad;            /* First element in linked list. pad->pad_Next already NULL. */
    /*------------- QUERY AND ADD MORE POSSIBLE SGI DEVICES TO THE LINKED LIST: -------------------*/
    /*---------------------------------------------------------------------------------------------*/
	return r;
}
开发者ID:0521guo,项目名称:RakNet,代码行数:39,代码来源:pthread-pa_sgi.c


示例20: PlaySine

PaError PlaySine( paTestData *data, PaStreamFlags flags, float amplitude )
{
    PortAudioStream *stream;
    PaError err;
    data->left_phase = data->right_phase = 0;
    data->amplitude = amplitude;
    err = Pa_Initialize();
    if( err != paNoError ) goto error;
    err = Pa_OpenStream(
              &stream,
              paNoDevice,/* default input device */
              0,              /* no input */
              paFloat32,  /* 32 bit floating point input */
              NULL,
              Pa_GetDefaultOutputDeviceID(), /* default output device */
              2,              /* stereo output */
              paFloat32,      /* 32 bit floating point output */
              NULL,
              SAMPLE_RATE,
              1024,
              0,              /* number of buffers, if zero then use default minimum */
              flags,      /* we won't output out of range samples so don't bother clipping them */
              sineCallback,
              (void *)data );
    if( err != paNoError ) goto error;

    err = Pa_StartStream( stream );
    if( err != paNoError ) goto error;
    Pa_Sleep( NUM_SECONDS * 1000 );
    printf("CPULoad = %8.6f\n", Pa_GetCPULoad( stream ) );
    err = Pa_CloseStream( stream );
    if( err != paNoError ) goto error;
    Pa_Terminate();
    return paNoError;
error:
    return err;
}
开发者ID:Excalibur201010,项目名称:sharpsdr,代码行数:37,代码来源:patest_dither.c



注:本文中的Pa_GetDefaultOutputDeviceID函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Pa_GetDeviceCount函数代码示例发布时间:2022-05-30
下一篇:
C++ Pa_GetDefaultOutputDevice函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap