예제 #1
0
TSR::TSR(QObject *parent) :
    QObject(parent)
{
    memset(finishedQ, 0, sizeof(finishedQ));
    ts = TS_STOPPED;
    inProcess = false;
    elapsedTime = 0;
    totalTime = 0;

    saveLoc  = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); //QDir::currentPath();
    saveLoc += "/";
    //qDebug() << "Default saveLoc" << saveLoc;

    QAudioEncoderSettings audioSettings;
    //audioSettings.setBitRate();
    audioSettings.setChannelCount(1);
    //audioSettings.setCodec("audio/amr");
    //audioSettings.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
    //audioSettings.setQuality(QMultimedia::HighQuality);
    //audioSettings.setSampleRate(16000);

    audioRecorder = new QAudioRecorder;
    audioRecorder->setEncodingSettings(audioSettings);
    //audioRecorder->setAudioInput(audioRecorder->defaultAudioInput());
    //audioRecorder->setAudioInput(audioRecorder->audioInputs()[0]);
    audioRecorder->setVolume(1.0);

    connect(this, SIGNAL(queueProcess()), this, SLOT(process()), Qt::QueuedConnection);
    connect(&timer, SIGNAL(timeout()), this, SLOT(process()));
    timer.start(250);
}
QAudioEncoderSettings AndroidAudioEncoderControl::audioSettings() const
{
    QAudioEncoderSettings settings;
    settings.setCodec(tr("audio/amr-nb"));
    settings.setSampleRate(8);
    return settings;
}
예제 #3
0
AudioRecorder::AudioRecorder(QObject *parent) : QObject(parent)
{
    m_audioRecorder = new QAudioRecorder( this );
    QAudioEncoderSettings audioSettings;
    audioSettings.setCodec("audio/PCM");
    audioSettings.setQuality(QMultimedia::HighQuality);
    m_audioRecorder->setEncodingSettings(audioSettings);
    // https://forum.qt.io/topic/42541/recording-audio-using-qtaudiorecorder/2
    m_audioRecorder->setContainerFormat("wav");
    m_recording = false;
}
QList<int> QAndroidAudioEncoderSettingsControl::supportedSampleRates(const QAudioEncoderSettings &settings, bool *continuous) const
{
    if (continuous)
        *continuous = false;

    if (settings.isNull() || settings.codec().isNull() || settings.codec() == QLatin1String("aac")) {
        return QList<int>() << 8000 << 11025 << 12000 << 16000 << 22050
                            << 24000 << 32000 << 44100 << 48000 << 96000;
    } else if (settings.codec() == QLatin1String("amr-nb")) {
        return QList<int>() << 8000;
    } else if (settings.codec() == QLatin1String("amr-wb")) {
        return QList<int>() << 16000;
    }

    return QList<int>();
}
예제 #5
0
void AudioRecorder::startRecording(){
    if(recorder->state() != QMediaRecorder::StoppedState)
        return;
    source->setAudioInput(source->defaultAudioInput());
    QAudioEncoderSettings encoderSettings;
    encoderSettings.setChannelCount(1);
    encoderSettings.setSampleRate(44000);
    // for FLAC encoding:
    encoderSettings.setCodec("audio/FLAC");
    encoderSettings.setEncodingMode(QtMultimediaKit::ConstantQualityEncoding);
    encoderSettings.setQuality(QtMultimediaKit::EncodingQuality(QtMultimediaKit::VeryLowQuality));
    recorder->setEncodingSettings(encoderSettings);
    recorder->record();
}
예제 #6
0
void AudioEncoderControl::setAudioSettings(const QAudioEncoderSettings &settings)
{
    QAudioFormat fmt = m_session->format();

    if (settings.encodingMode() == QMultimedia::ConstantQualityEncoding) {
        if (settings.quality() == QMultimedia::LowQuality) {
            fmt.setSampleSize(8);
            fmt.setChannelCount(1);
            fmt.setSampleRate(8000);
            fmt.setSampleType(QAudioFormat::UnSignedInt);

        } else if (settings.quality() == QMultimedia::NormalQuality) {
            fmt.setSampleSize(16);
            fmt.setChannelCount(1);
            fmt.setSampleRate(22050);
            fmt.setSampleType(QAudioFormat::SignedInt);

        } else {
            fmt.setSampleSize(16);
            fmt.setChannelCount(1);
            fmt.setSampleRate(44100);
            fmt.setSampleType(QAudioFormat::SignedInt);
        }

    } else {
        fmt.setChannelCount(settings.channelCount());
        fmt.setSampleRate(settings.sampleRate());
        if (settings.sampleRate() == 8000 && settings.bitRate() == 8000) {
            fmt.setSampleType(QAudioFormat::UnSignedInt);
            fmt.setSampleSize(8);
        } else {
            fmt.setSampleSize(16);
            fmt.setSampleType(QAudioFormat::SignedInt);
        }
    }
    fmt.setCodec("audio/pcm");

    m_session->setFormat(fmt);
    m_settings = settings;
}
예제 #7
0
void AudioRecorder::toggleRecord()
{
    if (audioRecorder->state() == QMediaRecorder::StoppedState) {
        audioRecorder->setAudioInput(boxValue(ui->audioDeviceBox).toString());

        QAudioEncoderSettings settings;
        settings.setCodec(boxValue(ui->audioCodecBox).toString());
        settings.setSampleRate(boxValue(ui->sampleRateBox).toInt());
        settings.setBitRate(boxValue(ui->bitrateBox).toInt());
        settings.setChannelCount(boxValue(ui->channelsBox).toInt());
        settings.setQuality(QMultimedia::EncodingQuality(ui->qualitySlider->value()));
        settings.setEncodingMode(ui->constantQualityRadioButton->isChecked() ?
                                 QMultimedia::ConstantQualityEncoding :
                                 QMultimedia::ConstantBitRateEncoding);

        QString container = boxValue(ui->containerBox).toString();

        audioRecorder->setEncodingSettings(settings, QVideoEncoderSettings(), container);
        audioRecorder->record();
    }
    else {
        audioRecorder->stop();
    }
}
void S60AudioEncoderControl::setAudioSettings(const QAudioEncoderSettings &settings)
{
    QAudioFormat fmt = m_session->format();
    if (settings.encodingMode() == QtMultimediaKit::ConstantQualityEncoding) {
        fmt.setCodec(settings.codec());
        setQuality(settings.quality(), fmt);
        if (settings.sampleRate() > 0) {
            fmt.setFrequency(settings.sampleRate());
        }
        if (settings.channelCount() > 0)
            fmt.setChannels(settings.channelCount());
    }else {
        if (settings.sampleRate() == 8000) {
            fmt.setSampleType(QAudioFormat::UnSignedInt);
            fmt.setSampleSize(8);
        } else {
            fmt.setSampleType(QAudioFormat::SignedInt);
            fmt.setSampleSize(16);
        }
        fmt.setCodec(settings.codec());
        fmt.setFrequency(settings.sampleRate());
        fmt.setChannels(settings.channelCount());
    }
    m_session->setFormat(fmt);
    m_settings = settings;
}
예제 #9
0
QAudioEncoderSettings encoderSettings() {
    QAudioEncoderSettings audioSettings;
    audioSettings.setCodec("audio/pcm");
    audioSettings.setQuality(QMultimedia::HighQuality);
    return audioSettings;
}