June 23, 2011

Swoone Swoone
Lab Rat
10 posts

Fade out sound

Page  
1

Hi all,

I have been a Qt developer for 5 years and C++ for developer for 12 years but never really did any audio programming. For a big project I am working on 2 multitouch applications. One of which needs basic audio support, looping an audio file, being able to stop it at any time with a fadeout. I was hoping to use Phonon for this but it doesn’t seem to work with Mingw. Since I want to use the same Qt SDK for both apps and I already finished the other app using Mingw, I am a bit puzzled how to get the audio working without setting up a separate Visual C++ environment for the second app.

I looked at Qt multimedia classes, this could be an option, but I found no support for fade out. Any suggestions? I have limited time on this but the audio support I need is so simple, yet trivial part of the app experience.

Regards, Henk

17 replies

June 23, 2011

loladiro loladiro
Lab Rat
596 posts

Have a look at QMediaPlayer [doc.qt.nokia.com]

June 23, 2011

Swoone Swoone
Lab Rat
10 posts

Thanks, but that appears to be available in Qt Mobility only?! My apps are desktop apps running on windows 7

June 23, 2011

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

Qt Mobility is not only for mobile platforms. It also contains some support (limited afaik) for desktop platforms

June 23, 2011

Swoone Swoone
Lab Rat
10 posts

Still I am afraid since this not an option since I have to port my already finished app to Qt Mobility. I would be surprised if it would work the same as on plain Qt, since it is a 52 inch multitouch application using heavy QGraphicsView stuff. But thanks for the effort.

June 23, 2011

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

all you need is link QtM to your app and start use it, there is no needance for rewriting

June 23, 2011

Swoone Swoone
Lab Rat
10 posts

Okay, that would be cool. I will look into it. Thanks!

June 24, 2011

Swoone Swoone
Lab Rat
10 posts

I’m having problems getting Qt Mobility to work. First I thought it was because I was using Qt SDK 2010.05. So I installed the latest SDK (1.1.2) from http://qt.nokia.com/downloads/. Which claims to contain Qt Mobility version 1.1.3. However after installing I created a simple app from Qt documentation using QMediaPlayer, see http://doc.qt.nokia.com/qtmobility-1.1.3/quickstart.html.

If I try to compile it complains about the following:

#include <QMediaPlayer> main.cpp:2:24: error: QMediaPlayer: No such file or directory

QTM_USE_NAMESPACE main.cpp:6: error: expected constructor, destructor, or type conversion before ‘int’

I must be missing out on something. Should I build Qt Mobility myself. I even can’t seem to find the source files for it in the SDK directories :-s

June 24, 2011

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

AFAIK desktop Qt in QtSDK doesn’t contain QtMobility. You have to build it manually or use one precompiled (if you use some package-based linux distro it will be easy to install it from repos).

June 24, 2011

Swoone Swoone
Lab Rat
10 posts

It does contain it. The create project wizard even supports creating a mobile project. Which still feels weird since I am targeting a 52” inch desktop environment ;-)

This is the .pro file created (and my changes):

  1. # Add files and directories to ship with the application
  2. # by adapting the examples below.
  3. # file1.source = myfile
  4. # dir1.source = mydir
  5. # DEPLOYMENTFOLDERS = # file1 dir1
  6.  
  7. # symbian:TARGET.UID3 = 0xE80DF1B4
  8.  
  9. # Smart Installer package's UID
  10. # This UID is from the protected range
  11. # and therefore the package will fail to install if self-signed
  12. # By default qmake uses the unprotected range value if unprotected UID is defined for the application
  13. # and 0x2002CCCF value if protected UID is given to the application
  14. #symbian:DEPLOYMENT.installer_header = 0x2002CCCF
  15.  
  16. # Allow network access on Symbian
  17. # symbian:TARGET.CAPABILITY += NetworkServices
  18.  
  19. # If your application uses the Qt Mobility libraries, uncomment
  20. # the following lines and add the respective components to the
  21. # MOBILITY variable.
  22. CONFIG += mobility
  23. MOBILITY += multimedia
  24.  
  25. SOURCES += main.cpp mainwindow.cpp
  26. HEADERS += mainwindow.h
  27. FORMS += mainwindow.ui
  28.  
  29. # Please do not modify the following two lines. Required for deployment.
  30. # include(deployment.pri)
  31. # qtcAddDeployment()

And here is my main.cpp:

  1. #include "mainwindow.h"
  2. #include <QApplication>
  3. #include <QMediaPlayer>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7.     QApplication app(argc, argv);
  8.  
  9.     MainWindow mainWindow;
  10.     mainWindow.setOrientation(MainWindow::ScreenOrientationAuto);
  11.     mainWindow.showExpanded();
  12.  
  13.     return app.exec();
  14. }

And it does not compile for previous posted reasons!

June 24, 2011

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

Qt Creator is only part of Qt SDK and another part is Qt library itself. Your errors really looks like QtM is missing, aren’t they?

June 24, 2011

loladiro loladiro
Lab Rat
596 posts

Do you have

  1.  #include <QtMultimediaKit>

and more importantly, did you select Qt Mobility APIs in the Updater?

June 24, 2011

Swoone Swoone
Lab Rat
10 posts

Yes, QtM appears to be missing. But when I go this url it says QtM is part of the SDK:

https://qt.nokia.com/products/qt-addons/mobility

That’s also claimed on this page, from where I downloaded and installed the SDK:

https://qt.nokia.com/downloads

Check these screenshots from my system for more details:

http://www.vanmezelf.nl/images/screenshot.png
http://www.vanmezelf.nl/images/screenshot-2.png

June 24, 2011

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

It can be part of mobile libraries (symbian, maemo), I’m not sure on this btw (I’m using mostly selfbuilded Qt or Qt from my linux repo).

June 24, 2011

loladiro loladiro
Lab Rat
596 posts

Try copying the mobility.prf from QtSDK/Simulator/Qt/gcc/mkspecs/features to QtSDK/Desktop/Qt/gcc/mkspecs/features

EDIT: This might not work. Don’t be disappointed if it doesn’t.

June 24, 2011

Swoone Swoone
Lab Rat
10 posts

Okay, thanks for your efforts anyway :-)

Page  
1

  ‹‹ [solved] Forbid user to uncheck all QRadioButtons when there is only one button.      Qt binaries ››

You must log in to post a reply. Not a member yet? Register here!