CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2011
    Posts
    27

    Post Loop problem using windows media player controll

    Hi guys,
    New Riddle!

    Ok So I am using the windows media player control to play sound (i need to play several sounds at a time).

    I have a sound let say a diesel engine working.
    Now I want this sound to be played continuously using :
    Code:
     this->axWindowsMediaPlayer2->settings->setMode("loop",true);
    It works however when the sound is over there's a short delay before the WMP will play it again Although the sound itself if uniform (has no pause in it).

    My question is :
    How to get rid of this pause and play it really continuously ?
    Maybe I could use another scope for the sound, but I have to be able to play several sound at a time.

    I was trying to use irrKlang library but couldn't manage to get it work.

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Loop problem using windows media player controll

    Quote Originally Posted by smallbit View Post
    How to get rid of this pause and play it really continuously ?
    Looping a sound really continously is a challanging task, even if the sound appears to be uniform to the human ear when played loopless. Sophisticated tools that do that usually cross-fade the end of the sound into the start of the next loop. I don't know of any ready-to-use Windows facility that supports this, though.

    Maybe I could use another scope for the sound, but I have to be able to play several sound at a time.
    And is the WMP able to do that? Conceptually being an MP3/Video player, I wouldn't expect it to have a need for that feature.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Mar 2011
    Posts
    27

    Re: Loop problem using windows media player controll

    Quote Originally Posted by Eri523 View Post
    And is the WMP able to do that? Conceptually being an MP3/Video player, I wouldn't expect it to have a need for that feature.
    Well not directly but you are able to have several instances of the player and that way play sounds simultaneously, this was contrasted for example with PlaySound() method from winmm32.lib, that is not able to do so.

    Quote Originally Posted by Eri523 View Post
    even if the sound appears to be uniform to the human ear when played loopless..
    Good Point, but on editing sound you can see it visually too
    Last edited by smallbit; March 24th, 2011 at 09:51 AM.

  4. #4
    Join Date
    Jan 2010
    Posts
    1,133

    Re: Loop problem using windows media player controll

    Quote Originally Posted by Eri523 View Post
    Looping a sound really continously is a challanging task, even if the sound appears to be uniform to the human ear when played loopless. Sophisticated tools that do that usually cross-fade the end of the sound into the start of the next loop.
    Really? I didn't know that. Interesting...
    Can you tell me, if you happen to know, how it is determined when to start the next loop? (Does the code just rely on the duration of the sound file, hoping that there aren't gonna be any problems during the playback that could affect the actual duration, or there's a more sophisticated way?)

  5. #5
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Loop problem using windows media player controll

    The only system I ever used this method was a sampler (i.e. musical instrument - in hardware!) and that allowed to pre-listen to the resulting sound and fine-tune the cross-fade parameters before finally saving it. Of course all that happened before the sound was actually used.

    I don't understand what you mean by the part in parentheses, though. Can you clarify that a bit?
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  6. #6
    Join Date
    Jan 2010
    Posts
    1,133

    Re: Loop problem using windows media player controll

    What I meant is: when done in software, using the method you described, how should the code determine when to start playing/fading the next loop?
    It can be done by relying on the duration of the tune, and measuring time. But what if, during playback, some sort of a problem occurs, and the tune stops playing for a sec? Then the actual time required for the tone to come to the end will increase, and the next loop might start too soon.
    Or is this kind of situation handled by the playback code, in such a way that the duration is always the same (maybe the player can skip to the expected time)?
    I don't know, I'm not really that familiar with audio playback.

  7. #7
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Loop problem using windows media player controll

    Quote Originally Posted by TheGreatCthulhu View Post
    What I meant is: when done in software, using the method you described, how should the code determine when to start playing/fading the next loop?
    If you exclude the option of hand-tuning the cross-fade parameters during development, the most natural alternative is applying a fixed cross-fade time span, either specified as an absolute value or a percentage of the duration of the original sound.

    However, a simple automatic like this may be terribly off depending on the sound to process, for instance if it contains drum beats whose rhythm is to be preserved. There are certainly algorithms that can achieve this automatically as well, but I suppose they're computationally expensive so that they proably need to be run before the actual playback.

    I don't have, however, that much pratical experience with software that is used for these purposes nowadays (and, as you certainly know, hardware solutions for these purposes gets increasingly rare).

    It can be done by relying on the duration of the tune, and measuring time. But what if, during playback, some sort of a problem occurs, and the tune stops playing for a sec? Then the actual time required for the tone to come to the end will increase, and the next loop might start too soon.
    What you describe there in your first sentence is pretty much the basic method I described as the first option above. But software would most likely use some sort of time code (relative to the sound sample itself) provided by the sound playback API rather than absolute system time which would implicitly eliminate the possible timing problem you ask about. This API may be OS-supplied (I think Windows has something like that but I'm not sure; at least the .NET Media::SoundPlayer class does not offer that functionality) or 3rd-party.

    However, sound playback ceasing for a noticable time (and at best that starts in the low milliseconds range) is at least pretty annoying, and in a musical environment it is likely to be quite fatal, for instance by ruining synchronization between individual tracks.

    Or is this kind of situation handled by the playback code, in such a way that the duration is always the same (maybe the player can skip to the expected time)?
    Any audio drop-out problem is pretty bad anyway, as described above. I think, in general, the time code-based approach ist the most robust one, as it would ensure the proper relation between the end of the currently running sample and the start of the next pass through it after the loop point.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured