当前位置: 首页>>代码示例>>C++>>正文


C++ Pa_GetDeviceCount函数代码示例

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


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

示例1: displayOption

void displayOption()
{
    Pa_Initialize();
    fprintf(stderr, "--------------------------------------------------\n");
    fprintf(stderr, "Input Devices\n");
    fprintf(stderr, "--------------------------------------------------\n");
    for (int i = 0; i < Pa_GetDeviceCount(); i++) {
        const PaDeviceInfo *deviceInfo;
        deviceInfo = Pa_GetDeviceInfo(i);
        if (deviceInfo->maxInputChannels > 0) {
            const PaHostApiInfo *apiInfo;
            apiInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
            fprintf(stderr, "%2d %s(%s)\n", i, deviceInfo->name, apiInfo->name);
        }
    }

    fprintf(stderr, "\n--------------------------------------------------\n");
    fprintf(stderr, "Output Devices\n");
    fprintf(stderr, "--------------------------------------------------\n");
    for (int i = 0; i < Pa_GetDeviceCount(); i++) {
        const PaDeviceInfo *deviceInfo;
        deviceInfo = Pa_GetDeviceInfo(i);
        if (deviceInfo->maxOutputChannels > 0) {
            const PaHostApiInfo *apiInfo;
            apiInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
            fprintf(stderr, "%2d %s(%s)\n", i, deviceInfo->name, apiInfo->name);
        }
    }
    Pa_Terminate();
}
开发者ID:DMPinc,项目名称:portaudio,代码行数:30,代码来源:portaudio-test.cpp

示例2: Pa_CloseStream

void
PortAudioOutput::initAudio( long sampleRate, int channels )
{
    if ( m_audio )
    {
        Pa_CloseStream( m_audio );
        m_audio = 0;
    }

    if ( m_deviceNum >= Pa_GetDeviceCount() || m_deviceNum < 0 )
        m_deviceNum = 0;

    int bufferSize = 512;
    int deviceID = internalSoundCardID( m_deviceNum );
    qDebug() << "Internal ID:" << deviceID << "-" << "Config:" << m_deviceNum;

    if ( deviceID < 0 )
    {
        emit error( Radio_NoSoundcard, tr( "Your soundcard is either busy or not present. "
            "Try restarting the application." ) );
        return;
    }

    PaStreamParameters p;
    memset( &p, 0, sizeof( PaStreamParameters ) );

    p.sampleFormat = paInt16;
    p.channelCount = 0;

    while ( p.channelCount < channels && deviceID < Pa_GetDeviceCount() )
    {
#ifdef Q_WS_WIN
        p.device = Pa_HostApiDeviceIndexToDeviceIndex( Pa_HostApiTypeIdToHostApiIndex( paDirectSound ), deviceID++ );
#endif
#ifdef Q_WS_MAC
        p.device = Pa_HostApiDeviceIndexToDeviceIndex( Pa_HostApiTypeIdToHostApiIndex( paCoreAudio ), deviceID++ );
#endif
#ifdef Q_WS_X11
        p.device = Pa_HostApiDeviceIndexToDeviceIndex( Pa_HostApiTypeIdToHostApiIndex( paALSA ), deviceID++ );
#endif

        p.suggestedLatency = Pa_GetDeviceInfo( p.device )->defaultHighOutputLatency;
        p.channelCount = Pa_GetDeviceInfo( p.device )->maxOutputChannels;
    }

    qDebug() << "Using device with id:" << --deviceID;
    p.channelCount = channels;
//     Pa_IsFormatSupported( 0, &p, bufferSize );

    m_deviceInfo = *Pa_GetDeviceInfo( p.device );
    m_sourceChannels = channels;

    PaError error = Pa_OpenStream( &m_audio, 0, &p, sampleRate, bufferSize, 0, audioCallback, this );
    if ( error != paNoError )
    {
        qDebug() << "PortAudio Error:" << Pa_GetErrorText( error );
        m_audio = 0;
    }
}
开发者ID:exic,项目名称:last.fm-dbus,代码行数:59,代码来源:portAudioOutput.cpp

示例3: get_device_list

