예제 #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);
}
예제 #2
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();
}
예제 #3
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();
    }
}