int main(int argv, char **args)
{
    QApplication app(argv, args);
    app.setApplicationName("Audio effect tester");

    Phonon::MediaObject *mediaObject = new Phonon::MediaObject;
    mediaObject->setCurrentSource(QString("/home/gvatteka/Music/Lumme-Badloop.ogg"));

    Phonon::AudioOutput *audioOutput =
        new Phonon::AudioOutput(Phonon::MusicCategory);

//! [0]
    QList<Phonon::EffectDescription> effectDescriptions =
            Phonon::BackendCapabilities::availableAudioEffects();
    Phonon::EffectDescription effectDescription = effectDescriptions.at(4);

    Phonon::Path path = Phonon::createPath(mediaObject, audioOutput);

//! [1]
    Phonon::Effect *effect = new Phonon::Effect(effectDescription);
    path.insertEffect(effect);
//! [0]

    Phonon::EffectWidget *effectWidget = new Phonon::EffectWidget(effect);
    effectWidget->show();
//! [1]

    mediaObject->play();

    effectWidget->setWindowTitle("Effect Name: " + effectDescription.name());

    app.exec();
}
Exemple #2
0
Window::Window()
{
    {
//![0]
    Phonon::MediaObject *music =
        Phonon::createPlayer(Phonon::MusicCategory,
                             Phonon::MediaSource("/path/mysong.wav"));
    music->play();
//![0]
    }

    {
    QWidget *parentWidget = new QWidget;
    QUrl url("Myfancymusic");
//![1]
    Phonon::VideoPlayer *player =
        new Phonon::VideoPlayer(Phonon::VideoCategory, parentWidget);
    player->play(url);
//![1]
    }

    {
//![2]
    Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
    mediaObject->setCurrentSource(Phonon::MediaSource("/mymusic/barbiegirl.wav"));
    Phonon::AudioOutput *audioOutput =
        new Phonon::AudioOutput(Phonon::MusicCategory, this);
    Phonon::Path path = Phonon::createPath(mediaObject, audioOutput);
//![2]
    
//![3]
    Phonon::Effect *effect =
        new Phonon::Effect(
            Phonon::BackendCapabilities::availableAudioEffects()[0], this);
    path.insertEffect(effect);
//![3]    
    }

    {
//![4]
    Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);

    Phonon::VideoWidget *videoWidget = new Phonon::VideoWidget(this);
    Phonon::createPath(mediaObject, videoWidget);

    Phonon::AudioOutput *audioOutput =
        new Phonon::AudioOutput(Phonon::VideoCategory, this);
    Phonon::createPath(mediaObject, audioOutput);
//![4]
//![5]
    mediaObject->play();
//![5]
    }
}
Exemple #3
0
MediaOutput::MediaOutput()
    : totalTimeInMSec(0)
    , prefinishMark( 0 )
    , currentVolume( 1.0 )
    , m_audioOutput( Phonon::MusicCategory, this )
    , m_mediaFader()
{
    m_mediaFader.setFadeCurve( Phonon::VolumeFaderEffect::Fade12Decibel );

    Phonon::Path path = Phonon::createPath( this, &m_audioOutput );

    fadingAvailable = path.insertEffect( &m_mediaFader );

    tDebug() << "Connect media output " << &m_audioOutput;
    connect( &m_audioOutput, SIGNAL( volumeChanged( qreal ) ), SLOT( onVolumeChanged( qreal ) ) );
    connect( this, SIGNAL( tick( qint64 ) ), SLOT( checkPrefinishMark( qint64 ) ) );

    blockSignals( true );
}
Exemple #4
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
    mediaObject->setCurrentSource(Phonon::MediaSource("../myPhonon1/mysong.mp3"));
    Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    Phonon::Path path = Phonon::createPath(mediaObject, audioOutput);
    mediaObject->play();

    // 获取可用的音频效果的描述
    QList<Phonon::EffectDescription> effectDescriptions =
                Phonon::BackendCapabilities::availableAudioEffects();
    qDebug() << effectDescriptions;
    Phonon::EffectDescription effectDescription = effectDescriptions.at(5);
    // 使用指定的音频效果的描述来创建音频效果
    Phonon::Effect *effect = new Phonon::Effect(effectDescription);
    // 在路径中插入音频效果
    path.insertEffect(effect);
    // 创建效果部件,它可以用来更改效果中的参数
    Phonon::EffectWidget *effectWidget = new Phonon::EffectWidget(effect);
    effectWidget->show();
}
Exemple #5
0
CaptureWidget::CaptureWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f)
{
    // Create the objects used for capture
    m_media = new Phonon::MediaObject(this);

    // Create the audio and video outputs (sinks)
    m_audioOutput = new Phonon::AudioOutput(this);
    m_videoWidget = new Phonon::VideoWidget(this);

    /*
     * Set up the buttons and layouts and widgets
     */
    m_playButton = new QPushButton(this);
    m_playButton->setText(tr("Play"));
    connect(m_playButton, SIGNAL(clicked()), this, SLOT(playPause()));

    m_stopButton = new QPushButton(this);
    m_stopButton->setText(tr("Stop"));
    m_stopButton->setEnabled(false);
    connect(m_stopButton, SIGNAL(clicked()), m_media, SLOT(stop()));

    setLayout(new QVBoxLayout);

    // Configure the video widget a bit
    m_videoWidget->setMinimumSize(QSize(400, 300));
    m_videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    layout()->addWidget(m_videoWidget);

    QHBoxLayout *buttonsLayout = new QHBoxLayout();
    buttonsLayout->addWidget(m_playButton);
    buttonsLayout->addWidget(m_stopButton);
    layout()->addItem(buttonsLayout);

    /*
     * Create the paths from the capture object to the outputs
     * If the paths are invalid, then probably the backend doesn't support capture
     */
    Phonon::Path audioPath = Phonon::createPath(m_media, m_audioOutput);
    Phonon::Path videoPath = Phonon::createPath(m_media, m_videoWidget);

    if (!audioPath.isValid()) {
        QMessageBox::critical(this, "Error", "Your backend may not support audio capturing.");
    }
    if (!videoPath.isValid()) {
        QMessageBox::critical(this, "Error", "Your backend may not support video capturing.");
    }

    /*
     * Set up the devices used for capture
     * Phonon can easily get you the devices appropriate for a specific category.
     */
    Phonon::MediaSource source(Phonon::Capture::VideoType, Phonon::NoCaptureCategory);
    m_media->setCurrentSource(source);

    // Connect the stateChanged signal from the media object used for capture
    connect(m_media, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
            this, SLOT(mediaStateChanged(Phonon::State)));

    // Start capturing
    playPause();
}