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


C++ AudioDeviceManager::getAvailableDeviceTypes方法代码示例

本文整理汇总了C++中AudioDeviceManager::getAvailableDeviceTypes方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioDeviceManager::getAvailableDeviceTypes方法的具体用法?C++ AudioDeviceManager::getAvailableDeviceTypes怎么用?C++ AudioDeviceManager::getAvailableDeviceTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AudioDeviceManager的用法示例。


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

示例1: getDeviceNames

vector<string> getDeviceNames(bool wantInputs = false) {
    vector<string> result;
    AudioDeviceManager manager;
    auto& types = manager.getAvailableDeviceTypes();
    for (auto& t: types) {
        t->scanForDevices();
        auto names = t->getDeviceNames(wantInputs);
        for (auto& name: names)
            result.push_back(name.trimEnd().toStdString());
    }
    return result;
}
开发者ID:TopRamenGod,项目名称:echomesh,代码行数:12,代码来源:DefaultDevice.cpp

示例2: main

//==============================================================================
int main( int argc, char* argv[] )
{
    AudioDeviceManager* dm = new AudioDeviceManager();
    auto callback = new SimpleCallback();

    const OwnedArray< AudioIODeviceType >* deviceTypes = &( dm->getAvailableDeviceTypes() );

    for ( auto& t : *( deviceTypes ) ) {
        DBG( "+-- device type  : ------------+" );
        DBG( "  " + t->getTypeName() );
        t->scanForDevices();
        if ( t->hasSeparateInputsAndOutputs() ) {
            DBG( "+-- inputs   : ------------+" );
            auto deviceNames = t->getDeviceNames( true );
            for ( auto& name : deviceNames ) {
                DBG( "    +-- device name  : ------------+" );
                DBG( "      " + name );
            }
            DBG( "+-- outputs  : ------------+" );
            deviceNames = t->getDeviceNames( false );
            for ( auto& name : deviceNames ) {
                DBG( "    +-- device name  : ------------+" );
                DBG( "      " + name );
            }
        } else {
        }
        DBG( "has separate inputs and outputs : " << t->hasSeparateInputsAndOutputs() );
    }

    // initialize audio with the following requirements:
    auto result =
      dm->initialise( /* num inputs */ 0, /* num outputs */ 2, /* xml settings file */ nullptr,
                      /* select default device on failure */ true );

    if ( !result.isEmpty() ) {
        DBG( "Error on initialize : " + result );
    }

    logMessage( "--------------------------------------" );
    logMessage( "Current audio device type: " +
                ( dm->getCurrentDeviceTypeObject() != nullptr
                    ? dm->getCurrentDeviceTypeObject()->getTypeName()
                    : "<none>" ) );

    if ( AudioIODevice* device = dm->getCurrentAudioDevice() ) {
        logMessage( "Current audio device: " + device->getName().quoted() );
        logMessage( "Sample rate: " + String( device->getCurrentSampleRate() ) + " Hz" );
        logMessage( "Block size: " + String( device->getCurrentBufferSizeSamples() ) + " samples" );
        logMessage( "Output Latency: " + String( device->getOutputLatencyInSamples() ) +
                    " samples" );
        logMessage( "Input Latency: " + String( device->getInputLatencyInSamples() ) + " samples" );
        logMessage( "Bit depth: " + String( device->getCurrentBitDepth() ) );
        logMessage( "Input channel names: " +
                    device->getInputChannelNames().joinIntoString( ", " ) );
        logMessage( "Active input channels: " +
                    getListOfActiveBits( device->getActiveInputChannels() ) );
        logMessage( "Output channel names: " +
                    device->getOutputChannelNames().joinIntoString( ", " ) );
        logMessage( "Active output channels: " +
                    getListOfActiveBits( device->getActiveOutputChannels() ) );
    } else {
        logMessage( "No audio device open" );
    }

    dm->addAudioCallback( callback );

    sleep( 3 ); // 3 seconds of audio
//    while ( true ) {
//    }

    dm->removeAudioCallback( callback );
    delete callback;

    delete dm;

    return 0;
}
开发者ID:ilzxc,项目名称:CHIPAudioInfo,代码行数:78,代码来源:Main.cpp


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