<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QAudioDeviceInfo Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QAudioDeviceInfo Class Reference<br /><sup><sup>[<a href="qtmultimedia.html">QtMultimedia</a> module]</sup></sup></h1><p>The QAudioDeviceInfo class provides an interface to query audio devices and their functionality. <a href="#details">More...</a></p> <h3>Methods</h3><ul><li><div class="fn" /><b><a href="qaudiodeviceinfo.html#QAudioDeviceInfo">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qaudiodeviceinfo.html#QAudioDeviceInfo-2">__init__</a></b> (<i>self</i>, QAudioDeviceInfo <i>other</i>)</li><li><div class="fn" />QString <b><a href="qaudiodeviceinfo.html#deviceName">deviceName</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qaudiodeviceinfo.html#isFormatSupported">isFormatSupported</a></b> (<i>self</i>, QAudioFormat <i>format</i>)</li><li><div class="fn" />bool <b><a href="qaudiodeviceinfo.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" />QAudioFormat <b><a href="qaudiodeviceinfo.html#nearestFormat">nearestFormat</a></b> (<i>self</i>, QAudioFormat <i>format</i>)</li><li><div class="fn" />QAudioFormat <b><a href="qaudiodeviceinfo.html#preferredFormat">preferredFormat</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QAudioFormat.Endian <b><a href="qaudiodeviceinfo.html#supportedByteOrders">supportedByteOrders</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-int <b><a href="qaudiodeviceinfo.html#supportedChannelCounts">supportedChannelCounts</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-int <b><a href="qaudiodeviceinfo.html#supportedChannels">supportedChannels</a></b> (<i>self</i>)</li><li><div class="fn" />QStringList <b><a href="qaudiodeviceinfo.html#supportedCodecs">supportedCodecs</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-int <b><a href="qaudiodeviceinfo.html#supportedFrequencies">supportedFrequencies</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-int <b><a href="qaudiodeviceinfo.html#supportedSampleRates">supportedSampleRates</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-int <b><a href="qaudiodeviceinfo.html#supportedSampleSizes">supportedSampleSizes</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QAudioFormat.SampleType <b><a href="qaudiodeviceinfo.html#supportedSampleTypes">supportedSampleTypes</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />list-of-QAudioDeviceInfo <b><a href="qaudiodeviceinfo.html#availableDevices">availableDevices</a></b> (QAudio.Mode <i>mode</i>)</li><li><div class="fn" />QAudioDeviceInfo <b><a href="qaudiodeviceinfo.html#defaultInputDevice">defaultInputDevice</a></b> ()</li><li><div class="fn" />QAudioDeviceInfo <b><a href="qaudiodeviceinfo.html#defaultOutputDevice">defaultOutputDevice</a></b> ()</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QAudioDeviceInfo class provides an interface to query audio devices and their functionality.</p> <p>QAudioDeviceInfo lets you query for audio devices--such as sound cards and USB headsets--that are currently available on the system. The audio devices available are dependent on the platform or audio plugins installed.</p> <p>You can also query each device for the formats it supports. A format in this context is a set consisting of a specific byte order, channel, codec, frequency, sample rate, and sample type. A format is represented by the <a href="qaudioformat.html">QAudioFormat</a> class.</p> <p>The values supported by the the device for each of these parameters can be fetched with <a href="qaudiodeviceinfo.html#supportedByteOrders">supportedByteOrders</a>(), <a href="qaudiodeviceinfo.html#supportedChannelCounts">supportedChannelCounts</a>(), <a href="qaudiodeviceinfo.html#supportedCodecs">supportedCodecs</a>(), <a href="qaudiodeviceinfo.html#supportedSampleRates">supportedSampleRates</a>(), <a href="qaudiodeviceinfo.html#supportedSampleSizes">supportedSampleSizes</a>(), and <a href="qaudiodeviceinfo.html#supportedSampleTypes">supportedSampleTypes</a>(). The combinations supported are dependent on the platform, audio plugins installed and the audio device capabilities. If you need a specific format, you can check if the device supports it with <a href="qaudiodeviceinfo.html#isFormatSupported">isFormatSupported</a>(), or fetch a supported format that is as close as possible to the format with <a href="qaudiodeviceinfo.html#nearestFormat">nearestFormat</a>(). For instance:</p> <pre class="cpp"> <span class="type"><a href="qaudioformat.html">QAudioFormat</a></span> format; format<span class="operator">.</span>setFrequency(<span class="number">44100</span>); ... format<span class="operator">.</span>setSampleType(<span class="type"><a href="qaudioformat.html">QAudioFormat</a></span><span class="operator">.</span>SignedInt); <span class="type">QAudioDeviceInfo</span> info(<span class="type">QAudioDeviceInfo</span><span class="operator">.</span>defaultOutputDevice()); <span class="keyword">if</span> (<span class="operator">!</span>info<span class="operator">.</span>isFormatSupported(format)) format <span class="operator">=</span> info<span class="operator">.</span>nearestFormat(format); </pre> <p>A QAudioDeviceInfo is used by Qt to construct classes that communicate with the device--such as <a href="qaudioinput.html">QAudioInput</a>, and <a href="qaudiooutput.html">QAudioOutput</a>. The static functions <a href="qaudiodeviceinfo.html#defaultInputDevice">defaultInputDevice</a>(), <a href="qaudiodeviceinfo.html#defaultOutputDevice">defaultOutputDevice</a>(), and <a href="qaudiodeviceinfo.html#availableDevices">availableDevices</a>() let you get a list of all available devices. Devices are fetch according to the value of mode this is specified by the <a href="qaudio.html#Mode-enum">QAudio.Mode</a> enum. The QAudioDeviceInfo returned are only valid for the <a href="qaudio.html#Mode-enum">QAudio.Mode</a>.</p> <p>For instance:</p> <pre class="cpp"> <a href="qtcore.html#foreach">foreach</a>(<span class="keyword">const</span> <span class="type">QAudioDeviceInfo</span> <span class="operator">&</span>deviceInfo<span class="operator">,</span> <span class="type">QAudioDeviceInfo</span><span class="operator">.</span>availableDevices(<span class="type"><a href="qaudio.html">QAudio</a></span><span class="operator">.</span>AudioOutput)) <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">"Device name: "</span> <span class="operator"><</span><span class="operator"><</span> deviceInfo<span class="operator">.</span><a href="qaudiodeviceinfo.html#deviceName">deviceName</a>(); </pre> <p>In this code sample, we loop through all devices that are able to output sound, i.e., play an audio stream in a supported format. For each device we find, we simply print the <a href="qaudiodeviceinfo.html#deviceName">deviceName</a>().</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QAudioDeviceInfo" />QAudioDeviceInfo.__init__ (<i>self</i>)</h3><p>Constructs an empty <a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> object.</p> <h3 class="fn"><a name="QAudioDeviceInfo-2" />QAudioDeviceInfo.__init__ (<i>self</i>, <a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> <i>other</i>)</h3><p>Constructs a copy of <i>other</i>.</p> <h3 class="fn"><a name="availableDevices" />list-of-QAudioDeviceInfo QAudioDeviceInfo.availableDevices (<a href="qaudio.html#Mode-enum">QAudio.Mode</a> <i>mode</i>)</h3><p>Returns a list of audio devices that support <i>mode</i>.</p> <h3 class="fn"><a name="defaultInputDevice" /><a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> QAudioDeviceInfo.defaultInputDevice ()</h3><p>Returns the name of the default input audio device. All platform and audio plugin implementations provide a default audio device to use.</p> <h3 class="fn"><a name="defaultOutputDevice" /><a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> QAudioDeviceInfo.defaultOutputDevice ()</h3><p>Returns the name of the default output audio device. All platform and audio plugin implementations provide a default audio device to use.</p> <h3 class="fn"><a name="deviceName" />QString QAudioDeviceInfo.deviceName (<i>self</i>)</h3><p>Returns human readable name of audio device.</p> <p>Device names vary depending on platform/audio plugin being used.</p> <p>They are a unique string identifiers for the audio device.</p> <p>eg. default, Intel, U0x46d0x9a4</p> <h3 class="fn"><a name="isFormatSupported" />bool QAudioDeviceInfo.isFormatSupported (<i>self</i>, <a href="qaudioformat.html">QAudioFormat</a> <i>format</i>)</h3><p>Returns true if <i>settings</i> are supported by the audio device of this <a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a>.</p> <h3 class="fn"><a name="isNull" />bool QAudioDeviceInfo.isNull (<i>self</i>)</h3><p>Returns whether this <a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a> object holds a device definition.</p> <h3 class="fn"><a name="nearestFormat" /><a href="qaudioformat.html">QAudioFormat</a> QAudioDeviceInfo.nearestFormat (<i>self</i>, <a href="qaudioformat.html">QAudioFormat</a> <i>format</i>)</h3><p>Returns closest <a href="qaudioformat.html">QAudioFormat</a> to <i>settings</i> that system audio supports.</p> <p>These settings are provided by the platform/audio plugin being used.</p> <p>They also are dependent on the <a href="qaudio.html#Mode-enum">QAudio.Mode</a> being used.</p> <h3 class="fn"><a name="preferredFormat" /><a href="qaudioformat.html">QAudioFormat</a> QAudioDeviceInfo.preferredFormat (<i>self</i>)</h3><p>Returns <a href="qaudioformat.html">QAudioFormat</a> of default settings.</p> <p>These settings are provided by the platform/audio plugin being used.</p> <p>They also are dependent on the <a href="qaudio.html#Mode-enum">QAudio.Mode</a> being used.</p> <p>A typical audio system would provide something like:</p> <ul> <li>Input settings: 8000Hz mono 8 bit.</li> <li>Output settings: 44100Hz stereo 16 bit little endian.</li> </ul> <h3 class="fn"><a name="supportedByteOrders" />list-of-QAudioFormat.Endian QAudioDeviceInfo.supportedByteOrders (<i>self</i>)</h3><p>Returns a list of supported byte orders.</p> <h3 class="fn"><a name="supportedChannelCounts" />list-of-int QAudioDeviceInfo.supportedChannelCounts (<i>self</i>)</h3><p>Returns a list of supported channel counts.</p> <p>This function was introduced in Qt 4.7.</p> <h3 class="fn"><a name="supportedChannels" />list-of-int QAudioDeviceInfo.supportedChannels (<i>self</i>)</h3><h3 class="fn"><a name="supportedCodecs" />QStringList QAudioDeviceInfo.supportedCodecs (<i>self</i>)</h3><p>Returns a list of supported codecs.</p> <p>All platform and plugin implementations should provide support for:</p> <p>"audio/pcm" - Linear PCM</p> <p>For writing plugins to support additional codecs refer to:</p> <p>http://www.iana.org/assignments/media-types/audio/</p> <h3 class="fn"><a name="supportedFrequencies" />list-of-int QAudioDeviceInfo.supportedFrequencies (<i>self</i>)</h3><h3 class="fn"><a name="supportedSampleRates" />list-of-int QAudioDeviceInfo.supportedSampleRates (<i>self</i>)</h3><p>Returns a list of supported sample rates.</p> <p>This function was introduced in Qt 4.7.</p> <h3 class="fn"><a name="supportedSampleSizes" />list-of-int QAudioDeviceInfo.supportedSampleSizes (<i>self</i>)</h3><p>Returns a list of supported sample sizes.</p> <h3 class="fn"><a name="supportedSampleTypes" />list-of-QAudioFormat.SampleType QAudioDeviceInfo.supportedSampleTypes (<i>self</i>)</h3><p>Returns a list of supported sample types.</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>