// Get device list
// If first argument is NULL, return the maximum number of devices
int
get_device_list(int *devidlist, char **namelist, int maxstrlen, int maxnum)
{
  PaDeviceIndex numDevice = Pa_GetDeviceCount(), i;
  const PaDeviceInfo *deviceInfo;
  const PaHostApiInfo *apiInfo;
  static char buf[256];
  int n;

  n = 0;
  for(i=0;i<numDevice;i++) {
    deviceInfo = Pa_GetDeviceInfo(i);
    if (!deviceInfo) continue;
    if (deviceInfo->maxInputChannels <= 0) continue;
    apiInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
    if (!apiInfo) continue;
    if (devidlist != NULL) {
      if ( n >= maxnum ) break;
      snprintf(buf, 255, "%s: %s", apiInfo->name, deviceInfo->name);
      buf[255] = '\0';
      devidlist[n] = i;
      strncpy(namelist[n], buf, maxstrlen);
    }
    n++;
  }
  
  return n;
}
开发者ID:0K7mGXj9thSA,项目名称:testrepositoryforjulius,代码行数:30,代码来源:adin_portaudio.c

示例4: paqaVerifyDeviceInfoLatency

static int paqaVerifyDeviceInfoLatency( void )
{
    PaDeviceIndex id;
    const PaDeviceInfo *pdi;
    int numDevices = Pa_GetDeviceCount();
    
    printf("\n ------------------------ paqaVerifyDeviceInfoLatency\n");
    for( id=0; id<numDevices; id++ ) /* Iterate through all devices. */
    {
        pdi = Pa_GetDeviceInfo( id );
        printf("Using device #%d: '%s' (%s)\n", id, pdi->name, Pa_GetHostApiInfo(pdi->hostApi)->name);
        if( pdi->maxOutputChannels > 0 )
        {
            printf("  Output defaultLowOutputLatency  = %f seconds\n", pdi->defaultLowOutputLatency);
            printf("  Output defaultHighOutputLatency = %f seconds\n", pdi->defaultHighOutputLatency);
            QA_ASSERT_TRUE( "defaultLowOutputLatency should be > 0", (pdi->defaultLowOutputLatency > 0.0) );
            QA_ASSERT_TRUE( "defaultHighOutputLatency should be > 0", (pdi->defaultHighOutputLatency > 0.0) );
            QA_ASSERT_TRUE( "defaultHighOutputLatency should be >= Low", (pdi->defaultHighOutputLatency >= pdi->defaultLowOutputLatency) );
        }
        if( pdi->maxInputChannels > 0 )
        {
            printf("  Input defaultLowInputLatency  = %f seconds\n", pdi->defaultLowInputLatency);
            printf("  Input defaultHighInputLatency = %f seconds\n", pdi->defaultHighInputLatency);
            QA_ASSERT_TRUE( "defaultLowInputLatency should be > 0", (pdi->defaultLowInputLatency > 0.0) );
            QA_ASSERT_TRUE( "defaultHighInputLatency should be > 0", (pdi->defaultHighInputLatency > 0.0) );
            QA_ASSERT_TRUE( "defaultHighInputLatency should be >= Low", (pdi->defaultHighInputLatency >= pdi->defaultLowInputLatency) );
        }
    }
    return 0;
error:
    return -1;
}
开发者ID:Excalibur201010,项目名称:sharpsdr,代码行数:32,代码来源:paqa_latency.c

示例5: paqaVerifySuggestedLatency

static int paqaVerifySuggestedLatency( void )
{
    PaDeviceIndex id;
    int result = 0;
    const PaDeviceInfo *pdi;
    int numDevices = Pa_GetDeviceCount();
    
    printf("\n ------------------------ paqaVerifySuggestedLatency\n");
    for( id=0; id<numDevices; id++ )            /* Iterate through all devices. */
    {
        pdi = Pa_GetDeviceInfo( id );
        printf("\nUsing device #%d: '%s' (%s)\n", id, pdi->name, Pa_GetHostApiInfo(pdi->hostApi)->name);
        if( pdi->maxOutputChannels > 0 )
        {
            if( paqaCheckMultipleSuggested( id, 0 ) < 0 )
            {
                printf("OUTPUT CHECK FAILED !!! #%d: '%s'\n", id, pdi->name);
                result -= 1;
        }
        }
        if( pdi->maxInputChannels > 0 )
        {
            if( paqaCheckMultipleSuggested( id, 1 ) < 0 )
            {
                printf("INPUT CHECK FAILED !!! #%d: '%s'\n", id, pdi->name);
                result -= 1;
        }
    }
    }
    return result;
}
开发者ID:Excalibur201010,项目名称:sharpsdr,代码行数:31,代码来源:paqa_latency.c

示例6: GetAudioInfo

