PDA

View Full Version : How to record and play audio on N8



doubleti
1st December 2011, 11:46
i want record and play audio on N8 but it can't play please help me
this is my code
void
RecordAndPlay::on_Record_clicked()
{
QAudioFormat format = getFormat();
_input = new QAudioInput(devices.at(deviceIndex), format, this);
connect(_input, SIGNAL(stateChanged(QAudio::State)), this, SLOT(inputStateChange(QAudio::State)));
_duLieu = new AudioInfo(format, this);
_duLieu->start();

_devi = _input->start();

_ouput = new QAudioOutput(ouputDevices.at(outputDeviceIndex), format, this);
_ouput->start(_devi);
connect(_ouput, SIGNAL(stateChanged(QAudio::State)), this, SLOT(outputStateChange(QAudio::State)));

}

QAudioFormat
RecordAndPlay::getFormat()
{
QAudioFormat format;
format.setFrequency(8000);
format.setChannels(1);
format.setSampleSize(16);
format.setSampleType(QAudioFormat::SignedInt);
format.setByteOrder(QAudioFormat::LittleEndian);
format.setCodec("audio/pcm");

QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice());
if (!info.isFormatSupported(format)) {
qDebug() << "Default format not supported - trying to use nearest";
format = info.nearestFormat(format);
}
return format;
}