×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    6

    Sound Latency <100ms possible ?

    Hi everyone,
    I know there are already a lot of topics talking about sound latency problem, but none of it has really given a working solution, and most of these did not asked for such low latency.

    So what I want is Simple, I want that in response to a user input, a sound is played with less latency as possible (less than 10ms should be good enough)
    All of this while a background sound is playing, and I mix the different sounds from user input(because they can overlap each other) and the background sound together


    I'm using CMdaAudioOutputStream to output sound (44100Hz Stereo)
    It's working but the problem with it, is that it uses a huge buffer, so if I make the calls to WriteL() in MaoscBufferCopied I get Huge latency (about 500ms or something like that)
    and I get this for any size of buffer I send with WriteL(), even if I send very small, it will eat a lot of small buffers very fast at first to fill it's buffer before it starts playing a sound.

    In order to reduce latency, I did this :
    I fill the buffer (call to WriteL) only when the remaining amount data that has been sent but not played yet is small enough (I use CMdaAudioOutputStream::Position() to get what have been played so far).

    with this I can get around 130ms latency (which is too much for what I want to do),
    but I can't get less than that, because it waits for a minimum of data to be received before it starts playing a sound,
    It looks like it only plays block by block (blocks of about 80ms) , if you send one and half block, it'll only play the first block and not even try to play the remaining half-block until more have been received.

    From what I've seen, this seems to be true on all devices.

    I heard that it was because of a software layer adding extra buffering

    I also heard that a way to bypass it is using directly CMMFDevSound :
    http://nioulk.newlc.com/topic-12532
    while some says you'll get the same result with it:
    http://discussion.forum.nokia.com/fo...ad.php?t=73155

    but I can't even try because CMMFDevSound is not available under S60 5th :
    http://discussion.forum.nokia.com/fo...d.php?t=177874


    so is there a way to bypass this annoying and useless "way too big" buffering ?

    thank you



    and don't tell me to go see the "mixer example" this one has a HUUUGE sound latency, about 1 sec.

  2. #2
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: Sound Latency <100ms possible ?

    Hello,
    with all due respect to you, sir, allow me to disagree - on my XM5800, the delay is minimal.

    However, I have heard that some phones are problematic latencywise...but as I don't have one of these in house, I can not state much more re this.
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  3. #3
    Registered User
    Join Date
    Oct 2009
    Posts
    6

    Re: Sound Latency <100ms possible ?

    Thanks for your answer,
    what you're saying is interesting because I did all my tests on a nokia 5800XM,
    and I can tell you that if I play the "sound mixer example" on this device, there is clearly a huge delay between when a box hit the wall and when the sound is actually played.
    Is it the same for you ?

    when you say the delay is minimal, what do you mean exactly ? how much latency ? using what ?
    If you can tell me how to get that minimal latency, that would be great

    but I think you got the same result as mine, it's just that :
    -100ms latency is sufficient to suit most needs, so you may consider 100ms a minimal latency
    -you may refer to the latency at the first call to writeL, then it's something different from what I want to do


    If you've got something to share, I'll be happy to hear it, since I'm desperate to find solution to solve this problem

  4. #4
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: Sound Latency <100ms possible ?

    Hello,
    if I recall correctly, the sound plays only if a ball hits another ball. For me (I have written some Qt games), the latency always "felt" right on my XM58.

    Tested it again now...it may not be 100msec, but it "feels right".

    May I ask what you are trying to achieve?
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  5. #5
    Registered User
    Join Date
    Oct 2009
    Posts
    6

    Re: Sound Latency <100ms possible ?

    I understand that "500ms" may feel right for you but for me it's huge.
    Because what I want to do is a rhythm game, so in order to really feel the rhythm, zero-latency is required, as if you were playing a real instrument.

    I looked a the source code of CMdaAudioOutputStream to see how it used DevSound and what kind of buffering is done,
    And from what I've seen, I don't think i'll be able to get really less latency by using DevSound direclty, I'd like to try, but since I can't...

  6. #6
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,560

    Re: Sound Latency <100ms possible ?

    Perhaps the RGA (Real-time Graphics and Audio) APIs could help, if you are targeting a compatible phone: http://wiki.forum.nokia.com/index.ph...duction_to_RGA

  7. #7
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: Sound Latency <100ms possible ?

    Quote Originally Posted by nadeshiko View Post
    I understand that "500ms" may feel right for you but for me it's huge.
    Because what I want to do is a rhythm game, so in order to really feel the rhythm, zero-latency is required, as if you were playing a real instrument.

    I looked a the source code of CMdaAudioOutputStream to see how it used DevSound and what kind of buffering is done,
    And from what I've seen, I don't think i'll be able to get really less latency by using DevSound direclty, I'd like to try, but since I can't...
    I have to apologize, but I fear that we have reached the border of my knowledge here.

    Can't you somehow change the usage model?
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  8. #8
    Registered User
    Join Date
    Oct 2009
    Posts
    6

    Re: Sound Latency <100ms possible ?

    Quote Originally Posted by petrib View Post
    Perhaps the RGA (Real-time Graphics and Audio) APIs could help, if you are targeting a compatible phone: http://wiki.forum.nokia.com/index.ph...duction_to_RGA
    I don't think using another API can help
    Let me explain the situation
    What I do now is that I use CMdaAudioOutputStream and only send small buffer (10 ms) with a timer, and only when there is few data.
    according to the source of CMdaAudioOutputStream, in this case there is no buffering done by CMdaAudioOutputStream, because it's always waiting for a buffer, so when I call WriteL, it immediatly send it to DevSound.

    so the problem is with DevSound itself, and Since every sound API uses DevSound...
    now DevSound is the direct implementation of the audio driver, so unless I create a new audio driver, there is now way to avoid this problem.


    maybe the way I'm using it is wrong, so if someone know something about this, your help is appreciated.

  9. #9
    Registered User
    Join Date
    Mar 2010
    Posts
    7

    Re: Sound Latency <100ms possible ?

    Hi all,
    I'm new with Symbian and would like to develop audio apps using Qt for S60. I'm experienced with Qt with audio programming (on other platforms like win32,linux,OS X).

    Like other users I'd like to know what's the best API to use (closest to the hardware) for achieving decently low latencies.
    I would need full duplex, possibly 22-44kHz, 16 bit PCM, no codecs in the way (I am not developing a VOIP app) , just plains simple reading from PCM record buffer, do some processing and then write the resulting
    16 bit PCM data to the output buffer.

    I'd like to target at least Symbian 3th ed FP1 and 5th ed.
    What's the recommended audio API to achieve the best result ? I've read about DevSound. Does DevSound require special capabilities ?
    Is there a way to set the audio buffer to a small size ?
    Where can I find working example code which demonstrates full duplex audio by using DevSound ?
    Using the Symbian 5.0 SDK
    I tried to compile this:
    http://www.forum.nokia.com/info/sw.n..._0_en.zip.html

    I installed S60_5th_Ed_SDK_API_Plug-In_Pack_v1_1.exe

    but when compiling the full duplex audio example the compiler complains that mmfserverbaseclasses.dso is missing.
    Indeed I did not find it in my symbian tree.

    I kindly ask for some hints how I can compile the example and then start experimenting with full duplex, low latency audio and report back my finding.
    many thanks in advance to everyone!
    best regards,
    Mark

Similar Threads

  1. Problem with Sound class getState()
    By creepymo in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-06-20, 18:43
  2. MIDI Sound problem (J2ME / Series 60)
    By JPapke in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2004-10-29, 08:17
  3. Sound in Midp 2.0 stalls
    By astraton2001 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2004-03-25, 06:58
  4. sound bug (possibly) on 6610
    By alex_crowther in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2004-02-05, 11:44
  5. Nokia Smart Expert - solve this sound problem
    By tsoh_tan in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2003-10-30, 04:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×