本文整理汇总了C++中Pa_GetDefaultInputDevice函数的典型用法代码示例。如果您正苦于以下问题:C++ Pa_GetDefaultInputDevice函数的具体用法?C++ Pa_GetDefaultInputDevice怎么用?C++ Pa_GetDefaultInputDevice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Pa_GetDefaultInputDevice函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: stream
AudioInput::AudioInput()
: stream(0)
{
PaStreamParameters inputParameters;
PaError err = paNoError;
std::cout << "Initializing PortAudio\n";
err = Pa_Initialize();
if( err != paNoError ) return;
std::cout << "Getting default audio input device\n";
inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
if (inputParameters.device == paNoDevice) {
std::cerr << "Error: No default input device.\n";
return;
}
inputParameters.channelCount = 1; /* mono input */
inputParameters.sampleFormat = paInt16;
inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultLowInputLatency;
inputParameters.hostApiSpecificStreamInfo = NULL;
std::cout << "Opening stream\n";
/* Open audio stream. -------------------------------------------- */
err = Pa_OpenStream(
&stream,
&inputParameters,
NULL, /* &outputParameters, */
SAMPLE_RATE,
CHUNK_SIZE,
paNoFlag,
NULL,
NULL);
if (err != paNoError) {
std::cerr << "Error opening stream: " << Pa_GetErrorText(err) << '\n';
return;
}
std::cout << "Audio device open\n";
if ((err = Pa_StartStream(stream)) != paNoError) {
std::cerr << "Error starting stream: " << Pa_GetErrorText(err) << '\n';
}
}
开发者ID:ollisal,项目名称:soundnunni,代码行数:48,代码来源:AudioInput.cpp
示例17: portaudio_manager_t
portaudio_manager_t(int p_sample_rate, int p_size) :
sample_rate(p_sample_rate), size(p_size),
input_stream_parameters(), input_stream(NULL) {
// initialize portaudio to stream from the default audio device
PaError pa_error;
pa_error = Pa_Initialize();
if (pa_error != 0) {
std::ostringstream ss;
ss << "failure initializing portaudio " << pa_error;
throw std::runtime_error(ss.str());
}
input_stream_parameters.device = Pa_GetDefaultInputDevice();
if (input_stream_parameters.device == paNoDevice) {
throw std::runtime_error("No device. Cannot continue.");
}
input_stream_parameters.channelCount = 1;
input_stream_parameters.sampleFormat = paFloat32;
input_stream_parameters.suggestedLatency =
Pa_GetDeviceInfo(input_stream_parameters.device)->defaultHighInputLatency;
input_stream_parameters.hostApiSpecificStreamInfo = NULL;
std::cout << "Opening input "
<< Pa_GetDeviceInfo(input_stream_parameters.device)->name
<< "\n";
pa_error = Pa_OpenStream(&input_stream,
&input_stream_parameters,
NULL,
sample_rate,
size,
paClipOff, // ?
NULL,
NULL);
if (pa_error != 0) {
std::ostringstream ss2;
ss2 << "failure opening input stream " << pa_error;
throw std::runtime_error(ss2.str());
}
// start the input stream
pa_error = Pa_StartStream(input_stream);
if (pa_error != 0) {
std::ostringstream ss3;
ss3 << "failure starting input stream " << pa_error;
throw std::runtime_error(ss3.str());
}
}
开发者ID:BruceMty,项目名称:soundcheck,代码行数:48,代码来源:portaudio_manager.hpp
示例18:
void AudioManager::initInput()
{
if ((this->_inputParam.device = Pa_GetDefaultInputDevice()) == paNoDevice)
{
// std::cout << "ZIZI" << std::endl;
this->errorAudio();
return ;
}
this->_inputParam.channelCount = 1;
this->_inputParam.sampleFormat = PA_SAMPLE_TYPE;
this->_inputParam.suggestedLatency = Pa_GetDeviceInfo(this->_inputParam.device)->defaultHighInputLatency;
this->_inputParam.hostApiSpecificStreamInfo = NULL;
// std::cout << "Input device # " << this->_inputParam.device << std::endl;
// std::cout << "Input LowLatency : " << Pa_GetDeviceInfo(this->_inputParam.device)->defaultLowInputLatency << std::endl;
// std::cout << "Input HighLatency : " << Pa_GetDeviceInfo(this->_inputParam.device)->defaultHighInputLatency << std::endl;
}
开发者ID:stephanemombuleau,项目名称:babelEpitech,代码行数:16,代码来源:AudioManager.cpp
示例19: pa_defaultinputdevice
static int pa_defaultinputdevice(lua_State *L)
{
int narg = lua_gettop(L);
PaDeviceIndex dev;
if(narg != 0)
luaL_error(L, "invalid arguments: no argument expected");
dev = Pa_GetDefaultInputDevice();
if(dev == paNoDevice)
return 0;
else
lua_pushnumber(L, dev+1);
return 1;
}
开发者ID:andresy,项目名称:lua---pa,代码行数:17,代码来源:init.c
示例20: audio_pa_run
int audio_pa_run(audio_callback_fn_pt callback, double sample_rate, unsigned long chunk_size) {
chunk = calloc(chunk_size, sizeof *chunk);
if(chunk == NULL) MEMFAIL();
PaError err = Pa_Initialize();
if(err != paNoError) FAIL("Could not initialize PortAudio\n");
PaStreamParameters inputParameters;
inputParameters.device = Pa_GetDefaultInputDevice();
inputParameters.channelCount = NUM_CHANNELS;
inputParameters.sampleFormat = PA_SAMPLE_TYPE;
inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultHighInputLatency ;
inputParameters.hostApiSpecificStreamInfo = NULL;
PaStream *stream = NULL;
err = Pa_OpenStream(&stream,
&inputParameters,
0,
sample_rate,
chunk_size,
paClipOff,
0,
0);
if(err != paNoError) FAIL("Could not open PortAudio input stream\n");
err = Pa_StartStream(stream);
if(err != paNoError) FAIL("Could not open audio input stream\n");
/*
printf("Gracefully terminated PortAudio\n");
*/
int cb_err = 0;
while(cb_err == 0){
err = Pa_ReadStream(stream, chunk, chunk_size );
if(err != paNoError) FAIL("Could not read audio chunk\n");
cb_err = callback(chunk);
}
err = Pa_Terminate();
if(err != paNoError) FAIL("Could not terminate PortAudio\n");
free(chunk);
return 0;
}
开发者ID:zbanks,项目名称:radiance,代码行数:45,代码来源:input_pa.c
注:本文中的Pa_GetDefaultInputDevice函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论