QT QAudiooutput仅在立体声时通过左耳播放

时间:2017-01-01 18:12:07

标签: qt

我目前所拥有的是尝试让信号发生器以立体声播放。目前正在发生的事情是,当格式被接受时,它只会播放左耳的音频。然而,当我切换到单声道时,它可以通过双耳正常工作,但我想要做的就是让我可以控制我正在听哪个耳朵。例如,如果我只想让它在左耳上播放我将听到的是左耳上的音频,但是我也想要能够切换耳朵或使用两者。我目前使用的方法如下。

    format.setFrequency(44100);
    format.setChannels(2);
    format.setSampleSize(16);
    format.setCodec("audio/pcm");
    format.setByteOrder(QAudioFormat::LittleEndian);
    format.setSampleType(QAudioFormat::SignedInt);
    //This is just the format setup.

    // i am using push mode for this program
    audio_outputStream = new QAudioOutput(format, this);
    audio_outputDevice = audio_outputStream->start();

    //now when i write the numbers from the signal generator i use this  method

    QByteArray array;
    array.append(integerValueThatIsConvertedToConstChar,SizeOfInt);

    //And i write the data from the ByteArray to the IODevice as such
     audio_outputDevice.write(array.data(),MaxSizeOfInt);

    //Afterwhich i remove the front of the ByteArray for the next number to be appended and wrote in. 
    array.remove(0,SizeOfInt);

如上所述,我在我的代码中使用上面的步骤,使用一个频道单调,但只在左侧使用2个频道的立体声时播放。我的目标是能够通过推送模式控制我写入的频道。我目前不明白为什么它目前只使用两个频道中的一个,我只是不写第二个频道?

0 个答案:

没有答案