void GetAudioInfo()
{
	PaHostApiIndex ApiCount = Pa_GetHostApiCount();

	Log::Logf("AUDIO: The default API is %d\n", Pa_GetDefaultHostApi());

	for (PaHostApiIndex i = 0; i < ApiCount; i++)
	{
		const PaHostApiInfo* Index = Pa_GetHostApiInfo(i);
		Log::Logf("(%d) %s: %d (%d)\n", i, Index->name, Index->defaultOutputDevice, Index->type);

#ifdef WIN32
		if (Index->type == paWASAPI)
			DefaultWasapiDevice = Index->defaultOutputDevice;
		else if (Index->type == paDirectSound)
			DefaultDSDevice = Index->defaultOutputDevice;
#endif
	}

	Log::Logf("\nAUDIO: The audio devices are\n");

	PaDeviceIndex DevCount = Pa_GetDeviceCount();
	for (PaDeviceIndex i = 0; i < DevCount; i++)
	{
		const PaDeviceInfo *Info = Pa_GetDeviceInfo(i);
		Log::Logf("(%d): %s\n", i, Info->name);
		Log::Logf("\thighLat: %f, lowLat: %f\n", Info->defaultHighOutputLatency, Info->defaultLowOutputLatency);
		Log::Logf("\tsampleRate: %f, hostApi: %d\n", Info->defaultSampleRate, Info->hostApi);
		Log::Logf("\tmaxchannels: %d\n", Info->maxOutputChannels);
	}
}
开发者ID:Sp3ct3r2k11,项目名称:raindrop,代码行数:31,代码来源:Audio.cpp

示例7: while

/// Gets a NEW list of devices by terminating and restarting portaudio
/// Assumes that DeviceManager is only used on the main thread.
void DeviceManager::Rescan()
{
   // get rid of the previous scan info
   this->mInputDeviceSourceMaps.clear();
   this->mOutputDeviceSourceMaps.clear();

   // if we are doing a second scan then restart portaudio to get NEW devices
   if (m_inited) {
      // check to see if there is a stream open - can happen if monitoring,
      // but otherwise Rescan() should not be available to the user.
      if (gAudioIO) {
         if (gAudioIO->IsMonitoring())
         {
            gAudioIO->StopStream();
            while (gAudioIO->IsBusy())
               wxMilliSleep(100);
         }
      }

      // restart portaudio - this updates the device list
      // FIXME: TRAP_ERR restarting PortAudio
      Pa_Terminate();
      Pa_Initialize();
   }

   // FIXME: TRAP_ERR PaErrorCode not handled in ReScan()
   int nDevices = Pa_GetDeviceCount();

   //The heirarchy for devices is Host/device/source.
   //Some newer systems aggregate this.
   //So we need to call port mixer for every device to get the sources
   for (int i = 0; i < nDevices; i++) {
      const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
      if (info->maxOutputChannels > 0) {
         AddSources(i, info->defaultSampleRate, &mOutputDeviceSourceMaps, 0);
      }

      if (info->maxInputChannels > 0) {
#ifdef __WXMSW__
#if !defined(EXPERIMENTAL_FULL_WASAPI)
         if (Pa_GetHostApiInfo(info->hostApi)->type != paWASAPI ||
             PaWasapi_IsLoopback(i) > 0)
#endif
#endif
         AddSources(i, info->defaultSampleRate, &mInputDeviceSourceMaps, 1);
      }
   }

   // If this was not an initial scan update each device toolbar.
   // Hosts may have disappeared or appeared so a complete repopulate is needed.
   if (m_inited) {
      DeviceToolBar *dt;
      for (size_t i = 0; i < gAudacityProjects.size(); i++) {
         dt = gAudacityProjects[i]->GetDeviceToolBar();
         dt->RefillCombos();
      }
   }
   m_inited = true;
   mRescanTime = std::chrono::steady_clock::now();
}
开发者ID:finefin,项目名称:audacity,代码行数:62,代码来源:DeviceManager.cpp

示例8: setupInputParametersWithDeviceName

/**
 * Sets up the input device with name given by the string
 * passed in as a parameter
 * @param in_pars	Poiner to a PaStreamParameters struct that will be
 * 					modified and setup properly
 * @param device	String with the desired device name 
 * @param format the sample format for the input device to use
 */
void setupInputParametersWithDeviceName( PaStreamParameters *in_pars, 
										const char *device, 
										PaSampleFormat format)
{
	int i;
	int device_found = false;
	for (i = 0; i < Pa_GetDeviceCount(); i++) {
		if(strcmp(Pa_GetDeviceInfo(i)->name, device) == 0) {
			in_pars->device = i;
			printf("Using %s\n", device);
			device_found = true;
			break;
		}
	}

	/* If device isn't found, use the default device */
	if (!device_found) {
		printf("Requested device not found. Using default\n");
		in_pars->device = Pa_GetDefaultInputDevice();
	}
    if (in_pars->device == paNoDevice) 
        fatal_terminate("No default input device");
    in_pars->channelCount = 
    in_pars->sampleFormat = format;
    in_pars->suggestedLatency = 
		Pa_GetDeviceInfo(in_pars->device)->maxInputChannels;
       Pa_GetDeviceInfo(in_pars->device)->defaultLowInputLatency;
    in_pars->hostApiSpecificStreamInfo = NULL;
}
开发者ID:amill676,项目名称:realtime_audio,代码行数:37,代码来源:audio_tools.c

