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


C++ Pa_GetDefaultInputDevice函数代码示例

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


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

示例1: main

int main(void)
{
    PaStreamParameters inputParameters, outputParameters;
    PaStream *stream;
    PaError err;

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

    inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
    if (inputParameters.device == paNoDevice) {
      fprintf(stderr,"Error: No default input device.\n");
      goto error;
    }
    inputParameters.channelCount = 2;       /* stereo input */
    inputParameters.sampleFormat = PA_SAMPLE_TYPE;
    inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultLowInputLatency;
    inputParameters.hostApiSpecificStreamInfo = NULL;

    outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
    if (outputParameters.device == paNoDevice) {
      fprintf(stderr,"Error: No default output device.\n");
      goto error;
    }
    outputParameters.channelCount = 2;       /* stereo output */
    outputParameters.sampleFormat = PA_SAMPLE_TYPE;
    outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
    outputParameters.hostApiSpecificStreamInfo = NULL;

    err = Pa_OpenStream(
              &stream,
              &inputParameters,
              &outputParameters,
              SAMPLE_RATE,
              FRAMES_PER_BUFFER,
              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:edd83,项目名称:Skype-like,代码行数:59,代码来源:pa_fuzz.c

示例2: initializeAudio

bool initializeAudio()
{
	PaError err=Pa_Initialize();

#ifdef MAKETEST
	printf("Devs: %d\ndefInp: %d\n", Pa_GetDeviceCount(), Pa_GetDefaultInputDevice());

	const PaDeviceInfo*di=Pa_GetDeviceInfo(Pa_GetDefaultInputDevice());
	printf("defNfo: %s\ndefHostApi: %d\n", di->name, di->hostApi);
#endif

	pthread_spin_init(&recBufferLock, 0);
	recBuffer=0;
	audioStream=0;
	
	return (err==paNoError);
}
开发者ID:detlevn,项目名称:qgismapper,代码行数:17,代码来源:PluginAudioWorker.cpp

示例3: Pa_GetDefaultInputDevice

bool AudioStream::setInputDevice(int device, AudioSample::eChannel channel, eLatency latency)
{
    if (device < 0)
        device = Pa_GetDefaultInputDevice();

    _inputDevice = device;
    return _setDevice(device, channel, latency, _inputParameter, INPUT_STREAM, _inputDeviceInfo);
}
开发者ID:Wayt,项目名称:Skypy,代码行数:8,代码来源:audiostream.cpp

示例4: default_device_names

    std::pair<std::string, std::string> default_device_names()
    {
        const PaDeviceIndex default_input = Pa_GetDefaultInputDevice();
        const PaDeviceIndex default_output = Pa_GetDefaultOutputDevice();

        std::cout << default_input << " " << default_output;

        return std::make_pair(device_name(default_input), device_name(default_output));
    }
开发者ID:giuliomoro,项目名称:supercollider,代码行数:9,代码来源:portaudio_backend.hpp

示例5: Pa_Initialize

bool AudioCapturePortAudio::initialize()
{
    PaError err;
    PaStreamParameters inputParameters;

    err = Pa_Initialize();
    if( err != paNoError )
        return false;

    QSettings settings;
    QVariant var = settings.value(SETTINGS_AUDIO_INPUT_DEVICE);
    if (var.isValid() == true)
        inputParameters.device = QString(var.toString()).toInt();
    else
        inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */

    if (inputParameters.device == paNoDevice)
    {
        qWarning("Error: No default input device found.\n");
        Pa_Terminate();
        return false;
    }

    inputParameters.channelCount = m_channels;
    inputParameters.sampleFormat = paInt16;
    inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultLowInputLatency;
    inputParameters.hostApiSpecificStreamInfo = NULL;

    // ensure initialize() has not been called multiple times
    Q_ASSERT(stream == NULL);

    /* -- setup stream -- */
    err = Pa_OpenStream( &stream, &inputParameters, NULL, m_sampleRate, paFramesPerBufferUnspecified,
              paClipOff, /* we won't output out of range samples so don't bother clipping them */
              NULL, /* no callback, use blocking API */
              NULL ); /* no callback, so no callback userData */
    if( err != paNoError )
    {
        qWarning("Cannot open audio input stream (%s)\n",  Pa_GetErrorText(err));
        Pa_Terminate();
        return false;
    }

    /* -- start capture -- */
    err = Pa_StartStream( stream );
    if( err != paNoError )
    {
        qWarning("Cannot start stream capture (%s)\n",  Pa_GetErrorText(err));
        Pa_CloseStream( stream );
        stream = NULL;
        Pa_Terminate();
        return false;
    }

    return true;
}
开发者ID:PML369,项目名称:qlcplus,代码行数:56,代码来源:audiocapture_portaudio.cpp

示例6: snd_open_stream

int snd_open_stream()
{
	  faacEncConfigurationPtr pConfiguration; 
    hEncoder = faacEncOpen(samplerate, channel, &nInputSamples, &nMaxOutputBytes);
    if(hEncoder == NULL)
    {
        printf("[ERROR] Failed to call faacEncOpen()\n");
        return -1;
    }

    // (2.1) Get current encoding configuration
    pConfiguration = faacEncGetCurrentConfiguration(hEncoder);
    pConfiguration->inputFormat = FAAC_INPUT_16BIT;

    // (2.2) Set encoding configuration
    int nRet = faacEncSetConfiguration(hEncoder, pConfiguration);
    
    pbAACBuffer = new unsigned char [nMaxOutputBytes];


		////////////////////////
    char info_buf[256];

    PaStreamParameters pa_params;
    PaError pa_err;
    
    pa_params.device = Pa_GetDefaultInputDevice(); /* default input device */
    if (pa_params.device == paNoDevice) {
        fprintf(stderr,"Error: No default input device.\n");
        return 1;
    }
    pa_params.channelCount = channel;
    pa_params.sampleFormat = paInt16;
    pa_params.suggestedLatency = Pa_GetDeviceInfo(pa_params.device)->defaultHighInputLatency;
    pa_params.hostApiSpecificStreamInfo = NULL;

    pa_err = Pa_IsFormatSupported(&pa_params, NULL, samplerate);
    if(pa_err != paFormatIsSupported)
    {
    	  printf("Samplerate not supported: %dHz\n", samplerate);
        return 1;
    }

    pa_err = Pa_OpenStream(&stream, &pa_params, NULL,
                            samplerate, PA_FRAMES,
                            paNoFlag, snd_callback, NULL);

    if(pa_err != paNoError)
    {
        printf("error opening sound device: \n%s\n", Pa_GetErrorText(pa_err));
        return 1;
    }
    
    Pa_StartStream(stream);
    return 0;
}
开发者ID:leslie-wang,项目名称:faac-test,代码行数:56,代码来源:liveaac.cpp

示例7: Pa_Initialize

int AudioStreamManager::StreamAudio(ISoundDelegate* delegate)
{
	PaStreamParameters inputParameters, outputParameters;
	PaError err;

	soundDelegate = delegate;

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

	inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
	if (inputParameters.device == paNoDevice) {
		fprintf(stderr, "Error: No default input device.\n");
		goto error;
	}
	inputParameters.channelCount = 2;       /* stereo input */
	inputParameters.sampleFormat = PA_SAMPLE_TYPE;
	inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency;
	inputParameters.hostApiSpecificStreamInfo = NULL;

	outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
	if (outputParameters.device == paNoDevice) {
		fprintf(stderr, "Error: No default output device.\n");
		goto error;
	}
	outputParameters.channelCount = 2;       /* stereo output */
	outputParameters.sampleFormat = PA_SAMPLE_TYPE;
	outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
	outputParameters.hostApiSpecificStreamInfo = NULL;
	
	err = Pa_OpenStream(
		&audioStream,
		&inputParameters,
		&outputParameters,
		SAMPLE_RATE,
		FRAMES_PER_BUFFER,
		0, /* paClipOff, */  /* we won't output out of range samples so don't bother clipping them */
		readStreamCallback,
		NULL);
	if (err != paNoError) goto error;

	delegate->willBeginPlay();

	err = Pa_StartStream(audioStream);
	if (err != paNoError) goto error;	
	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));
	delegate->didEndPlay();
	return -1;
}
开发者ID:garbagemza,项目名称:fv1-emu,代码行数:55,代码来源:AudioStreamManager.cpp

示例8: freeBuffers

void GuitarSori::init( const int mFramesPerBuffer, const int mNumChannels, const int mSampleSize, PaSampleFormat mSampleFormat, const double mSampleRate)
{
	int numBytes, numBytesConverted;

	framesPerBuffer = mFramesPerBuffer;
	numChannels = mNumChannels;
	sampleSize = mSampleSize;
	sampleFormat = mSampleFormat;
	sampleRate = mSampleRate;

	numBytes = mFramesPerBuffer * mNumChannels * mSampleSize;
	numBytesConverted = mFramesPerBuffer * mNumChannels * 8;

	freeBuffers();
	sampleBlock = (char *)malloc(numBytes);
	sampleBlockConverted = (double *)malloc(numBytesConverted);
	sampleBlockFFT = (double *)malloc(numBytesConverted / 2);

	if ( !isBuffersReady() )
	{
		printf("Cannot allocate sample block\n");
		return;
	}

	memset(sampleBlock, 0x00, numBytes);
	memset(sampleBlockConverted, 0x00, numBytesConverted);
	memset(sampleBlockFFT, 0x00, numBytesConverted / 2);

	err = Pa_Initialize();

	printf("──────────────────────────────\n");
	inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
	inputParameters.device = 1;
	printf("Input device # %d. : %s\n", inputParameters.device, Pa_GetDeviceInfo(inputParameters.device)->name);
	printf("Input LL: %g s\n", Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency);
	printf("Input HL: %g s\n", Pa_GetDeviceInfo(inputParameters.device)->defaultHighInputLatency);
	printf("Input HL: %g s\n", Pa_GetDeviceInfo(inputParameters.device)->defaultHighInputLatency);
	printf("Input Channel(MAX.) : %d ", Pa_GetDeviceInfo(inputParameters.device)->maxInputChannels);
	inputParameters.channelCount = numChannels;
	inputParameters.sampleFormat = sampleFormat;
	inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)->defaultHighInputLatency;
	inputParameters.hostApiSpecificStreamInfo = NULL;

	outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
	printf("Output device # %d.\n", outputParameters.device);
	printf("Output LL: %g s\n", Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency);
	printf("Output HL: %g s\n", Pa_GetDeviceInfo(outputParameters.device)->defaultHighOutputLatency);
	outputParameters.channelCount = numChannels;
	outputParameters.sampleFormat = sampleFormat;
	outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultHighOutputLatency;
	outputParameters.hostApiSpecificStreamInfo = NULL;

	err = Pa_OpenStream(&stream, &inputParameters, &outputParameters, sampleRate, framesPerBuffer, paClipOff, NULL, NULL);
	err = Pa_StartStream(stream);
}
开发者ID:flpeng00,项目名称:GuitarSori,代码行数:55,代码来源:GuitarSori.cpp

示例9: quisk_pa_name2index

static int quisk_pa_name2index (struct sound_dev * dev, int is_capture)
{	// Based on the device name, set the portaudio index, or -1.
	// Return non-zero for error.  Not a portaudio device is not an error.
	const PaDeviceInfo * pInfo;
	int i, count;

	if (strncmp (dev->name, "portaudio", 9)) {
		dev->portaudio_index = -1;	// Name does not start with "portaudio"
		return 0;		// Not a portaudio device, not an error
	}
	if ( ! strcmp (dev->name, "portaudiodefault")) {
		if (is_capture)		// Fill in the default device index
			dev->portaudio_index = Pa_GetDefaultInputDevice();
		else
			dev->portaudio_index = Pa_GetDefaultOutputDevice();
		strncpy (dev->msg1, "Using default portaudio device", QUISK_SC_SIZE);
		return 0;
	}
	if ( ! strncmp (dev->name, "portaudio#", 10)) {		// Integer index follows "#"
		dev->portaudio_index = i = atoi(dev->name + 10);
		pInfo = Pa_GetDeviceInfo(i);
		if (pInfo) {
			snprintf (dev->msg1, QUISK_SC_SIZE, "PortAudio device %s",  pInfo->name);
			return 0;
		}
		else {
			snprintf (quisk_sound_state.err_msg, QUISK_SC_SIZE,
				"Can not find portaudio device number %s", dev->name + 10);
		}
		return 1;
	}
	if ( ! strncmp (dev->name, "portaudio:", 10)) {
		dev->portaudio_index = -1;
		count = Pa_GetDeviceCount();		// Search for string in device name
		for (i = 0; i < count; i++) {
			pInfo = Pa_GetDeviceInfo(i);
			if (pInfo && strstr(pInfo->name, dev->name + 10)) {
				dev->portaudio_index = i;
				snprintf (dev->msg1, QUISK_SC_SIZE, "PortAudio device %s",  pInfo->name);
				break;
			}
		}
		if (dev->portaudio_index == -1)	{	// Error
			snprintf (quisk_sound_state.err_msg, QUISK_SC_SIZE,
				"Can not find portaudio device named %s", dev->name + 10);
			return 1;
		}
		return 0;
	}
	snprintf (quisk_sound_state.err_msg, QUISK_SC_SIZE,
		"Did not recognize portaudio device %s", dev->name);
	return 1;
}
开发者ID:JeremyGrosser,项目名称:quisk,代码行数:53,代码来源:sound_portaudio.c

示例10: Pa_GetDefaultInputDevice

PaDeviceIndex SoundcardDialog::getInputSource()
{
    int index = ui->inputComboBox->currentIndex();
    if (index == -1)
    {
        // no item was selected, so we return the
        // default input device
        return Pa_GetDefaultInputDevice();
    }
    else
    {
        bool ok;
        PaDeviceIndex idx = ui->inputComboBox->itemData(index).toInt(&ok);
        if (!ok)
        {
            // conversion to int not succesfull
            // return the default input device .. :(
            return Pa_GetDefaultInputDevice();
        }
        return idx;
    }
}
开发者ID:trcwm,项目名称:BasicDSP,代码行数:22,代码来源:soundcarddialog.cpp

