void MusicAudioRecorderWidget::initMonitor() { m_mFormatSound.setSampleSize(16); //set sample sze to 16 bit m_mFormatSound.setSampleType(QAudioFormat::UnSignedInt ); //Sample type as usigned integer sample m_mFormatSound.setByteOrder(QAudioFormat::LittleEndian); //Byte order m_mFormatSound.setCodec("audio/pcm"); //set codec as simple audio/pcm QAudioDeviceInfo infoIn(QAudioDeviceInfo::defaultInputDevice()); if (!infoIn.isFormatSupported(m_mFormatSound)) { //Default format not supported - trying to use nearest m_mFormatSound = infoIn.nearestFormat(m_mFormatSound); } QAudioDeviceInfo infoOut(QAudioDeviceInfo::defaultOutputDevice()); if (!infoOut.isFormatSupported(m_mFormatSound)) { //Default format not supported - trying to use nearest m_mFormatSound = infoOut.nearestFormat(m_mFormatSound); } createAudioInput(); createAudioOutput(); m_mpOutputDevSound = m_mpAudioOutputSound->start(); m_mpInputDevSound = m_mpAudioInputSound->start(); connect(m_mpInputDevSound, SIGNAL(readyRead()), SLOT(onReadMore())); connect(ui->horizontalSlider, SIGNAL(valueChanged(int)), SLOT(onSliderValueChanged(int))); }
void AudioTest::initializeAudio() { connect(m_pullTimer, SIGNAL(timeout()), SLOT(pullTimerExpired())); m_pullMode = true; m_format.setSampleRate(DataFrequencyHz); m_format.setChannelCount(1); m_format.setSampleSize(8); m_format.setCodec("audio/pcm"); m_format.setByteOrder(QAudioFormat::LittleEndian); m_format.setSampleType(QAudioFormat::UnSignedInt); QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); if (!info.isFormatSupported(m_format)) { qWarning() << "Default format not supported - trying to use nearest"; m_format = info.nearestFormat(m_format); } m_generator = new Generator(m_format, DurationSeconds*1000000, ToneFrequencyHz, this); //input_sender = new InputSender(this, udpSocket, "127.0.0.1" , 60000); createAudioOutput(); createAudioInput(); }
void WhistleListener::startListening() { initializeAudio(); createAudioInput(); }