示例9: Java_org_jpab_PortAudio_getDevicesAsBuffer

JNIEXPORT jobject JNICALL Java_org_jpab_PortAudio_getDevicesAsBuffer(JNIEnv *env, jclass paClass) {
	Device * device;
	const PaDeviceInfo * device_info;
	const UINT8 count = Pa_GetDeviceCount();
	UINT16 index, size = DEVICE_SIZE * count, offset = 0, temp;
	char * buffer = (char *)malloc(size);
	for (index = 0; index < count; index ++) {
        device_info = Pa_GetDeviceInfo(index);
		device = (Device *) (buffer + offset);
		device->default_high_input_latency = device_info->defaultHighInputLatency;
		device->default_high_output_latency = device_info->defaultHighOutputLatency;
		device->default_low_input_latency = device_info->defaultLowInputLatency;
		device->default_low_output_latency = device_info->defaultLowOutputLatency;
		device->default_sample_rate = device_info->defaultSampleRate;
		device->index = index;
		device->host_api = device_info->hostApi;
		device->max_input_channels = device_info->maxInputChannels;
		device->max_output_channels = device_info->maxOutputChannels;
		temp = strlen(device_info->name);
		device->name_length = temp;
		size += temp;
		buffer = (char *) realloc(buffer, size);
		offset += DEVICE_SIZE;
		memcpy(buffer + offset, device_info->name, temp);
		offset += temp;
	}
	return env->NewDirectByteBuffer(buffer, (jint) size);
}
开发者ID:jenia,项目名称:milestone4,代码行数:28,代码来源:PortAudioJNI.cpp

示例10: Pa_GetDeviceCount

void
CPaCommon::Enumerate(vector < string > &choices, vector < string > &descriptions)
{
    vector < string > tmp;

    names.clear();
    descriptions.clear();
	names.push_back(""); /* default device */
	descriptions.push_back("");

    int numDevices = Pa_GetDeviceCount();
    if (numDevices < 0)
        throw string("PortAudio error: ") + Pa_GetErrorText(numDevices);
    PaHostApiIndex nApis = Pa_GetHostApiCount();

    for (int i = 0; i < numDevices; i++)
    {
        const PaDeviceInfo *deviceInfo = Pa_GetDeviceInfo(i);
        if (( is_capture && deviceInfo->maxInputChannels > 1)
                || ( (!is_capture) && deviceInfo->maxOutputChannels > 1))
        {
            string api="";
            if (nApis>1)
            {
                const PaHostApiInfo* info = Pa_GetHostApiInfo(deviceInfo->hostApi);
                if (info)
                    api = string(info->name)+":";
            }
            names.push_back(api+deviceInfo->name);
            devices.push_back(i);
        }
    }
    choices = names;
}
开发者ID:castrouk,项目名称:LinDrm,代码行数:34,代码来源:drm_portaudio.cpp

示例11: TestDevices

/*******************************************************************
* Try each output device, through its full range of capabilities. */
static void TestDevices( int mode )
{
    int id, jc, i;
    int maxChannels;
    const PaDeviceInfo *pdi;
    static double standardSampleRates[] = {  8000.0,  9600.0, 11025.0, 12000.0,
                                            16000.0,          22050.0, 24000.0,
                                            32000.0,          44100.0, 48000.0,
                                                              88200.0, 96000.0,
                                               -1.0 }; /* Negative terminated list. */
    int numDevices = Pa_GetDeviceCount();
    for( id=0; id<numDevices; id++ )            /* Iterate through all devices. */
    {
        pdi = Pa_GetDeviceInfo( id );
        /* Try 1 to maxChannels on each device. */
        maxChannels = (( mode == MODE_INPUT ) ? pdi->maxInputChannels : pdi->maxOutputChannels);
        
        for( jc=1; jc<=maxChannels; jc++ )
        {
            printf("Name         = %s\n", pdi->name );
            /* Try each standard sample rate. */
            for( i=0; standardSampleRates[i] > 0; i++ )
            {
                TestFormats( mode, (PaDeviceIndex)id, standardSampleRates[i], jc );
            }
        }
    }
}
开发者ID:Excalibur201010,项目名称:sharpsdr,代码行数:30,代码来源:paqa_devs.c

