Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QAudioInput Class Reference
[QtBluetoothModule, QtMediaModule, QtPimModule, QtTelephonyModule]

The QAudioInput class provides an interface to read raw audio data from a microphone input. More...

    #include <QAudioInput>

Inherits QIODevice.

Public Functions

  • 32 public functions inherited from QIODevice
  • 29 public functions inherited from QObject

Protected Functions

  • virtual qint64 readData ( char * data, qint64 maxlen )
  • virtual qint64 writeData ( const char * data, qint64 len )
  • 5 protected functions inherited from QIODevice
  • 7 protected functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 4 signals inherited from QIODevice
  • 1 signal inherited from QObject
  • 1 public type inherited from QObject
  • 4 static public members inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QAudioInput class provides an interface to read raw audio data from a microphone input.

Client applications that need direct access to the microphone should use QAudioInput to capture raw audio samples for further processing. This class abstracts the details of the underlying operating system, so that clients do not need to be aware of whether the operating system uses OSS or Alsa.

The usual sequence for opening the microphone is as follows:

    QAudioInput *audio = new QAudioInput();
    audio->setFrequency( 11025 );
    audio->setChannels( 1 );
    if ( audio->open( QIODevice::ReadOnly ) )
        audio->read( buffer, sizeof( buffer ) );

You must call read() at least once just after opening because some devices will not start recording until the first read is performed.

The audio data will be normalized to signed 16-bit samples in host byte order, regardless of what the underlying device supports.

Use the readyRead() signal to be notified of new input.

See also QAudioOutput.


Member Function Documentation

QAudioInput::QAudioInput ( const QByteArray & device, QObject * parent = 0 )

Construct a new audio input stream and attach it to parent. The device that is opened is specified by device. The default parameters are 44100 Hz Stereo, with 16-bit samples.

The device parameter is implementation-specific, and might not be honored by all implementations. It is usually an Alsa device name such as plughw:0,0. The string default can be passed for device if the client application wishes to use the default device and is not concerned with what that default device may be called.

QAudioInput::QAudioInput ( QObject * parent = 0 )

Construct a new audio input stream and attach it to parent. The default parameters are 44100 Hz Stereo, with 16-bit samples.

QAudioInput::~QAudioInput ()

Destroy this audio input stream.

qint64 QAudioInput::bytesAvailable () const   [virtual]

Returns the number of bytes that are available for reading.

Reimplemented from QIODevice.

See also read().

int QAudioInput::channels () const

Returns the number of playback channels. The default value is 2.

See also setChannels().

void QAudioInput::close ()   [virtual]

Closes this audio input stream.

Reimplemented from QIODevice.

int QAudioInput::frequency () const

Returns the current frequency of audio samples. The default value is 44100.

See also setFrequency().

bool QAudioInput::isSequential () const   [virtual]

Determines if this QIODevice is sequential. Always returns true.

Reimplemented from QIODevice.

bool QAudioInput::open ( QIODevice::OpenMode mode )

Opens this audio input stream in mode. Returns true if the audio input stream could be opened; false otherwise.

qint64 QAudioInput::readData ( char * data, qint64 maxlen )   [virtual protected]

Reads a block of raw audio samples from the input device into data. The samples are guaranteed to be signed, 16 bits in size, and in host byte order. The maxlen value is the maximum buffer size in bytes, which is twice the number of logical samples.

Returns the number of bytes read, or zero if none are currently available. This function will not block.

If the device is mono, then the number of raw samples is the same as the number of logical samples. If the device is stereo, then the number of raw samples is twice the number of logical samples.

This function may reduce the length to a logical device buffer size. Use bytesAvailable() to determine if there are still bytes left to be read.

Reimplemented from QIODevice.

int QAudioInput::samplesPerBlock () const

Returns the number of samples per block that the audio input stream will attempt to deliver upon each read. The default value is -1, which indicates that the hardware should dictate the block size.

See also setSamplesPerBlock().

void QAudioInput::setChannels ( int value )

Sets the number of playback channels to value. Should be called before open().

See also channels().

void QAudioInput::setFrequency ( int value )

Sets the frequency of audio samples to value. Should be called before open().

See also frequency().

void QAudioInput::setSamplesPerBlock ( int value )

Sets the number of samples per block that the audio input stream will attempt to deliver upon each read to value. The value -1 indicates that the hardware should dictate the block size. Should be called before open().

See also samplesPerBlock().

qint64 QAudioInput::writeData ( const char * data, qint64 len )   [virtual protected]

Writes len bytes from data to this QIODevice. Not used for audio input devices.

Reimplemented from QIODevice.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 80
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 6
Page suivante

Le Qt Developer Network au hasard

Logo

Combiner licence, à propos et fermer d'une dernière manière

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtextended4.4
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web