示例11: FindInputOnlyDevice

static PaDeviceIndex FindInputOnlyDevice(void)
{
    PaDeviceIndex result = Pa_GetDefaultInputDevice();
    if( result != paNoDevice && Pa_GetDeviceInfo(result)->maxOutputChannels == 0 )
        return result;

    for( result = 0; result < Pa_GetDeviceCount(); ++result )
    {
        if( Pa_GetDeviceInfo(result)->maxOutputChannels == 0 )
            return result;
    }

    return paNoDevice;
}
开发者ID:Kirushanr,项目名称:audacity,代码行数:14,代码来源:paqa_errs.c

示例12: Pa_GetDeviceCount

void PortAudioHelper::loadDevices() {
    DEVICE_COUNT = Pa_GetDeviceCount();
    DEFAULT_INPUT_DEVICE = Pa_GetDefaultInputDevice();
    DEFAULT_OUTPUT_DEVICE = Pa_GetDefaultOutputDevice();
    for (PaDeviceIndex i=0; i<DEVICE_COUNT; i++) {
        AudioDeviceInfo deviceInfo;
        deviceInfo.deviceInfo = *Pa_GetDeviceInfo(i);
        deviceInfo.supportedSampleRates = getSupportedSampleRate(i);
        DEVICES.append(deviceInfo);
    }

    CURRENT_INPUT_DEVICE = loadFromSettings(keyDefaultInputDevice, DEFAULT_INPUT_DEVICE).toInt();
    CURRENT_OUTPUT_DEVICE = loadFromSettings(keyDefaultOutputDevice, DEFAULT_OUTPUT_DEVICE).toInt();
}
开发者ID:mohabouje,项目名称:phonospeechstudio,代码行数:14,代码来源:portaudiohelper.cpp

示例13: strlen

int AudioRecorder::open(const char* file)
{
  size_t s = strlen(file);
  char* filename = new char[s];
  strncpy(filename, file, s);
  PaError err;
  file_ = new AudioFile(filename);

  if ((err = file_->open(AudioFile::Write))) {
    HANDLE_PA_ERROR(err);
    return err;
  }

  ring_buffer_ = new RingBuffer<SamplesType, 4>(chunk_size_);

  err = Pa_Initialize();
  if(err != paNoError) {
    HANDLE_PA_ERROR(err);
  }

  input_params_.device = Pa_GetDefaultInputDevice();
  if (input_params_.device == paNoDevice) {
    HANDLE_PA_ERROR(err);
  }

  input_params_.channelCount = 1;
  input_params_.sampleFormat = paFloat32;
  input_params_.suggestedLatency = Pa_GetDeviceInfo( input_params_.device )->defaultLowInputLatency;
  input_params_.hostApiSpecificStreamInfo = NULL;

  err = Pa_OpenStream(
      &stream_,
      &input_params_,
      NULL,
      file_->samplerate(),
      chunk_size_,
      paClipOff,
      audio_callback,
      this);

  if(err != paNoError) {
    HANDLE_PA_ERROR(err);
  }

  err = Pa_SetStreamFinishedCallback(stream_, &finished_callback);
  if(err != paNoError) {
    HANDLE_PA_ERROR(err);
  }
  return 0;
}
开发者ID:padenot,项目名称:AudioTechnology,代码行数:50,代码来源:AudioRecorder.cpp

示例14: Pa_GetDefaultInputDevice

QString DevicePortAudio::deviceInputDefaultName()
{
	PaDeviceIndex		 DevIdx = Pa_GetDefaultInputDevice();

	if( DevIdx == paNoDevice )
	{
		return( QString() );
	}

	const PaDeviceInfo	*DevInf = Pa_GetDeviceInfo( DevIdx );

	const PaHostApiInfo *HstInf = Pa_GetHostApiInfo( DevInf->hostApi );

	return( QString( "%1: %2" ).arg( HstInf->name ).arg( DevInf->name ) );
}
开发者ID:Daandelange,项目名称:Fugio,代码行数:15,代码来源:deviceportaudio.cpp

示例15: return

bool			PAudioStream::initInput()
{
  if (_buffer->input == NULL)
    return (false);
  if ((_inputParam.device = Pa_GetDefaultInputDevice()) == paNoDevice)
    {
      qDebug() << "No default input device.";
      return (false);
    }
  _inputParam.channelCount = NUM_CHANNELS;
  _inputParam.sampleFormat = PA_SAMPLE_TYPE;
  _inputParam.suggestedLatency = (Pa_GetDeviceInfo(_inputParam.device))->defaultLowInputLatency;
  _inputParam.hostApiSpecificStreamInfo = NULL;
  return (true);
}
开发者ID:AGuismo,项目名称:V-and-Co-Babel,代码行数:15,代码来源:PAudioStream.cpp


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