示例12: GetDefaultInputDevice

/*
 * Try to intelligently fetch a default audio input device
 */
static PaDeviceIndex
GetDefaultInputDevice()
{
    int i, n;
    PaDeviceIndex def;
    const PaDeviceInfo *deviceInfo;
    
    n = Pa_GetDeviceCount();
    if (n < 0) {
        return paNoDevice;
    }
    
    /* Try default input */
    if ((def = Pa_GetDefaultInputDevice()) != paNoDevice) {
        return def;
    }
    
    /* No luck, iterate and check for API specific input device */
    for (i = 0; i < n; i++) {
        deviceInfo = Pa_GetDeviceInfo(i);
        if (i == Pa_GetHostApiInfo(deviceInfo->hostApi)->defaultInputDevice) {
            return i;
        }
    }
    /* No device :( */
    return paNoDevice;
}
开发者ID:1981khj,项目名称:rainbow,代码行数:30,代码来源:AudioSourceMac.cpp

示例13: Pa_Initialize

void AudioPortAudioSetupUtil::updateDevices()
{
	PaError err = Pa_Initialize();
	if( err != paNoError ) {
		printf( "Couldn't initialize PortAudio: %s\n", Pa_GetErrorText( err ) );
		return;
	}

	// get active backend 
	const QString& backend = m_backendModel.currentText();
	int hostApi = 0;
	const PaHostApiInfo * hi;
	for( int i = 0; i < Pa_GetHostApiCount(); ++i )
	{
		hi = Pa_GetHostApiInfo( i );
		if( backend == hi->name )
		{
			hostApi = i;
			break;
		}
	}

	// get devices for selected backend
	m_deviceModel.clear();
	const PaDeviceInfo * di;
	for( int i = 0; i < Pa_GetDeviceCount(); ++i )
	{
		di = Pa_GetDeviceInfo( i );
		if( di->hostApi == hostApi )
		{
			m_deviceModel.addItem( di->name );
		}
	}
	Pa_Terminate();
}
开发者ID:BaraMGB,项目名称:lmms,代码行数:35,代码来源:AudioPortAudio.cpp

示例14: pa_getdevs

    /* scanning for devices */
void pa_getdevs(char *indevlist, int *nindevs,
    char *outdevlist, int *noutdevs, int *canmulti, 
        int maxndev, int devdescsize)
{
    int i, nin = 0, nout = 0, ndev;
    *canmulti = 1;  /* one dev each for input and output */

    pa_init();
    ndev = Pa_GetDeviceCount();
    for (i = 0; i < ndev; i++)
    {
        const PaDeviceInfo *pdi = Pa_GetDeviceInfo(i);
        if (pdi->maxInputChannels > 0 && nin < maxndev)
        {
            sprintf(indevlist + nin * devdescsize, "(%d)%s",
                pdi->hostApi,pdi->name);
            /* strcpy(indevlist + nin * devdescsize, pdi->name); */
            nin++;
        }
        if (pdi->maxOutputChannels > 0 && nout < maxndev)
        {
            sprintf(outdevlist + nout * devdescsize, "(%d)%s",
                pdi->hostApi,pdi->name);
            /* strcpy(outdevlist + nout * devdescsize, pdi->name); */
            nout++;
        }
    }
    *nindevs = nin;
    *noutdevs = nout;
}
开发者ID:ailo,项目名称:pd-mousike,代码行数:31,代码来源:s_audio_pa.c

示例15: do_portaudio

static int
do_portaudio(int argc, char *argv[])
{
	PaError err;
	PaDeviceIndex idx;

	err = Pa_Initialize();
	do_pa_error(err,"init");

	if(!f_log) usage(2,stderr);

	if (argc > 1) usage(2,stderr);
	idx = Pa_GetDeviceCount();
	if(!idx) {
		fprintf(stderr,"No devices available!\n");
		exit(1);
	} else if (idx < 0)
		do_pa_error(idx,"Device enum");

	while(idx-- > 0) {
		const struct PaDeviceInfo *dev = Pa_GetDeviceInfo(idx);
		if(argc) {
			if (!strcmp(dev->name,argv[0]))
				do_pa_run(idx, dev->defaultLowInputLatency);
		} else
			printf("%s (%f)\n",dev->name, dev->defaultSampleRate);
	}
	if (argc) {
		fprintf(stderr,"Device '%s' not found.\n",argv[0]);
		exit(1);
	}
	exit(0);
	/* NOTREACHED */
}
开发者ID:M-o-a-T,项目名称:moat,代码行数:34,代码来源:reader.c


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