Results 1 to 8 of 8

Thread: Sound Volume

  1. #1
    Join Date
    Jan 2008
    Posts
    91
    Thanks
    8

    Default Sound Volume

    Hi all,
    I want to change my Arm9 DVEVM 's sound level via Qt is it possible? There is Montavista linux on it. TI DM355 MCU and Montavista linux

  2. #2
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Sound Volume

    Hi,
    There is no direct way using the QSound class. You have to open the mixer and do an IOCTL on it. I did it as such.

    Qt Code:
    1. bool setLevel(int level)
    2. {
    3. int iDevice,isetlv = (level + (level << 8));
    4. isetlv &= 0x00ff;
    5. // Set value
    6. if ((iDevice = open("/dev/mixer", O_RDONLY)) == -1) {
    7. return false;
    8. }
    9. if (ioctl(iDevice, MIXER_WRITE(0), &isetlv) == -1) {
    10. return false;
    11. }
    12.  
    13. close(iDevice);
    14. return true;
    15. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2008
    Posts
    91
    Thanks
    8

    Default Re: Sound Volume

    Dear QbelcorT;
    I tried that but when i do that , the sound is cutting off , and QSound doesn't work any more.

  4. #4
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Sound Volume

    Please post your code. Are you using alsa? Did you try different values? Is this the correct /dev/mixer for your device?

  5. #5
    Join Date
    Jan 2008
    Posts
    91
    Thanks
    8

    Default Re: Sound Volume

    I am very newbie at embedded linux , i am not sure my T.I DVEVM soard support or not the ALSA, but my QSound works, I have added my codes below.


    Qt Code:
    1. #include <QSound>
    2. #include <linux/soundcard.h>
    3. #define MIXER_DEVICE "/dev/mixer"
    4. .
    5. .
    6. .
    7. ..
    8. ....
    9. .....
    10. ......
    11. .......
    12. int myThread::setAudioLevel(int audioLevel)
    13. {
    14. int vol = audioLevel | (audioLevel << 8);
    15. int mixerFd;
    16. /* Set the output volume */
    17. mixerFd = open(MIXER_DEVICE, O_RDONLY);
    18. if (mixerFd == -1)
    19. {
    20. // ERR_A("Failed to open %s\n", MIXER_DEVICE);
    21. return -1;
    22. }
    23.  
    24. if (ioctl(mixerFd, SOUND_MIXER_WRITE_VOLUME, &vol) == -1)
    25. {
    26. // ERR_A("Failed to set the volume of line in.\n");
    27. close(mixerFd);
    28. return -1;
    29. }
    30. close(mixerFd);
    31. return 0;
    32. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Sound Volume

    Hi,
    It is difficult to debug from this point. I don't know the details of your eval kit. You must use this method I gave you to set the volume though. This should point you in the right direction. You'll have to google a few things about sound in linux or check the documents that came with your kit.
    You need to know a few things.
    1) Which mixer your sound card is using /dev/mixer0,1,2
    2) In the bash prompt , can you type 'amixer'? This is the basis of setting the audio details (sound level, bass, treble or any details for your particular card). 'amixer -h' will give you a list options.
    3) Without even using qtopia in bash prompt can you type 'aplay "soundname", where soundname is the name of the wav file.

    PS. Did you try different values in setLevel?

  7. #7
    Join Date
    Jan 2008
    Posts
    91
    Thanks
    8

    Default Re: Sound Volume

    Dear QbelcorT,
    I tried to do what you said, but it didnt help me . I think, i have to find an other way except QSound . I can't use together QSound and "/dev/mixer" together. I wonder that, Are there any other way except QSound for playing sounds on Linux? Does the Linux device like "/dev/dsp" do that function?
    Last edited by anafor2004; 24th November 2008 at 08:06.

  8. #8
    Join Date
    Jan 2011
    Posts
    39
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Sound Volume

    want to control windows volume control.Is there any way to control using qslider??

    advance thanks

Similar Threads

  1. How to get the Volume name from QFileDialog?
    By vishal.chauhan in forum Qt Programming
    Replies: 0
    Last Post: 30th August 2008, 12:28
  2. No sound on embedded devices
    By winarko in forum Qt for Embedded and Mobile
    Replies: 5
    Last Post: 25th June 2008, 22:08
  3. Getting sound data from a wave file
    By ko9 in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2007, 11:23
  4. Volume control for Windows XP
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 30th May 2007, 06:18
  5. MP3 Sound / OGG Sound Play on GUI
    By patrik08 in forum Newbie
    Replies: 3
    Last Post: 1st September 2006, 19:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.