Programming Audio Delay ... Any Ideas?

Discussion in 'OT Technology' started by Blindsight, Jul 9, 2003.

  1. Blindsight

    Blindsight Guest

    Hey guys, I have an interesting one for you.

    I'm working on a quick and dirty little program that takes wave input from the microphone and simply delays it by a specified number of milliseconds before sending it to the line out of the sound card.

    I know what needs to happen technically, but I'm not sure of the best (most efficient) way to program it. It has to be very accurate because the desired effect only happens in a very small range, something like 220-240 milliseconds. This effect (hearing your own speech slightly delayed) will cause you to temporarily be unable to speak... :big grin:

    Any ideas, suggestions, help, or comments are greatly appreciated! :wiggle:
     
    Last edited by a moderator: Jul 9, 2003
  2. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    Circular buffer, big enough to hold at least 240 ms of data, start reading from the buffer 220-240 ms after you start filling it.
     
  3. Blindsight

    Blindsight Guest

    I'm looking at the windows APIs and I know it can be done using them, am I stupid for trying the APIs? Is there a more elegant, efficient way to do this kind of stuff out there?
     
  4. Blindsight

    Blindsight Guest

    No love? :wtc:
     
  5. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    You can always look at using OpenGL and/or DirectX. They have pretty good sound APIs. All in all, it's not going to be a super easy task. It will take some time a research if you're not a strong programmer.
     
  6. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Wouldn't a simple but accurate reverb/echo achieve the same thing?
     
  7. Blindsight

    Blindsight Guest

    I'm a decent programmer, I just don't program frequently enough to be considered "good"... :hs:

    I think I'm just going to stick to the windows APIs because I've been researching and learning the code etc, and you're right.. it's not simple.
     
  8. Blindsight

    Blindsight Guest

    Sure, if it only echoes once and you can do it on the fly, do you know of a proggie that can do that? :x:
     
  9. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    Sleep your main thread for two seconds in Java. :dunno:

    Code:
    Thread.sleep(2000);
    
     
  10. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    No - you have to write to a buffer and replay the buffer back - a one time pause of 2000 milliseconds means nothing is happening until that 2000 milliseconds is up. It's almost like you have to hit record and then .2 seconds later start playing back the open recording wav while still recording.
     
  11. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    "takes wave input from the microphone and simply delays it by a specified number of milliseconds before sending it to the line out of the sound card"

    From that I took he just needed a few second delay. :dunno:
     
  12. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    But during those .2 seconds, the program must continue to record or else it won't produce the required effect. So you have to have one thread that is constantly recording the sound and another that starts .2 seconds after the start of the other thread that constantly plays.
     
  13. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    I would have had a thread that does the recording from the start. And 2000 is 2 seconds. ;)
     
  14. why 2000 when he asked for 220-240ms ... and specified accuracy in this matter?

    :uh:

    Chris strikes again

    :uh:
     
  15. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    It's called an example dumbfuck. I think he can figure out how long he needs to sleep it when he codes it. :slap:
     
  16. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
  17. Blindsight

    Blindsight Guest

    Optimally it SHOULD be able to go up to 2-3 seconds, though it is not 100% necessary, it would be nice.
     
  18. Blindsight

    Blindsight Guest

    I'm checking that out now, thanks!

    I'm also looking for programs I can "acquire" which would suit my needs :x:
     
  19. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    The delay would have to be variable due to the distance of the speakers from the ear.
     
  20. Blindsight

    Blindsight Guest

    Headphones are used ideally
     
  21. or you could simply provide numbers that fit the given scenario in the first place. I understand how difficult it is for someone of your limited understanding and experience to understand proper example-making, but I'm sure you'll get it someday. Maybe. That or you could just admit you misread and/or mis-typed, but I know your fragile ego has a hard time admitting mistakes.
     
  22. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
  23. Blindsight

    Blindsight Guest

    No one cares but you, please stop bantering
     
  24. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    I care! Oh wait - I forgot - I marked that one as "flying-fuck".
     

Share This Page