![]() |
CopperSpice API
2.0.0
|
CsMultimedia offers a range of audio classes, covering both low and high level approaches to audio input, output and processing.
To play audio or video audio files that are compressed use the QMediaPlayer class. The supported compression formats depend on the operating system and any media plugins the user installed.
The following example shows how to play a local mp3 file.
You can also put files or remote URLs into a playlist.
The QAudioRecorder class allows you to compress audio data from an input device and record it.
In addition to the raw access to sound devices described above, the QSoundEffect class offers a slightly higher level way to play sounds. These classes allow you to specify a WAV format file which can then be played with low latency when necessary. Both QSoundEffect and SoundEffect have essentially the same API.
You can adjust the number of loops a sound effect is played, as well as the volume (or muting) of the effect.
To support older applications QSound is also available. QSoundEffect is preferred where possible.
The QAudioProbe class allows you to monitor audio data being played or recorded using classes like QMediaPlayer, QCamera and QAudioRecorder.
After creating an instance of one of these classed set the source of the probe to the instance. The probe will receive audio buffers as they are processed. This is useful for audio processing tasks like visualization or adjusting gain. The buffers are read only and they may arrive at a slightly different time than the media pipeline processes them.
The following example shows how to install a probe before recording. The probe will emit a signal each time a new audio buffer is recorded.
In some cases you may want to decode a compressed audio file and do further processing yourself. For example, mixing multiple samples or using custom digital signal processing algorithms. QAudioDecoder supports decoding local files or data streams from QIODevice instances.
The following is an example of decoding a local file.